Archived

This topic is now archived and is closed to further replies.

PsycoBlade

Overwriting the sort order?

Recommended Posts

Is there any way so that when I render an object onto the screen, it will appear as if it is on top of all other things rendered on the screen even if it isn''t really in front? Thanks. -Rich

Share this post


Link to post
Share on other sites
I know of two ways to do this depending on what you want to do.

If you want to render an entire scene and a bunch on objects on top of another scene you can clear the Z-Buffer once the lower scene is rendered:
PR_ClearViewportOpt (&viewport, PR_CLEAR_DEPTHBUFFER);




If you just want to render a couple of objects on top of a scene after you render the lower scene you can:

PR_DepthBufferMode (PR_DEPTHBUFFER_DISABLE);
// Render your objects //
PR_DepthBufferMode (PR_DEPTHBUFFER_ENABLE);




Gary

Share this post


Link to post
Share on other sites
That sort-of worked. What I have is in my game I need to draw a bunch of these little objects on the screen. The all are on the same z axis, but I want each one that I draw to appear in front of the one I drew last (they are drawn in a big loop). What I mean by "in front" is not closer to the camera, but just hiding the object behind it, like when you draw an overlay over another overlay. The PR_DepthBufferMode did that, but it also messed up the objects because the polygons in the object itself were not being sorted. If any of you know how to do what I am trying to do I would appreciate the help. Thank you.

-Rich

Share this post


Link to post
Share on other sites
I put a ClearViewportOpt in the loop to be run after each object is rendered. That gave me the exact effect I was looking for. Now I just wonder does ClearViewportOpt require a lot of CPU time? I''m caling it 10 times per frame.

-Rich

Share this post


Link to post
Share on other sites
I'm not sure how long it actually takes to clear the ZBuffer but my guess is that it isn't a really lighting fast proccess since it's a pretty large chunk of memory.

Unfortinately these are the only ways that I currently know of to do this in PR.


PR_DepthBufferMode (PR_DEPTHBUFFER_DISABLE); disables the ZBuffer entirely while PR_ClearViewportOpt (, PR_CLEAR_DEPTHBUFFER); just clears the current ZBuffer.


So, PR_ClearViewportOpt is the slower method of doing this, you should probibly try to keep the viewport you are clearing as small as possible.


It's too bad Chris is on vacation. He probibly knows how long it takes.


Gary

Edited by - Gary on August 14, 2001 9:49:06 PM

Share this post


Link to post
Share on other sites
Clearing the zbuffer is a hardware operation and I assume the speed will be different depending on the graphics card.

If it''s fast enough to do 10 times in a frame then keep it. Personally I wouldn''t call it more than twice during a frame though. You might want to look for another method that doesn''t involved clearing entire buffers.

Share this post


Link to post
Share on other sites