Graphics Reference
In-Depth Information
Source file. Pseudocode; no
corresponding source file.
class GraphicsSystem {
Functionality demanded by OnCreate() of Listings 4.3 and 4.4.
CreateGraphicsContext(); // Create and Initialize GHC and RC
Functionality demanded by the OnPaint() of Listings 4.1 and 4.2.
// Select and initialize the RC for drawing
BeginDraw();
// Present the drawn results on the GUI drawing area
EndDrawAndShow();
};
GraphicsSystem TheAPI
Listing 4.5. The GraphicsSystem class.
bool OnCreate() {
. // Initialize GUI system
// Create and Initialize GHC and RC
if (! TheAPI .CreateGraphicsContext() )
return false ;
Source file. Pseudocode; no
corresponding source file.
.
return true ;
}
void OnPaint() {
TheAPI .BeginDraw(); // Initialize RC for drawing
m _ LargeSquare.Draw();
// Draw the large square
.
TheAPI .EndDrawAndShow();
// Present the drawn results on the application window
};
Listing 4.6. Pseudocode for OnCreate() and OnPaint() .
The functionality presented in Listing 4.5 is driven entirely by our experience
from working with graphics APIs. The CreateGraphicsContext() function
should create/initialize the GHC and create one instance of RC. The BeginDraw()
and EndDrawAndShow() functions are designed to encapsulate graphics API ini-
tialization and configuration calls. As we can see from the OnPaint() function
in Listing 4.6, in this way, application programmers can focus on specifying the
Search WWH ::




Custom Search