mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-07 11:58:13 +00:00
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()`
This commit is contained in:
@@ -85,13 +85,15 @@ int main()
|
||||
|
||||
BeginTextureMode(target); // Enable drawing to texture
|
||||
|
||||
BeginMode3D(camera);
|
||||
ClearBackground(RAYWHITE); // Clear texture background
|
||||
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
|
@@ -130,13 +130,15 @@ int main()
|
||||
|
||||
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)
|
||||
|
||||
@@ -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);
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user