Home

wglGetProcAddress

wglGetProcAddress is a Windows-specific function used in OpenGL to obtain pointers to OpenGL extension functions and newer core functions that may not be exported by the system library. It is provided by opengl32.dll and is commonly used to access functions introduced after OpenGL 1.1 or functions added by graphics drivers as extensions.

The function signature is typically described as PROC wglGetProcAddress(const char* lpszProc); The return value is a

Usage and context requirements: A current OpenGL rendering context must be made current on the calling thread

Limitations and best practices: wglGetProcAddress relies on the driver’s support, so the result should be checked

Example usage: a function pointer is retrieved and cast to the appropriate type, then used if non-NULL.

generic
function
pointer
that
must
be
cast
to
the
appropriate
type,
for
example
PFNGLGENBUFFERSPROC
for
glGenBuffers.
If
the
requested
function
is
not
available
from
the
driver,
the
function
returns
NULL.
before
invoking
wglGetProcAddress.
The
returned
address
may
be
context-specific
and
can
vary
between
contexts
or
driver
reloads,
so
pointers
should
be
queried
per
context
as
needed.
Core
OpenGL
functions
that
are
supported
by
the
installed
context
may
be
returned
as
well,
but
the
common
practice
is
to
query
functions
not
exported
by
opengl32.dll
or
only
available
via
extensions.
for
NULL
before
use.
It
is
not
a
cross-platform
mechanism;
for
portability,
loader
libraries
such
as
GLEW,
GLAD,
or
GL3W
are
often
used
to
encapsulate
the
querying
process.
On
Windows,
opengl32.dll
provides
OpenGL
1.1
functions
directly,
while
newer
or
extension
functions
are
typically
retrieved
through
wglGetProcAddress.