# To subscribers of the xforms list from Praveen Thiagarajan <praveen@capsl.udel.edu> :
On Thu, 21 Jun 2001, Dianna Xu wrote:
> # To subscribers of the xforms list from Dianna Xu
<xuy@gradient.cis.upenn.edu> :
>
> Hi,
>
> Has anyone successfully programmed openGL's selection (via
> glRenderMode(GL_SELECT) in an xforms openGL canvas? I have been trying
to
> get it to work for 3 days.
>
> Finainally in a moment's desperation tonight, I rewrote the code using
> glut to manage the gl window and events, just for the heck of it. and
> guess what, the selection worked! All functions were almost identical,
> except for minor details like event masks. Does this mean that selection
> will not work under xforms glcanvas? This will be a major setdown
because
> I switched from glut to xforms in the first place in the hope that the
> GUI will be much easier to handle.
>
> Any help greatly appreciated!
>
> -Di
I have used opengl's selection successfully in an xforms glcanvas. What I
do is pretty much the same as the sample code in the red book except a
few modifications to get the keymask. If your code works in glut check
the following code it might help solve ur problem
int mbutton_cb(FL_OBJECT *ob, Window win, int w, int h, XEvent *xev,
void *ud)
{
FL_Coord x, y;
unsigned int keymask;
GLuint selectBuf[BUFSIZE];
GLint hits;
GLint viewport[4];
fl_get_win_mouse(fl_get_canvas_id(ui->canvas), &x, &y, &keymask);
switch(xev->xbutton.button) {
case Button1:
glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(BUFSIZE, selectBuf);
(void) glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix((GLdouble) x, (GLdouble) (viewport[3] - y),
2.0, 2.0, viewport);
if (!orthographic_mode) {
gluPerspective(45.0, (GLfloat) w/h, 0.1, 10000.0);
glTranslatef( 0.0, 0.0, -60.0 );
} else {
glOrtho (0.0, (GLdouble) w, 0.0, (GLdouble) h, -1.0, 10000.0);
glTranslatef((GLdouble) w/2, (GLdouble) h/2, 0.0 );
}
glMatrixMode(GL_MODELVIEW);
idle_cb(0,0);
glFlush();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
hits = glRenderMode(GL_RENDER);
if (debug)
sniff_for_opengl_errors();
processHits(hits, selectBuf);
....
}
}
-pT
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/
This archive was generated by hypermail 2b29 : Thu Jun 21 2001 - 13:02:29 EDT