Browse Source

Review RenderTexture drawing usage

Now `BeginTextureMode()` does not clean buffers automatically, that behaviour has been changed because there could be some case (i.e. painting software) where texture buffer does not ned to be cleared; user is responsible of clearing buffers using `ClearBackground()`
pull/703/head
Ray 6 years ago
parent
commit
ed269b8d9a
4 changed files with 15 additions and 13 deletions
  1. +7
    -4
      examples/shaders/shaders_custom_uniform.c
  2. +7
    -4
      examples/shaders/shaders_postprocessing.c
  3. +1
    -1
      games/wave_collector/screens/screen_gameplay.c
  4. +0
    -4
      src/core.c

+ 7
- 4
examples/shaders/shaders_custom_uniform.c View File

@ -83,19 +83,21 @@ int main()
ClearBackground(RAYWHITE);
BeginTextureMode(target); // Enable drawing to texture
BeginTextureMode(target); // Enable drawing to texture
ClearBackground(RAYWHITE); // Clear texture background
BeginMode3D(camera);
BeginMode3D(camera); // Begin 3d mode drawing
DrawModel(model, position, 0.5f, WHITE); // Draw 3d model with texture
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D();
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, RED);
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
BeginShaderMode(shader);
@ -104,6 +106,7 @@ int main()
EndShaderMode();
// Draw some 2d text over drawn texture
DrawText("(c) Barracks 3D model by Alberto Cano", screenWidth - 220, screenHeight - 20, 10, GRAY);
DrawFPS(10, 10);

+ 7
- 4
examples/shaders/shaders_postprocessing.c View File

@ -128,17 +128,19 @@ int main()
ClearBackground(RAYWHITE);
BeginTextureMode(target); // Enable drawing to texture
BeginTextureMode(target); // Enable drawing to texture
BeginMode3D(camera);
ClearBackground(RAYWHITE); // Clear texture background
BeginMode3D(camera); // Begin 3d mode drawing
DrawModel(model, position, 0.1f, WHITE); // Draw 3d model with texture
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D();
EndMode3D(); // End 3d mode drawing, returns to orthographic 2d mode
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
// Render previously generated texture using selected postpro shader
BeginShaderMode(shaders[currentShader]);
@ -148,6 +150,7 @@ int main()
EndShaderMode();
// Draw 2d shapes and text over drawn texture
DrawRectangle(0, 9, 580, 30, Fade(LIGHTGRAY, 0.7f));
DrawText("(c) Church 3D model by Alberto Cano", screenWidth - 200, screenHeight - 20, 10, GRAY);

+ 1
- 1
games/wave_collector/screens/screen_gameplay.c View File

@ -430,8 +430,8 @@ void DrawGameplayScreen(void)
else
{
// Draw wave using render target
ClearBackground(BLANK);
BeginTextureMode(waveTarget);
ClearBackground(BLANK);
DrawSamplesMap(samples, totalSamples, currentSample, (Rectangle){ 0, 0, waveTarget.texture.width, waveTarget.texture.height }, MAROON);
EndTextureMode();

+ 0
- 4
src/core.c View File

@ -1173,10 +1173,6 @@ void BeginTextureMode(RenderTexture2D target)
rlEnableRenderTexture(target.id); // Enable render target
// Some projects need the buffer to not be empited when drawing to
// the render texture.
//rlClearScreenBuffers(); // Clear render texture buffers
// Set viewport to framebuffer size
rlViewport(0, 0, target.texture.width, target.texture.height);

Loading…
Cancel
Save