medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit b34ea80f37609a3c53254971f061e98cb1dd5ce1
parent 7e315ef92aa9875939f8ec38e3485398bbd9dfe1
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Nov  5 12:44:39 +0200

textureformat_to_glenum

Diffstat:
renderer.cc | 21++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/renderer.cc b/renderer.cc @@ -63,6 +63,21 @@ static GLenum bufferusage_to_glenum( BufferUsage usage ) { } } +static GLenum textureformat_to_glenum( TextureFormat format ) { + switch( format ) { + case TEXFMT_RGBA_FLOAT: return GL_RGBA32F; + case TEXFMT_RGB_FLOAT: return GL_RGB32F; + case TEXFMT_R_FLOAT: return GL_R32F; + case TEXFMT_R_U8: return GL_R8; + + default: + FATAL( "unsupported TextureFormat: %d", format ); + break; + } + + return 0; +} + VB renderer_new_vb( const void * data, size_t len, BufferUsage usage ) { GLuint vbo; glGenBuffers( 1, &vbo ); @@ -238,30 +253,26 @@ Texture renderer_new_texture( TextureConfig config ) { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - GLenum internal_format; + GLenum internal_format = textureformat_to_glenum( config.format ); GLenum channels, type; switch( config.format ) { case TEXFMT_RGBA_FLOAT: - internal_format = GL_RGBA32F; channels = GL_RGBA; type = GL_FLOAT; break; case TEXFMT_RGB_FLOAT: - internal_format = GL_RGB32F; channels = GL_RGB; type = GL_FLOAT; break; case TEXFMT_R_FLOAT: - internal_format = GL_R32F; channels = GL_RED; type = GL_FLOAT; break; case TEXFMT_R_U8: - internal_format = GL_R8; channels = GL_RED; type = GL_UNSIGNED_BYTE; break;