PDA

View Full Version : Textures and Quality



Aumnayan
11-17-2011, 11:48 AM
I have a bitmap, with text, that I'm attempting to get displayed on the screen. This isn't a problem in itself, as I simply create a texture based on the bitmap and display it. The problem is that the quality of the image is degraded to the point where the text is illegible, even when the area allocated to the image on the screen is equivalent to the texture size. I have experimented with glDrawPixels, and though the quality of the image this method generates is what I'm looking for, it degrades performance of the overall application to a non-acceptable level. So I have been experimenting with mipmap's, and have found no perceptible difference in the texture (leading me to conclude I'm not doing it right).

This is being run on a ATI Radeon X1200 with opengl 2.1.8543 in linux .

The original way I was generating the texture


glGenTextures( 1, &texId);
glBindTexture(GL_TEXTURE_2D, texId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 676, 1024, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, bitmapdata);


The current, attempting to generate mipmaps for a ledgable bitmap.


glGenTextures( 1, &texId);
glBindTexture(GL_TEXTURE_2D, texId);
glEnable(GL_TEXTURE_2D);
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 676, 1024, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, bitmapdata);


The current method appears to be consistent with opengl.org mipmap documentation (http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation). Any ideas as to where I'm messing up?

Aumnayan
11-17-2011, 01:49 PM
Sometimes it's the stupidest things that trip us up.

The problem appears to be the size of the textures used. Creating the bitmap in a 1024x1024 buffer instead of the 676x1024 correct the quality problems I was seeing.