00001 
00032 #ifndef LL_LLGL_H
00033 #define LL_LLGL_H
00034 
00035 
00036 
00037 #include <string>
00038 #include <map>
00039 
00040 #include "llerror.h"
00041 #include "v4color.h"
00042 #include "llstring.h"
00043 #include "stdtypes.h"
00044 #include "v4math.h"
00045 #include "llgltypes.h"
00046 
00047 #define LL_DEBUG_GL 1
00048 
00049 #define LL_GL_ERRS llerrs
00050 
00051 
00052 class LLGLManager
00053 {
00054 public:
00055         LLGLManager();
00056 
00057         bool initGL();
00058         void shutdownGL();
00059 
00060         void initWGL(); 
00061 
00062         LLString getRawGLString(); 
00063 
00064         BOOL mInited;
00065         BOOL mIsDisabled;
00066 
00067         
00068         BOOL mHasMultitexture;
00069         S32      mNumTextureUnits;
00070         BOOL mHasMipMapGeneration;
00071         BOOL mHasPalettedTextures;
00072         BOOL mHasCompressedTextures;
00073         BOOL mHasFramebufferObject;
00074 
00075         
00076         BOOL mHasVertexBufferObject;
00077         BOOL mHasPBuffer;
00078         BOOL mHasShaderObjects;
00079         BOOL mHasVertexShader;
00080         BOOL mHasFragmentShader;
00081         BOOL mHasOcclusionQuery;
00082         BOOL mHasPointParameters;
00083 
00084         
00085         BOOL mHasAnisotropic;
00086         BOOL mHasARBEnvCombine;
00087         BOOL mHasCubeMap;
00088 
00089         
00090         BOOL mIsATI;
00091         BOOL mIsNVIDIA;
00092         BOOL mIsIntel;
00093         BOOL mIsGF2or4MX;
00094         BOOL mIsGF3;
00095         BOOL mIsGFFX;
00096         BOOL mATIOffsetVerticalLines;
00097 
00098 #if LL_WINDOWS
00099         BOOL mHasWGLARBPixelFormat;
00100 #endif // LL_WINDOWS
00101 
00102 #if LL_DARWIN
00103         
00104         BOOL mHasAPPLEVertexArrayRange;
00105         BOOL mHasAPPLEFence;
00106         BOOL mHasAPPLEVAO;
00107 #endif
00108 
00109         
00110         BOOL mHasSeparateSpecularColor;
00111         
00112         S32 mDriverVersionMajor;
00113         S32 mDriverVersionMinor;
00114         S32 mDriverVersionRelease;
00115         F32 mGLVersion; 
00116         LLString mDriverVersionVendorString;
00117 
00118         S32 mVRAM; 
00119         S32 mGLMaxVertexRange;
00120         S32 mGLMaxIndexRange;
00121         
00122         void getPixelFormat(); 
00123 
00124         LLString getGLInfoString();
00125 
00126         
00127         LLString mGLVendor;
00128         LLString mGLVendorShort;
00129 
00130         
00131         LLString mGLRenderer;
00132 
00133 private:
00134         void initExtensions();
00135         void initGLStates();
00136         void initGLImages();
00137 };
00138 
00139 extern LLGLManager gGLManager;
00140 
00141 class LLQuaternion;
00142 class LLMatrix4;
00143 
00144 void rotate_quat(LLQuaternion& rotation);
00145 
00146 void flush_glerror(); 
00147 
00148 void assert_glerror();
00149 
00150 void clear_glerror();
00151 
00152 #if LL_DEBUG
00153 # define stop_glerror() assert_glerror()
00154 # define llglassertok() assert_glerror()
00155 #else
00156 # define stop_glerror()
00157 # define llglassertok()
00158 #endif
00159 
00160 #define llglassertok_always() assert_glerror()
00161 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 
00209 
00210 
00211 
00212 
00213 
00214 
00215 
00216 
00217 class LLGLState
00218 {
00219 public:
00220         static void initClass();
00221         static void restoreGL();
00222 
00223         static void resetTextureStates();
00224         static void dumpStates();
00225         static void checkStates();
00226         static void checkTextureChannels();
00227         static void checkClientArrays(U32 data_mask = 0x0001);
00228         
00229 protected:
00230         static std::map<LLGLenum, LLGLboolean> sStateMap;
00231         
00232 public:
00233         enum { CURRENT_STATE = -2 };
00234         LLGLState(LLGLenum state, S32 enabled = CURRENT_STATE);
00235         ~LLGLState();
00236         void setEnabled(S32 enabled);
00237         void enable() { setEnabled(TRUE); }
00238         void disable() { setEnabled(FALSE); }
00239 protected:
00240         LLGLenum mState;
00241         BOOL mWasEnabled;
00242         BOOL mIsEnabled;
00243 };
00244 
00245 class LLGLEnable : public LLGLState
00246 {
00247 public:
00248         LLGLEnable(LLGLenum state) : LLGLState(state, TRUE) {}
00249 };
00250 
00251 class LLGLDisable : public LLGLState
00252 {
00253 public:
00254         LLGLDisable(LLGLenum state) : LLGLState(state, FALSE) {}
00255 };
00256 
00257 #include "llglstates.h"
00258 
00259 void init_glstates();
00260 void enable_vertex_weighting(const S32 index);
00261 void disable_vertex_weighting(const S32 index);
00262 void enable_binormals(const S32 index);
00263 void disable_binormals(const S32 index);
00264 void enable_cloth_weights(const S32 index);
00265 void disable_cloth_weights(const S32 index);
00266 void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights);
00267 void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights);
00268 void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals);
00269 void set_palette(U8* palette_data);
00270 void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_specific );
00271 
00272 extern BOOL gClothRipple;
00273 extern BOOL gNoRender;
00274 #endif // LL_LLGL_H