1 | /******************************************************************************************* |
2 | * |
3 | * raylib [textures] example - Texture loading and drawing |
4 | * |
5 | * This example has been created using raylib 1.0 (www.raylib.com) |
6 | * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) |
7 | * |
8 | * Copyright (c) 2014 Ramon Santamaria (@raysan5) |
9 | * |
10 | ********************************************************************************************/ |
11 | |
12 | #include "raylib.h" |
13 | |
14 | int main(void) |
15 | { |
16 | // Initialization |
17 | //-------------------------------------------------------------------------------------- |
18 | const int screenWidth = 800; |
19 | const int screenHeight = 450; |
20 | |
21 | InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing" ); |
22 | |
23 | // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) |
24 | Texture2D texture = LoadTexture("resources/raylib_logo.png" ); // Texture loading |
25 | //--------------------------------------------------------------------------------------- |
26 | |
27 | // Main game loop |
28 | while (!WindowShouldClose()) // Detect window close button or ESC key |
29 | { |
30 | // Update |
31 | //---------------------------------------------------------------------------------- |
32 | // TODO: Update your variables here |
33 | //---------------------------------------------------------------------------------- |
34 | |
35 | // Draw |
36 | //---------------------------------------------------------------------------------- |
37 | BeginDrawing(); |
38 | |
39 | ClearBackground(RAYWHITE); |
40 | |
41 | DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); |
42 | |
43 | DrawText("this IS a texture!" , 360, 370, 10, GRAY); |
44 | |
45 | EndDrawing(); |
46 | //---------------------------------------------------------------------------------- |
47 | } |
48 | |
49 | // De-Initialization |
50 | //-------------------------------------------------------------------------------------- |
51 | UnloadTexture(texture); // Texture unloading |
52 | |
53 | CloseWindow(); // Close window and OpenGL context |
54 | //-------------------------------------------------------------------------------------- |
55 | |
56 | return 0; |
57 | } |