diff options
| author | Ray <[email protected]> | 2019-05-20 16:40:30 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-20 16:40:30 +0200 |
| commit | 3d7d174c70b2d00fd879ade64c5085d4ff34d4aa (patch) | |
| tree | 3b690948f186f855aa2ee8bab312b3ca28a56200 /examples/web/textures/textures_image_text.c | |
| parent | 0b56b996bd053ec875c229e9793f7806b666839c (diff) | |
| download | raylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.tar.gz raylib.com-3d7d174c70b2d00fd879ade64c5085d4ff34d4aa.zip | |
Review and recompile ALL examples
Diffstat (limited to 'examples/web/textures/textures_image_text.c')
| -rw-r--r-- | examples/web/textures/textures_image_text.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/examples/web/textures/textures_image_text.c b/examples/web/textures/textures_image_text.c index dc393bb..4b5f0f1 100644 --- a/examples/web/textures/textures_image_text.c +++ b/examples/web/textures/textures_image_text.c @@ -18,13 +18,13 @@ //---------------------------------------------------------------------------------- // Global Variables Definition //---------------------------------------------------------------------------------- -int screenWidth = 800; -int screenHeight = 450; +const int screenWidth = 800; +const int screenHeight = 450; // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) -Font font; -Texture2D texture; +Font font = { 0 }; +Texture2D texture = { 0 }; Vector2 position = { 0.0f, 0.0f }; @@ -36,17 +36,17 @@ bool showFont = false; void UpdateDrawFrame(void); // Update and Draw one frame //---------------------------------------------------------------------------------- -// Main Enry Point +// Program Main Entry Point //---------------------------------------------------------------------------------- -int main() +int main(void) { // Initialization //-------------------------------------------------------------------------------------- InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing"); - + // TTF Font loading with custom generation parameters font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0); - + Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM) // Draw over image using custom font @@ -54,7 +54,7 @@ int main() texture = LoadTextureFromImage(parrots); // Image converted to texture, uploaded to GPU memory (VRAM) UnloadImage(parrots); // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM - + position = (Vector2){ (float)(screenWidth/2 - texture.width/2), (float)(screenHeight/2 - texture.height/2 - 20) }; #if defined(PLATFORM_WEB) @@ -62,7 +62,7 @@ int main() #else SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- - + // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { @@ -73,9 +73,9 @@ int main() // De-Initialization //-------------------------------------------------------------------------------------- UnloadTexture(texture); // Texture unloading - + UnloadFont(font); // Unload custom spritefont - + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- @@ -103,15 +103,15 @@ void UpdateDrawFrame(void) { // Draw texture with text already drawn inside DrawTextureV(texture, position, WHITE); - + // Draw text directly using sprite font - DrawTextEx(font, "[Parrots font drawing]", (Vector2){ position.x + 20, + DrawTextEx(font, "[Parrots font drawing]", (Vector2){ position.x + 20, position.y + 20 + 280 }, (float)font.baseSize, 0.0f, WHITE); } else DrawTexture(font.texture, screenWidth/2 - font.texture.width/2, 50, BLACK); - + DrawText("PRESS SPACE to SEE USED SPRITEFONT ", 290, 420, 10, DARKGRAY); - + EndDrawing(); //---------------------------------------------------------------------------------- } |
