I...Just need a colorful line...

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

beyondlwm
Just popping in
Just popping in
Posts: 7
Joined: Wed Jul 27, 2011 13:23

I...Just need a colorful line...

Postby beyondlwm » Sat Aug 27, 2011 18:58

hi,

It is said that we need to recover the render state after rendering cegui , because cegui will change some of the render state.
Is it true? Is there a better way to do it rather than guess what should be recovered?

Now my problem is, I'm trying to draw a line on screen to show current direction. I give it a color that is 0xffff0000 which should be red.

However, if I render CEGUI at the same time ,the line will always be WHITE~
If I STOP render CEGUI, the line becomes red, that is WHAT I WANT.

I guess CEGUI may change a render state which will effect this. my current function to recover render state from cegui is:

(And please try to consider the simplest way of the whole render process, in fact I really just draw a line)
{
LPDIRECT3DDEVICE9 pDevice = m_pRenderer->getDevice();

pDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
pDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
pDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);

pDevice->SetTextureStageState( 0 , D3DTSS_COLORARG1, D3DTA_TEXTURE );
pDevice->SetTextureStageState( 0 , D3DTSS_COLORARG2, D3DTA_DIFFUSE );
pDevice->SetTextureStageState( 0 , D3DTSS_COLOROP, D3DTOP_SELECTARG1 );

pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
pDevice->SetFVF(NULL);
}


Any reply will be helpful :)

beyondlwm
Just popping in
Just popping in
Posts: 7
Joined: Wed Jul 27, 2011 13:23

Re: I...Just need a colorful line...

Postby beyondlwm » Mon Aug 29, 2011 02:34

Hi all,

I just figure out , We need to set pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DISABLE); to restore the render state :)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 42 guests