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

Re: [pygame] 3D sample code



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?
>

A while ago, I had had some success in specifying OpenGL+blit
functionality, but I suspect that was very driver-specific, so it probably
wasn't reliable or portable.

Since then, I've abandoned all SDL-like drawing, and gone over to OpenGL
for everything. Instead of blitting an interface, I draw a (probably
textured) rectangle parallel to the screen.

Here's an example that doesn't use textures:
http://media.pyweek.org/dl/4/BDG_07_04/07-04-03-09-28-gasGiantMemo.png

And a dialog box with multiple child button widgets:
http://media.pyweek.org/dl/4/BDG_07_04/07-04-05-09-19-optionsScreen.png


I'm getting afield from your question, though, of integrating PyGame/SDL
graphics with OpenGL graphics. What is it that you'd prefer to do in
PyGame/SDL instead of OpenGL?

-Dave LeCompte