I’ve got a problem in figuring out how to render the same objects in two seperate windows at the same time. Right now all it does is render in one window when the mouse pointer is over it. I’ve seen posts here talking about how you set the current window and then render it and then set the next window and render that…then you swap the buffers.
Well I’ve tried to do that but I’m not sure if I’m going the right way about it. Here’s some code.
This is my renderScene function that draws the animation on the window thats selected with the mouse pointer over it.
void RenderScene(void)
{
int i, j;
int x, y ,z, r, g, b;
glLoadIdentity();
glTranslatef(70.0, 125.0, 0.0);
glPushMatrix();
glRotatef(rotate,1.0,1.0,0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glFrontFace(GL_CW);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glEnable(GL_COLOR_MATERIAL);
for (j = 0; j <= 1; j++)
{
if (j == 0){
currentSize = overAllSize;
PolySel = polygons;
}
else{
currentSize = overAllSize2;
PolySel = polygons2;
}
for (i = 0; i < currentSize; i++){
glBegin(GL_TRIANGLES);
glNormal3f(PolySel[i].norm.x,PolySel[i].norm.y,PolySel[i].norm.z);
x = PolySel[i].v1.x;
y = PolySel[i].v1.y;
z = PolySel[i].v1.z;
glVertex3f(x,y,z);
glColorMaterial(GL_FRONT, GL_SPECULAR);
glColor3f(PolySel[i].spec.r, PolySel[i].spec.g, PolySel[i].spec.b);
glColorMaterial(GL_FRONT, GL_AMBIENT);
glColor3f(PolySel[i].amb.r, PolySel[i].amb.g, PolySel[i].amb.b);
x = PolySel[i].v2.x;
y = PolySel[i].v2.y;
z = PolySel[i].v2.z;
glVertex3f(x,y,z);
glColorMaterial(GL_FRONT, GL_EMISSION);
glColor3f(PolySel[i].emm.r, PolySel[i].emm.g, PolySel[i].emm.b);
glColorMaterial(GL_FRONT, GL_SPECULAR);
glColor3f(PolySel[i].spec.r, PolySel[i].spec.g, PolySel[i].spec.b);
x = PolySel[i].v3.x;
y = PolySel[i].v3.y;
z = PolySel[i].v3.z;
glVertex3f(x,y,z);
glColorMaterial(GL_FRONT, GL_SPECULAR);
glColor3f(PolySel[i].spec.r, PolySel[i].spec.g, PolySel[i].spec.b);
glColorMaterial(GL_FRONT, GL_AMBIENT);
glColor3f(PolySel[i].amb.r, PolySel[i].amb.g, PolySel[i].amb.b);
glEnd();
}
glPopMatrix();
glTranslatef(130.0, -10.0, 0.0);
glRotatef(rotate,1.0,-1.0,0.0);
}
glutIdleFunc(RotateSceneClockwise);
glutSwapBuffers();// I KNOW IT SHOULD MOVE
}
This is my main function…
void main(int argc, char **argv)
{
int i, win1, win2;
fileLoader(“file1.txt”, “file2.txt”);
for (i = 0; i <= 1; i++){
if (i == 0){
currentSize = overAllSize;
PolySel = polygons;
}
else{
currentSize = overAllSize2;
PolySel = polygons2;
}
addPolygonNormals();
}
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glEnable(GL_DEPTH_TEST);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,0);
win1 = glutCreateWindow(“WINDOW 1”);
SetupScreen(0);
glutSetWindow(win1);
glutDisplayFunc(RenderScene);
glutReshapeFunc(ChangeSize);
glutInitWindowPosition(610,0);
win2 = glutCreateWindow(“WINDOW 2”);
glutSetWindow(win2);
SetupScreen(1);
glutDisplayFunc(RenderScene);
glutReshapeFunc(ChangeSize);
// glutSwapBuffers(); <- Doesn’t work
glutMainLoop();
}