igl.h

Go to the documentation of this file.
00001 /*
00002  Copyright (C) 2001-2006, William Joseph.
00003  All Rights Reserved.
00004 
00005  This file is part of GtkRadiant.
00006 
00007  GtkRadiant is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by
00009  the Free Software Foundation; either version 2 of the License, or
00010  (at your option) any later version.
00011 
00012  GtkRadiant is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU General Public License for more details.
00016 
00017  You should have received a copy of the GNU General Public License
00018  along with GtkRadiant; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #if !defined(INCLUDED_IGL_H)
00023 #define INCLUDED_IGL_H
00024 
00025 #include <cstddef>
00026 #include <string.h>
00027 #include "generic/constant.h"
00028 
00029 #ifdef __APPLE__
00030 # include <OpenGL/gl.h>
00031 #else
00032 # include <GL/gl.h>
00033 #endif
00034 
00035 #if defined(WIN32)
00036 #define QGL_DLLEXPORT __stdcall
00037 #include <GL/glext.h>
00038 #else
00039 #define QGL_DLLEXPORT
00040 #endif
00041 
00042 #define glActiveTexture GlobalOpenGL().m_glActiveTexture
00043 #define glClientActiveTexture GlobalOpenGL().m_glClientActiveTexture
00044 
00047 struct OpenGLBinding
00048 {
00049         INTEGER_CONSTANT(Version, 2);
00050         STRING_CONSTANT(Name, "qgl");
00051 
00053         int major_version, minor_version;
00054 
00056         bool contextValid;
00057 
00058         OpenGLBinding () :
00059             contextValid(false)
00060         {
00061         }
00062 
00064         void (*assertNoErrors) ();
00065 
00066         GLuint m_font;
00067         int m_fontHeight;
00068 
00070         void drawString (const std::string string) const
00071         {
00072             glListBase(m_font);
00073             glCallLists(GLsizei(string.length()), GL_UNSIGNED_BYTE, reinterpret_cast<const GLubyte*> (string.c_str()));
00074         }
00075 
00077         void drawChar (char character) const
00078         {
00079             glListBase(m_font);
00080             glCallLists(1, GL_UNSIGNED_BYTE, reinterpret_cast<const GLubyte*> (&character));
00081         }
00082 
00083         void perspective (GLdouble fovy, GLdouble yaspect, GLdouble zNear, GLdouble zFar)
00084         {
00085             GLdouble xmin, xmax, ymin, ymax;
00086 
00087             xmax = zNear * tan(fovy * 3.14159265 / 360.0);
00088             xmin = -xmax;
00089 
00090             ymin = xmin * yaspect;
00091             ymax = xmax * yaspect;
00092 
00093             glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
00094         }
00095 
00096         // GL_ARB_multitexture
00097         void (QGL_DLLEXPORT *m_glActiveTexture) (GLenum texture);
00098         void (QGL_DLLEXPORT *m_glClientActiveTexture) (GLenum texture);
00099 
00100         bool support_ARB_multitexture;
00101         bool ARB_multitexture ()
00102         {
00103             return support_ARB_multitexture;
00104         }
00105 
00106         // ARB_texture_compression
00107         bool support_ARB_texture_compression;
00108         bool ARB_texture_compression ()
00109         {
00110             return support_ARB_texture_compression;
00111         }
00112 
00113         // EXT_texture_compression_s3tc
00114         bool support_EXT_texture_compression_s3tc;
00115         bool EXT_texture_compression_s3tc ()
00116         {
00117             return support_EXT_texture_compression_s3tc;
00118         }
00119 
00120         // GL 1.2
00121         bool support_GL_1_2;
00122         bool GL_1_2 ()
00123         {
00124             return support_GL_1_2;
00125         }
00126 
00127         // GL 1.3
00128         bool support_GL_1_3;
00129         bool GL_1_3 ()
00130         {
00131             return support_GL_1_3;
00132         }
00133 
00134         // GL 1.4
00135         bool support_GL_1_4;
00136         bool GL_1_4 ()
00137         {
00138             return support_GL_1_4;
00139         }
00140 
00141         // GL 1.5
00142         bool support_GL_1_5;
00143         bool GL_1_5 ()
00144         {
00145             return support_GL_1_5;
00146         }
00147 
00148         // GL_ARB_vertex_program
00149         bool support_ARB_vertex_program;
00150         bool ARB_vertex_program ()
00151         {
00152             return support_ARB_vertex_program;
00153         }
00154 
00155         // GL_ARB_fragment_program
00156         bool support_ARB_fragment_program;
00157         bool ARB_fragment_program ()
00158         {
00159             return support_ARB_fragment_program;
00160         }
00161 
00162         // GL_ARB_shader_objects
00163         bool support_ARB_shader_objects;
00164         bool ARB_shader_objects ()
00165         {
00166             return support_ARB_shader_objects;
00167         }
00168 
00169         // GL_ARB_vertex_shader
00170         bool support_ARB_vertex_shader;
00171         bool ARB_vertex_shader ()
00172         {
00173             return support_ARB_vertex_shader;
00174         }
00175 
00176         // ARB_fragment_shader
00177         bool support_ARB_fragment_shader;
00178         bool ARB_fragment_shader ()
00179         {
00180             return support_ARB_fragment_shader;
00181         }
00182 
00183         // ARB_shading_language_100
00184         bool support_ARB_shading_language_100;
00185         bool ARB_shading_language_100 ()
00186         {
00187             return support_ARB_shading_language_100;
00188         }
00189 };
00190 
00191 #include "modulesystem.h"
00192 
00193 template<typename Type>
00194 class GlobalModule;
00195 typedef GlobalModule<OpenGLBinding> GlobalOpenGLModule;
00196 
00197 template<typename Type>
00198 class GlobalModuleRef;
00199 typedef GlobalModuleRef<OpenGLBinding> GlobalOpenGLModuleRef;
00200 
00201 inline OpenGLBinding& GlobalOpenGL ()
00202 {
00203     return GlobalOpenGLModule::getTable();
00204 }
00205 
00206 #endif

Generated by  doxygen 1.6.2