aboutsummaryrefslogtreecommitdiff
path: root/examples/shaders_postprocessing.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/shaders_postprocessing.c')
-rw-r--r--examples/shaders_postprocessing.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/examples/shaders_postprocessing.c b/examples/shaders_postprocessing.c
index 44829648..e9fafe15 100644
--- a/examples/shaders_postprocessing.c
+++ b/examples/shaders_postprocessing.c
@@ -38,10 +38,11 @@ int main()
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
- Shader shader = LoadShader("resources/shaders/base.vs",
- "resources/shaders/bloom.fs"); // Load postpro shader
+ Shader shader = LoadShader("resources/shaders/glsl330/base.vs",
+ "resources/shaders/glsl330/bloom.fs"); // Load postpro shader
- SetPostproShader(shader); // Set fullscreen postprocessing shader
+ // Create a RenderTexture2D to be used for render to texture
+ RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
// Setup orbital camera
SetCameraMode(CAMERA_ORBITAL); // Set an orbital camera mode
@@ -65,15 +66,26 @@ int main()
ClearBackground(RAYWHITE);
- Begin3dMode(camera);
+ BeginTextureMode(target); // Enable drawing to texture
- DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
+ Begin3dMode(camera);
- DrawGrid(10, 1.0f); // Draw a grid
+ DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture
- End3dMode();
+ DrawGrid(10, 1.0f); // Draw a grid
+
+ End3dMode();
+
+ DrawText("HELLO POSTPROCESSING!", 70, 190, 50, RED);
+
+ EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
+
+ SetCustomShader(shader);
+ // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
+ DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
+ SetDefaultShader();
- DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, BLACK);
+ DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY);
DrawFPS(10, 10);
@@ -83,11 +95,12 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
- UnloadShader(shader); // Unload shader
- UnloadTexture(texture); // Unload texture
- UnloadModel(dwarf); // Unload model
+ UnloadShader(shader); // Unload shader
+ UnloadTexture(texture); // Unload texture
+ UnloadModel(dwarf); // Unload model
+ UnloadRenderTexture(target); // Unload render texture
- CloseWindow(); // Close window and OpenGL context
+ CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;