Sign in to follow this  
musawirali

Window not being painted on creation

Recommended Posts

musawirali    199
Hi Guys, Generally when I write a directx program I call my rendering code in the windows message loop so that its called repeatedly. For the particular application I am working on right now, I need to render only when required ... i.e., when the client area of the window is invalidated. Therefore, I have moved my render code call from the message loop and placed it under the WM_PAINT event. This works as intended, except that it doesn't render at the beginning when the window is created. I get the window with nothing rendered on it. When I resize the window, the rendering appears. Then when I minimize and maximize the window, the rendering is gone until I resize it again. Any ideas what is going on? I have stepped through the code and I see that my rendering code IS called in the beginning, but it just doesn't show anything on the screen until after I have resized.

Share this post


Link to post
Share on other sites
Armadon    1091
The invalidating might only fire for the resizing, you could possibly debug it and check when the render method is called upon if you maximize or minimize.

With regards to your initial problem of the rendering not happening when the window is created, you might have a non-valid handle. Check the debug output.

I hope this helps.
take care.

Share this post


Link to post
Share on other sites
CodeReaver    131
Well in C# you have to you have to call the Invalidate function every time you handle the Paint event. I think that's the same as the WM_PAINT message in C++ and that's also where the frame rendering in C# gets done. So I imagine you'd need a C++ equivilant of Invalidate to queue the next WM_PAINT message or oy won't update. I had a similar problem recently, except it was the non DirectX stuff that wasn't rendering and I had to call Update as well. I don't know if that has a C++ equivilant as well.

EDIT: If I leave out my invalidate call, then it only updated when the window was resized or moved, which sounds like the same problem you're having.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this