Graphics Reference
In-Depth Information
void CRectangle2D:: Draw() const {
LPDIRECT3DDEVICE9 pDevice = GraphicsSystemD3D::GetSystem().GetActiveDevice();
if (pDevice) {
DeviceVertexFormat v[4];
Source file.
Rectangle2D.cpp file in
the Primitives folders of
the D3D _ GraphicsSystem
project.
.
// set the vertices of the rectangle ...
.
pDevice->DrawPrimitiveUP(D3DPT _ TRIANGLEFAN, 2, (CONST void * )v,
... );
}
}
Listing 4.9. The D3D Rectangle2D class Draw() function.
Tutorial 4.2. The D3D Graphics Library
Tutorial 4.2.
Project Name:
D3D _ SeparateLibrary
Library Support:
D3D _ GraphicsLib
In Tutorial 2.7, we grouped GUI API-specific functions/classes into a separate
software library to organize our source code structure. Here we define another
separate software library to organize graphics API-specific functionality. We col-
lect the files defining the GraphicsSystemD3D , Circle2D ,and Rectangle2D
classes and define the D3D _ GraphicsLibrary . Our main source code project
only contains files that are related to our scene definition.
As we learn more graphics concepts and implement more graphics-specific
classes, our graphics library will continue to grow. In this way, not only do we
learn graphics and use graphics APIs, we also implement our own API. This sep-
aration of source according to functionality simplifies solution development. In
our case, this separation can also help focus our learning when we develop an
isolated part of the code system. For example, as a program developed based
on the D3D _ GraphicsLibrary , when working with Tutorial 4.2 we can concen-
trate on designing the scene with circles and rectangles and not be concerned with
graphics API-specific details.
Tutorial 4.3.
Project Name
OGL _ GraphicsSystem
In every sense, our graphics software library presents an API for our applica-
tion. Interestingly, in this case we are both the API developer and the application
developer. In this manner, we will learn how to use sophisticated APIs, and we
will also gain experience designing our own API.
Tutorial 4.4.
Project Name:
OGL _ SeparateLibrary
Library Support:
OGL _ GraphicsLib
The OpenGL Tutorials
Tutorial 4.3 is an OpenGL version of Tutorial 4.1, and Tutorial 4.4 is an OpenGL
version of Tutorial 4.2.
Because of the similarities, the details of the OpenGL
Search WWH ::




Custom Search