Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


why should direct2d program delete WNDCLASSEX's hbrBackground statement


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 06 May 2013 - 06:24 AM

i test that if keeping the hbrBackground statement, when the program starts or resets from device lost, that background color will appear clearly

 

delete that statement is easy, but why keeping that statement is okay for the general direct3d program except fullscreen app



Sponsor:

#2 Rattrap   Members   -  Reputation: 1730

Like
0Likes
Like

Posted 06 May 2013 - 07:00 AM

It can be a hair more efficient, since there is nothing to repaint.

 

When this member is NULL, an application must paint its own background whenever it is requested to paint in its client area. To determine whether the background must be painted, an application can either process the WM_ERASEBKGND message or test the fErase member of the PAINTSTRUCT structure filled by the BeginPaint function.



#3 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 06 May 2013 - 07:14 AM

It can be a hair more efficient, since there is nothing to repaint.

 

When this member is NULL, an application must paint its own background whenever it is requested to paint in its client area. To determine whether the background must be painted, an application can either process the WM_ERASEBKGND message or test the fErase member of the PAINTSTRUCT structure filled by the BeginPaint function.

 

 

thanks a lot, i find it's the problem of WM_PAINT

 

but why in almost every example, direct2d always renders in WM_PAINT and direct3d renders when no message processing



#4 Amr0   Members   -  Reputation: 1131

Like
1Likes
Like

Posted 06 May 2013 - 07:15 AM

The background brush of the window class is used by the default message processor to repaint the background in response to WM_ERASEBKGND. If you are doing all your painting in WM_PAINT, or continuously in the render loop, then yes, you will not need a background brush. Note that if you use GetStockObject( BLACK_BRUSH ) to set the brush of the window class, then you won't need to delete the brush, because stock objects are shared between apps.

 

but why in almost every example, direct2d always renders in WM_PAINT and direct3d renders when no message processing

 

Well, it depends on how you want your application to behave, it has nothing to do with the application using D2D or D3D. If you want the application to render continuously, then you do all the rendering in the message loop when there are no messages. This is used when the contents displayed by the application is dynamic and changes frequently. If the contents change only when the user does something to change it (like painting programs for example), then the application will update its display only when needed, and in response to WM_PAINT.


Edited by Amr0, 06 May 2013 - 07:24 AM.


#5 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 06 May 2013 - 08:02 AM

The background brush of the window class is used by the default message processor to repaint the background in response to WM_ERASEBKGND. If you are doing all your painting in WM_PAINT, or continuously in the render loop, then yes, you will not need a background brush. Note that if you use GetStockObject( BLACK_BRUSH ) to set the brush of the window class, then you won't need to delete the brush, because stock objects are shared between apps.

 

thanks a lot

 

is this true, 'if not processing WM_PAINT, then the defalut will not do WM_ERASEBKGND generally, but still do WM_ERASEBKGND for fullscreen app'



#6 Amr0   Members   -  Reputation: 1131

Like
0Likes
Like

Posted 06 May 2013 - 08:14 AM

I have never heard or experienced a difference between regular windows and fullscreen windows in the way that paint messages are processed, if that's what you're asking. Generally the window will receive a WM_ERASEBKGND message and then a WM_PAINT message. In the case of D2D and D3D applications, all painting is done in one step (typically the Render() function), so you should set the window class brush to NULL (or return 1 in response to WM_ERASEBKGND without actually doing anything), and call your Render() function in response to WM_PAINT (but you will need to call BeginPaint() and EndPaint() to tell the OS that the window has been painted). This is of course only if your application does not use continuous rendering. If it uses continuous rendering, then you don't need to bother with these paint messages and just set the class background brush to NULL and do all the rendering in the message loop.



#7 tcige   Members   -  Reputation: 206

Like
0Likes
Like

Posted 06 May 2013 - 08:27 AM

I have never heard or experienced a difference between regular windows and fullscreen windows in the way that paint messages are processed, if that's what you're asking. Generally the window will receive a WM_ERASEBKGND message and then a WM_PAINT message. In the case of D2D and D3D applications, all painting is done in one step (typically the Render() function), so you should set the window class brush to NULL (or return 1 in response to WM_ERASEBKGND without actually doing anything), and call your Render() function in response to WM_PAINT (but you will need to call BeginPaint() and EndPaint() to tell the OS that the window has been painted). This is of course only if your application does not use continuous rendering. If it uses continuous rendering, then you don't need to bother with these paint messages and just set the class background brush to NULL and do all the rendering in the message loop.

 

i mean continuous rendering

 

i discover that for fullscreen app, even not processing WM_PAINT, WM_ERASEBKGND still will be called, and WM_ERASEBKGND will not be called for non-fullscreen app






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS