Sign in to follow this  

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

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

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
Ok bad texcoords, tex coords range from 0 - 1, anything in between iscropping the image, anythong over is repeating the image, so basically you are repeating the image you want over and over gain, change all of the 1024s and 768s to 1s(in glTexCoord2f).

Share this post


Link to post
Share on other sites

This topic is 4663 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this