Hi,
I'm making a small framework for making Direct3D games (mainly just for myself), called DXW. I seem to be having a weird problem in which my programs use up the entire CPU's time and don't let any other programs use any (so it takes around 5 minutes to close the damn thing when it locks up). I found out that calling 'Sleep(1)' fixes it, but I'm positive that last time I made a framework (recoding because I lost it in a HD crash), I didn't need to call that. It used 99% CPU time but it didn't 'hog' like it's doing now.
This is the code in question:
while (DXW_HandleMessages()) {
dxw_device->Clear(0,NULL,D3DCLEAR_TARGET,0x00000000,1.0f, 0);
dxw_device->BeginScene();
dxw_device->EndScene();
dxw_device->Present(0,0,0,0);
//Sleep(1);
}
And here's DXW_HandleMessages() :
bool DXW_HandleMessages() {
MSG msg;
while (PeekMessage(&msg,dxw_window,0,0,PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
while (PeekMessage(&msg,0,WM_QUIT,WM_QUIT,PM_REMOVE)) {
if (msg.message == WM_QUIT) return false;
}
}
return true;
}
This is my initialisation code:
memset(¶ms,0,sizeof(params));
params.BackBufferWidth = width;
params.BackBufferHeight = height;
params.BackBufferFormat = format;
params.MultiSampleType = D3DMULTISAMPLE_NONE;
params.MultiSampleQuality = 0;
params.SwapEffect = D3DSWAPEFFECT_DISCARD;
params.hDeviceWindow = window;
params.Windowed = !fullscreen;
params.EnableAutoDepthStencil = false;
params.AutoDepthStencilFormat = D3DFMT_UNKNOWN;
params.Flags = 0;
params.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
params.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
result = dxw_d3d->CreateDevice( D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,
window,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
¶ms,
&dxw_device);
I'm guessing that some of the initialisation parameters I've used this time may be different to the ones I used last time.
Any ideas?
Thanks,
Kris
[Edited by - Kris_A on July 2, 2005 10:54:16 AM]