From 68a7bafe37adef0e5ef12c2d0e8461a21e05363b Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 16 Jul 2012 19:17:26 +0200 Subject: Fixes in texture loading - added other texture formats: BGR and BGRA - fixed texture loading in model viewer - moved code from texture.cpp module to texture.h --- src/graphics/opengl/gldevice.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/graphics/opengl/gldevice.cpp') diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index eb4eb31..e329ff4 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -393,10 +393,16 @@ Gfx::Texture* Gfx::CGLDevice::CreateTexture(CImage *image, const Gfx::TextureCre glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE); GLenum sourceFormat = 0; - if (params.alpha) + if (params.format == Gfx::TEX_IMG_RGB) + sourceFormat = GL_RGB; + else if (params.format == Gfx::TEX_IMG_BGR) + sourceFormat = GL_BGR; + else if (params.format == Gfx::TEX_IMG_RGBA) sourceFormat = GL_RGBA; + else if (params.format == Gfx::TEX_IMG_BGRA) + sourceFormat = GL_BGRA; else - sourceFormat = GL_RGB; + assert(false); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data->surface->w, data->surface->h, 0, sourceFormat, GL_UNSIGNED_BYTE, data->surface->pixels); -- cgit v1.2.3-1-g7c22