[GtkGLExt] follow-up gdk_gl_drawable_swap_buffers(gldrawable)
- From: "Brian Dudley" <Brian-Dudley utc edu>
- To: gtkglext-list gnome org
- Subject: [GtkGLExt] follow-up gdk_gl_drawable_swap_buffers(gldrawable)
- Date: Wed, 07 Jul 2004 15:15:17 -0400
Hello again:
Please see the below function I altered in lw.c.
I am trying to draw a red rectangle to the GL_BACK_LEFT buffer and the alien to the GL_BACK_RIGHT buffer, but instead both objects are being drawn to both the left and right monitors. (Ideally, in stereo mode, the rectangle should appear just on the left monitor, and the alien on the right monitor.) I hope this clarifies what I am trying to accomplish. Any suggestions would be great.
Thank you.
Brian Dudley
void lw_object_show(const lwObject *lw_object)
{
int i,j;
int prev_index_cnt = -1;
int prev_material = -1;
GLfloat prev_nx = 0;
GLfloat prev_ny = 0;
GLfloat prev_nz = 0;
g_return_if_fail(lw_object != NULL);
for (i=0; i<lw_object->face_cnt; i++) {
GLfloat ax,ay,az,bx,by,bz,nx,ny,nz,r;
const lwFace *face = lw_object->face+i;
/* ignore faces with less than 3 points */
if (face->index_cnt < 3)
continue;
/* calculate normal */
ax = PX(1) - PX(0);
ay = PY(1) - PY(0);
az = PZ(1) - PZ(0);
bx = PX(face->index_cnt-1) - PX(0);
by = PY(face->index_cnt-1) - PY(0);
bz = PZ(face->index_cnt-1) - PZ(0);
nx = ay * bz - az * by;
ny = az * bx - ax * bz;
nz = ax * by - ay * bx;
r = sqrt(nx*nx + ny*ny + nz*nz);
if (r < 0.000001) /* avoid division by zero */
continue;
nx /= r;
ny /= r;
nz /= r;
glDrawBuffer(GL_BACK_RIGHT);
/* glBegin/glEnd */
if (prev_index_cnt != face->index_cnt || prev_index_cnt > 4) {
if (prev_index_cnt > 0) glEnd();
prev_index_cnt = face->index_cnt;
switch (face->index_cnt) {
case 3:
glBegin(GL_TRIANGLES);
break;
case 4:
glBegin(GL_QUADS);
break;
default:
glBegin(GL_POLYGON);
}
}
/* update material if necessary */
if (prev_material != face->material) {
prev_material = face->material;
glColor3f(lw_object->material[face->material].r,
lw_object->material[face->material].g,
lw_object->material[face->material].b);
}
/* update normal if necessary */
if (nx != prev_nx || ny != prev_ny || nz != prev_nz) {
prev_nx = nx;
prev_ny = ny;
prev_nz = nz;
glNormal3f(nx,ny,nz);
}
/* draw polygon/triangle/quad */
for (j=0; j<face->index_cnt; j++)
glVertex3f(PX(j),PY(j),PZ(j));
}
/* if glBegin was called call glEnd */
if (prev_index_cnt > 0)
glEnd();
glDrawBuffer(GL_BACK_LEFT);
glColor3f(1,0,0);
glRectf(0,0,10,10);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]