View Full Version : Non-square textures in OS X OpenGL
tigakub
2005.03.29, 01:17 AM
I know the red book and several other sources say that non-square power-of-2 textures are permissible. But I can't seem to get it to work. Is there something I have to enable? I don't want to use GL_TEXTURE_RECTANGLE_EXT because I am using mipmaps.
Does anyone know if this is somehow broken in Apple's implementation of OpenGL?
OneSadCookie
2005.03.29, 01:56 AM
it's always worked fine for me.
arekkusu
2005.03.29, 02:00 AM
But I can't seem to get it to work.
You'll have to clarify "can't get it to work". You get all white? Pink? Zebra stripes?
tigakub
2005.03.29, 02:07 AM
I have code that's working for square images. But if I use a non-square image, the texture is blank.
OneSadCookie
2005.03.29, 03:10 AM
you have a bug.
maaaaark
2005.03.29, 03:12 AM
oh that onesadcookie. :lol:
arekkusu
2005.03.29, 04:08 AM
OK, round 2: your texture is blank. Something about the texture is invalid. What is it?
* what does glGetError() say, after every single gl function?
* what are the texture dimensions? format? type? shoe size?
* how are you loading the texture data? Are you sure the client-side texels are OK?
* are you sure you've got the mipmap state set right, and a valid mipmap for every level (remember, every level must have POT dimensions.)
PowerMacX
2005.03.29, 04:08 AM
I have code that's working for square images. But if I use a non-square image, the texture is blank.
Size?
[filling the minimum 10 chars post....]
tigakub
2005.03.29, 04:54 AM
* are you sure you've got the mipmap state set right, and a valid mipmap for every level (remember, every level must have POT dimensions.)
You guys are great! That was it. I am generating the mipmaps by right-shifting width and height variables and stopping when either reaches 0. That means that I'm not generating the final 1 pixel high mipmap.
Thanks for your help.
arekkusu
2005.03.29, 05:03 AM
You can also set the base and max mip levels if you don't want to define every level.
tigakub
2005.03.29, 07:47 AM
cool! thanks, I did not know that and will definitely look into it
:D
Puzzler183
2005.03.29, 01:36 PM
Also, did you set the x and y sizes differently now that you are using a rectangular image? And are you taking into account pitch in the actual image data?
tigakub
2005.03.31, 09:24 PM
Hmmm. Not really sure why I need to be concerned about that unless you mean whether I'm scaling the texel coordinates to compensate for the non-square aspect ratio -- yes I'm doing that.
willThimbleby
2005.04.01, 06:36 AM
I suspect your problem is that rectangular texture coordinates are not scaled to (1,1) but are left as the actual image size (eg. (100, 200)). Your texture is probably "blank" because your are only using one pixel of the whole texture. You can either modify the texture matrix or just multiply them yourself which is simpler.
OneSadCookie
2005.04.01, 07:18 AM
that is only the case for EXT_texture_rectangle, which the OP specifically stated he's avoiding!
willThimbleby
2005.04.01, 07:39 AM
Hmm I should read more closely, thanks for catching that. But then surely rectangular textures aren't available? Non-power-of-two is a different matter afaik.
arekkusu
2005.04.01, 10:58 AM
This thread is about non-square POT textures. That is, 32x64 or 1x256 and so on.
This thread is about non-square POT textures. That is, 32x64 or 1x256 and so on.
Eh? POT is POT, square or rectangular doesn't matter, they are handled the same. A 100x50 texture is a non POT and needs the texture rectangle stuff to work.
KenD
arekkusu
2005.04.01, 04:29 PM
Correct. But the OP had difficulty reducing i.e. 64x32 to 2x1 and 1x1 mipmaps. I believe the problem is solved now.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.