Jump to content
  • Advertisement
Sign in to follow this  

Clearing the Screen

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

Hi. I am using Visual C++ CLR (2005) / DirectX 9. My OS is a VISTA machine. I am trying to render a d3dx Cube. My cube renders correctly however when I try rotating the cube on a time interval, the cube rotates but the screen is not cleared properly. I am not sure why this happens as I continually clear my target and zbuffer.
		while(bRunning == true)

				D3DXMatrixTranslation(&mtxCubeWorldMatrix,0.0f,0.0f, 0.0f);
				D3DXMatrixRotationY(&mtxCubeWorldMatrix,(D3DX_PI * dAngle)/180);
				dev->SetTransform(D3DTS_WORLD, &mtxCubeWorldMatrix);
Any ideas? Thanks in advance!

Share this post

Link to post
Share on other sites
I'd bet that you didn't actually ask for a Z buffer, and the clear is failing.

First, find the DirectX control panel, and enable the debug runtimes. Next time you run your app in Visual Studio, it should tell you you're missing a ZBuffer and clear is failing. You should also link with d3dx9d.lib rather than d3dx9.lib. The D is for debug. It will give helpful information when D3DX functions fail.(like texture load or shader compiling)

Now that you know how to find what went wrong, finding out how to fix the next problem should be easier.

The fix for your missing Z buffer is to ask for one to be created. This is done with the presentation parameters you pass to CreateDevice. Set "EnableAutoDepthStencil" to true. Set "AutoDepthStencilFormat" to a valid depth format, like D3DFMT_D24X8. I think ZBuffering defaults to disabled, so enable it like so:
pDev->SetRenderState(D3DRS_ZENABLE, true);

Share this post

Link to post
Share on other sites
Thanks for the tip! Actually I had enabled by Z Buffer (sorry for not mentioning that). The problem was that I hadn't enabled my stencil buffer. Thanks again for your help!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!