// stb_glext.h v0.01 - Sean Barrett - http://nothings.org/stb/stb_glext.h
// requires glext.h; or just concatenate glext.h to the end of this; note
// that if this file incorporates SGI's glext.h, this file follows the
// licensing rules specified. otherwise this file is in the public domain.
//
// Usage:
//
//    1. Make a file called something like "extlist.txt" which contains stuff like:
//         GLE(SHADERSOURCEARB,ShaderSourceARB)
//         GLE(UNIFORM1IARB,Uniform1iARB)   // or GLARB(UNIFORM1I,Uniform1i)
//
//    2. To declare functions (to make a header file), do this:
//         #define STB_GLEXT_DECLARE "extlist.txt"
//         #include "stb_gl.h"
//
//    3. To define functions (implement), do this:
//         #define STB_GLEXT_DEFINE "extlist.txt"
//         #include "stb_gl.h"
//
//       If you've already declare them, you can just do
//         #define  STB_GLEXT_DEFINE  STB_GLEXT_DECLARE
//         #include "stb_gl.h"

#ifndef STB_GLEXT_SKIP

#ifndef GL_GLEXT_VERSION
   // First check if glext.h is concatenated on the end of this file

   #define STB_GLEXT_SKIP
   #include __FILE__
   #undef STB_GLEXT_SKIP

   // now check if it's still undefined; if so, try going for it by name;
   // if this errors, that's fine, since we can't compile without it
   #ifndef GL_GLEXT_VERSION
   #include "glext.h"
   #endif
#endif

#define GLARB(a,b) GLE(a##ARB,b##ARB)
#define GLEXT(a,b) GLE(a##EXT,b##EXT)
#define GLNV(a,b)  GLE(a##NV ,b##NV)
#define GLATI(a,b) GLE(a##ATI,b##ATI)

#if defined(STB_GLEXT_DECLARE) && defined(STB_GLEXT_DEFINE)
#undef STB_GLEXT_DECLRE
#endif

#ifdef STB_GLEXT_DECLARE
   #define GLE(a,b) extern PFNGL##a##PROC gl##b;

   #ifdef __cplusplus
   extern "C" {
   #endif

   #include STB_GLEXT_DECLARE

   #ifdef __cplusplus
   };
   #endif

#else

   #ifndef STB_GLEXT_DEFINE
   #error "You must define one of STB_GLEXT_DECLARE or STB_GLEXT_DEFINE"
   #endif

   #ifdef _WIN32
   #define WIN32_LEAN_AND_MEAN
   #include <windows.h> // wglGetProcAddress
   #endif

   #ifdef GLE
   #undef GLE
   #endif

   #define GLE(a,b)  PFNGL##a##PROC gl##b;
   #include STB_GLEXT_DEFINE

   #undef GLE
   #define GLE(a,b) gl##b = (PFNGL##a##PROC) wglGetProcAddress("gl" #a );

   void stb_glext_init(void)
   {
      #include STB_GLEXT_DEFINE
   }

   #undef GLE

#endif // STB_GLEXT_DECLARE

#endif // STB_GLEXT_SKIP






