Skip to main content
GameDev.net gamedev.net
🔒 Locked

Device not clearing

Started by slyprid Jan 1, 2007 at 9:49 AM 4 replies 950+ views
Original Post
slyprid
slyprid
I'm working on a new framework currently, and I've ran into a problem with the device. It seems that even though the device is there, and its running the code, it doesn't want to clear the screen to a specified color. Here is what I have. Most likely its something simple I over looked. This here is my scene manager. The device is showing that it has a memory location, so figuring it loaded right. Also don't have any errors during runtime.

void clsScene::Render()
{
	switch(CurrentScene)
	{
	case 0:
		dev->BeginScene();
		dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,0,0), 1.0f, 0);
		dev->EndScene();
		dev->Present(NULL,NULL,NULL,NULL);
		break;
	case 1:
		break;
	case 2:
		break;
	case 3:
		break;
	}
};


This is how I create the device.

//--------------------------------------------------------------------------------------
// Create DX Device
//--------------------------------------------------------------------------------------
IDirect3DDevice9 *CreateDXDevice(bool bWindowed)
{
    HRESULT hr;

    ZeroMemory( &d3dpp, sizeof(d3dpp) );
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	d3dpp.BackBufferCount = 1;
	d3dpp.BackBufferWidth = winWidth;
	d3dpp.BackBufferHeight = winHeight;
	d3dpp.hDeviceWindow = hWnd;
	d3dpp.Windowed = bWindowed;
    
	if(FAILED(dxInterface->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &device)))
	{
		if(FAILED(dxInterface->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &device)))
		{
			MessageBox(NULL, L"DirectX Device creation failure!", L"Error", MB_OK);
			return false;
		}
	}
    
	SetRenderStates();
	SetCamera();

	return device;
};

Thanks for your time, Slyprid
slyprid
slyprid
Ok I did notice that on HRESULT of my clear statement i'm getting
-2005530516 as the result instead of S_OK.
slyprid
slyprid
Ok I took out the D3DCLEAR_ZBUFFER from the clear command and it worked. Is there a reason why this would work? Am I not setting up the zbuffer or something?
Promit
Promit
You set your AutoDepthStencilFormat in your present parameters, but you didn't set EnableAutoDepthStencil to TRUE, so it never actually gave you a depth buffer.

By the way, state pattern. Please.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
slyprid
slyprid
Lol, wow thanks. Went through and did a bunch of gutting my program and it was just that. Figures. Thanks for the help.

Oh, btw what did you want to reference when stating about state patterns?

Slyprid
slyprid
slyprid
Ah, I see what your talking about. I'm just using the switch statement for time being to test out loading and such in the framework, than I'll be moving over to a more proper state system.

Slyprid

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.