Archived

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

BigAndy

Adding 2D elements in 3D scene

Recommended Posts

BigAndy    128
Hi all, Can someone point me in the right direction? I would like to add some 2D elements to my 3D scene like an energy bar / score / lives left etc using graphics not text (I can do that already). I guess I need to use the stencil buffer but I''m not sure how. Any articles or sample code would be great. Or just a few function names to point me in the right direction. Cheers Andy ----------------------------- Andy Pike DirectX 8 Tutorials: www.andypike.com

Share this post


Link to post
Share on other sites
BigAndy    128
The SDK refers to "Compositing". That sounds like what I''m after.

"Using DirectX Graphics" > "Techniques and Special Effects" > "Stencil Buffer Techniques" > "Compositing"

-----------------------------
Andy Pike
DirectX 8 Tutorials: www.andypike.com

Share this post


Link to post
Share on other sites
jobless    122
You don''t have to use a stencil. After you draw the 3d scene, turn off the z-buffer, so anything you draw will appear on top of the scene. Then, set an orthogonal projection matrix and position your camera for 2D.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
- set up orthogonal-projection viewpoint
- disable the depth buffer
- render sprites in screen space rather than world-space
- restore depth buffer
- restore the worldspace viewpoint

Share this post


Link to post
Share on other sites
BigAndy    128
So, when it comes to rendering, do I render textures of my energy bar (for example) on to polygons? Or should I blit to the screen (if you can)?

-----------------------------
Andy Pike
DirectX 8 Tutorials: www.andypike.com

Share this post


Link to post
Share on other sites
DrunkenHyena    805
G''day!

Definitely render them as sprites. Whether you use D3DXSprite, or just some quads, it''ll do the trick. Don''t blit, it can cause some nasty performance hits.

If your 2D elements are fairly static you can just use XYZRHW vertices and edit them manually for changes, that way you don''t have to mess with the Ortho view. but if doing more fancy things, the Ortho view is a big win.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites