PDA

View Full Version : Texture distorsion



Toinou
06-13-2001, 10:27 PM
Hi there, I need to show an image in an OpenGL space (I would like to show it like a 2D viewer would do), but the image is not exactly the same as what it is in reality (I mean in a 2D viewing program), although I use glOrtho, and a viewport which has the same dimensions as my image, there is color distorsion...
This is the code I use :
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
Is it a problem of filter, lighting (I chose the default one), projection, environment???
Anybody to help me?
Thanks a lot,
Antoine Rennuit.

julius
06-14-2001, 01:40 AM
Well you could try to use GL_DECAL instead of GL_MODULATE.

Toinou
06-14-2001, 03:42 AM
Well, well, it doesn't work...

ffish
06-14-2001, 04:45 AM
You need to get a copy of the blue book (or find an online copy) and tailor the texture function to your needs. Read the specs for glTexEnv. You need to take into account what format your image data is in and how the texture functions act on the fragment to be textured. From the sounds of what you want to do, julius was right - you either want GL_DECAL or GL_REPLACE instead of GL_MODULATE. Unfortunately you have to know what OpenGL will do to your textures using these functions and the only way is to read it (I'm not going to type it all out here - sorry http://www.opengl.org/discussion_boards/ubb/smile.gif).

You also need to know how OpenGL treats colour - differently from your 2D drawing program I would think. There was a lengthy discussion on one of the boards (probably the advanced board) about colour spaces a while ago. Either do a search or maybe someone else remembers the link.

Hope that helps.