Skip to content

Commit cf16edd

Browse files
committed
render target zooming
TODO: Move this to a more general camera class
1 parent 8310c77 commit cf16edd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Source/Renderer/RenderTarget.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RenderTarget::~RenderTarget() {
5252
rlUnloadTexture(m_Depth.id);
5353
}
5454

55-
void RenderTarget::Begin(bool clear) {
55+
void RenderTarget::Begin(bool clear, float zoom) {
5656
rlDrawRenderBatchActive();
5757
rlResetDrawDepth();
5858
rlEnableFramebuffer(m_FBO);
@@ -65,6 +65,10 @@ void RenderTarget::Begin(bool clear) {
6565
rlMatrixMode(RL_PROJECTION);
6666
rlLoadIdentity();
6767
rlOrtho(0.0f, m_Size.w, m_Size.h, 0.0f, c_NearDepth, c_FarDepth);
68+
rlTranslatef(m_Size.w / 2, m_Size.h / 2, 0.0f);
69+
rlScalef(zoom, zoom, 1.0f);
70+
rlTranslatef(-m_Size.w / 2, -m_Size.h / 2, 0.0f);
71+
rlMatrixMode(RL_MODELVIEW);
6872
rlMatrixMode(RL_MODELVIEW);
6973
rlLoadIdentity();
7074

Source/Renderer/RenderTarget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace RTE {
2121

2222
/// Enables this RenderTarget for drawing and sets up projection matrix. Draws current batch, resets draw depth and model matrix.
2323
/// @param clear Whether to clear the target.
24-
void Begin(bool clear = true);
24+
void Begin(bool clear = true, float zoom = 1.0f);
2525

2626
/// Disables this RenderTarget and flushes the active batch.
2727
void End();

0 commit comments

Comments
 (0)