Jump to content
  • Advertisement
Sign in to follow this  
Graham

Rendering 3D and 2D

This topic is 4911 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

I was wondering what is the proper way to render 3d objects and 2d objects. I need the 3d objects for my world, and need 2 2d triangles for my console. When I create my D3d device I create a stencil buffer. And every frame I do: m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ); Which will cause problems if I try to render my 2 2d triangles. In order to get the 2d triangles to show up I have to not create a stencil buffer and then not clear the zbuffer every frame. My 2d triangles have this struct: struct VertexColor2D { float x, y, z, rhw; // The transformed position for the vertex DWORD color; // The vertex color };

Share this post


Link to post
Share on other sites
Advertisement
Since you have created a stencil buffer, you need to clear that, too.

m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );

Share this post


Link to post
Share on other sites
I have decided to take out the stencil buffer since Im not using any of the features. I have a triangle that is spinning on the y-axis. When I clear the ZBUFFER I get many artifacts. But when I clear only the targets it looks fine. Why would that be? I though a 3d triangle needed a cleared zbuffer every frame.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!