Hi Alex,

Thanks for the reply.

<snip>
> >  I can create a GL Context in a PyGTK window, and according to one post
> >  that I read what I need to do is "trick" PyGlet into using this GL
> >  context.

Just to be clear I'm using GtkGLExt:  http://www.k-3d.org/gtkglext/Main_Page
to create my GL context.

> >  So my questions are:
>
> >  1) How would I trick PyGlet into using the GL context that I have
> >  already created
>
> There's actually no trick... OpenGL has only one active context at a
> time.  In pyglet you can switch contexts with Window.switch_to().
> When you create a new window the context will switch to that window
> automatically.  If you never call switch_to() or create a new window,
> the context never changes; so the PyGTK one remains active.
>
> The situation could get a lot more complicated if you're using more
> than one PyGTK window (context), or trying to mix pyglet windows with
> PyGTK windows.
>
> In pyglet 1.1 you should also set pyglet.options['shadow_window'] to False.

Thanks for the information Alex, I've been able to try this out and it
feels as though I almost have it going. The only problem now is that
my sprites are not drawing properly. Instead of seeing the actual
image what I'm getting are white squares (the size of the image) where
the sprites should be. This happens if I use a batch draw or just an
Image.blit().

Just to make sure that I understand what you are saying properly. I'm
creating my GL Context and doing all the other OpenGL stuff using
GtkGLExt, and then in my draw() function I'm trying to use PyGlet as I
normally would...which at the moment is giving my white squares.

I think I'm close, it feels as though I'm missing something simple.

I'm setting up the GL context with the following options:

display_mode = (gtk.gdkgl.MODE_RGBA
                | gtk.gdkgl.MODE_DOUBLE
                | gtk.gdkgl.MODE_DEPTH
                | gtk.gdkgl.MODE_ALPHA)

And then configuring it like so:

gldrawable.gl_begin(glcontext)
glViewport(0, 0, 1000, 800)
gldrawable.gl_end()

And then I set things up in my realize event like so:

if not gldrawable.gl_begin(glcontext):
            return

glClearColor(1.0, 1.0, 1.0, 1.0)
glMatrixMode(GL_PROJECTION)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glLoadIdentity()
glOrtho( 0, 1000, 0, 800, -1.0, 1.0)
glMatrixMode(GL_MODELVIEW)
gldrawable.gl_end()

And then finally I draw like so:

gldrawable.gl_begin(glcontext)
glClearColor(0,0,0,0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

self.display()

gldrawable.swap_buffers()
gldrawable.gl_end()

Where self.display() calls the PyGlet draw code.

Does anything in that appear wrong or way off base? Most of the code
is from a GtkGLExt example that I have configured to work with PyGlet.

>
>
> >  2) How feasible is the idea of a PyGlet level editor in a PyGTK
> >  application?
>
> I can't foresee any problems if you stick to just one PyGTK window.

Thanks I'm planning on sticking with one window.

mark.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to