let me explain in detail about last problem

i used glut to creat 2 windows and wanted to display different interactive display function. i wrote :
{
glutMouseFunc(mouseEvent);
glutMotionFunc(mouseActiveMotion);
glutReshapeFunc(reshape);
glutDisplayFunc(depthdisplay);
glutIdleFunc(depthdisplay);
}

{
glutMouseFunc(mouseEvent);
glutMotionFunc(mouseActiveMotion);
glutReshapeFunc(reshape);
glutDisplayFunc(heightdisplay);
glutIdleFunc(heightdisplay);
}

glutMainLoop();

afer execution, it showed same result that was by heightdisplay.
how to solve it?

So you’re talking about glut, then?
As far as I’m aware, there is no such thing as a glut ‘object’ or a glut ‘handle’ so you probably won’t be able to create 2 glut windows. I’m probably wrong, though - I don’t think I’ve ever actually used glut… it always seemed a little limited to me.

are there some other ways or tools which can meet my requirement, 2 different interactive opengl windows at same time?

Does your application have to work on anything other than Microsoft Windows?
If no, then just hijack any old windows WndProc and create your opengl contexts in there. There’s plenty of tutorials on how to do this on the internet.

Works fine for me to create two independent windows in GLUT. They can share the same callback functions if they want (like the reshape function in my example).

glutCreateWindow(“Window 1”);
glutDisplayFunc(display1);
glutReshapeFunc(reshape);

glutCreateWindow(“Window 2”);
glutDisplayFunc(display2);
glutReshapeFunc(reshape);

hi ,bob

why can’t my programme work? 2 windows show same !

// Create our window	
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB |GLUT_DEPTH);
glutInitWindowSize(320, 320);
glutInitWindowPosition(470,0 );
glutCreateWindow("Slices Show Along Y-axe" );
glClearColor(0.2,0.4,0.4,0.0);
 glutDisplayFunc(depthdisplay);
glutReshapeFunc(reshape);
glutMouseFunc(mouseEvent);
glutMotionFunc(mouseActiveMotion);
glutIdleFunc(depthdisplay);

glutInitWindowSize(320, 320);
glutInitWindowPosition(100, 400 );
glutCreateWindow("Slices Show Along Z-axe" );
glClearColor(0.2,0.4,0.4,0.0);
	glutMouseFunc(mouseEvent);
glutMotionFunc(mouseActiveMotion);
glutDisplayFunc(heightdisplay);
glutReshapeFunc(reshape);
glutIdleFunc(heightdisplay);

glutMainLoop();

There’s more than just creating the windows that matters. Show us more code. And please, use the code tag.

Just noticed something. You have a display function in the idle callback. The display function should go in the display callback only. GLUT doesn’t have separate idle functions for each window. Use glutPostRedisplay in the idle function to redisplay your scene.

thanks for reply. I delete the glutIdleFuc and Add glutPostRedisplay in every display fuction. now they can show different things in every window. But new problem appears. if i change things in one window by mouse, all of the others change also. my original problem is that the same thing appears in every window, but if i change things in one window, all of the others don’t change . I tryed several ways, but can not find solution. is it possible to show different things in several window,and change by mouse in one window don’t influence other windows?

Aren’t your mouse funcs and motion funcs the same for both windows???

Don’t you need different mouse and motion funcs for each window?

if you look in glutint.h and find
struct _GLUTwindow {
int num; /* Small integer window id (0-based). */

… etc

You will find the part which shows which callbacks can be assigned per window!

e.g.

/* Per-window callbacks. /
GLUTdisplayCB display; /
redraw /
GLUTreshapeCB reshape; /
resize (width,height) /
GLUTmouseCB mouse; /
mouse (button,state,x,y) */

Rob.

thank you. it is solved by creat several mouse function.