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 <mac@...> 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 http://www.dgp.toronto.edu/~mac
>
|