Problems with D3DXCOLOR() In DirectX 11

closed account (3qX21hU5)
So I would first like to say i'm still quite new at d3d11 so sorry if this is quite a stupid question.

The problem I'm having is I'm following the tutorial at DirectXTutorial.com and in one of the lessons we need to render a single frame to a certain background color. He chose to use devcon->ClearRenderTargetView(backbuffer, D3DXCOLOR(0.0f, 0.2f, 0.4f, 1.0f));. The problem with that is D3DXCOLOR() uses a header that no longer exists (I think D3DX10Math.h) or it doesn't on my version of the directx SDK.

So the question I have is is there another way to render what I want onto the screen using devcon->ClearRenderTargetView() but replace D3DXCOLOR() with something else? Or should I use something totally different. Thanks in advance for the help guys.

I believe I have the June 2010 version of DirectX SDK if that helps.

EDIT: After some searching on MSDN I can up with something like this (Remmber I'm still learning that's why I got so many comments to help me remmber ;p)

1
2
3
4
5
6
7
8
9
10
11
12
13
void RenderFrame(void)
{
        // Declares a texture color
	const FLOAT Mycolor = D3DCOLOR D3DCOLOR_COLORVALUE(0.0f, 0.2f, 0.4f, 1.0f);

	// Clear the back buffer to a deep blue
	devcon->ClearRenderTargetView(backbuffer, &Mycolor);

	// Do 3D Rendering on the back buffer here

	// Switches back buffer and the front buffer
	swapchain->Present(0, 0);
}


So it seems to be working (Except its a dark red instead of blue...) just wondering if thats the right way to do it or not.
Last edited on
Yes, that's how you can clear the screen to a given color. In DirectX 10 I use D3DXCOLOR() like this:

1
2
3
4
5
6
7
clearColor = D3DXCOLOR(0.0f, 0.0f, 1.0f, 1.0f);

ID3D10RenderTargetView* renderTargetView;

d3dDevice->ClearRenderTargetView(renderTargetView, clearColor);

swapChain->Present(0, 0);


So this doesn't compile for you with DirectX 11? (I haven't written any programs using DX11 so far, so I wouldn't know)

In a book I have for DX11 (Sherrod and Jones' "Beginning DirectX 11 Game Programming"), I see that in a sample program for DX11 initialization the authors use a float array like so:
1
2
3
float clearColor[4] = { 0.0f, 0.0f, 0.25f, 1.0f };
d3dContext_->ClearRenderTargetView( backBufferTarget_, clearColor );
swapChain_->Present( 0, 0 );


Ogoyant
Last edited on
closed account (3qX21hU5)
Yes I switched to using a floating array also like in your DX11 book. I just find it kind of wierd that I dont have the D3DX10Math header file. From what I have been able to find is that the new DX thats included with windows 8 no longer using the D3DX10Math.h and some other headers.

I'm pretty sure I'm using the June 2010 SDK since that is what I just downloaded and I dont have windows 8.
Yes, a little research on my part right now shows pretty much the same result, apparently the new(er?) version of the DirectX SDK that accompanies Windows 8 doesn't include certain (or all) D3DX- related features.

In my system, having the June 2010 SDK (I use Windows 7 and I don't have the Windows 8 SDK or the DirectX version that comes with it), I find D3DX10math.h here:

C:\Program Files\Microsoft DirectX SDK (June 2010)\Include


Good to know about this, interesting.

Ogoyant
Last edited on
Topic archived. No new replies allowed.