[Solved] CEGUI only renders in certain part of an app
Posted: Wed Jul 20, 2011 01:54
Hi everyone,
First, a reference: http://www.cegui.org.uk/phpBB2/viewtopic.php?f=10&t=4620.
As in the above thread, I am hooking into a game in the attempt to draw a custom gui on top of the game. In the CreateDevice function, I initialize the CEGUI system using a Direct3D9Renderer. Before calling the Present function I call BeginScene, renderGUI, and EndScene followed by the original Present.
Initially, the gui is rendered and shows up on the screen. I was so ecstatic! However, once you proceed past the login screen, to the loading screen, the gui disappears. Continuing into the game itself the gui remains invisible. After logging out of the game and returning to the login or start screen, the gui will reappear.
While the problem encountered in the referenced thread is different, the cause of mine seems very likely to be one of states because of the nature of hooking into a third party application: you have pretty much no idea what it is doing.
The required information is as follows.
The reset of the initialization looks pretty typical. No errors show up (which makes sense because the gui shows up!).
A simple std::wcout call shows that renderGUI() is still being called even though nothing is showing up.
The referenced thread has two potential solutions to the problem.
1)
2) Explicitly set the display size
Seeing how the gui is rendered initially it seems that (2) is unlikely, and that (1) is the likely solution.
I tried this and nothing changed. I also tried explicitly setting all render, sampler, and texture-stage states (below) to their defaults from the msdn documentation with no avail. What confused me about this was even though I did not restore the previous state, the game continued to function normally. While it is possible the game restores all states each frame, it seems unlikely. As such, this confused me.
So with no more ideas I've come to everyone here. I apologize if I've overlooked something simple; This is my first foray into Direct3D.
Thanks everyone.
First, a reference: http://www.cegui.org.uk/phpBB2/viewtopic.php?f=10&t=4620.
As in the above thread, I am hooking into a game in the attempt to draw a custom gui on top of the game. In the CreateDevice function, I initialize the CEGUI system using a Direct3D9Renderer. Before calling the Present function I call BeginScene, renderGUI, and EndScene followed by the original Present.
Initially, the gui is rendered and shows up on the screen. I was so ecstatic! However, once you proceed past the login screen, to the loading screen, the gui disappears. Continuing into the game itself the gui remains invisible. After logging out of the game and returning to the login or start screen, the gui will reappear.
While the problem encountered in the referenced thread is different, the cause of mine seems very likely to be one of states because of the nature of hooking into a third party application: you have pretty much no idea what it is doing.
The required information is as follows.
Code: Select all
19/07/2011 18:41:10 (Std) ********************************************************************************
19/07/2011 18:41:10 (Std) * -------- START OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM -------- *
19/07/2011 18:41:10 (Std) ********************************************************************************
19/07/2011 18:41:10 (Std) ---- Version 0.7.5 (Build: Nov 19 2010 Microsoft Windows MSVC++ 10.0 32 bit) ----
19/07/2011 18:41:10 (Std) ---- Renderer module is: CEGUI::Direct3D9Renderer - Official Direct3D 9 based 2nd generation renderer module. ----
19/07/2011 18:41:10 (Std) ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
19/07/2011 18:41:10 (Std) ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
19/07/2011 18:41:10 (Std) ---- Scripting module is: None ----
19/07/2011 18:41:10 (Std) ********************************************************************************
19/07/2011 18:41:10 (Std) * -------- END OF ESSENTIAL SECTION TO BE POSTED ON THE FORUM -------- *
19/07/2011 18:41:10 (Std) ********************************************************************************
The reset of the initialization looks pretty typical. No errors show up (which makes sense because the gui shows up!).
A simple std::wcout call shows that renderGUI() is still being called even though nothing is showing up.
The referenced thread has two potential solutions to the problem.
1)
Another option you have is this:
1) When D3D first starts up (states at default), set the CEGUI states from initPerFrameStates, and record a state block.
2) Rewrite initPerFrameStates so instead of setting states, it applies the state block recorded above.
3) Do everything else the same as now.
4) ????
5 Profit!
2) Explicitly set the display size
Seeing how the gui is rendered initially it seems that (2) is unlikely, and that (1) is the likely solution.
I tried this and nothing changed. I also tried explicitly setting all render, sampler, and texture-stage states (below) to their defaults from the msdn documentation with no avail. What confused me about this was even though I did not restore the previous state, the game continued to function normally. While it is possible the game restores all states each frame, it seems unlikely. As such, this confused me.
Code: Select all
this->m_device->BeginScene();
// Set by CEGUI
this->m_device->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
this->m_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
this->m_device->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
// Set by CEGUI
this->m_device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
this->m_device->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
this->m_device->SetRenderState(D3DRS_LASTPIXEL, TRUE);
...
...
...
CEGUI::System::getSingleton().renderGUI();
this->m_device->EndScene();
// Present called
So with no more ideas I've come to everyone here. I apologize if I've overlooked something simple; This is my first foray into Direct3D.
Thanks everyone.