[C++, DX11] System crash with Frame Counter
Posted: Sat Oct 01, 2011 17:02
Hello,
I'm trying to implement CEGUI into my engine and having some troubles. I've managed to get DirectX 11 renderer working and rendered simple Hello World window. Next thing I tried to do was FPS counter (the part I added is between Start and End comments in Frame Render), which causes my system to crash.
CEGUI initialization:
Frame Move:
Frame Render:
To be exact, system crashes when DXUT calls SwapChain->Present();.
CEGUI log: http://dl.dropbox.com/u/2637453/CEGUI/C ... 0-2011.log
If I forgot to provide any information let me know.
Thank you.
Edit:
New Frame Render code:
I used WARP device and code works fine: it renders string perfectly and doesn't spew any errors. However if I use HARDWARE device it still crashes on same line.
New CEGUI log: http://dl.dropbox.com/u/2637453/CEGUI/C ... 0-2011.log
I'm trying to implement CEGUI into my engine and having some troubles. I've managed to get DirectX 11 renderer working and rendered simple Hello World window. Next thing I tried to do was FPS counter (the part I added is between Start and End comments in Frame Render), which causes my system to crash.
CEGUI initialization:
Code: Select all
CEGUI::Direct3D11Renderer *renderer = &CEGUI::Direct3D11Renderer::bootstrapSystem(pDevice, pDeviceContext);
CEGUI::DefaultResourceProvider* rp = (CEGUI::DefaultResourceProvider*)(CEGUI::System::getSingleton().getResourceProvider());
rp->setResourceGroupDirectory("schemes", "datafiles/schemes/");
rp->setResourceGroupDirectory("imagesets", "datafiles/imagesets/");
rp->setResourceGroupDirectory("fonts", "datafiles/fonts/");
rp->setResourceGroupDirectory("looknfeels", "datafiles/looknfeel/");
rp->setResourceGroupDirectory("layouts", "datafiles/layouts/");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::Imageset::setDefaultResourceGroup("imagesets");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser();
if(parser->isPropertyPresent("SchemaDefaultResourceGroup"))
parser->setProperty("SchemaDefaultResourceGroup", "schemas");
CEGUI::SchemeManager::getSingleton().create(CEGUI::String("TaharezLook.scheme"));
CEGUI::System::getSingleton().setDefaultFont("DejaVuSans-10");
CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
CEGUI::Window *myRoot = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "_MasterRoot");
CEGUI::System::getSingleton().setGUISheet(myRoot);
CEGUI::Window *wnd = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow", "Demo Window");
myRoot->addChildWindow(wnd);
wnd->setPosition(CEGUI::UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
wnd->setSize(CEGUI::UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
wnd->setMaxSize(CEGUI::UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
wnd->setMinSize(CEGUI::UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
wnd->setText("Hello world!");
Frame Move:
Code: Select all
CEGUI::System::getSingleton().injectTimePulse(fElapsedTime);
Frame Render:
Code: Select all
void CALLBACK OnFrameRender(ID3D11Device *pd3dDevice, ID3D11DeviceContext *pd3dImmediateContext, double fTime, float fElapsedTime, void *pUserContext) {
float ClearColor[4] = {0.2, 0.2, 0.7, 0};
ID3D11RenderTargetView *pRTV = DXUTGetD3D11RenderTargetView();
pDeviceContext->ClearRenderTargetView(pRTV, ClearColor);
// Clear the depth stencil
ID3D11DepthStencilView *pDSV = DXUTGetD3D11DepthStencilView();
pDeviceContext->ClearDepthStencilView(pDSV, D3D11_CLEAR_DEPTH, 1, 0);
pDeviceContext->OMSetRenderTargets(1, &pRTV, pDSV);
// ==== Start ====
CEGUI::Direct3D11GeometryBuffer *buffer = (CEGUI::Direct3D11GeometryBuffer*)&CEGUI::System::getSingleton().getRenderer()->createGeometryBuffer();
buffer->reset();
CEGUI::System::getSingleton().getDefaultFont()->drawText(*buffer, CEGUI::String((char*)DXUTGetFrameStats(DXUTIsVsyncEnabled())), CEGUI::Vector2(0, 0), 0, CEGUI::colour(0xFFFFFFFF));
CEGUI::System::getSingleton().getDefaultFont()->drawText(*buffer, CEGUI::String((char*)DXUTGetDeviceStats()), CEGUI::Vector2(0, 20), 0, CEGUI::colour(0xFFFFFFFF));
buffer->draw();
CEGUI::System::getSingleton().getRenderer()->destroyGeometryBuffer(*buffer);
// ==== End ====
CEGUI::System::getSingleton().renderGUI();
}
To be exact, system crashes when DXUT calls SwapChain->Present();.
CEGUI log: http://dl.dropbox.com/u/2637453/CEGUI/C ... 0-2011.log
If I forgot to provide any information let me know.
Thank you.
Edit:
New Frame Render code:
Code: Select all
void CALLBACK OnFrameRender(ID3D11Device *pd3dDevice, ID3D11DeviceContext *pd3dImmediateContext, double fTime, float fElapsedTime, void *pUserContext) {
float ClearColor[4] = {0.2, 0.2, 0.7, 0};
ID3D11RenderTargetView *pRTV = DXUTGetD3D11RenderTargetView();
pDeviceContext->ClearRenderTargetView(pRTV, ClearColor);
// Clear the depth stencil
ID3D11DepthStencilView *pDSV = DXUTGetD3D11DepthStencilView();
pDeviceContext->ClearDepthStencilView(pDSV, D3D11_CLEAR_DEPTH, 1, 0);
pDeviceContext->OMSetRenderTargets(1, &pRTV, pDSV);
static CEGUI::Direct3D11GeometryBuffer *buffer = 0;
if(!buffer)
buffer = (CEGUI::Direct3D11GeometryBuffer*)&CEGUI::System::getSingleton().getRenderer()->createGeometryBuffer();
const CEGUI::Rect scrn(CEGUI::Vector2(0, 0), CEGUI::System::getSingleton().getRenderer()->getDisplaySize());
buffer->setClippingRegion(scrn);
buffer->reset();
wstring wstr = wstring(DXUTGetFrameStats(DXUTIsVsyncEnabled())) + wstring(L"\n") + wstring(DXUTGetDeviceStats());
size_t length = wstr.length() + 1;
char *string = new char[length];
wcstombs(string, wstr.c_str(), length);
CEGUI::System::getSingleton().getDefaultFont()->drawText(*buffer, CEGUI::String(string), CEGUI::Vector2(0, 0), 0, CEGUI::colour(0xFFFFFFFF));
delete[] string;
buffer->draw();
CEGUI::System::getSingleton().renderGUI();
}
I used WARP device and code works fine: it renders string perfectly and doesn't spew any errors. However if I use HARDWARE device it still crashes on same line.
New CEGUI log: http://dl.dropbox.com/u/2637453/CEGUI/C ... 0-2011.log