Hello, I’ve been working on mapping images on planes in an OpenGL workspace, everything works pretty well : I can read images, display them on the screen…
But I need to show the exact images, and there are slight color distorsions :
-
my viewport and my image have the same dimensions
-
I am using an orthogonal projection
Is it a problem of filter, of texture generation, binding, of blending… or anything else?
Here is how I init textures:
void TMainWin::init ( void )
{
// Enable material properties for lighting
glEnable ( GL_COLOR_MATERIAL );
glColorMaterial ( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );glEnable ( GL_TEXTURE_2D );
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
glGenTextures ( 2, texture_id );glBindTexture ( GL_TEXTURE_2D, texture_id[0]);
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 );
loadTextureFromBMPFile ( “c:\back24b.bmp”, 640, 480, 3, GL_RGB);// Leave depth test off for speed, theres no ‘in and out’ movement anyhoo
// glEnable (GL_DEPTH_TEST);
// glEnable ( GL_CULL_FACE );
// glEnable ( GL_BLEND );
// glBlendFunc ( GL_ONE, GL_ONE );
glClearColor ( 0.0, 0.0, 0.0, 0.0 );
}
//---------------------------------------------------------------------------
and this is how I render my scene :
void __fastcall TMainWin::RenderGLScene( int tex_id )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0, 0, -2);
glBindTexture ( GL_TEXTURE_2D, texture_id[tex_id] );
glBegin(GL_QUADS);
glTexCoord2f(1, 1); glVertex3f(2, 1.5, -1);
glTexCoord2f(0, 1); glVertex3f(-2, 1.5, -1);
glTexCoord2f(0, 0); glVertex3f(-2, -1.5, -1);
glTexCoord2f(1, 0); glVertex3f(2, -1.5, -1);
glEnd();
}
//---------------------------------------------------------------------------
Thanks a lot,
Antoine Rennuit.