commit 7b298c9ec1ffe8e11a5255eb1acf9a1c0c57a356 parent 779476146e4bd77169e7318875ff4857f9b38992 Author: Michael Savage <mikejsavage@gmail.com> Date: Sat May 20 00:09:10 +0300 Small cleanup Diffstat:
hm.cc | | | 2 | +- |
renderer.cc | | | 12 | ++++++++---- |
renderer.h | | | 74 | +++++++++++++++++++++++++++++++++++++------------------------------------- |
diff --git a/hm.cc b/hm.cc @@ -118,7 +118,7 @@ extern "C" GAME_FRAME( game_frame ) { { PROFILE_BLOCK( "renderer_begin_frame" ); - renderer_begin_frame( CLEARCOLOUR_DONT ); + renderer_begin_frame( RENDERER_CLEAR_COLOUR_DONT ); } float fb = float( input->keys[ KEY_W ] - input->keys[ KEY_S ] ); diff --git a/renderer.cc b/renderer.cc @@ -21,10 +21,14 @@ static const GLuint ATTR_TEX_COORD1 = 3; static const GLuint ATTR_COLOUR = 4; void renderer_begin_frame( ClearColourBool clear_colour, ClearDepthBool clear_depth ) { - if( clear_colour == CLEARCOLOUR_DO || clear_depth == CLEARDEPTH_DO ) { - GLbitfield clear_mask = 0; - clear_mask |= clear_colour == CLEARCOLOUR_DO ? GL_COLOR_BUFFER_BIT : 0; - clear_mask |= clear_depth == CLEARDEPTH_DO ? GL_DEPTH_BUFFER_BIT : 0; + GLbitfield clear_mask = 0; + if( clear_colour == RENDERER_CLEAR_COLOUR_DO ) { + clear_mask |= GL_COLOR_BUFFER_BIT; + } + if( clear_depth == RENDERER_CLEAR_DEPTH_DO ) { + clear_mask |= GL_DEPTH_BUFFER_BIT; + } + if( clear_mask != 0 ) { glClear( clear_mask ); } diff --git a/renderer.h b/renderer.h @@ -49,6 +49,40 @@ enum BufferUsage { BUFFERUSAGE_STREAM, }; +enum PrimitiveType { + PRIMITIVETYPE_TRIANGLES, + PRIMITIVETYPE_TRIANGLE_STRIP, + PRIMITIVETYPE_POINTS, + PRIMITIVETYPE_LINES, +}; + +enum TextureFormat { + TEXFMT_INVALID, + TEXFMT_RGBA_FLOAT, + TEXFMT_RGB_FLOAT, + TEXFMT_R_FLOAT, + TEXFMT_R_U8, + + TEXFMT_DEPTH, + + TEXFMT_BC1, + TEXFMT_BC3, + TEXFMT_BC4, + TEXFMT_BC5, +}; + +enum TextureWrapMode { + TEXWRAP_REPEAT, + TEXWRAP_CLAMP, + TEXWRAP_MIRROR, + TEXWRAP_BORDER, +}; + +enum FramebufferAttachment { + FB_COLOUR, + FB_DEPTH, +}; + struct TB { TextureBufferObject tbo; Texture texture; @@ -73,13 +107,6 @@ struct RenderState { bool wireframe = false; }; -enum PrimitiveType { - PRIMITIVETYPE_TRIANGLES, - PRIMITIVETYPE_TRIANGLE_STRIP, - PRIMITIVETYPE_POINTS, - PRIMITIVETYPE_LINES, -}; - struct Mesh { u32 num_vertices; PrimitiveType primitive_type; @@ -130,28 +157,6 @@ struct ShaderConfig { StaticArray< const char *, RENDERER_MAX_TEXTURE_BUFFERS > texture_buffer_uniform_names = { }; }; -enum TextureFormat { - TEXFMT_INVALID, - TEXFMT_RGBA_FLOAT, - TEXFMT_RGB_FLOAT, - TEXFMT_R_FLOAT, - TEXFMT_R_U8, - - TEXFMT_DEPTH, - - TEXFMT_BC1, - TEXFMT_BC3, - TEXFMT_BC4, - TEXFMT_BC5, -}; - -enum TextureWrapMode { - TEXWRAP_REPEAT, - TEXWRAP_CLAMP, - TEXWRAP_MIRROR, - TEXWRAP_BORDER, -}; - struct TextureConfig { u32 width = 0; u32 height = 0; @@ -167,15 +172,10 @@ struct TextureConfig { bool srgb = false; }; -enum FramebufferAttachment { - FB_COLOUR, - FB_DEPTH, -}; - -enum ClearColourBool { CLEARCOLOUR_DONT, CLEARCOLOUR_DO }; -enum ClearDepthBool { CLEARDEPTH_DONT, CLEARDEPTH_DO }; +enum ClearColourBool { RENDERER_CLEAR_COLOUR_DONT, RENDERER_CLEAR_COLOUR_DO }; +enum ClearDepthBool { RENDERER_CLEAR_DEPTH_DONT, RENDERER_CLEAR_DEPTH_DO }; -void renderer_begin_frame( ClearColourBool clear_colour = CLEARCOLOUR_DO, ClearDepthBool clear_depth = CLEARDEPTH_DO ); +void renderer_begin_frame( ClearColourBool clear_colour = RENDERER_CLEAR_COLOUR_DO, ClearDepthBool clear_depth = RENDERER_CLEAR_DEPTH_DONT ); // TODO #define renderer_clear renderer_begin_frame