Several ways of drawing by GDI (games do not flash)

Source: Internet
Author: User
1 drawing method:
1.1 When a temporary DC is used, all the interfaces to be painted will be painted to the temporary DC, and then all the posts will be posted back to the original DC, so that no flashes will occur.
1.2 Delete the created GDI object. Otherwise, leakage may occur.
Select the new object to DC. Generally, the old object must be retained, and then the new object is used up, and the old object is elected back to DC.
Generally, you must remember to delete multiple create *** functions ***
Getdc <--> releasedc
In addition, cpaintdc (this) does not need to be deleted, and cpaintdc has been encapsulated.
Beginpaint and endpaint combination

2. Update method:
2.1 Update all plotting items
This method is mainly used on controls (Small Scope). There are not many items to draw. You can use this method.
2.2 partial update of all images
This method is mostly used for convenience, but the CPU usage is relatively higher.
One of my mahjong games adopts this method, and the CPU usage is generally maintained at 5% (5%-10%) [test environment: no graphics card in The Notebook]
2.3 partial drawing local update
This method is the best, Code A little more complicated. If the class is encapsulated well, there is no problem.
My card games and some airplane Games use this type of method. The CPU usage is generally only 1-3% [test environment: no graphics card in The Notebook]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.