diff options
Diffstat (limited to 'examples/shaders/shaders_eratosthenes.c')
| -rw-r--r-- | examples/shaders/shaders_eratosthenes.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/examples/shaders/shaders_eratosthenes.c b/examples/shaders/shaders_eratosthenes.c index d5163a7f..65fd9f98 100644 --- a/examples/shaders/shaders_eratosthenes.c +++ b/examples/shaders/shaders_eratosthenes.c @@ -46,11 +46,11 @@ int main(void) // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/eratosthenes.fs", GLSL_VERSION)); - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- @@ -59,35 +59,33 @@ int main(void) // Draw //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); + BeginTextureMode(target); // Enable drawing to texture + ClearBackground(BLACK); // Clear the render texture - BeginTextureMode(target); // Enable drawing to texture - ClearBackground(BLACK); // Clear the render texture + // Draw a rectangle in shader mode to be used as shader canvas + // NOTE: Rectangle uses font white character texture coordinates, + // so shader can not be applied here directly because input vertexTexCoord + // do not represent full screen coordinates (space where want to apply shader) + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK); + EndTextureMode(); // End drawing to texture (now we have a blank texture available for the shader) - // Draw a rectangle in shader mode to be used as shader canvas - // NOTE: Rectangle uses font white character texture coordinates, - // so shader can not be applied here directly because input vertexTexCoord - // do not represent full screen coordinates (space where want to apply shader) - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK); - EndTextureMode(); // End drawing to texture (now we have a blank texture available for the shader) + BeginDrawing(); + ClearBackground(RAYWHITE); // Clear screen background BeginShaderMode(shader); // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE); EndShaderMode(); - EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- - UnloadShader(shader); // Unload shader - UnloadRenderTexture(target); // Unload texture + UnloadShader(shader); // Unload shader + UnloadRenderTexture(target); // Unload render texture - CloseWindow(); // Close window and OpenGL context + CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; |
