1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #ifdef _WIN32
#define DECLARE_FUNC(func, f_type) \
static f_type func = NULL; \
static unsigned int func##_is_loaded = 0;
#define LOAD_FUNC(func, f_type) \
func = (f_type) wglGetProcAddress(#func); \
if (func != NULL) func##_is_loaded = 1;
#define IS_FUNC_LOADED(func) \
if (!func##_is_loaded) raise_exception("Unable to load " #func);
// list of all the functions that windows has to load
DECLARE_FUNC(glCreateShader, PFNGLCREATESHADERPROC)
/* etc ... */
void windows_init()
{
// list of the functions that windows has to load:
LOAD_FUNC(glCreateShader, PFNGLCREATESHADERPROC)
/* etc ... */
}
#else
#define IS_FUNC_LOADED(func)
void windows_init() { return; }
#endif
/* utilisation */
IS_FUNC_LOADED(glCreateShader)
GLuint s = glCreateShader(GL_VERTEX_SHADER); |
Partager