Re: XForms: multiple gl canvases

Humberto Cervantes Cuevas (hcc@hp9000a1.uam.mx)
Fri, 27 Nov 1998 13:45:20 -0600 (CST)

# To subscribers of the xforms list from Humberto Cervantes Cuevas <hcc@hp9000a1.uam.mx> :

Hi!

Recently I had a similar problem with using multiple glCanvases.

What I did was this:

inside of the Expose function:

int Expose(FL_OBJECT *ob,Window win,int w,int h,XEvent *xev,void *ud)
{
glXMakeCurrend(fl_display,win,form->FIRST_CANVAS->u_vdata);

// draw things for canvas 1
.
.
.

glXMakeCurrent(fl_display,win,form->SECOND_CANVAS->u_vdata);

// draw things for canvas 2
.
.
.

}

Ok. Now let me explain.

If you go to www.opengl.org and find somewhere the documentation for Glx
(it's glx1.3.ps) and go to page 42, you can see that glXMakeCurrent has
the following parameters:

bool glXMakeCurrent(Display *dpy,GLXDrawable draw,GLXContext ctx);

Ok! So you've got the Display and the Drawable, but where on earth do you
get the Context??? And how do you know that form->CANVAS->u_vdata is the
GLXContext???

Well, maybe it's documented in the forms.ps manual but I never saw that,
so what I did was take a look at gl.c and then if you check the glx_init
function you can see something like this:

glx_init(FL_OBJECT *ob)
{ .
.
.
context = glXCreateContext(fl_display, vi, None, GL_TRUE);
.
.
.
ob->u_vdata = context; <- AHA! Here it is!!!
return 0;
}

What you have to do then is to 'rescue' your context buried in this
obscure pointer so you can happily make the switching and Voila, the trick
is over!

I hope this will help you!

Humberto

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/