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

Re: [pygame] Using PyOpenGL for 2D graphics





On 7/7/07, Dave LeCompte (really) <dave@xxxxxxxxxxxx> wrote:
"Ian Mallett" <geometrian@xxxxxxxxx> wrote:
> Try looking at glOrtho2D() or something like that...

Yes, glOrtho() or glOrtho2D() both work.


> Why do you want to use
> PyOpenGL for 2D-ness?  It's much better suited to 3D stuff.

Well, just because OpenGL was designed for 3D doesn't mean it's not also a
very good tool for 2D.

Some reasons I prefer OpenGL for 2D to SDL's drawing code:

- performance
- sub-pixel positioning
- scaling/rotation
- blending
- vertex coloring
- lots of good documentation, lots of sample code, lots of tips on
optimizing performance available on the web

Basically, a lot of the graphical features I might want to use in a 3D
renderer, I might also want to use in a 2D renderer.


> I've always
> found it easier to use pygame for 2D games.  Oh, and ummm...  Don't tell
> Silicon Graphics, but I've found pygame is much much faster at 2D.

I'm in the other camp - I find OpenGL easy and fast, and if I want to
reuse code from a 2D game in a later 3D project, the port will be much
easier than if I have to rewrite it from SDL to OpenGL.

Yes, by far an large, OpenGL is better at 3D, but 2D?  I don't know.  My experience has been that OpenGL is slower, but then again, I was new to that sort of thing.  It would be good to run a few tests to confirm one way or the other.  And yes, you are right.  Porting code would be much easier without those changes.

-Dave LeCompte