Skip to content

Instantly share code, notes, and snippets.

@malkia
Created October 3, 2011 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malkia/1259634 to your computer and use it in GitHub Desktop.
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
// maglev -- malkia's GL extension vectors
// For more complete options, look at:
// GL3W, GLEW and GLEE
//
// Dimiter "malkia" Stanev
// malkia@gmail.com
//
// 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
@malkia
Copy link
Author

malkia commented Oct 3, 2011

This version was done so that Cairo Graphics can compile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment