Thread: [PyOpenGL-Users] Ingame Overlays
Brought to you by:
mcfletch
From: Rowan <row...@gm...> - 2006-06-22 06:48:38
|
Hello, I am thinking of embarking on a project to create an in-game mp3 player control. This control will be brought into the foreground of the game. My question is it possible to overlay or bring to the very foreground a graphical control on top of any directx or opengl game, using pyopengl? The system would work similar to xfire, an in game messaging program for windows. This program creates a "window" in the foreground of the game you are playing to allow you to type messages to other players. If opengl is over kill or isn't able to complete the task, could you direct me to another method or GUI. Please reply in non-esoteric terms as I am new to python and opengl, and am using this project as a learning tool for python. Regards. |
From: Maciej K. <ma...@dg...> - 2006-06-22 13:11:25
|
On Thu, Jun 22, 2006 at 07:48:37AM +0100, Rowan wrote: > I am thinking of embarking on a project to create an in-game mp3 > player control. This control will be brought into the foreground of > the game. > > My question is it possible to overlay or bring to the very foreground > a graphical control on top of any directx or opengl game, using > pyopengl? This is relatively trivial to do in OpenGL in general. Many games do something similar for all kinds of "Heads-Up Display". A good way of thinking about this is to imagine that your view of the game world comes from a camera placed in this world. To create a HUD, or anything else that appears to overlay the view, imagine affixing a sheet of glass, perpendicular to the viewing direction, some small fixed distance from the camera lens (say, 3 feet or 1 meter). Wherever you turn the camera, you're always looking through the same piece of glass. Then you can start "scribbling" stuff on this piece of glass, such as current # of points earned, log messages, chat windows, etc. To implement this your rendering routine usually would look like this: - first, draw your game world as usual - reset the projection matrix, preferrably using gluOrtho, and disable depth testing (i.e., glDisable(GL_DEPTH)); this allows you to write & draw stuff using simple 2D graphics, and turning off depth testing ensures that you fully overwrite what's already shown on screen - now draw your user interface/overlay stuff Here's a rough snippet from my render code: # draw the gameworld as usual draw_world() # setup the projection for Heads-Up Display w, h = get_window_size() glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0, w, 0, h, 0.1, 1) glMatrixMode(GL_MODELVIEW) glLoadIdentity() glDisable(GL_DEPTH_TEST) # draw all the overlay stuff draw_hud() Good luck, -- Maciej Kalisiak mac "at" dgp.toronto.edu www.dgp.toronto.edu/~mac |
From: Rowan <row...@gm...> - 2006-06-22 15:43:30
|
Thanks for your replay Maciej, Just to make sure you understood my intentions and I don't go off chasing rainbows, I want to use this HUD ontop of any game, not one release by me. e.g. Battlefield 2 or World or Warcraft, or whatever. With that inmind does your suggestions still hold true. On 6/22/06, Maciej Kalisiak <ma...@dg...> wrote: > On Thu, Jun 22, 2006 at 07:48:37AM +0100, Rowan wrote: > > I am thinking of embarking on a project to create an in-game mp3 > > player control. This control will be brought into the foreground of > > the game. > > > > My question is it possible to overlay or bring to the very foreground > > a graphical control on top of any directx or opengl game, using > > pyopengl? > > This is relatively trivial to do in OpenGL in general. Many games do > something similar for all kinds of "Heads-Up Display". A good way of thinking > about this is to imagine that your view of the game world comes from a camera > placed in this world. To create a HUD, or anything else that appears to > overlay the view, imagine affixing a sheet of glass, perpendicular to the > viewing direction, some small fixed distance from the camera lens (say, 3 > feet or 1 meter). Wherever you turn the camera, you're always looking through > the same piece of glass. Then you can start "scribbling" stuff on this piece > of glass, such as current # of points earned, log messages, chat windows, etc. > > To implement this your rendering routine usually would look like this: > - first, draw your game world as usual > - reset the projection matrix, preferrably using gluOrtho, and disable depth > testing (i.e., glDisable(GL_DEPTH)); this allows you to write & draw stuff > using simple 2D graphics, and turning off depth testing ensures that you > fully overwrite what's already shown on screen > - now draw your user interface/overlay stuff > > Here's a rough snippet from my render code: > > # draw the gameworld as usual > draw_world() > > # setup the projection for Heads-Up Display > w, h = get_window_size() > glMatrixMode(GL_PROJECTION) > glLoadIdentity() > glOrtho(0, w, 0, h, 0.1, 1) > glMatrixMode(GL_MODELVIEW) > glLoadIdentity() > glDisable(GL_DEPTH_TEST) > > # draw all the overlay stuff > draw_hud() > > Good luck, > > -- > Maciej Kalisiak mac "at" dgp.toronto.edu www.dgp.toronto.edu/~mac > |
From: Maciej K. <ma...@dg...> - 2006-06-22 18:35:15
|
On Thu, Jun 22, 2006 at 04:43:28PM +0100, Rowan wrote: > Just to make sure you understood my intentions and I don't go off > chasing rainbows, I want to use this HUD ontop of any game, not one > release by me. e.g. Battlefield 2 or World or Warcraft, or whatever. > With that inmind does your suggestions still hold true. Ahhh, that is a very different ball of yarn. I don't think that's possible with PyOpenGL. In fact I don't think you can do it with OpenGL at all... this seems more like a lower-level, platform/windowing system specific thing. If you're looking at Windows in particular, then maybe, mayyyybe, DirectX allows an external program (i.e., your program) to "break into" the graphical context of another (i.e., the game). More likely is that you need to do some Windows higher-magic through some other API (e.g., your app would read the game's window, to see what was rendered, modify it, and then write it back into the game window). To sum up: what you propose is very non-trivial to do, is very platform-specific, and would need a fair bit of intimate knowledge of the OS API. Considering your situation, I think the best bet for you is to Google around and try to find a project that has attempted to do something similar. This will be Windows-specific stuff, and will likely have very little to do with OpenGL or DirectX (but it may involve one of the other Direct* thingies under Windows; I know very little about them). -- Maciej Kalisiak mac "at" dgp.toronto.edu www.dgp.toronto.edu/~mac |