Drawing my HUD

Started by
8 comments, last by Wavesonics 19 years, 8 months ago
Ok I'm trying to draw a HUD, well actualy thats later, right now I'm just trying 2 add a tag image to my engine. Which once done could easily be made into a HUD but thats off the point here... My understanding of rasterpos and drawpixels was that you were drawing to a section of the screen but aparently your drawing to coordinates in the world. I want to draw to just a portion of the screen like say the bottom 50 or 100 pixels (think doom HUD). Now I understand drawpixels is very expensive so I don't intent to use it. I was thinking i could possition a quad down there before my scene rotations and shit and texture it so it stays w\ the camera but is there another way? How are HUDs usualy drawn?
==============================
A Developers Blog | Dark Rock Studios - My Site
Advertisement
switch to orthographic project, that will give you a 2D plane to work on and draw your hud on that AFTER the rest of the world (preferable with depth testing disabled)
and still use drawpixels?
==============================
A Developers Blog | Dark Rock Studios - My Site
Quote:Original post by Wavesonics
and still use drawpixels?


No, use the standard drawing procedures.
um... srry for being a bit of a nub here but what would those be exactly. I have a book (which sux btw...) and it only has 2 functions for drawing 2D stuff, 1 is for bit maps the other is glDrawPixles. What should I use if not these?
==============================
A Developers Blog | Dark Rock Studios - My Site
sorry, i wasnt clear about that, I was kinda following on from your idea about using a quad.

As MikeMJH says you should use the standard way of doing things, primatives and texturing as you would for any other drawing, it'll be MUCH MUCH MUCH (you get the idea) faster than Drawpixels will ever be.

Infact, as a rule of thumb you dont want to push pixels at the screen at all.
aw awesome thx man. So is switching to orthographic nessisary then? I expect thats gotta be kinda expensive to switch ever frame. and if i just draw a 2D squad where I want and not have it affected by my translations and shit it should remain right up against the viewport and appear to b 2d.
==============================
A Developers Blog | Dark Rock Studios - My Site
>>I expect thats gotta be kinda expensive to switch ever frame<<

only if you do it 1,000,000 times a frame. sticking to less than 1,000 x + u should be alright
If you are REALLY that bothered about it you could pre-store the matrices in question and just glLoadMatrix them into the right matrix static, however this is somewhat pointless as 99.9% of the work the gfx card is going to be doing is going to be drawing your scene, 2 projective matrix switches per frame is nuffin at all in the grand scheme of things.

The total order of operations can be done as follows :

- switch to projective matrix
- push matrix
- switch to ortho mode
- switch to modelview matrix
- draw hud
- switch to projective matrix
- pop matrix
- switch to modelview matrix

very very cheap, in fact it probably costs more to switch a texture or two...
awesome thx man, so the push and pop take care of switching back to the original prospective? Thats awesome.

Is this really how HUDs are done? I guess most stuff like say life counters are done with rendering out font text since changing the texture every time to 1 displaying a new number would suck.
==============================
A Developers Blog | Dark Rock Studios - My Site

This topic is closed to new replies.

Advertisement