• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
tcige

why should direct2d program delete WNDCLASSEX's hbrBackground statement

6 posts in this topic

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

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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
1

Share this post


Link to post
Share on other sites

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'

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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

0

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  
Followers 0