diff options
author | Eric Anholt <eric@anholt.net> | 2009-06-12 04:13:45 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2009-06-12 04:16:32 -0700 |
commit | e50e6662e02ce0a627ccb1c6e5115c432f83566f (patch) | |
tree | c24b6eda827b99b955ea5e9a455f89c161aec27b /load_texture.c | |
parent | eb6a99f6aa80f7f0e7a3d1ae884abce244c42676 (diff) |
Handle PNG_COLOR_TYPE_RGB as opposed to RGBA.
Diffstat (limited to 'load_texture.c')
-rw-r--r-- | load_texture.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/load_texture.c b/load_texture.c index fa7e46d..b191a57 100644 --- a/load_texture.c +++ b/load_texture.c @@ -55,6 +55,7 @@ GLuint load_texture_rgb(const char *filename) int stride; png_bytep *row_pointers; int i; + GLenum format; glGenTextures(1, &tex); @@ -107,8 +108,18 @@ GLuint load_texture_rgb(const char *filename) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + switch (png_info->color_type) { + case PNG_COLOR_TYPE_RGB: + format = GL_RGB; + break; + case PNG_COLOR_TYPE_RGBA: + format = GL_RGBA; + break; + default: + abort(); + } glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, - GL_RGBA, GL_UNSIGNED_BYTE, data); + format, GL_UNSIGNED_BYTE, data); free(data); free(row_pointers); |