Coder Social home page Coder Social logo

gl3w's Introduction

gl3w: Simple OpenGL core profile loading

Introduction

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

Its main part is a simple gl3w_gen.py Python script that downloads the Khronos supported glcorearb.h header and generates gl3w.h and gl3w.c from it. Those files can then be added and linked (statically or dynamically) into your project.

Requirements

gl3w_gen.py requires Python version 2.7 or newer. It is also compatible with Python 3.x.

Example

Here is a simple example of using gl3w with glut. Note that GL/gl3w.h must be included before any other OpenGL related headers:

#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);
        glutCreateWindow("cookie");

        glutReshapeFunc(reshape);
        glutDisplayFunc(display);
        glutKeyboardFunc(keyboard);
        glutSpecialFunc(special);
        glutMouseFunc(mouse);
        glutMotionFunc(motion);

        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),
               glGetString(GL_SHADING_LANGUAGE_VERSION));

        // ...

        glutMainLoop();
        return 0;
}

API Reference

The gl3w API consists of just 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, non-zero 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.

GL3WglProc gl3wGetProcAddress(const char *proc)

Returns the address of an OpenGL extension function. Generally, you won't need to use it since gl3w loads all functions defined in the OpenGL core profile on initialization. It allows you to load OpenGL extensions outside of the core profile.

Options

The generator script optionally takes the arguments:

--ext to include the GL Extensions in output header.

--root=outputdir to set the location for the output to something else than current working directory.

License

public-domain-mark.png

gl3w is in the public domain. See the file UNLICENSE for more information.

Credits

Slavomir Kaslev <[email protected]>
Initial implementation
Kelvin McDowell
Mac OS X support
Sjors Gielen
Mac OS X support
Travis Gesslein
Patches regarding glcorearb.h
Arthur Tombs
Port to Python 3
Daniel Cousens [https://github.com/dcousens]
Code contributions

Copyright

OpenGL is a registered trademark of SGI.

gl3w's People

Contributors

skaslev avatar tombsar avatar marovira avatar exbibyte avatar stolk avatar dcousens avatar jasinb avatar podsvirov avatar mrautio avatar shadowninja avatar soarqin avatar crackedmind avatar travisgesslein avatar kotauskas avatar cmourglia avatar crosire avatar leopph avatar lzubiaur avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.