Sign in to follow this  
Graham

Rendering 3D and 2D

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
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

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