[PyOpenGL-Users] Using both PyOpenGL and C to drive OpenGL
Brought to you by:
mcfletch
From: Lorcan H. <lh-...@lo...> - 2003-07-20 14:59:58
|
Hi folks, (Just discovered this list, so sorry if this is an FAQ - there doesn't seem to be a list archive, or I'd have searched it.) I'm working on a new fork of TuxRacer (based on the last GPL'd release, at http://tuxracer.sourceforge.net/), and I'm think of replacing the UI code with Python, using PyOpenGL. The main game engine, which is written in C, would remain intact, as far as possible. Could that be done? How? :) I'm thinking along these lines: A top-level Python script initialises OpenGL, loads the textures using pygame.image, draws the splash screen, menus, etc. using PyOpenGL, handling input with pygame. The script creates an instance of a new GameEngine class that I would implement in C, and invokes methods on that object to set up the course. When the game is ready to go, the Python script would invoke GameEngineObject.run(). At that point, the C code in the extension module would take over - using the OpenGL API to refresh the screen, and SDL for keyboard and/or joystick input. Is that approach feasible? Can both PyOpenGL and a custom C extension module share the use of OpenGL like that? They'd take turns, obviously, so that the Python script would not invoke any OpenGL functions until after GameEngineObject.run() had returned. The screen would be repainted completely (and the OpenGL context could be reset) between the two different modes of operation, but it shouldn't change resoltion, or flicker, or anything like that. Has anyone done anything like this? A working example would be *really* useful... I'd also have the problem of making the C extension and pygame take turns in handling input events, but I guess that's off-topic for this list. :) Thanks in advance, for any helpful replies. And thanks for PyOpenGL! Lorcan Hamill |