Jump to content
  • Advertisement
Sign in to follow this  

Render() on WM_PAINT crash

This topic is 4253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
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:

case WM_PAINT:

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!