Duncan C
Duncan C

Reputation: 131426

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.

Upvotes: 5

Views: 1796

Answers (2)

datenwolf
datenwolf

Reputation: 162234

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.

Upvotes: 5

Alan
Alan

Reputation: 4933

What format are your textures? S3TC compressed texture formats operate on 4x4 tiles, so may not work or may have visual artifacts if the dimensions are not multiples of 4.

Upvotes: 0

Related Questions