Jump to content
  • Advertisement
Sign in to follow this  
savail

WinApi controls cleared together with screen in DirectX

This topic is 2282 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

Hey,
So I'm not creating a game but a map editor for my game and this is my main message loop:
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);

if(!Render())
{
MessageBox(NULL, "Failed to render", "Error", MB_OK | MB_ICONEXCLAMATION);
break;
}
}

Here is my Render() function:
bool Graphics::Render()
{
HRESULT hr = Input::Obj().d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);
if(FAILED(hr)) return false;

hr = Input::Obj().d3dDevice->Present(NULL, NULL, NULL, NULL);
if(FAILED(hr)) return false;

return true;
}


I have created a scrollbar also on my window and when I'm putting my function Render() to my main message loop as above the scrollbar is being cleared all the time. How to make scrollbar refresh together with clearing a screen?

Share this post


Link to post
Share on other sites
Advertisement
Is the scroll bar parented to the same window that draw to with D3D? If so, it's not going to work. D3D assumes that it owns the entire client area of the window and won't play nice with other controls trying to render to the same client area. You should put your scroll bars beside the D3D window, perhaps parented to same window that the D3D window is parented to.

Also you should change your message loop so that you pump all queued messages before rendering. Otherwise you can end up with messages building up in the queue quicker than you pull them out.

Share this post


Link to post
Share on other sites
hmm so how should the common message loop for normal programs(not games) look? Where rendering should be done? I can't find a good example, every refer to game message loop ;/.
And yea the scrollbar is parented to the same window where D3D draws. I'm not sure if I understood well the matter connected with scrollbar, should I put the scrollbars on another window? Could you explain it wider?

Share this post


Link to post
Share on other sites
For the D3D render area make another control of type STATIC. Then you use the HWND of that static control for the D3D creation. Then the scrollbar is parented to the main window, and the static is also parented to the main window, but D3D won't clear the main window, just the static control.

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!