00001 #ifndef GL_EXTENSIONS_H_IS_INCLUDED 00002 #define GL_EXTENSIONS_H_IS_INCLUDED 00003 00004 /*! 00005 * \file gl_extensions.H 00006 * \brief To use OpenGL extensions, just include this header. 00007 * 00008 * \sa gl_extensions.C 00009 * 00010 */ 00011 00012 #include "std/support.H" 00013 #include "glew/glew.H" 00014 00015 /*! 00016 * \brief Jot interface for loading OpenGL extensions. 00017 * 00018 * Statically constructed at run-time and initializes 00019 * a set of extensions to GL. The public queries will 00020 * return the availability of the extensions, but 00021 * the calls to extensions must still be placed in 00022 * #ifdef's. e.g. 00023 * 00024 * if (gl_arb_multitexture_suported()) 00025 * { 00026 * #ifdef GL_ARB_multitexture 00027 * do_stuff(); 00028 * #endif 00029 * } 00030 * 00031 * \note The general is_extension_supported() is 00032 * not exposed, since win32 requires that extension 00033 * functions be declared as pointers, and fetched from 00034 * the opengl icd. The baked in extension queries in this 00035 * class indicate if an extension is supported AND that 00036 * the functions are ready to call. 00037 * 00038 */ 00039 class GLExtensions { 00040 private: 00041 /******** STATIC MEMBER VARIABLES ********/ 00042 00043 static bool _gl_arb_multitexture_supported; 00044 static bool _gl_nv_register_combiners_supported; 00045 static bool _gl_nv_vertex_program_supported; 00046 static bool _gl_ext_compiled_vertex_array_supported; 00047 static bool _gl_arb_vertex_program_supported; 00048 static bool _gl_arb_fragment_program_supported; 00049 static bool _gl_ati_fragment_shader_supported; 00050 static bool _gl_nv_fragment_program_option_supported; 00051 static bool _gl_arb_shader_objects_supported; 00052 static bool _gl_arb_vertex_shader_supported; 00053 static bool _gl_arb_fragment_shader_supported; 00054 00055 static bool _init; 00056 00057 static bool _debug; 00058 00059 /******** CONSTRUCTOR/DECONSTRUCTOR *******/ 00060 GLExtensions(); 00061 00062 public: 00063 ~GLExtensions(); 00064 private: 00065 00066 /******** STATIC MEMBER METHODS ********/ 00067 00068 static void internal_init(); 00069 00070 static void init_extensions(); 00071 00072 static bool init_gl_arb_multitexture(); 00073 static bool init_gl_nv_register_combiners(); 00074 static bool init_gl_nv_vertex_program(); 00075 static bool init_gl_ext_compiled_vertex_array(); 00076 static bool init_gl_arb_vertex_program(); 00077 static bool init_gl_arb_fragment_program(); 00078 static bool init_gl_ati_fragment_shader(); 00079 static bool init_gl_nv_fragment_program_option(); 00080 static bool init_gl_arb_shader_objects(); 00081 static bool init_gl_arb_vertex_shader(); 00082 static bool init_gl_arb_fragment_shader(); 00083 00084 static bool is_extension_supported(const char *extension); 00085 00086 public: 00087 static void set_debug(bool d) { _debug = d; } 00088 static bool get_debug() { return _debug; } 00089 00090 static void init() { if (!_init) internal_init(); }; 00091 00092 static bool gl_arb_multitexture_supported() 00093 { init(); return _gl_arb_multitexture_supported; } 00094 static bool gl_nv_register_combiners_supported() 00095 { init(); return _gl_nv_register_combiners_supported; } 00096 static bool gl_nv_vertex_program_supported() 00097 { init(); return _gl_nv_vertex_program_supported; } 00098 static bool gl_ext_compiled_vertex_array_supported() 00099 { init(); return _gl_ext_compiled_vertex_array_supported; } 00100 static bool gl_arb_vertex_program_supported() 00101 { init(); return _gl_arb_vertex_program_supported; } 00102 static bool gl_arb_fragment_program_supported() 00103 { init(); return _gl_arb_fragment_program_supported; } 00104 static bool gl_ati_fragment_shader_supported() 00105 { init(); return _gl_ati_fragment_shader_supported; } 00106 static bool gl_nv_fragment_program_option_supported() 00107 { init(); return _gl_nv_fragment_program_option_supported; } 00108 static bool gl_arb_shader_objects_supported() 00109 { init(); return _gl_arb_shader_objects_supported; } 00110 static bool gl_arb_vertex_shader_supported() 00111 { init(); return _gl_arb_vertex_shader_supported; } 00112 static bool gl_arb_fragment_shader_supported() 00113 { init(); return _gl_arb_fragment_shader_supported; } 00114 00115 00116 static bool gl_arb_vertex_program_loaded(Cstr_ptr &,bool &, const unsigned char *); 00117 static bool gl_arb_fragment_program_loaded(Cstr_ptr &,bool &, const unsigned char *); 00118 }; 00119 00120 #endif // GL_EXTENSIONS_H_IS_INCLUDED