commit fb2ad848ba52c2c03cac817d90456dcfa2e8340c parent 79f3e1c90927c09886464ea14853f7c07dc02363 Author: Michael Savage <mikejsavage@gmail.com> Date: Wed Jan 18 19:52:39 +0200 Default to invalid texture format Diffstat:
renderer.cc | | | 15 | +++++++++------ |
renderer.h | | | 4 | ++-- |
diff --git a/renderer.cc b/renderer.cc @@ -50,10 +50,11 @@ static GLenum textureformat_to_glenum( TextureFormat format ) { case TEXFMT_R_FLOAT: return GL_R32F; case TEXFMT_R_U8: return GL_R8; case TEXFMT_BC4: return GL_COMPRESSED_RED_RGTC1; - } - FATAL( "unsupported TextureFormat: %d", format ); - return 0; + default: + FATAL( "unsupported TextureFormat: %d", format ); + return 0; + } } VB renderer_new_vb( const void * data, u32 len, BufferUsage usage ) { @@ -300,13 +301,15 @@ static u32 texture_byte_size( u32 width, u32 height, TextureFormat format, bool return total_dim * 1 * sizeof( u8 ); case TEXFMT_BC4: return total_dim / 2; + default: + FATAL( "unsupported TextureFormat: %d", format ); + return 0; } - - FATAL( "unsupported TextureFormat: %d", format ); - return 0; } Texture renderer_new_texture( TextureConfig config ) { + ASSERT( config.format != TEXFMT_INVALID ); + GLuint texture; glGenTextures( 1, &texture ); glBindTexture( GL_TEXTURE_2D, texture ); diff --git a/renderer.h b/renderer.h @@ -130,18 +130,18 @@ struct ShaderConfig { }; enum TextureFormat { + TEXFMT_INVALID, TEXFMT_RGBA_FLOAT, TEXFMT_RGB_FLOAT, TEXFMT_R_FLOAT, TEXFMT_R_U8, TEXFMT_BC4, - TEXFMT_INVALID, }; struct TextureConfig { u32 width = 0; u32 height = 0; - TextureFormat format = TEXFMT_RGBA_FLOAT; + TextureFormat format = TEXFMT_INVALID; bool srgb = false; const void * data = NULL; u32 data_size;