Render() on WM_PAINT crash
Hi!
I'm programming DirectX in C++ under WinXP.
My window is shown and updated, D3D object and device created and initialized.
After that I use the device to clear the window to a blue color and the present.
So far all is well, when run the window plopps up and is blue.
But everytime the window is redrawn it goes white. So I try to fix it like this:
(in the window procedure:)
case WM_PAINT:
Device->Clear
Device->Present
break;
But then I can't even run the program because it "encounterd a problem and must exit". If it works in WinMain, why doesn't it work when redrawing?
Thanks in advance,
/Rayben
Your device is probably null. Your window will receive WM_PAINT messages before Direct3D is set up - for instance the window recieves one while inside the CreateWindow() call, so there's nop way your device could be set up by this point.
You can prevent the window being redrawn as white by specifying NULL for the hbrBackground member of your WNDCLASS when you create the window. Then Windows won't clear the window, leaving you free to draw to it.
Alternatively, try:
You can prevent the window being redrawn as white by specifying NULL for the hbrBackground member of your WNDCLASS when you create the window. Then Windows won't clear the window, leaving you free to draw to it.
Alternatively, try:
case WM_PAINT: if(Device) { Device->Clear Device->Present } break;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement