tquack

12-11-2002, 03:00 AM

I am wondering if the following is possible with opengl and if yes, how:

1. I am loading Pixel coordinates of the corners of a animated (moving) series ofParalellograms from a file.

2. I use glUnproject() and gl_Begin(GL_QUADS) to draw the parallelogram and I animate it in the display function using swapbuffers.

Points 1. and 2. are implemnted and work fine

3. I want to see, what change happens to the parallelogram from one frame to the other (i.e. one buffer to the next) and apply the same transformation to another object (i.e. another GL_Quads) in the same scene.

Is this possible? I thought I might be able to look at the modelview matrix or something, but this doesn't work, i.e. it always has the same values.

The code i use for 1. and 2. http://www.opengl.org/discussion_boards/ubb/tongue.gifoint* points;

points=current->getpoints();

// FIND OBJECT COORDINATES FOR PIXEL POINTS FROM REGION

/************************************************** ***/

GLdouble objx[4],objy[4],objz[4];

GLint viewport[4];

GLdouble modelview[16],projection[16];

glGetIntegerv(GL_VIEWPORT,viewport);

glGetDoublev(GL_MODELVIEW_MATRIX,modelview);

glGetDoublev(GL_PROJECTION_MATRIX,projection);

for(int i=0;i<4;i++){

int x=(int)points[i].get()[0];

int y=winH-(int)points[i].get()[1]; /

GLdouble z; // Get the right z coordinate

glReadPixels (x, y, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, &z);

gluUnProject(x,y,z,modelview,projection,viewport,&objx[i], &objy[i],&objz[i]);

}

/************************************************** ***/

glBegin (GL_QUADS);

glTexCoord2f (0.0f,0.0f);

glVertex3f (objx[0], objy[0], 0);

glTexCoord2f (1.0f, 0.0f);

glVertex3f (objx[1], objy[1], 0);

glTexCoord2f (1.0f, 1.0f);

glVertex3f (objx[3], objy[3], 0);

glTexCoord2f (0.0f, 1.0f);

glVertex3f (objx[2], objy[2], 0);

glEnd ();

1. I am loading Pixel coordinates of the corners of a animated (moving) series ofParalellograms from a file.

2. I use glUnproject() and gl_Begin(GL_QUADS) to draw the parallelogram and I animate it in the display function using swapbuffers.

Points 1. and 2. are implemnted and work fine

3. I want to see, what change happens to the parallelogram from one frame to the other (i.e. one buffer to the next) and apply the same transformation to another object (i.e. another GL_Quads) in the same scene.

Is this possible? I thought I might be able to look at the modelview matrix or something, but this doesn't work, i.e. it always has the same values.

The code i use for 1. and 2. http://www.opengl.org/discussion_boards/ubb/tongue.gifoint* points;

points=current->getpoints();

// FIND OBJECT COORDINATES FOR PIXEL POINTS FROM REGION

/************************************************** ***/

GLdouble objx[4],objy[4],objz[4];

GLint viewport[4];

GLdouble modelview[16],projection[16];

glGetIntegerv(GL_VIEWPORT,viewport);

glGetDoublev(GL_MODELVIEW_MATRIX,modelview);

glGetDoublev(GL_PROJECTION_MATRIX,projection);

for(int i=0;i<4;i++){

int x=(int)points[i].get()[0];

int y=winH-(int)points[i].get()[1]; /

GLdouble z; // Get the right z coordinate

glReadPixels (x, y, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, &z);

gluUnProject(x,y,z,modelview,projection,viewport,&objx[i], &objy[i],&objz[i]);

}

/************************************************** ***/

glBegin (GL_QUADS);

glTexCoord2f (0.0f,0.0f);

glVertex3f (objx[0], objy[0], 0);

glTexCoord2f (1.0f, 0.0f);

glVertex3f (objx[1], objy[1], 0);

glTexCoord2f (1.0f, 1.0f);

glVertex3f (objx[3], objy[3], 0);

glTexCoord2f (0.0f, 1.0f);

glVertex3f (objx[2], objy[2], 0);

glEnd ();