Slavomir Kaslev edited this page Jun 3, 2014 · 4 revisions

gl3w: Simple OpenGL core profile loading


gl3w is the easiest way to get your hands on the functionality offered by OpenGL core profile specification.

It consists of a simple Python script that downloads the Khronos supported glcorearb.h header and generates gl3w.h and gl3w.c from it. The resulting files can then be included and statically linked into your project.


Here is a simple example of using gl3w with glut:

#include <stdio.h>
#include <GL/gl3w.h>
#include <GL/glut.h>

// ...

int main(int argc, char **argv)
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
        glutInitWindowSize(width, height);


        if (gl3wInit()) {
                fprintf(stderr, "failed to initialize OpenGL\n");
                return -1;
        if (!gl3wIsSupported(3, 2)) {
                fprintf(stderr, "OpenGL 3.2 not supported\n");
                return -1;
        printf("OpenGL %s, GLSL %s\n", glGetString(GL_VERSION),

        // ...

        return 0;

API Reference

The gl3w API consist of three functions:

int gl3wInit(void)

Initializes the library. Should be called once after an OpenGL context has been created. Returns 0 when gl3w was initialized successfully, -1 if there was an error.

int gl3wIsSupported(int major, int minor)

Returns 1 when OpenGL core profile version major.minor is available, and 0 otherwise.

void *gl3wGetProcAddress(const char *proc)

Returns the address of an OpenGL extension function. You probably won’t need to use this function since gl3w loads all the functions defined in the OpenGL core profile. It’s only exposed for completeness.


gl3w is in the puclic domain.


2010 Slavomir Kaslev <>

OpenGL is a registered trademark of SGI.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.