Created
October 3, 2011 17:14
-
-
Save malkia/1259634 to your computer and use it in GitHub Desktop.
maglev - malkia's GL extension vectors - a very tiny (and not full) glee/gl3w/glew/etc. replacement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// maglev -- malkia's GL extension vectors | |
// For more complete options, look at: | |
// GL3W, GLEW and GLEE | |
// | |
// Dimiter "malkia" Stanev | |
// [email protected] | |
// | |
// To use it, just compile it like "cl -c maglev.c", and then link the .obj file with your stuff | |
// | |
#define WIN32_LEAN_AND_MEAN 1 | |
#define WIN32_EXTRA_LEAN 1 | |
#include <windows.h> | |
#include <GL/gl.h> | |
#include "GL/glext.h" | |
// WARNING: Not thread safe, could be made using threadlocal | |
// I avoided that, as Windows XP msvcrt.dll runtime does not support them | |
#define BOMBAX(FUNC, NAME, DEF_ARGS, CALL_ARGS) \ | |
__declspec(dllexport) GLAPI void APIENTRY FUNC DEF_ARGS\ | |
{\ | |
typedef void (APIENTRY* MAGL_PROC) DEF_ARGS;\ | |
static MAGL_PROC stored_proc = NULL;\ | |
MAGL_PROC proc = stored_proc;\ | |
\ | |
if( !proc ) {\ | |
proc = (MAGL_PROC) wglGetProcAddress( NAME );\ | |
if( !proc ) return;\ | |
stored_proc = proc;\ | |
}\ | |
\ | |
proc CALL_ARGS ;\ | |
if( glGetError() )\ | |
stored_proc = NULL;\ | |
}\ | |
#define BOMBA0(n) BOMBAX(n,#n,(),()) | |
#define BOMBA1(n,A) BOMBAX(n,#n,(A a),(a)) | |
#define BOMBA2(n,A,B) BOMBAX(n,#n,(A a, B b),(a,b)) | |
#define BOMBA3(n,A,B,C) BOMBAX(n,#n,(A a, B b, C c),(a,b,c)) | |
#define BOMBA4(n,A,B,C,D) BOMBAX(n,#n,(A a, B b, C c, D d),(a,b,c,d)) | |
BOMBA1(glActiveTexture, GLenum) | |
BOMBA4(glBlendFuncSeparate, GLenum, GLenum, GLenum, GLenum) | |
// Add here more functions to extend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This version was done so that Cairo Graphics can compile