PDA

View Full Version : opening two winodws gxl + opengl



nt
10-23-2007, 04:43 PM
Hi,
I am trying to open two windows, in one program of different sizes and ortho, I using the following code

/* window of size 480 x 480 with view port 480,480 */
myGfxw[0] = XCreateWindow(myDpy,RootWindow(myDpy,vi->screen), 725,
55,480, 480, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask
| CWOverrideRedirect, &swa);

XSetStandardProperties(myDpy, myGfxw[0], "MY", "MY", 0,0,0,
&myHints);

XMapWindow(myDpy, myGfxw[0]);
glXMakeCurrent(myDpy, myGfxw[0], GfxCx);
glViewport(0, 0, 480, 480);

/* window of size 680 x 680 with view port 240,240 */

myGfxw[0] = XCreateWindow(myDpy,RootWindow(myDpy,vi->screen), 725,
55,680, 680, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask
| CWOverrideRedirect, &swa);

XSetStandardProperties(myDpy, myGfxw[0], "MY", "MY", 0,0,0,
&myHints);

XMapWindow(myDpy, myGfxw[0]);
glXMakeCurrent(myDpy, myGfxw[0], GfxCx);
glViewport(0, 0, 240, 240);


but it only takes the last glViewport(0, 0, 240, 240); call for both windows, I am drawing a square, so both square looks like the same, as per the first window view port, it should be a bigger square (the
co-ordinates are same and uses one draw rotine to draw the square)

I made it to work, making call to glviewport for both windows in each frame, is there any better way.


the change I made is
glViewport(0, 0, 680, 680);
glXMakeCurrent(myDpy, myGfxw[1], myGfxCx);
glXSwapBuffers(myDpy, myGfxw[1]);
glXWaitVideoSyncSGI(1, 0, &cnt);
glFlush();
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
draw();

glViewport(0, 0, 240, 240);
glXMakeCurrent(myDpy, myGfxw[0], myGfxCx);
glXSwapBuffers(myDpy, myGfxw[0]);
glXWaitVideoSyncSGI(1, 0, &cnt);
glFlush();
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
draw();

draw routine is
glOrtho(240.0, -240.0, 240.0, -240.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (-220, 220, 0.0);
glVertex3f (220, 220, 0.0);
glVertex3f (220,-220,0.0);
glVertex3f (-220,-220, 0.0);
glEnd();


what should I do make it more efficient

thanks,
nt