upside-down textures in DevIL
hi, I just tried to use DevIL to load my textures. Everything ok but the textures are upside-down for any image format... Im sure the texture mapping is correct. Does anyone know if this is normal and how can I correct it (except of reversing the y tex coords or inverting the image file). Is there a setting or something? Or is there a better image loading lib?
Can you show us your texture mapping [smile]
Whenever a programmer says they know something is right...[wink]
Whenever a programmer says they know something is right...[wink]
Yes, I think this is the problem with the latest version of DevIL and it applies only to BMP formats. Are you using BMP? If not, then what I am thinking about does not apply to you, but if you are I believe the reason has something to do with the way DevIL stores BMP files. A simple solution is to use something other than BMP, like PNG - much smaller size with lossless compression.
sure
[Edited by - eXXXile on March 20, 2005 5:16:53 PM]
glBegin(GL_QUADS);{ glTexCoord2d(0,0); glVertex3f(-1,-1,-3); glTexCoord2d(1,0); glVertex3f( 1,-1,-3); glTexCoord2d(1,1); glVertex3f( 1, 1,-3); glTexCoord2d(0,1); glVertex3f(-1, 1,-3);}glEnd();
[Edited by - eXXXile on March 20, 2005 5:16:53 PM]
no, this does apply to ANY format I tried (png, jpg, tga, bmp) all have dimensions that are power of two. There must be a setting or something... BTW how do I add source code to this forum?
Quote:
Original post by eXXXile
no, this does apply to ANY format I tried (png, jpg, tga, bmp) all have dimensions that are power of two. There must be a setting or something... BTW how do I add source code to this forum?
Use the [source] [/source] tags. You can also look at the FAQ at the very top of the page, next to active topics and search for some more info with using the source tags.
Ok so your code looks correct to me, as you said, so if this is not a DevIL problem, then you might want to check your camera maybe? As for a better image library, I would just use NeHe's IPicture
* Loads : BMP, EMF, GIF, ICO, JPG, WMF ** Source : Reads From Disk Or The Internet ** Extras : Images Can Be Any Width Or Height *
There is nothing to link in, you just use that function in the file and that's it! Well you will need to link in some standard windows librarie, but nothing custom!
- Drew
it's definitely not the camera, using my own loader the texture shows ok, but I want to use a ready library created by more experienced programmers than me. I will give IPicture a try. Still my question for the DevIL remains. Does anyone here use it?
I'm using DevIL right now. Here's my texture mapping code:
And here's my View setup code:
//this code would render a quad across the entire viewing areaglBegin(GL_QUADS); glTexCoord2f(1.0f, 1.0f); glVertex3f( 11.0f, 8.3f, -20.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-11.0f, 8.3f, -20.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-11.0f, -8.3f, -20.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 11.0f, -8.3f, -20.0f);glEnd();
And here's my View setup code:
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); glEnable( GL_TEXTURE_2D ); glEnable( GL_DEPTH_TEST ); glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45.0f, (float)SCREEN_WIDTH / (float)SCREEN_HEIGHT, 1.0f, 100.0f); glMatrixMode (GL_MODELVIEW); glLoadIdentity ();
Flip it before sending to opengl (with glTexImage..)
I'm sure Devil has a function for flipping
I'm sure Devil has a function for flipping
I had the very same problem...An easy solution is to use negative texture coordinates on the y axis for all of your texture calls.
or you can automatically do the same thing for all of them by doing
glMatrixMode(GL_TEXTURE);
glScalef(1.0f,-1.0f,1.0f);
glMatrixMode(GL_MODELVIEW);
Or write your own flipping code. not hard to do at all. This is what I did
Or just wait for the glitch to be fixed :)
or you can automatically do the same thing for all of them by doing
glMatrixMode(GL_TEXTURE);
glScalef(1.0f,-1.0f,1.0f);
glMatrixMode(GL_MODELVIEW);
Or write your own flipping code. not hard to do at all. This is what I did
Or just wait for the glitch to be fixed :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement