[XForms] Patch: GLCanvas context sharing support.

Angus Leeming angus.leeming at btopenworld.com
Fri May 14 12:16:15 EDT 2004


On Friday 14 May 2004 4:30 pm, jason cipriani wrote:
>     /* under some conditions, the parent of the gl canvas might go
> away, leaving the old context and vi hanging. */
>     glx_cleanup(ob);
>
> What conditions are "some conditions"?

Ha! I have no idea. My knowledge of this part of the code base is nil.

> What I am doing now is keeping the FL_OBJECT* for the glcanvas you
> want to share a context with in the glcanvas's CSPEC. Then, in
> glx_init(), it checks to see if that glcanvas has a GLXContext yet.
> If it doesn't, then it forces initialization of that canvas. That's
> fine but what that means is that if "some conditions" are true and
> also if the shared canvas is created -before- the canvas it's
> sharing context data with, then the shared canvas's glx_init()
> won't attempt to initialize the canvas its sharing data with (since
> it's GLXContext isn't 0), so it will use it's GLXContext. But then
> when the canvas its sharing data with is initialized (and some
> conditions are true), then its context will be destroyed and a new
> one will be creating, invalidating the GLXContext that the shared
> canvas is sharing data with.

Phew. 2 sentences covering 10 lines. I keep forgetting the start 
before I get to the end ;-)

> So I need to figure out a way to ensure that the canvas its sharing
> data with is properly initialized first, rather than it just having
> some leftover old GLXContext associated with it because "the parent
> of the gl canvas [went] away".

The parent of the gl canvas is the Window on which the FL_FORM and 
FL_OBJECT are displayed, right? Or is it the FL_FORM itself?

If the former, could you not use (form->window == GLPROP(ob)->window) 
as a check. You'd need to add a new variable, window, to CSPEC but so 
what?

Or have I got all this wrong?

> As far as the GL stuff, the problem was that this was removed from
> forms.h in 1.0.90 (it was there in 1.0):
>
> #if defined(__GLX_glx_h__) || defined(GLX_H)
> #include <X11/glcanvas.h>
> #endif
>
> Simple solution was to add it back in, rather than #include'ing
> glcanvas.h in all the xforms apps we have.

Ahhhhhh. So you'd like forms.h to #include glcanvas.h if a 
preprocessor guard is defined. What defines __GLX_glx_h__, GLX_H? I 
don't think that the preprocessor guard should be a system or 
compiler-defined macro. You should have to define it explicitly. Eg

#ifdef FORM_GLCANVAS_H
#include FORM_GLCANVAS_H
#endif

where FORM_GLCANVAS_H is defined either in your <config.h> file for 
the project or is passed via a -D flag on the compiler command.

Angus
k



More information about the Xforms mailing list