1 registered members (AndrewAMD),
1,643
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
DirectX n00b having CPU usage problem.
#224864
09/01/08 17:41
09/01/08 17:41
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
Hi all. I've been experimenting with DirectX and Win32 quite recently (haven't even started getting into rendering 3D with it yet), and already I have a problem. I can't seem to figure out why, but every time I start my program (it just displays the standard blue background on a 640x480 window), my CPU usage skyrockets to 100%. And, when I close the window, the process doesn't end. I'm guessing the CPU usage thing is a common problem, as I've seen other DirectX programs that do the same thing (not 3DGS, of course, ). EDIT: In case anyone is interested, I'm working from this DirectX Tutorial: DirectXTutorial.com
Last edited by MrCode; 09/01/08 18:33. Reason: Added tutorial link
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
Re: DirectX n00b having CPU usage problem.
[Re: mk_1]
#226056
09/07/08 17:05
09/07/08 17:05
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
Ok, the CPU usage thing seems to have been mostly solved (I added a Sleep(1) and my CPU usage has been halved). As for the handling the close message, I have this code:
LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
break;
}
return DefWindowProc(hwnd,msg,wparam,lparam);
}
I know basic Win32 (I'm up to doing GDI stuff), I'm just new to DirectX. I don't know why my messages aren't being handled correctly. Usually when I'm writing a normal Win32 program, I don't really even need the WM_CLOSE/DestroyWindow() handler. I can just use WM_DESTROY. EDIT: ok, CPU usage thing must have been a strange coincidence, because it's still at 100%. Well, Sleep(10) makes it lower, but I'm afraid that might make the rendering FPS (for when I start doing more with 3D) drop quite a bit.
Last edited by MrCode; 09/07/08 17:16. Reason: CPU usage still problem, and more wait time could be not good
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
|