Skip to content

Commit

Permalink
Update readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
mackron committed Mar 14, 2019
1 parent c95f4e0 commit 67252ea
Showing 1 changed file with 57 additions and 2 deletions.
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,66 @@ platform-specific sections are all contained within the same file.

Usage
=====
glbind is a single file library with no dependencies. There's no need to link to any libraries, nor do you need to
include any other headers. Everything you need is included in `glbind.h`.
```c
#define GLBIND_IMPLEMENTATION
#include "glbind.h"

int main()
{
GLenum result = glbInit(NULL, NULL);
if (result != GL_NO_ERROR) {
printf("Failed to initialize glbind.");
return -1;
}

...

glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);

Examples
========
...

glbUninit();
return 0;
}
```
The example above binds everything to global scope and uses default settings for the internal rendering context. You
can also initialize glbind like the code below.
```
GLBapi gl;
GLBconfig config = glbConfigInit();
config.singleBuffered = GL_TRUE; /* Don't use double-buffering on the internal rendering context. */
GLenum result = glbInit(&gl, &config);
if (result != GL_NO_ERROR) {
... error initializing glbind ...
}
#if defined(GLBIND_WGL)
HGLRC hRC = glbGetRC();
... do something with hRC ...
#endif
#if defined(GLBIND_GLX)
GLXContext rc = glbGetRC();
... do something with rc ...
#endif
/* Draw something using local function pointers in the "gl" object instead of global scope. */
gl.glClearColor(0, 0, 0, 0);
gl.glClear(GL_COLOR_BUFFER_BIT);
```
Since OpenGL requires a rendering context in order to retrieve function pointers, it makes sense to give the client
access to it so they can avoid wasting time and memory creating their own rendering context unnecessarily. Instead,
glbind allows you to configure the internal rendering context and retrieve a handle to it so the application can
make use of it.

You can also initialize a `GLBapi` object against the current context (previously set with wglMakeCurrent or
glXMakeCurrent) using `glbInitContextAPI()` or `glbInitCurrentContextAPI()`. Note, however, that before calling these
functions you must have previously called `glbInit()`. These also do not automatically bind anything to global scope.

You can explicitly bind the function pointers in a `GLBapi` object to global scope by using `glbBindAPI()`.

License
=======
Expand Down

0 comments on commit 67252ea

Please sign in to comment.