00001 // ogl.h -- by Thatcher Ulrich <tu@tulrich.com> 00002 00003 // This source code has been donated to the Public Domain. Do 00004 // whatever you want with it. 00005 00006 // Some OpenGL helpers; mainly to generically deal with extensions. 00007 00008 #ifndef OGL_H 00009 #define OGL_H 00010 00011 //#include "tu_config.h" 00012 #include "tu_opengl_includes.h" 00013 00014 namespace ogl 00015 { 00016 void open(); 00017 void close(); 00018 00019 // Return true if the specified extension is available. 00020 bool check_extension(const char* extension); 00021 00022 // Return GL_CLAMP, or GL_CLAMP_TO_EDGE_EXT, depending on 00023 // which is available. I pretty much always want the 00024 // GL_CLAMP_TO_EDGE_EXT behavior, but it's not in the OpenGL 00025 // 1.1 standard, so in those cases I must fall back to 00026 // GL_CLAMP. 00027 int get_clamp_mode(); 00028 00029 // For allocating DMA or video memory, for holding vertex arrays. 00030 void* allocate_vertex_memory( int size ); // @@ add a flag for selecting AGP vs. video mem? 00031 void free_vertex_memory( void* buffer ); 00032 00033 // Fences; for synchronizing with the GPU. 00034 void gen_fences(int count, unsigned int* fence_array); 00035 void set_fence(unsigned int fence_id); 00036 void finish_fence(unsigned int fence_id); 00037 00038 // Stream operations; for pushing dynamic vertex data. 00039 void* stream_get_vertex_memory(int size); 00040 void stream_flush_combiners(); // do this after filling your buffer, and before calling glDrawElements() 00041 00042 // Rudimentary multitexture stuff. 00043 void client_active_texture(int stage); 00044 void multi_tex_coord_2f(int stage, float s, float t); 00045 void multi_tex_coord_2fv(int stage, float* st); 00046 } 00047 00048 00049 // Some old gl/gl.h files don't define these, e.g. default Windows includes. 00050 // It shouldn't hurt anything to call glTexEnvf() with these values on a system 00051 // that doesn't implement them. 00052 00053 #ifndef GL_TEXTURE_FILTER_CONTROL_EXT 00054 #define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 00055 #endif 00056 00057 #ifndef GL_TEXTURE_LOD_BIAS_EXT 00058 #define GL_TEXTURE_LOD_BIAS_EXT 0x8501 00059 #endif 00060 00061 00062 #endif // OGL_H 00063 00064 00065 // Local Variables: 00066 // mode: C++ 00067 // indent-tabs-mode: t 00068 // End: