Graphics Reference
In-Depth Information
void
CGrfxWindowOGL::OnPaint() {
.
// check to ensure drawing area is defined
Source file.
GrfxWindowOGL.cpp
file in
the
GrfxWindow
folders of the
OGL
_
Rectangles2D
project.
Step 1:
select graphics hardware render buffer.
wglMakeCurrent(pDC->m
_
hDC, m
_
hRenderingContext);
Step 2:
initialize selected hardware and set the coordinate system parameters.
glDisable( GL
_
CULL
_
FACE );
.
glMatrixMode(GL
_
PROJECTION);
glTranslated(-1.0, -1.0, 0.0);
glScaled(2.0/
double
(rect.Width()), 2.0/
double
(rect.Height()), 1.0);
.
Step 3:
clear drawing buffer and draw two squares.
//clear the draw buffer to light gray
glClear( GL
_
COLOR
_
BUFFER
_
BIT );
glBegin(GL
_
QUADS);
glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
// The large Square
glVertex3d(160,122,0);
// The vertices of the large square
glVertex3d( 80,122,0);
.
// The small square
glVertex3d(
...
);
// The vertices of the small square
glEnd();
Step 4:
present the drawing buffer in the application window.
SwapBuffers(pDC->m
_
hDC);
.
Listing 3.4.
CGrfxWndOGL::OnPaint()
(Tutorial 3.2).
Listing 3.4 shows that the
OnPaint()
function is significantly different. However,
even with completely different function names, we can still apply the semantic
structure derived from Tutorial 3.1.
•
Step 1: select graphics hardware render buffer.
The
m
_
hRenderingCon
text
is a graphics device that was created and properly initialized. The
wgl
MakeCurrent()
function associates the graphics device with the OpenGL
Search WWH ::
Custom Search