From e71153258b2f1b78b2d6de5578786f22582e523f Mon Sep 17 00:00:00 2001 From: Jett <30197659+JettMonstersGoBoom@users.noreply.github.com> Date: Tue, 19 Dec 2023 18:27:59 -0500 Subject: [PATCH] fix for deferred rendering example. (#3655) * fix for deferred rendering example. * missed defines to build. --- examples/shaders/shaders_deferred_render.c | 4 ++-- src/rlgl.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/shaders/shaders_deferred_render.c b/examples/shaders/shaders_deferred_render.c index 21d2af34..9df1b249 100644 --- a/examples/shaders/shaders_deferred_render.c +++ b/examples/shaders/shaders_deferred_render.c @@ -254,8 +254,8 @@ int main(void) EndMode3D(); // As a last step, we now copy over the depth buffer from our g-buffer to the default framebuffer. - rlEnableFramebuffer(gBuffer.framebuffer); //glBindFramebuffer(GL_READ_FRAMEBUFFER, gBuffer.framebuffer); - rlEnableFramebuffer(0); //glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + rlBindFramebuffer(GL_READ_FRAMEBUFFER, gBuffer.framebuffer); + rlBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); rlBlitFramebuffer(0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight, 0x00000100); // GL_DEPTH_BUFFER_BIT rlDisableFramebuffer(); diff --git a/src/rlgl.h b/src/rlgl.h index 4b318498..b49185f1 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -320,6 +320,8 @@ #define RL_BLEND_SRC_ALPHA 0x80CB // GL_BLEND_SRC_ALPHA #define RL_BLEND_COLOR 0x8005 // GL_BLEND_COLOR +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 //---------------------------------------------------------------------------------- // Types and Structures Definition @@ -621,6 +623,7 @@ RLAPI void rlEnableFramebuffer(unsigned int id); // Enable render texture RLAPI void rlDisableFramebuffer(void); // Disable render texture (fbo), return to default framebuffer 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 rlBindFramebuffer(unsigned int id,unsigned int val); // bind (FBO) // General render state RLAPI void rlEnableColorBlend(void); // Enable color blending @@ -631,6 +634,7 @@ RLAPI void rlEnableDepthMask(void); // Enable depth write RLAPI void rlDisableDepthMask(void); // Disable depth write RLAPI void rlEnableBackfaceCulling(void); // Enable backface culling RLAPI void rlDisableBackfaceCulling(void); // Disable backface culling +RLAPI void rlColorMask(bool,bool,bool,bool); // color mask control RLAPI void rlSetCullFace(int mode); // Set face culling mode RLAPI void rlEnableScissorTest(void); // Enable scissor test RLAPI void rlDisableScissorTest(void); // Disable scissor test @@ -1737,6 +1741,14 @@ void rlBlitFramebuffer(int srcX, int srcY, int srcWidth, int srcHeight, int dstX #endif } +// bind framebuffer object +void rlBindFramebuffer(unsigned int id,unsigned int val) +{ +#if (defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)) && defined(RLGL_RENDER_TEXTURES_HINT) + glBindFramebuffer(id, val); +#endif +} + // Activate multiple draw color buffers // NOTE: One color buffer is always active by default void rlActiveDrawBuffers(int count) @@ -1813,6 +1825,8 @@ void rlEnableBackfaceCulling(void) { glEnable(GL_CULL_FACE); } // Disable backface culling void rlDisableBackfaceCulling(void) { glDisable(GL_CULL_FACE); } +void rlColorMask(bool r,bool g,bool b,bool a) { glColorMask(r,g,b,a); } + // Set face culling mode void rlSetCullFace(int mode) {