25.1. The Windows sandwich

Windows graphics code typically has the form of a ‘sandwich.’ The top slice of bread is some preparation work, the filling is when you draw your graphics, and the bottom slice is cleanup work.

Assume that these variables get values set somewhere in your code.

COLORREF bubblecolor; 
int intcenterx, intcentery, intradius; 

Here’s an example of Windows sandwich code that draws a circle of bubblecolor with pixel intradius around the pixel (intcenterx, intcentery). The code uses two local CBrush variables, where a Windows CBrush is an object that Windows uses for filling in the insides of shapes. Note that one variable is a CBrush object, while the other is a CBrush* pointer.

CBrush cbrush, *pbrush_old; 
  • The preparatory ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.