A coder's home for Marc "Foddex" Oude Kotte, who used to be located in Enschede, The Netherlands, but now in Stockholm, Sweden!

OpenGL fun with modern and older hardware

Originally posted at Thu 05-06-2008 12:53:53, in the c++ category.
You gotta love open standards, and different implementations thereof. I recently stumbled across exactly such a problem in OpenGL.

It's been a normal requirement since very long that textures in OpenGL have to be of a size which is a power of 2. For example, a size of 256x128 (resp. 2^8 and 2^7) are fine, but a size of 640x480 isn't. When you try to generate a texture using glTexImage2D with these sizes, you get a GL_INVALID_VALUE error.

However, my 3D project I'm working on accidentally contained a texture of size 800x600 (which is not a power of 2), and my development hardware kinda responded differently to it than all other test hardware I ran it on.

I develop on a PC with a NVIDIA 8800 GTX Ultra 768Mb, and for some reason it accepted the texture with the non-standard size just fine (which is also the reason I never knew about the issue ;) .) Running the application on older NVIDIA hardware (a mobile FX5200) yielded the error described above and resulted in a white texture being displayed.

Running it on ATI hardware though would result in extreme behaviour: loading it with glTexImage2D would yield no error, but rendering a single quad with a call to glDrawArrays using only one texture - the wrongly sized one - would result in a call taking . . . . . 8 seconds!!!

That was kinda out of the ordinary, and at first I had no clue the white texture and the slow renders were related. Luckily due to some extensive error checking logs I found out about the erroneous glTexImage2D call, and things kind of solved automatically from there.

Goes to show that error checking - especially during development - is vital, as is testing on multiple hardware - both on very old and very new. Leaves me to say that I hope Google picks up on this blog entry and maybe this info might help some other coder ;)

-- Foddex

0 comment(s)

URL: (optional!)
Write your comment:
Answer this question to prove you're human:
Is the top of this site's background color mostly orange or green?