Sign in to follow this  
Cosmy

Direct3D10 & Color Problem

Recommended Posts

Cosmy    167
Hi all,

I have this

// CColorf class
real *GetARGB() const
{
real fColor[4] = { 0.0f };

fColor[0] = this->GetA();
fColor[1] = this->GetR();
fColor[2] = this->GetG();
fColor[3] = this->GetB();
return fColor;
}

// CD3D10Render class
void CRenderD3D10::Clear(const CColorf &Colorf)
{
if (m_pDevice)
{
m_pDevice->ClearRenderTargetView(m_pRenderTargetView, Colorf.GetARGB());
m_pDevice->ClearDepthStencilView(m_pDepthStencilView, D3D10_CLEAR_DEPTH | D3D10_CLEAR_STENCIL, 1, 0);
}
// move it in another function
if (m_pDXGISwapChain) m_pDXGISwapChain->Present(0, 0);
}

//--------------
if (m_pRenderD3D10) m_pRenderD3D10->Clear(CColorf(1.0f, 0.125f, 0.3f, 1.0f));




I'm using Visual C++ 2010. When i run the release exe the clear color is red-pink
when i run the debug exe the clear color is black why this???

i checked the any single color and this is my log:


//debug
(a)1.000000,(r)0.125000,(g)0.300000,(b)1.000000

//release
(a)1.000000,(r)0.125000,(g)0.300000,(b)1.000000




Please help me :(

Share this post


Link to post
Share on other sites
MJP    19754
You're returning a pointer to a temporary variable (fColor). Either make it a member of your CColorf class, or make it static member of that class, or have that GetARGB function take an array as a parameter that it will fill with the values.

Share this post


Link to post
Share on other sites
Cosmy    167
Quote:
Original post by MJP
You're returning a pointer to a temporary variable (fColor). Either make it a member of your CColorf class, or make it static member of that class, or have that GetARGB function take an array as a parameter that it will fill with the values.


Ok thanks now it work :)

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