Graphics Reference
In-Depth Information
drawing area ( m _ hDC ). This function activates an implicit drawing device
(or render context) for all drawing functions/commands.
Step 2: initialize selected hardware and set the coordinate system pa-
rameters. Here we see that a parameter of the render context is being
initialized to disable state. Once again, we see operations similar to those
from Listing 3.3, where similar scale and translate operations are defining
the same coordinate system as Tutorial 3.1.
Step 3: clear drawing buffer and draw two squares.
The vertices
GL_QUAD.
Readers
are
encouraged
to
read
the
associated with the two squares are specified between the glBegin() and
glEnd() scope. The GL _ QUADS parameter informs the render context to
process the positions specified by the glVertex3d() function as vertices
of quadrilaterals. In this way, appropriate geometry can be drawn into the
hardware buffers.
OpenGL
manual
on
the
glBegin() / glEnd()
func-
tions
and
the
corresponding
format
expected
by
the
GL _ QUAD parameter.
Step 4: present the drawing buffer in the application window. Similar
to Tutorial 3.1, our OpenGL implementation also supports double buffer-
ing. The contents of the internal drawing buffers are only presented to the
application window after all drawing is done.
Notice that in OpenGL programming, all commands/functions are directed to an
implicitly active graphics device, or the render context. For example, we call
the glClear() function to clear the currently active drawing area. This is in
contrast to the D3D approach (Listing 3.3) where functions are associated with
an explicitly referenced graphics device. For example, to clear a D3D draw-
ing area, we have to call the Clear() function referenced by the m _ pD3DDevice
( m _ pD3DDevice Clear() ). Even with this difference, we see that we can ap-
ply the knowledge gained from Tutorial 3.1 to an implementation based on a com-
pletely different API technology. In the next chapter we will discuss the principles
of working with graphics API technologies.
Tutorial 3.3.
Project Name
D3D _ RectangleClass
Tutorials 3.3 and 3.4. Reorganization with Classes
Tutorial 3.4.
Project Name
OGL _ RectangleClass
Goal. Remind ourselves of the importance of building software systems
with well-designed abstraction and a modularized interface.
Approach. Reorganize the source code of Tutorial 3.1 to demonstrate bet-
ter readability and to demonstrate that with a well-organized implementa-
tion, we can identify obvious potentials for expansion.
Search WWH ::




Custom Search