diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2013-05-26 11:34:53 +0200 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2013-05-26 11:34:53 +0200 |
commit | b41957f2f95d8f62817705a1c82322d9463d28a2 (patch) | |
tree | 0ff331e8dd61039ecc193add91b05e5fe07c7651 /src/graphics/opengl/gldevice.cpp | |
parent | ff101c6973baeac63f8027118d4dad644354d869 (diff) | |
download | colobot-b41957f2f95d8f62817705a1c82322d9463d28a2.tar.gz colobot-b41957f2f95d8f62817705a1c82322d9463d28a2.tar.bz2 colobot-b41957f2f95d8f62817705a1c82322d9463d28a2.zip |
Corrected some valgrind issues
* fixed several uninitialized variable issues
* fixed possible memory corruption in CEngine
Diffstat (limited to 'src/graphics/opengl/gldevice.cpp')
-rw-r--r-- | src/graphics/opengl/gldevice.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index f351f22..9d5abc3 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -653,7 +653,7 @@ void CGLDevice::SetTexture(int index, const Texture &texture) glBindTexture(GL_TEXTURE_2D, texture.id); // Params need to be updated for the new bound texture - SetTextureStageParams(index, m_textureStageParams[index]); + UpdateTextureParams(index); } void CGLDevice::SetTexture(int index, unsigned int textureId) @@ -674,7 +674,7 @@ void CGLDevice::SetTexture(int index, unsigned int textureId) glBindTexture(GL_TEXTURE_2D, textureId); // Params need to be updated for the new bound texture - SetTextureStageParams(index, m_textureStageParams[index]); + UpdateTextureParams(index); } /** @@ -727,6 +727,13 @@ void CGLDevice::SetTextureStageParams(int index, const TextureStageParams ¶m // Remember the settings m_textureStageParams[index] = params; + UpdateTextureParams(index); +} + +void CGLDevice::UpdateTextureParams(int index) +{ + assert(index >= 0 && index < static_cast<int>( m_currentTextures.size() )); + if (!m_multitextureAvailable && index != 0) return; @@ -734,6 +741,8 @@ void CGLDevice::SetTextureStageParams(int index, const TextureStageParams ¶m if (! m_currentTextures[index].Valid()) return; + const TextureStageParams ¶ms = m_textureStageParams[index]; + if (m_multitextureAvailable) glActiveTexture(GL_TEXTURE0 + index); |