This is a known problem with several video devices, see
http://groups.google.com/group/pyglet-users/web/faq. Please let us
know if your device is not in the list, so we can add it. Make sure
you have the most up-to-date driver first.
Alex.
... and only call OpenGL functions (and, by transitivity, many pyglet
functions) after creating that window.
Alex.
Each window in pyglet needs its own OpenGL context. Normally, OpenGL
contexts are completely separate from each other, so if you create a
texture, display list or VBO in one, you won't see it in the other.
Contexts can be "shared" with each other explicitly, which means the
contexts use the same set of textures, display lists and VBOs (and
some other object types not directly supported by pyglet).
Because it would be a nightmare to manage separate resources for each
open window, pyglet, by default, tries to share all OpenGL contexts it
creates. If the context can't be shared (for example, it's not
possible to share contexts that exist on separate video devices),
pyglet raises this exception ("Unable to share contexts") and gives
up.
You can, if you know what you're doing, create the context yourself
with the pyglet.gl module and pass this to the window; when you do
this you can set up any sharing or non-sharing system you like. Of
course, you must be careful to only use resources in each window
actually accessible by that window's context.
We've had reports from users with the listed video cards that they are
never able to share contexts, even on the same video device and with
the same pixel format (this is the default situation). This is due to
those devices not implementing the required functionality. I don't
believe this is technically a "bug" in those drivers, as the WGL, GLX
and AGL specifications don't put any minimum requirement on drivers to
provide this functionality at any time -- though most do.
Now, you're thinking to yourself, "but I'm only trying to open one
window!" This requires a little more explanation. In the early days
of pyglet 1.0, many users found it frustrating to have to create an
OpenGL context first, before creating any textures or setting any
OpenGL state. It just sort of turns out that the "default"
programming idiom people tend to use is to load all their resources
first, compile all their display lists, and _then_ open the main
window and start running.
It's not possible for pyglet to create textures and so on without a
current OpenGL context, so the default behaviour as of pyglet 1.1 is
to create an invisible window (the "shadow window") with its own GL
context as soon as the pyglet.gl module is imported. Because the
application's real windows will share objects with this hidden context
by default, there's now no problem in loading resources in any order
before any windows are created, and then using those resources in the
application window contexts.
As to why your device supports sharing of contexts and the earlier
poster's didn't; I can only guess that you have slightly different
firmware revisions, different video chipsets marked with the same
product code, different operating systems, or a different video mode
set up.
I'm looking to remedy this situation a little in pyglet 1.2: I
understand that some of the cards in the list that don't support
sharing of contexts created for on-screen drawing, do support sharing
contexts between an on-screen buffer and a pbuffer. By reimplementing
the "shadow window" as a pbuffer, some video devices previously unable
to be used with pyglet at all may become usable for single-window
applications (the vast majority, by my observation).
Cheers
Alex.