Jump to content
  • Advertisement
Sign in to follow this  
savage

OpenGL Wordaround for GL_TEXTURE_RECTANGLE_ARB GL_REPEAT issue

This topic is 3540 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi OpenGL gurus, I have recently discovered that the combination of GL_TEXTURE_RECTANGLE_ARB and GL_REPEAT just doesn't work ( Yes I should have read the Documentation ). Well the bottom line is that the IDE I am working on needs to be able to support ( load and display ) non power of 2 textures as well as power of 2 textures. 1. Is there an easy work around to get GL_TEXTURE_RECTANGLE_ARB textures repeating? 2. If not what is the correct way using GL_TEXTURE_2D with non power of 2 textures? I have Googled but not found any simple examples of how this should be done correctly and effeciently. Thanks. [Edited by - savage on December 8, 2008 4:07:22 AM]

Share this post


Link to post
Share on other sites
Advertisement
Instead of using GL_TEXTURE_RECTANGLE_ARB try to use GL_ARB_texture_non_power_of_two. If this extension is available, you can just use 1d,2d,3d textures of NPOT size with all its known features (wrapmodes, mipmapping..).

Take a look at
http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_non_power_of_two.txt

--
Ashaman

Share this post


Link to post
Share on other sites
here is another useful link:

http://www.opengl.org/wiki/index.php?title=NPOT_Textures&printable=yes

as You see we have three types of textures:
- POT - standard, with power of two size...
- NPOT - any size, and usage as POT textures - with all the features as POT!
- Texture Rectangles - any size, but with some restrictions... the appeared before POT textures

since NPOT textures was introduced as standard extension in opweGL 2.0 it is suggested to use it rather than texture rectangles.

Share this post


Link to post
Share on other sites
Thanks for the links Fen and Ashaman73 I read through both articles, but am non the wiser as to how I can implement GL_ARB_texture_non_power_of_two.
Do I use it in the same way as GL_TEXTURE_RECTANGLE_ARB?
ie.

glGenTextures(1, &textureID);
glBindTexture(GL_ARB_texture_non_power_of_two, textureID);
glTexParameteri(GL_ARB_texture_non_power_of_two, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_ARB_texture_non_power_of_two, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_ARB_texture_non_power_of_two, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_ARB_texture_non_power_of_two, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_ARB_texture_non_power_of_two, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);

Or is it used some other way?

Thanks.

Share this post


Link to post
Share on other sites
No, you use it in the same way as GL_TEXTURE_2D:

glBindTexture(GL_TEXTURE_2D, textureID);
...
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 123, 456, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);

Share this post


Link to post
Share on other sites
ok I'm confused or stupid or both.
With GL_TEXTURE_RECTANGLE_ARB I had to tell it specifically to use that, so how does OpenGL know to use GL_ARB_texture_non_power_of_two, if I don't explicitly tell it to do so for my textures?

If anyone happens to have a link or sample code that illustrates how this is done, it would be greatly appreciated.

Share this post


Link to post
Share on other sites
Quote:
Original post by savage
ok I'm confused or stupid or both.
With GL_TEXTURE_RECTANGLE_ARB I had to tell it specifically to use that, so how does OpenGL know to use GL_ARB_texture_non_power_of_two, if I don't explicitly tell it to do so for my textures?

If anyone happens to have a link or sample code that illustrates how this is done, it would be greatly appreciated.


You don't have to do anything. If you have GL_ARB_texture_non_power_of_two extension available, then GL_TEXTURE_2D can be non-POT, that's it.

Share this post


Link to post
Share on other sites
OK I did some searching and now understand that if the system supports the GL_ARB_texture_non_power_of_two extention, it just works. I tested this on one laptop and a desktop machine. And it works on one but not the other. Which makes sense as the laptop is a bit older and it seems does not support GL_ARB_texture_non_power_of_two but does support GL_TEXTURE_RECTANGLE_ARB while the desktop machine supports both.

Ok, my question now is, how can I ensure that if GL_ARB_texture_non_power_of_two is not supported, that I can still handle the loading and displaying of non power of 2 textures, so that the app works identically on both the laptop and desktop machines.

Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by savage
Ok, my question now is, how can I ensure that if GL_ARB_texture_non_power_of_two is not supported, that I can still handle the loading and displaying of non power of 2 textures, so that the app works identically on both the laptop and desktop machines.
If you need wrapping, rectangular textures aren't going to work for you. The simplest would be to do what gluBuild2DMipmaps does, and resize the image to the nearest power-of-two if GL_ARB_texture_non_power_of_two is not supported.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!