Glut - multiple display functions callback to display on single window

Hello,
I am relatively new to OpenGL and trying to display my two scenes in a single window. I am still not getting.
I have two display functions glutDisplay(), glutDisplay2().

void glutDisplay() {
glViewport(0, 0, (GLsizei) winSize2, (GLsizei) winSize2);


}

void glutDisplay2() {
glViewport(256, 0, (GLsizei) winSize2, (GLsizei) winSize2);


}
Then trying to call them mainloop

glutInitWindowSize(winSize1, winSize2);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA);
glutInit(&argc, argv);
glutCreateWindow(“MY scene”);
generateTexture();
glutDisplayFunc(glutDisplay);
//glutPostRedisplay();
//glutOverlayDisplayFunc(glutDisplay2);
glutDisplayFunc(glutDisplay2);
glutMouseFunc(glut_mouse);
glutMotionFunc(glut_mouseMotion);
glutMainLoop();

When i call like this i get only last display scene.
Can you please anyone help me to display my both scenes in a single window. I have tried with glutOverlayDisplayFunc, glutPostRedisplay functions, still i am not getting it done.
Can you please give me similar example?
Thanks in advance
summa

You can only register one function with glut to draw your scene. Write a function that calls your two display functions and register that as the glut display callback.

Thank you very much for your suggestion… I will write it so…

Hello Carsten,
I am still not success with my rendering two texture in same window. As you suggested I made my display call back for two scenes. Then calling in glmainloop, i dont see the texture scenes, i see only points. Should I have a reshape callback? Actually I dont have reshape callback. I have generate4d two textures (texture and texture2). Please have a look of my glutDisplay function.
Could you please suggest me what mistake I’m having.
Thanks lot in advance.
summa

void glutDisplay() {
///////////////////Initialization first scene////////////////////////////////////
glViewport(0, 0, (GLsizei) winSize2, (GLsizei) winSize2);
glClearColor(1.0, 1.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
// Setup projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1.0, 0.0, 1.0);
// Setup modelview matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(scale, scale, 1.0);
glTranslatef(transX, transY, 0.0);
// Setting up lights
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
// Draw the sample scene
glBindTexture(GL_TEXTURE_2D, texture);
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, 1.0); glVertex2f(1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
glEnd();
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
drawPoints();
glutSwapBuffers();
///////////////////////Initialization second scene/////////////////////////////
glViewport(winSize2, 0, (GLsizei) winSize2, (GLsizei) winSize2);
glClearColor(1.0, 1.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
// Setup projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1.0, 0.0, 1.0);
// Setup modelview matrix
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(scale, scale, 1.0);
glTranslatef(transX, transY, 0.0);
// Setting up lights
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
// Draw the sample scene
glBindTexture(GL_TEXTURE_2D, texture2);
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, 1.0); glVertex2f(1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 1.0);
glEnd();
glBindTexture(GL_TEXTURE_2D, 0);
glDisable(GL_TEXTURE_2D);
drawPoints();
glutSwapBuffers();
}
========================= Main function =========
int main(int argc,char **argv)
{ initialization();
runTests();
glutInitWindowSize(winSize1, winSize2);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA);
glutInit(&argc, argv);
glutCreateWindow(“2D_testScenes”);
generateTexture();
generateTexture2();
glutDisplayFunc(glutDisplay);
glutMouseFunc(glut_mouse);
glutMotionFunc(glut_mouseMotion);
glutMainLoop();
deinitialization();
return 0;
}

only clear the colour buffer once, and only call swap buffers once. You have litterally just repeated the draw routines without think about what you are doing.