Re: XForms: Still no multiple gl canvases...

Steve Lamont (spl@szechuan.ucsd.edu)
Sat, 28 Nov 98 12:32:43 PST

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> Thanks for the replies! But that doesn't seem to work for me.
> Mr Lamont suggested using fl_activate_glcanvas(FL_OBJECT *ob)
> (which I did use in my original expose handler), and which, as far
> as I understand, takes care of getting the context and making it
> current, so one shouldn't need either glXMakeCurrent()
> or fl_get_glcanvas_context(). ...

That's exactly correct. I am at this moment working on code which
draws into two GLCanvases for each Expose event.

> >In case of multiple canvases, the canvas driver takes
> >care of setting the proper context before invoking the
> >expose handler. In some cases, the application may
> >want to draw into canvases actively. In this case,
> >explicit drawing context switching may be required. To
> >this end, use the following routine
> > void fl_activate_glcanvas(FL_OBJECT *ob)
> >before drawing into glcanvas ob.
>
> Now does this mean that I need no context switching in my expose handler,
> since "the canvas driver takes care of setting the proper context
> _before_ invoking the expose handler"?

Yes. It calls glx_activate (an internal routine in gl.c). Are you by
any chance replacing the activate callback with one of your own with
fl_modify_canvas_prop()? If you are, this will subvert this automatic
call and leave you in an indeterminate state. However, this has
little or no bearing on the multiple GLCanvas problem.

Of course, you can call fl_activate_glcanvas() yourself in the Expose
handler if you wish.

> Anyway, I'm also interested in the "draw into canvases actively" bit.

You should be able to switch to any legal GLXContext by simply calling
fl_activate_glcanvas() with the appropriate argument.

> And for me, using fl_activate_glcanvas() on anything but the primary
> canvas results in the aforementionned X error

I presume you've checked to make sure that you're actually passing the
GLCanvas object pointer to fl_activate_glcanvas().

> Is there something essentially lacking in the approach "add another canvas
> to one of your forms, and when you need to, fl_activate_glcanvas() it and
> draw to it"? With no other tricks?

None of which I know. I'm not doing anything particularly special and
I use multiple GLCanvases on multiple forms (up to four GLCanvases on
three separate forms which may be visible and drawn to more or less
concurrently).

The following is the code I use to set up each GLCanvas for drawing:

void activate_graphics( FL_OBJECT *canvas, Logical clear )

{

fl_activate_glcanvas( canvas );
glDrawBuffer( GL_BACK );
glViewport( 0, 0, canvas->w, canvas->h );

if ( clear ) {

glClearColor( 0.0, 0.0, 0.5, 0.0 );
glClear( GL_COLOR_BUFFER_BIT );

}
glClear( GL_DEPTH_BUFFER_BIT );

}

[Logical is just my form of Boolean, typedefed as an enum so it shows
up in a more clear manner in the debugger -- my FORTRAN roots are
showing, I suppose. :-)]

Can you reduce the problem to a small example which exhibits the same
behavior that can be posted? This might be helpful at this point in
resolving this issue.

spl
_________________________________________________
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/