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

Re: [pygame] 3D sample code



Will McGugan wrote:
  kschnee@xxxxxxxxxx <mailto:kschnee@xxxxxxxxxx> wrote:
On Thu, June 7, 2007 2:45 pm, Horst JENS wrote:
On Mon, 2007-06-04 at 21:19 +0100, Will McGugan wrote:
I've just posted some sample code for using OpenGL with PyGame. Hope
you find it interesting.

http://www.willmcgugan.com/2007/06/04/opengl-sample-code-for-pygame/

that's exactly what i was looking for... thanks!
It is interesting. Am I right in understanding that you basically have to
choose between Pygame's normal (SDL) drawing functions, like surface.blit,
and OpenGL's? You can't just draw a 3D scene like that of the code above,
and then blit an interface or text atop it. Instead you have to switch to
a 2D mode, turn your Pygame drawing into an OpenGL texture, and draw a
rectangle textured with the new drawing -- and delete/replace the texture
every time you want to change something. That's so cumbersome that I've
barely ever gotten it to work; is there a better way to integrate OpenGL
and Pygame graphics?
You're right that you cant use any of the regular SDL drawing functions with OpenGL - or any other accelarated 3D API. You can work with 2D graphics in OpenGL though, by drawing texture quads. If you wrap that in a simplified interface, then the code doesn't look much different from what you are used to in 2D PyGame.

Will

Is there a way to render 3d objects out to disk only, and use the renders in a normal Pygame program? Is there any advantage to doing so, in speed, or memory, or anything?