Hi Eric and Stephan,
On 5/9/07, Stephan Huber <[EMAIL PROTECTED]> wrote:
E. Wing schrieb:
> Also attached is a picture from OpenGL Profiler showing a texture on
> my 9800 Pro. I don't think transparency is the issue because the text
> would show up as solid blocks if this was wrong, right? For some
> reason, OpenGL Profiler didn't show me anything when running on my
> Nvidia FX Go5200 so I don't have a screenshot to compare.
If I understand the openglprofiler-screenshot correctly, then the glyphs
don't have a transparent border (see the "O" for example, the
surrounding area is opaque/white), so texel interpolation will bring
some white into the textured quad. In my own font-rendering I solved
this by surrounding my glyphs with a 1 pixel transparent border.
It seems that the texture-image gets never initialized to a transparent
background, on my testings I can see a lot of pixel-garbage in the
unused areas of the texture.
Finally we seem to be getting to the bottom of it. The initial texture
object was be allocated using 0, when tells OpenGL to allocated the the data
by not copy any data. The init code look like this:
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA,
getTextureWidth(), getTextureHeight(), 0,
GL_ALPHA,
GL_UNSIGNED_BYTE,
0 );
What it looks like is that different drivers initialize the memory in
different ways, we lucked out with NVidia initializing to 0's. I have now
changed the implementation so that is initializes the original blank glyph
texture to all 0's, the code now looks like:
unsigned int imageDataSize = getTextureHeight()*getTextureWidth();
unsigned char* imageData = new unsigned char[imageDataSize];
for(unsigned int i=0; i<imageDataSize; ++i)
{
imageData[i] = 0;
}
// allocate the texture memory.
glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA,
getTextureWidth(), getTextureHeight(), 0,
GL_ALPHA,
GL_UNSIGNED_BYTE,
imageData );
delete [] imageData;
This is now checked in. Could you guys test it out?
(And why is the texture so big? 1024 x 1024)
Last week I upped it from 512x512 to 1024x1024 to provide enough room for
reasonably large font resolutions, the more glyphs you can fit into a single
texture the less textures are used, and the more efficient things should be
- as long as your blow memory on the card. A 1kx1kx1byte texture is just a
1Mb, when is a drop in th ocean on modern machines with even entry level
graphics having 256Mb onboard.
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/