NPOT textures on ATI cards

I’m having an issue with non-power-of-two textures on ATI cards that I’m hoping someone can help me find a software fix for.

Using an image that is 21x20 pixels, getImageTexCoords() is returning [0.0, 0.0, 21.0, 20.0]. This is using an updated ATI driver (from 12/4/2007, version 8.442.0.0), and has been replicated on two different machines, one with an X1400 and one with a Radeon XPress. Before the driver was updated, the image was displaying and these values were being returned correctly; bounded between 0 and 1 (and works correctly on all NVidia cards).

In addition, the Texture object is returning 21 and 20 as the results to calls to getWidth() and getHeight(), respectively. If this was returning the correct texture size, I could just create the texture coordinates myself, but I don’t have access to the actual created texture size, so I couldn’t do this correctly for all platforms.

As one last piece of data, if I hack in the correct texture coordinates, it seems that the wrong underlying image data is getting used for this texture, and a different image is actually getting displayed. The target object stored in the texture is different though, and writing the image being used out to disk does result in the correct image, so I don’t know how that would be happening.

We don’t have the option of asking our users to install a different driver so I need to determine a fix that I can deploy to our applet.

We’re using Jogl 1.1.1 rc6.

Many thanks,

Dale Beermann

The JOGL texture utilities attempt to heuristically detect whether the NPOT texture extensions will be really reliable on the current hardware. I’ve seen situations where the card reported it supported OpenGL 2.0 but not GL_ARB_texture_non_power_of_two, and the use of non-power-of-two textures caused fallbacks to software, killing performance. See the source code for the com.sun.opengl.util.texture.Texture class, in particular haveNPOT(). It sounds like in your case it is falling back to using the GL_ARB_texture_rectangle extension, in which texture coordinates go from (0, 0) to (imageWidth, imageHeight). If the jogl-demos demos.texture.TestTexture displays your image correctly, then there’s nothing fundamentally wrong with what the JOGL texture utilities are doing.

You can disable the use of the texture rectangle extension by setting the jogl.texture.notexrect system property to a non-null value. In the case where the NPOT extension doesn’t seem to be fully available, JOGL will expand the texture data out to power-of-two width and height.

Thank you for the quick reply. For our purposes, memory isn’t an issue so disabling the texture rectangle extension works fine. However, we’re having another issue as a result of it.

We commonly display foreign characters when using the TextRenderer. Before setting the system property to disable texture rectangles as you described, the characters would just render as squares if you didn’t have the font installed. Now, once a foreign character that is unsupported by fonts on the system is rendered, any other text, whether supported or not displays incorrectly. It seems as if the texture coordinates are incorrect, but I’m also not sure that the underlying image data is right.

Unfortunately, I tried attaching some files to show what’s happening, but got a message saying that the upload folder was full. If you want to email me at dale.beermann at sharendipity dot com, I can send them to you.

Thanks again,

Dale

I’ve emailed you separately. If you have a small test app which shows the problem and can also send the source code to me, that would be most helpful.