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



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. :)


--- Jack Chen <jacks_small_world yahoo com> wrote:
>  --- walter tallent <w41t3r yahoo com> wrote: > Heh.
> Ok.  So I'm
> STOOPID!
> > I just found the share-list EXAMPLE in the EXAMPLE
> > subdirectory of the GtkGlExt distribution.  
> > I looked all over the internet, but not on MY OWN
> > SILLY HARDDRIVE.
> > So now I see.
> > 
> 
> Hey what's a shared-list?
> 
>
______________________________________________________________________
> 
> Post your free ad now! http://personals.yahoo.ca


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html



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