Sign in to follow this  

FPS style HUD and gun rendering.

This topic is 4245 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How does one keep a player's gun and the heads-up display (like health and ammo counts) from clipping into other 3D objects? I think I could solve the gun problem by simply adjusting the bounding box a little. Say I want to draw a crosshair with GL_LINES, though. Is there a way I can keep it from clipping into walls and the ground when I look around?

Share this post


Link to post
Share on other sites
I just ran across a similar thread where zedzeek suggested using glOrtho for orthographic perspective. I thought I might be able to use orthographic.. I just didn't know how! :) I'll try it out.

Share this post


Link to post
Share on other sites
You should definately be using orthographic projection for the HUD.
Also you can do glDisable(GL_DEPTH_TEST) before drawing the hud to make sure it doesn't get clipped by anyting.

The gun will look weird if you render it with orthographic projection. So, either you need to have your collision detection keep the gun from sticking through stuff, or you can clear the depth buffer before drawing the gun, so that none of it is clipped.

Share this post


Link to post
Share on other sites
Draw the HUD using ortho projection. The gun should be rendered using normal perspective projection. To avoid penetrating objects by the gun just clear the depth buffer before drawing it (clearing the depth buffer is very fast).

Share this post


Link to post
Share on other sites
Quote:
Original post by Boder
You don't need to clear the depth buffer, just disable depth testing as echohead said.


No, disabling the depth buffer will simply lead to all the polygons of the gun model drawn in the order they are parsed and throughly wrong. You want to keep the depth buffer enabled but ensure it is cleared first before drawing the weapon model so it is not affected by the world that was rendered previously.

And only use orthographic for your hud, your model will be best drawn with a perspective projection.

Share this post


Link to post
Share on other sites
Hmm. I guess the only way you could disable depth testing is if you sorted the polygons from the gun yourself or if you had a 2D bitmap that you used as the gun.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Boder
Hmm. I guess the only way you could disable depth testing is if you sorted the polygons from the gun yourself or if you had a 2D bitmap that you used as the gun.


Yes, and why would you want to do that when you can clear the depth buffer?

Share this post


Link to post
Share on other sites
Quote:
Original post by Boder
You don't need to clear the depth buffer, just disable depth testing as echohead said.

Hehe, I love this suggestion. So you disable depth testing and render a 3D object?

Share this post


Link to post
Share on other sites

This topic is 4245 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this