medfall

A super great game engine
Log | Files | Refs

commit f50e7acf0f4d4089798a62af81dd29d89b65299b
parent d8eb933ac79d7b8064f23777f2fd8f2f2f87eb33
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat May 20 15:13:09 +0300

renderer_clear_fb wasn't updating viewport

Diffstat:
renderer.cc | 41+++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/renderer.cc b/renderer.cc @@ -599,12 +599,31 @@ static GLenum primitivetype_to_glenum( PrimitiveType primitive_type ) { static RenderState previous_render_state; static u32 previous_viewport_width, previous_viewport_height; -void renderer_clear_fb( FB fb ) { +static void bind_fb( FB fb ) { if( fb.fbo != previous_render_state.fb.fbo ) { glBindFramebuffer( GL_DRAW_FRAMEBUFFER, fb.fbo ); previous_render_state.fb = fb; + + u32 viewport_width, viewport_height; + if( fb.fbo == 0 ) { + viewport_width = WIDTH; + viewport_height = HEIGHT; + } + else { + viewport_width = fb.width; + viewport_height = fb.height; + } + + if( viewport_width != previous_viewport_width || viewport_height != previous_viewport_height ) { + previous_viewport_width = viewport_width; + previous_viewport_height = viewport_height; + glViewport( 0, 0, viewport_width, viewport_height ); + } } +} +void renderer_clear_fb( FB fb ) { + bind_fb( fb ); glClear( fb.attachment == FB_COLOUR ? GL_COLOR_BUFFER_BIT : GL_DEPTH_BUFFER_BIT ); } @@ -638,25 +657,7 @@ void renderer_draw_mesh( const Mesh & mesh, const RenderState & state ) { } // framebuffer - if( state.fb.fbo != previous_render_state.fb.fbo ) { - glBindFramebuffer( GL_DRAW_FRAMEBUFFER, state.fb.fbo ); - - u32 new_viewport_width, new_viewport_height; - if( state.fb.fbo == 0 ) { - new_viewport_width = WIDTH; - new_viewport_height = HEIGHT; - } - else { - new_viewport_width = state.fb.width; - new_viewport_height = state.fb.height; - } - - if( new_viewport_width != previous_viewport_width || new_viewport_height != previous_viewport_height ) { - previous_viewport_width = new_viewport_width; - previous_viewport_height = new_viewport_height; - glViewport( 0, 0, new_viewport_width, new_viewport_height ); - } - } + bind_fb( state.fb ); // depth writing if( state.disable_depth_writes != previous_render_state.disable_depth_writes ) {