Bug: Weapon Drawn on HUD going through world...

Started by
6 comments, last by jmoses 20 years, 3 months ago
Hello, I''m having a problem with the weapon on my Heads Up Display poking through the world, if I scoot it closer to the camera it happens less, but I like the way it looks where it is. I tried calling glClear( GL_DEPTH_BUFFER_BIT ); right before I draw the HUD (which is the last thing drawn in the game loop), but that didn''t fix it. I''m sure many people have ran into this problem before, how did you guys fix it?
- John Moses
Advertisement
I think you need to disable depth testing.
Prolly be better to just clear the Z buffer. You still want depth testing so the model comes out right.

-=[ Megahertz ]=-
-=[Megahertz]=-
DrEvil, If I disable depth testing on the level, the polygons of the level will overlap all funny, if I disable depth testing with the gun model on the HUD, the weapon models polygons will become all glitchy looking. I''m pretty sure I need to just clear the Z buffer (the depth buffer), and Right before I draw the weapon model I do call glClear( CL_DEPTH_BUFFER_BIT ); but that doesnt work
Any Ideas?

Thanks,
- John
- John Moses
Post your code, it should work.


"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
clear the buffers (z buffer, color, stencil, whatever you have), enable z-test, render the scene, clear the z buffer (or try disable depth test), render the gun, disable z-test, render the HUD, swap buffers.

Everything is better with Metal.

If you''re using the stencil buffer anywhere make sure you disable it too.
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V
Try this:
* Set the stencil op to output a 1 when drawing w/ no stencil test
* Draw your weapon model
* Swap the stencil test to skip pixels with a stencil 1
* Disable the stencil op
* Draw the world geometry

Good luck on yer project.
-"Sta7ic" Matt

This topic is closed to new replies.

Advertisement