[mapserver-commits] r8565 - sandbox/graphics
svn at osgeo.org
svn at osgeo.org
Tue Feb 17 08:54:57 EST 2009
Author: toby
Date: 2009-02-17 08:54:57 -0500 (Tue, 17 Feb 2009)
New Revision: 8565
Modified:
sandbox/graphics/mapoglrenderer.cpp
sandbox/graphics/mapoglrenderer.h
Log:
Improved opengl texture quality by checking if non-power-of-2 sized textures are supported.
Modified: sandbox/graphics/mapoglrenderer.cpp
===================================================================
--- sandbox/graphics/mapoglrenderer.cpp 2009-02-17 13:06:35 UTC (rev 8564)
+++ sandbox/graphics/mapoglrenderer.cpp 2009-02-17 13:54:57 UTC (rev 8565)
@@ -30,15 +30,14 @@
GLvoid CALLBACK vertexCallback(GLdouble *vertex);
OglTexture::OglTexture(ms_uint32 width, ms_uint32 height, colorObj* color)
- : OglRenderer(MS_MAX(MS_MIN(NextPowerOf2(width), OglContext::MAX_TEXTURE_SIZE), OglContext::MIN_TEXTURE_SIZE)+TEXTURE_BORDER,
- MS_MAX(MS_MIN(NextPowerOf2(height), OglContext::MAX_TEXTURE_SIZE), OglContext::MIN_TEXTURE_SIZE)+TEXTURE_BORDER)
+ : OglRenderer(getTextureSize(GL_TEXTURE_WIDTH, width)+TEXTURE_BORDER,
+ getTextureSize(GL_TEXTURE_HEIGHT, height)+TEXTURE_BORDER)
{
- this->width = width;
- this->height = height;
- this->transparency = 1.0;
- this->pow2width = MS_MAX(MS_MIN(NextPowerOf2(width), OglContext::MAX_TEXTURE_SIZE), OglContext::MIN_TEXTURE_SIZE);
- this->pow2height = MS_MAX(MS_MIN(NextPowerOf2(height), OglContext::MAX_TEXTURE_SIZE), OglContext::MIN_TEXTURE_SIZE);
+ this->pow2width = getWidth()-TEXTURE_BORDER;
+ this->pow2height = getHeight()-TEXTURE_BORDER;
+ this->textureWidth = width;
+ this->textureHeight = height;
glPushMatrix();
@@ -61,8 +60,8 @@
makeCurrent();
OglCache* tile = new OglCache();
tile->texture = createTexture(TEXTURE_BORDER/2, TEXTURE_BORDER/2);
- tile->width = width;
- tile->height = height;
+ tile->width = this->textureWidth;
+ tile->height = this->textureHeight;
return tile;
}
@@ -85,6 +84,21 @@
return texture;
}
+ms_uint32 OglTexture::getTextureSize(GLuint dimension, ms_uint32 value)
+{
+ glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, value, value, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GLint check;
+ glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, dimension, &check);
+ if (check == 0)
+ {
+ return MS_MAX(MS_MIN(NextPowerOf2(value), OglContext::MAX_TEXTURE_SIZE), OglContext::MIN_TEXTURE_SIZE);
+ }
+ else
+ {
+ return value;
+ }
+}
+
OglRenderer::OglRenderer(ms_uint32 width, ms_uint32 height, colorObj* color)
{
int viewPort[4];
@@ -339,7 +353,6 @@
glPopMatrix();
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
- int error = glGetError();
}
void OglRenderer::renderPolylineTile(shapeObj *shape, OglCache* tile){
Modified: sandbox/graphics/mapoglrenderer.h
===================================================================
--- sandbox/graphics/mapoglrenderer.h 2009-02-17 13:06:35 UTC (rev 8564)
+++ sandbox/graphics/mapoglrenderer.h 2009-02-17 13:54:57 UTC (rev 8565)
@@ -95,12 +95,13 @@
~OglTexture();
OglCache* renderToTile();
private:
- int width;
- int height;
- int pow2width;
- int pow2height;
+ ms_uint32 textureWidth;
+ ms_uint32 textureHeight;
+ ms_uint32 pow2width;
+ ms_uint32 pow2height;
double scaleWidth;
double scaleHeight;
+ ms_uint32 getTextureSize(GLuint dimension, ms_uint32 value);
GLuint NextPowerOf2(GLuint in);
GLuint createTexture(ms_uint32 x, ms_uint32 y);
static ms_uint32 TEXTURE_BORDER;
More information about the mapserver-commits
mailing list