Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL vers >=2.0 requires texture dimensions to be multiples of 4 pixels?

I'm working on a Mac application using OpenGL textures that I load from image files on disk using glTexImage2D.

According to the docs, for OpenGL versions >= 2.0, textures can be any arbitrary size. (for versions <2.0, the x and y dimensions both have to be a power of 2.)

However, I am getting bad textures if my image dimensions are not an even multiple of 4. I've searched and searched, but can't find any documentation on this requirement. In fact, the "red book" explicitly states that the texture dimensions can be any value for version >= 2.0.

What am I missing?

And, is there a performance benefit to converting a texture to the next largest power-of-two dimension? My app will require Mac OS 10.6.6 or later, which should run on any Intel Mac. Some of the early Intel macs had very "humble" graphics hardware.

Any help would be greatly appreciated.

like image 826
Duncan C Avatar asked Jan 27 '11 17:01

Duncan C


1 Answers

The constraint on ordinary textures having dimensions being powers of 2 remains in OpenGL versions >= 2. However there is a new texture target supported, GL_TEXTURE_RECTANGLE, which supports arbitrary dimensions, but won't do mipmaping.

There's no constraint on dimensions being multiples of 4, however I suspect you might have glPixelStore(GL_UNPACK...) parameters set, maybe set by other parts of the program, that cause this behaviour.

like image 61
datenwolf Avatar answered Sep 22 '22 01:09

datenwolf