Re: [GtkGLExt] how to use multiple gl windows?



 --- walter tallent <w41t3r yahoo com> wrote: > The share-list was the
answer to my problem.  I wanted
> to load up my chess models and board textures and so
> on, only once, and then allow new instances of my
> opengl capable widget to use these models when
> building its scene.  The way it's done is to allow the
> first instance to load the pieces normally (using
> whatever display lists or whatnot you've coded), and
> then pass that window's rendering context to the next
> instance as the 3rd parameter to
> gtk_widget_set_gl_capability.  I did it with a global
> GdkGLContext pointer like so:
> 
> /* global context */
> static GdkGLContext *global_context = NULL;
> 
> ... then in my "gl-canvas" widget's init() call (it is
> a subclass of GtkDrawingArea)...
> 
> gtk_widget_set_gl_capability (GTK_WIDGET(gl_canvas),
>                        	      glconfig,
>                		      global_context,
>                	              TRUE,
>                	              GDK_GL_RGBA_TYPE);
> 
> ...then in the "realize" event callback of
> gl_canvas...
> /* set up share list for new games */
> if(global_context == NULL)
> 	    global_context =
> gtk_widget_get_gl_context(GTK_WIDGET(gl_canvas));
> 
> So the first instance of gl_canvas shares the piece
> models and textures with nobody (gets a NULL for the
> 3rd parameter), but every instance afterward shares
> with the first (global_context then points to the
> first context).  As long as there's any valid context
> in existence everybody is happy! (Including me!)
> 
> In my program, the pieces and textures are loaded by a
> different object that is instanciated by gl_canvas in
> the init() call.  This object follows the "singleton"
> pattern, so that even though each gl_canvas  instance
> calls its constructor, only one instance of it exists.
>  Hence, one copy of the models and textures!  Whoopie!
> 
> I hope that answers the question without being too
> long-winded. :)
> 

No problem. I don't need to use it now, but I might use it in the
future, so thanks for the information.

By the way, do you know a way to solve my problem?

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]