summaryrefslogtreecommitdiffstats
path: root/src/graphics/opengl
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-05-11 23:05:20 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2013-05-11 23:12:13 +0200
commitcec406ea31c3ccb22ab676ce3fd52d4cd0dfcb0d (patch)
tree61c5c3a101e2ae5a1b4c0fe352d290462675aac5 /src/graphics/opengl
parentdcf4c8941f3d0d287f0068ef64949890edeefa95 (diff)
downloadcolobot-cec406ea31c3ccb22ab676ce3fd52d4cd0dfcb0d.tar.gz
colobot-cec406ea31c3ccb22ab676ce3fd52d4cd0dfcb0d.tar.bz2
colobot-cec406ea31c3ccb22ab676ce3fd52d4cd0dfcb0d.zip
Non-power-of-2 padding for background images
* added padding options * removed old hardcoded image sizes
Diffstat (limited to 'src/graphics/opengl')
-rw-r--r--src/graphics/opengl/gldevice.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 86f92b2..f351f22 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -423,11 +423,15 @@ Texture CGLDevice::CreateTexture(CImage *image, const TextureCreateParams &param
return Texture(); // invalid texture
}
- Math::IntPoint size = image->GetSize();
- if (!Math::IsPowerOfTwo(size.x) || !Math::IsPowerOfTwo(size.y))
- GetLogger()->Warn("Creating non-power-of-2 texture (%dx%d)!\n", size.x, size.y);
+ Math::IntPoint originalSize = image->GetSize();
- return CreateTexture(data, params);
+ if (params.padToNearestPowerOfTwo)
+ image->PadToNearestPowerOfTwo();
+
+ Texture tex = CreateTexture(data, params);
+ tex.originalSize = originalSize;
+
+ return tex;
}
Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &params)
@@ -437,6 +441,11 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
result.size.x = data->surface->w;
result.size.y = data->surface->h;
+ if (!Math::IsPowerOfTwo(result.size.x) || !Math::IsPowerOfTwo(result.size.y))
+ GetLogger()->Warn("Creating non-power-of-2 texture (%dx%d)!\n", result.size.x, result.size.y);
+
+ result.originalSize = result.size;
+
// Use & enable 1st texture stage
if (m_multitextureAvailable)
glActiveTexture(GL_TEXTURE0);