i am using glut and the ‘popular idle function’ for animation. It works pretty good, unless i want to add a background picture. It is an image with the size 1024 * 1024 and the whole program works when only the first picture is done (that means i can see the background and the 3D Object in front of it). But when i enable the idle function the background pic is erased by the ClearColor and i see only the 3D Objects moving…then the program hangs up after some seconds of animation.
The first lines of my display function that produce the background are:
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//-------------------------------------------(background)
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0,1.0,0.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDepthMask(GL_FALSE);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, 0.0);
glTexCoord2f(1.0, 768.0/1024.0); glVertex2f(1.0,1.0);
glTexCoord2f(0.0, 768.0/1024.0); glVertex2f(0.0, 1.0);
glEnd();
glDepthMask(GL_TRUE);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glDisable(GL_TEXTURE_2D);
//-------------------------------------------(background)