diff options
| author | Ray <raysan5@gmail.com> | 2016-06-06 20:46:06 +0200 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2016-06-06 20:46:06 +0200 |
| commit | 1c98e6b698b8002e0c6c769c6d9f23a6e15f3bdf (patch) | |
| tree | 0aba231bb77034cae38dc44e39d53b63197c6a2c /examples/shaders_postprocessing.c | |
| parent | 75a73d94171051037fcf670852877977d9251520 (diff) | |
| parent | 4dada3269374a82fa2c4a06bd29dfc0f37a64380 (diff) | |
| download | raylib-1c98e6b698b8002e0c6c769c6d9f23a6e15f3bdf.tar.gz raylib-1c98e6b698b8002e0c6c769c6d9f23a6e15f3bdf.zip | |
Merge pull request #125 from raysan5/develop
Develop branch integration
Diffstat (limited to 'examples/shaders_postprocessing.c')
| -rw-r--r-- | examples/shaders_postprocessing.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/examples/shaders_postprocessing.c b/examples/shaders_postprocessing.c index 0f851658..5e8b5a80 100644 --- a/examples/shaders_postprocessing.c +++ b/examples/shaders_postprocessing.c @@ -30,18 +30,19 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader"); // Define the camera to look into our 3d world - Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }}; + Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model - Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture + Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map) SetModelTexture(&dwarf, texture); // Bind texture to model 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,28 @@ 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) + + BeginShaderMode(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); + + EndShaderMode(); - 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 +97,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; |
