From 050f9d25428d8298b010c73e9721d7b7203ef31f Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 16 Sep 2012 20:39:32 +0200 Subject: Fix max lights error --- src/graphics/opengl/gldevice.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/graphics/opengl') diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index a779a5f..09efeb3 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -129,9 +129,11 @@ bool Gfx::CGLDevice::Create() glViewport(0, 0, m_config.size.x, m_config.size.y); + int numLights = 0; + glGetIntegerv(GL_MAX_LIGHTS, &numLights); - m_lights = std::vector(GL_MAX_LIGHTS, Gfx::Light()); - m_lightsEnabled = std::vector (GL_MAX_LIGHTS, false); + m_lights = std::vector(numLights, Gfx::Light()); + m_lightsEnabled = std::vector (numLights, false); int maxTextures = 0; glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextures); -- cgit v1.2.3-1-g7c22 From 4b67386a697c27186b6eb4809bea9547372dacd7 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 17 Sep 2012 23:41:53 +0200 Subject: Change of background image handling - removed old 4 quarter backgrounds - fixes in texture loading - other minor fixes --- src/graphics/opengl/gldevice.cpp | 58 ++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 14 deletions(-) (limited to 'src/graphics/opengl') diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 09efeb3..881e273 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -436,7 +436,10 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr else glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE); + + bool convert = false; GLenum sourceFormat = 0; + if (params.format == Gfx::TEX_IMG_RGB) { sourceFormat = GL_RGB; @@ -461,26 +464,26 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr { if (data->surface->format->Amask != 0) { - if ((data->surface->format->Rmask == 0xFF000000) && - (data->surface->format->Gmask == 0x00FF0000) && - (data->surface->format->Bmask == 0x0000FF00) && - (data->surface->format->Amask == 0x000000FF)) + if ((data->surface->format->Amask == 0xFF000000) && + (data->surface->format->Rmask == 0x00FF0000) && + (data->surface->format->Gmask == 0x0000FF00) && + (data->surface->format->Bmask == 0x000000FF)) { sourceFormat = GL_BGRA; result.alpha = true; } - else if ((data->surface->format->Bmask == 0xFF000000) && - (data->surface->format->Gmask == 0x00FF0000) && - (data->surface->format->Rmask == 0x0000FF00) && - (data->surface->format->Amask == 0x000000FF)) + else if ((data->surface->format->Amask == 0xFF000000) && + (data->surface->format->Bmask == 0x00FF0000) && + (data->surface->format->Gmask == 0x0000FF00) && + (data->surface->format->Rmask == 0x000000FF)) { sourceFormat = GL_RGBA; result.alpha = true; } else { - GetLogger()->Error("Auto texture format failed\n"); - return Gfx::Texture(); // other format? + sourceFormat = GL_RGBA; + convert = true; } } else @@ -501,16 +504,43 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr } else { - GetLogger()->Error("Auto texture format failed\n"); - return Gfx::Texture(); // other format? + sourceFormat = GL_RGBA; + convert = true; } } } else assert(false); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data->surface->w, data->surface->h, - 0, sourceFormat, GL_UNSIGNED_BYTE, data->surface->pixels); + SDL_Surface* actualSurface = data->surface; + SDL_Surface* convertedSurface = nullptr; + + if (convert) + { + SDL_PixelFormat format; + format.BytesPerPixel = 4; + format.BitsPerPixel = 32; + format.alpha = 0; + format.colorkey = 0; + format.Aloss = format.Bloss = format.Gloss = format.Rloss = 0; + format.Amask = 0xFF000000; + format.Ashift = 24; + format.Bmask = 0x00FF0000; + format.Bshift = 16; + format.Gmask = 0x0000FF00; + format.Gshift = 8; + format.Rmask = 0x000000FF; + format.Rshift = 0; + format.palette = nullptr; + convertedSurface = SDL_ConvertSurface(data->surface, &format, SDL_SWSURFACE); + if (convertedSurface != nullptr) + actualSurface = convertedSurface; + } + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, actualSurface->w, actualSurface->h, + 0, sourceFormat, GL_UNSIGNED_BYTE, actualSurface->pixels); + + SDL_FreeSurface(convertedSurface); // Restore the previous state of 1st stage -- cgit v1.2.3-1-g7c22 From 51884cef8e015bccbe1fa96dc56dc2f32439ccc5 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Wed, 19 Sep 2012 18:32:18 +0200 Subject: Input bindings rewrite - moved input bindings to CRobotMain - added virtual keymod and joystick button key presses - fixed putenv error; other minor fixes --- src/graphics/opengl/gldevice.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/graphics/opengl') diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 881e273..416b506 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -184,7 +184,6 @@ void Gfx::CGLDevice::BeginScene() void Gfx::CGLDevice::EndScene() { - glFlush(); } void Gfx::CGLDevice::Clear() -- cgit v1.2.3-1-g7c22