Jump to content
  • Advertisement
Sign in to follow this  
Braden

How do I display non-power-of-2 textures using OpenIL/DevIL?

This topic is 4970 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

Before I switched to OpenIL/DevIL I used GL_TEXTURE_RECTANGLE_ARB. How do I do this with OpenIL/DevIL? Thanks, Braden

Share this post


Link to post
Share on other sites
Advertisement
I've never used OpenIL or DevIL, but I don't see how they could possibly make it so that you can't use an OpenGL extension. You should be able to use it the same way as always.

Share this post


Link to post
Share on other sites
Calexus,

The reference page for gluBuild2DMipmaps() says that the target must be GL_TEXTURE_2D. GL_TEXTURE_2D doesn't let you use non-power-of-2 textures. I am going to try to put something else other then GL_TEXTURE_2D there to see if it works (even though it says not to (as an experiment)). Are there any other functions that would do it?

http://www.mevis.de/~uwe/opengl/gluBuild2DMipmaps.html


Kalidor,

I might be reading this documentation wrong, but I believe it takes an image loaded by the OpenIL/DevIL library and stores it in an opengl texture format returning a pointer to the texture.

http://openil.sourceforge.net/docs/ilut/f00171.htm


Thanks,
Braden

Share this post


Link to post
Share on other sites
Returns a pointer to the texture in VRAM or AGP memory? No. Returns a pointer to the texture in RAM? Most likely.
gluBuild2DMipmaps() builds (surprise!) mipmaps. GL_TEXTURE_RECTANGLE_ARB Doesn't support mipmaps.

Share this post


Link to post
Share on other sites
vNistelrooy,

I never stated which memory it was. I had intended it to mean RAM, which means you just restated what I said on all accounts.

Braden

Share this post


Link to post
Share on other sites

The texture doesn't display on the screen.

Braden



/* texid is of type GLuint */

glEnable(GL_TEXTURE_RECTANGLE_ARB);
ilBindImage(flat_textures[1]);
texid=ilutGLBindTexImage();
glBindTexture(GL_TEXTURE_RECTANGLE_ARB,texid);
glBegin(GL_QUADS);
{
glTexCoord2f(0,768); glVertex2f(0,0);
glTexCoord2f(0,0); glVertex2f(0,768);
glTexCoord2f(1024,0); glVertex2f(1024,768);
glTexCoord2f(1024,768); glVertex2f(1024,0);
}
glEnd();
glDeleteTextures(1,&texid);
glDisable(GL_TEXTURE_RECTANGLE_ARB);

Share this post


Link to post
Share on other sites
From the DevIL tutorial on using it with OpenGL:
Quote:
DevIL allows the use of arbitrarily-sized images, but OpenGL only works with images that have dimensions that are powers of 2, for optimization purposes. If an image has dimensions that are not powers of 2, DevIL will resize the image before sending it to OpenGL.


What this means is that DevIL is resizing your texture and then binding it to a TEXTURE_2D target. If you want to use TEXTURE_RECTANGLE, you will have to manually upload the texture.

Share this post


Link to post
Share on other sites
Oh, I didn't know that. I changed the extension to GL_TEXTURE_2D and something loads, but its not the image. Its garble. Im trying to think what might cause that.

Braden

Share this post


Link to post
Share on other sites
If you have only changed TEXTURE_RECTANGLE to TEXTURE_2D in that code snippet above, I can understand - the texture coordinates are way too large, making the texture tile like crazy. That may look like garbage.

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!