Skip to main content
gamedev.net
🔒 Locked

Rectangle Textures

Started by Gergo Aug 10, 2007 at 5:02 AM 3 replies 900+ views
Original Post
Gergo
Gergo
Hi! I'm trying to use the GL_ARB_texture_rectangle extension, but I get strange results. In theory my card supports this extension (it's in the extension string). This is what it looks like: http://img406.imageshack.us/my.php?image=error2se9.jpg This is an image of a landscape, but it becomes grayscale, and scrambled. I don't use mipmaps, and the texture coordinate wrap is gl_clamp, and I specify the texcoords in the [0..w]x[0..h] range... Does anyone encountered something like this? Any suggestions would be appreciated.
nmi
nmi
How do you create the texture in your application ? Maybe you are using the wrong storage format for the data.
Gergo
Gergo
This code loads the textures:

glGenTextures(1,&id);
glBindTexture(target,id);
glTexParameteri(target,GL_TEXTURE_MAG_FILTER,magfilt);
glTexParameteri(target,GL_TEXTURE_MIN_FILTER,minfilt);
glTexParameteri(target,GL_TEXTURE_WRAP_S,GL_CLAMP);
glTexParameteri(target,GL_TEXTURE_WRAP_T,GL_CLAMP);
glTexImage2D(target,0,type,f_width,f_height,border,type,GL_UNSIGNED_BYTE,img->Pixel(0,0));

where target is GL_TEXTURE_2D if both f_width and f_height are power of two, otherwise it's GL_TEXTURE_RECTANGLE_ARB. type is GL_RGB, border is 0.
nmi
nmi
Just some ideas which you might try:
1) Is the texture you provide to glTexImage2D() really a 24 bit RGB texture or does it contain alpha ?
2) Did you glEnable(GL_TEXTURE_RECTANGLE_ARB) ?
3) Are you using shaders ? Then use: "uniform Sampler2DRect Texture0; ... texture2DRect(Texture0, vec2(gl_TexCoord[0]));"
4) Are you using borders ? They are not supported for rectangular textures.

Gergo
Gergo
Thanks guys for the help, it turned out that even though the dimensions don't have to be power of two, they must be divisible by 2 :D

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.