core/vgui/vgui_texture_hacks.cxx
Go to the documentation of this file.
00001 // This is core/vgui/vgui_texture_hacks.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author fsm
00008 // \brief  See vgui_texture_hacks.h for a description of this file.
00009 
00010 #include "vgui_texture_hacks.h"
00011 
00012 #ifdef fsm_fake_gl_texture_calls
00013 
00014 #include <dlfcn.h>
00015 #include <vcl_cstdio.h>
00016 #include <vcl_cassert.h>
00017 
00018 static bool debug = false;
00019 #define return_GLboolean(x) return x
00020 #define return_void(x) { x; return; }
00021 
00022 // ret: return value type.
00023 // name: name of function to wrap.
00024 // proto: prototype for function.
00025 // args: argument list for function.
00026 #define macro(ret, name, proto, args) \
00027 ret urgh_##name proto \
00028 { \
00029   static void *f = 0; \
00030   if (!f) { \
00031     f = dlsym(RTLD_DEFAULT, #name); \
00032     if (debug) vcl_printf("dlsym(%s) => 0x%08X\n", #name, unsigned(f)); \
00033     if (! f) { \
00034       assert(false); \
00035       return_##ret( ret() ); \
00036     } \
00037   } \
00038   return_##ret( ((ret (*) proto) f) args); \
00039 }
00040 
00041 macro(GLboolean, glAreTexturesResident, (GLsizei a, GLuint const *b, GLboolean *c), (a, b, c));
00042 macro(void,      glBindTexture, (GLenum a, GLuint b), (a, b));
00043 macro(void,      glDeleteTextures, (GLsizei a, GLuint const *b), (a, b));
00044 macro(void,      glGenTextures, (GLsizei a, GLuint *b), (a, b));
00045 macro(GLboolean, glIsTexture, (GLuint a), (a));
00046 macro(void,      glPrioritizeTextures, (GLsizei a, GLuint const *b, GLclampf const *c), (a, b, c));
00047 
00048 #undef macro
00049 
00050 #endif