Game Development Reference
In-Depth Information
The
sLGLAPI
structure contains pointers to all the OpenGL functions
we use. Read the previous recipe
Unifying the OpenGL 3 core proile and
OpenGL ES 2
for implementation details.
HGLRC CreateContext( sLGLAPI* LGL3, HDC DeviceContext,
int VersionMajor, int VersionMinor )
{
HGLRC RenderContext = 0;
The irst time this function is called, it reaches the
else
block and creates an
OpenGL backwards-compatible context. When you retrieve a valid pointer to the
wglCreateContextAttribsARB()
function, save it in the
sLGLAPI
structure,
and call
CreateContext()
again. This time the irst
if
block takes control:
if ( LGL3->wglCreateContextAttribsARB )
{
const int Attribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, VersionMajor,
WGL_CONTEXT_MINOR_VERSION_ARB, VersionMinor,
WGL_CONTEXT_LAYER_PLANE_ARB, 0,
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
WGL_CONTEXT_PROFILE_MASK_ARB,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0 // zero marks the end of values
};
RenderContext = LGL3->wglCreateContextAttribsARB(
DeviceContext, 0, Attribs );
}
else
{
1.
The
lglCreateContext()
call is just a wrapper for an OS-speciic API call,
wglCreateContext()
in this case:
RenderContext = LGL3->lglCreateContext(
DeviceContext );
}
return RenderContext;
}