From 6966ad5717fbc9006f2a4fb0075eb539e20cc769 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 30 Sep 2025 18:39:27 +0200 Subject: [PATCH] Update shaders_ascii_rendering.c --- examples/shaders/shaders_ascii_rendering.c | 34 +++++++++------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/examples/shaders/shaders_ascii_rendering.c b/examples/shaders/shaders_ascii_rendering.c index 23ba1f549..33fb052f7 100644 --- a/examples/shaders/shaders_ascii_rendering.c +++ b/examples/shaders/shaders_ascii_rendering.c @@ -67,58 +67,52 @@ int main(void) // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_LEFT) && fontSize > 9.0) fontSize -= 1; // Reduce fontSize - - if (IsKeyPressed(KEY_RIGHT) && fontSize < 15.0) fontSize += 1; // Increase fontSize - - if (circlePos.x > 200.0f || circlePos.x < 40.0f) circleSpeed *= -1; // Revert speed - circlePos.x += circleSpeed; + if ((circlePos.x > 200.0f) || (circlePos.x < 40.0f)) circleSpeed *= -1; // Revert speed + + if (IsKeyPressed(KEY_LEFT) && (fontSize > 9.0)) fontSize -= 1; // Reduce fontSize + if (IsKeyPressed(KEY_RIGHT) && (fontSize < 15.0)) fontSize += 1; // Increase fontSize // Set fontsize for the shader SetShaderValue(shader, fontSizeLoc, &fontSize, SHADER_UNIFORM_FLOAT); // Draw //---------------------------------------------------------------------------------- - BeginTextureMode(target); - ClearBackground(WHITE); // The background of the scene itself + ClearBackground(WHITE); - // Samples Using custom shader + // Draw scene in our render texture DrawTexture(fudesumi, 500, -30, WHITE); DrawTextureV(raysan, circlePos, WHITE); - EndTextureMode(); + BeginDrawing(); - ClearBackground(RAYWHITE); BeginShaderMode(shader); - // Draw the scene texture (that we rendered earlier) to the screen // The shader will process every pixel of this texture DrawTextureRec(target.texture, - (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, - (Vector2){ 0, 0 }, - WHITE); + (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, + (Vector2){ 0, 0 }, WHITE); EndShaderMode(); DrawRectangle(0, 0, screenWidth, 40, BLACK); DrawText(TextFormat("Ascii effect - FontSize:%2.0f - [Left] -1 [Right] +1 ", fontSize), 120, 10, 20, LIGHTGRAY); DrawFPS(10, 10); - EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadTexture(fudesumi); // Unload texture - UnloadTexture(raysan); // Unload texture + UnloadRenderTexture(target); // Unload render texture + + UnloadShader(shader); // Unload shader + UnloadTexture(fudesumi); // Unload texture + UnloadTexture(raysan); // Unload texture CloseWindow(); // Close window and OpenGL context //--------------------------------------------------------------------------------------