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

Re: [pygame] is fast opengl a possibility in pygame?



You are right about display lists storing your positions, but that's actually a good thing, and it doesn't stop you from moving them around. When you create the displaylist for your player, you should create it at the origin instead of using the player's initial position. When you call the displaylist, you need to first call glTranslate with the player's current position like this: (My function names might be slightly off, I can't check right now)

glLoadIdentity()
glTranslatef(player.x, player.y, player.z)
glCallList(list)

-- Drew

On Wed, 24 Aug 2005 17:45:43 -0400
 Kris Schnee <kschnee@xxxxxxxxxx> wrote:
Sami Hangaslammi wrote:
On 8/24/05, Drewcore <drewsph@xxxxxxxxx> wrote:

is creating a playable game (speed-wise) a possibility with
pygame and pyopengl?

Absolutely. It's just that function calls have such a high overhead in
Python, that you have to minimize the frequency and number of OpenGL
calls you do from your code. This is pretty easily achieved by liberal
use of opengl display lists and vertex/color/texture-arrays. With
display lists, you can render a complex scene with a single function
call (glCallList), so the overhead of Python stays minimal.

I've played with display lists and had trouble with them. It seems that any variables the list descriptions use are fixed at that time, so that if a list uses "player.position.x" and it changes, the position to which the player is drawn doesn't change.


I've got cube-drawing code that builds a 3D landscape out of variable-height pillars, at some distance from the camera, with some tilt. This is done by translating "into" the screen, then tilting, then drawing relative to that axis. If I try to spin the landscape, nothing seems to happen if I'm using lists. What am I missing about "vertex/color/texture-arrays?" To the extent that I got lists working, they didn't seem to improve FPS by more than 1-2 anyway, when I expected massive gains.

Lists would probably help a lot if I had them working well; my landscape demo runs at 193 FPS with nothing drawn, 28 FPS with just a few "widgets," and 13 FPS with widgets and cubes.

Kris