Sign in to follow this  

Why does PresentParameters.EnableAutoDepthStencil = true break my scene

This topic is 3376 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've been having this problem for 2 days now and I can't figure out why enabling the AutoDepthStencil it breaks the scene. The second I enable m_PresentParameters.EnableAutoDepthStencil = true; in the code before my Draw method my scene's triangle cannot be seen, but the grey background can. If I comment out the line I can see the background/triangle fine. Now I've seen in many other example programs people enabling the depth buffer this way and their scene works fine, there's just something funky going on I can't catch. If anybody could provide an explanation as to why I would be very grateful. I could just keep that commented but it wouldn't help much when I needed to use it.
void CD3DObj::Draw(void)
{

	SVertex triangle[] = 
	{ 
		// x, y, z, w, color  coordinates expand from upper left to lower right on screen
		{ GetWidth() / 2.0f, GetHeight() / 3.0f, 15.0f, 1.0f, D3DCOLOR_ARGB(255, 255, 0, 0), }, 
		{ GetWidth() / 1.33f, GetHeight() / 1.2f, 15.0f, 1.0f, D3DCOLOR_ARGB(255, 0, 255, 0), },
		{ GetWidth() / 4.0f, GetHeight() / 1.2f, 15.0f, 1.0f, D3DCOLOR_ARGB(255, 0, 0, 255), },
	};	

	m_pDirect3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 100, 100, 100), 1.0f, 0);

	m_pDirect3DDevice->BeginScene();	

	m_pDirect3DDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);

	m_pDirect3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, triangle, sizeof(SVertex));

	m_pDirect3DDevice->EndScene();

	m_pDirect3DDevice->Present(NULL, NULL, NULL, NULL);

	Sleep(1); // Give the OS a bit of time to process other things

}

Share this post


Link to post
Share on other sites
I actually didn't set anything with matrices yet. I was building up to eventually using them but I was going for a barebones example in the interim. The tutorial I was using didn't have anything with matrices set.

I'm pretty sure I selected a valid format, I was using a combination of GameTutorials.com intros and two-kings.de/tutorials/dxgraphics/ and both of those work fine on my system.


m_PresentParameters.AutoDepthStencilFormat = D3DFMT_D16;



Share this post


Link to post
Share on other sites
Quote:
Original post by Madhed
-> D3DCLEAR_TARGET

gotta be

-> D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL
Ah, well spotted [smile]

Actually, you'll need to remove the D3DCLEAR_STENCIL flag, since there's no stencil buffer attached.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by Madhed
-> D3DCLEAR_TARGET

gotta be

-> D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL
Ah, well spotted [smile]

Actually, you'll need to remove the D3DCLEAR_STENCIL flag, since there's no stencil buffer attached.


Ah you got me there ;)

Share this post


Link to post
Share on other sites

This topic is 3376 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.

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