[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] using opengl in pygame?
Bob Ippolito wrote:
OpenGL is a display API only. It's common to use SDL for cross-platform
input/audio and acquiring a display context, and OpenGL for the rest of
it. OpenGL is not going to be available or perform acceptably on
several classes of devices and accelerated hardware support is shoddy or
non-existent on many operating systems. though it is great on Windows
and OS X.
OpenGL support in Linux is great too, at least for ATI and Nvidia cards.
It is roughly on par with the Windows support.
Is SDL kind of like and entry level grunt that'll handle most
everything you need, but if you want to get fancy do you break out the
OpenGL can of Whoopass?
OpenGL does one thing very well: accelerated 3D. SDL does not do that
at all, but it does several other things moderately well on many
platforms. SDL does simple 2D bitmap stuff, which OpenGL really isn't
geared for... though on modern machines on some platforms OpenGL can be
contorted to do 2D stuff in a MUCH more efficient way, but it requires a
bit more effort from the programmer. Additionally, there is
(supposedly, don't know from experience) an experimental backend for SDL
that uses OpenGL for its display layer, which means that eventually you
can get most of the OpenGL speed with the same SDL API.
Graphics card manufacturers nowadays expose their cards' most advanced
functionality via 3D APIs like OpenGL and DirectX. Even for something
as basic as alpha blending, you will need to use a 3D api to get hardware
acceleration. This is the reason why you will want to use OpenGL for
everything graphics-oriented and SDL for the rest (joystick, sound, etc...).
Unfortunately, OpenGL has very steep learning curve. Dave Olofson's GLSDL
is an attempt to port the graphics part of the SDL API to run on top of
OpenGL so you don't have to learn OpenGL to get the hardware acceleration
benefits. See http://olofson.net/mixed.html
I haven't seen (though I've probably overlooked) extensive
documentation on using OpenGL in Python. Should I look to the
PyOpenGL folks for that documentation?
I posted sample Pygame/OpenGL code for doing sprite (via textures) alpha
blending a couple years back:
http://archives.seul.org/pygame/users/Sep-2002/msg00063.html
Hope it still works...
Haven't checked out PyOpenGL for sometime now, but once it starts supporting
vertex and fragment programs (vertex and pixel shaders in DirectX parlance),
you can go wild with effects. Remember that if you have a retro bent and
still have a craving for the 2-D game styles of yore (see Crimsonland
http://crimsonland.reflexive.com/crimsonland/ ) you can always map the 3D
effects back onto 2-D Flatland.