Only restore GL scale back to screen scale if we are returning to a screen, not a render texture.

This commit is contained in:
Jeffery Myers 2024-01-20 18:23:17 -08:00
parent 5c25913e09
commit 6fc839a586
2 changed files with 17 additions and 5 deletions

View File

@ -952,9 +952,6 @@ void BeginMode2D(Camera2D camera)
// Apply 2d camera transformation to modelview // Apply 2d camera transformation to modelview
rlMultMatrixf(MatrixToFloat(GetCameraMatrix2D(camera))); rlMultMatrixf(MatrixToFloat(GetCameraMatrix2D(camera)));
// Apply screen scaling if required
rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale));
} }
// Ends 2D mode with custom camera // Ends 2D mode with custom camera
@ -963,6 +960,8 @@ void EndMode2D(void)
rlDrawRenderBatchActive(); // Update and draw internal render batch rlDrawRenderBatchActive(); // Update and draw internal render batch
rlLoadIdentity(); // Reset current matrix (modelview) rlLoadIdentity(); // Reset current matrix (modelview)
if (rlGetActiveFramebuffer() == 0)
rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale)); // Apply screen scaling if required rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale)); // Apply screen scaling if required
} }
@ -1016,6 +1015,7 @@ void EndMode3D(void)
rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix
rlLoadIdentity(); // Reset current matrix (modelview) rlLoadIdentity(); // Reset current matrix (modelview)
if (rlGetActiveFramebuffer() == 0)
rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale)); // Apply screen scaling if required rlMultMatrixf(MatrixToFloat(CORE.Window.screenScale)); // Apply screen scaling if required
rlDisableDepthTest(); // Disable DEPTH_TEST for 2D rlDisableDepthTest(); // Disable DEPTH_TEST for 2D

View File

@ -621,6 +621,7 @@ RLAPI void rlDisableShader(void); // Disable shader progra
// Framebuffer state // Framebuffer state
RLAPI void rlEnableFramebuffer(unsigned int id); // Enable render texture (fbo) RLAPI void rlEnableFramebuffer(unsigned int id); // Enable render texture (fbo)
RLAPI void rlDisableFramebuffer(void); // Disable render texture (fbo), return to default framebuffer RLAPI void rlDisableFramebuffer(void); // Disable render texture (fbo), return to default framebuffer
RLAPI unsigned int rlGetActiveFramebuffer(void); // Returns the active render texture (fbo), 0 for default framebuffer
RLAPI void rlActiveDrawBuffers(int count); // Activate multiple draw color buffers RLAPI void rlActiveDrawBuffers(int count); // Activate multiple draw color buffers
RLAPI void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int bufferMask); // Blit active framebuffer to main framebuffer RLAPI void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, int bufferMask); // Blit active framebuffer to main framebuffer
RLAPI void rlBindFramebuffer(unsigned int target, unsigned int framebuffer); // Bind framebuffer (FBO) RLAPI void rlBindFramebuffer(unsigned int target, unsigned int framebuffer); // Bind framebuffer (FBO)
@ -1725,6 +1726,17 @@ void rlEnableFramebuffer(unsigned int id)
#endif #endif
} }
// return the active render texture (fbo)
unsigned int rlGetActiveFramebuffer(void)
{
#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES3)) && defined(RLGL_RENDER_TEXTURES_HINT)
GLint fboId = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &fboId);
return fboId;
#endif
return 0;
}
// Disable rendering to texture // Disable rendering to texture
void rlDisableFramebuffer(void) void rlDisableFramebuffer(void)
{ {