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 "llplane.h"
00046 #include "llgltypes.h"
00047
00048 #include "llglheaders.h"
00049 #include "glh/glh_linear.h"
00050
00051 extern BOOL gDebugGL;
00052
00053 #define LL_GL_ERRS LL_ERRS("RenderState")
00054
00055 class LLSD;
00056
00057
00058 class LLGLManager
00059 {
00060 public:
00061 LLGLManager();
00062
00063 bool initGL();
00064 void shutdownGL();
00065
00066 void initWGL();
00067
00068 LLString getRawGLString();
00069
00070 BOOL mInited;
00071 BOOL mIsDisabled;
00072
00073
00074 BOOL mHasMultitexture;
00075 S32 mNumTextureUnits;
00076 BOOL mHasMipMapGeneration;
00077 BOOL mHasPalettedTextures;
00078 BOOL mHasCompressedTextures;
00079 BOOL mHasFramebufferObject;
00080
00081
00082 BOOL mHasVertexBufferObject;
00083 BOOL mHasPBuffer;
00084 BOOL mHasShaderObjects;
00085 BOOL mHasVertexShader;
00086 BOOL mHasFragmentShader;
00087 BOOL mHasOcclusionQuery;
00088 BOOL mHasPointParameters;
00089
00090
00091 BOOL mHasAnisotropic;
00092 BOOL mHasARBEnvCombine;
00093 BOOL mHasCubeMap;
00094
00095
00096 BOOL mIsATI;
00097 BOOL mIsNVIDIA;
00098 BOOL mIsIntel;
00099 BOOL mIsGF2or4MX;
00100 BOOL mIsGF3;
00101 BOOL mIsGFFX;
00102 BOOL mATIOffsetVerticalLines;
00103
00104
00105 BOOL mHasRequirements;
00106
00107
00108 BOOL mHasSeparateSpecularColor;
00109
00110 S32 mDriverVersionMajor;
00111 S32 mDriverVersionMinor;
00112 S32 mDriverVersionRelease;
00113 F32 mGLVersion;
00114 LLString mDriverVersionVendorString;
00115
00116 S32 mVRAM;
00117 S32 mGLMaxVertexRange;
00118 S32 mGLMaxIndexRange;
00119
00120 void getPixelFormat();
00121
00122 LLString getGLInfoString();
00123 void printGLInfoString();
00124 void getGLInfo(LLSD& info);
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
00153 # define stop_glerror() assert_glerror()
00154 # define llglassertok() assert_glerror()
00155
00156
00157
00158
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
00246 class LLGLEnableBlending : public LLGLState
00247 {
00248 public:
00249 LLGLEnableBlending(bool enable);
00250 };
00251
00252 class LLGLEnableAlphaReject : public LLGLState
00253 {
00254 public:
00255 LLGLEnableAlphaReject(bool enable);
00256 };
00257
00259 class LLGLEnable : public LLGLState
00260 {
00261 public:
00262 LLGLEnable(LLGLenum state) : LLGLState(state, TRUE) {}
00263 };
00264
00266 class LLGLDisable : public LLGLState
00267 {
00268 public:
00269 LLGLDisable(LLGLenum state) : LLGLState(state, FALSE) {}
00270 };
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284 class LLGLUserClipPlane
00285 {
00286 public:
00287
00288 LLGLUserClipPlane(const LLPlane& plane, const glh::matrix4f& modelview, const glh::matrix4f& projection);
00289 ~LLGLUserClipPlane();
00290
00291 void setPlane(F32 a, F32 b, F32 c, F32 d);
00292
00293 private:
00294 glh::matrix4f mProjection;
00295 glh::matrix4f mModelview;
00296 };
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 class LLGLClampToFarClip
00307 {
00308 public:
00309 LLGLClampToFarClip(glh::matrix4f projection);
00310 ~LLGLClampToFarClip();
00311 };
00312
00313
00314
00315
00316
00317 class LLGLNamePool
00318 {
00319 public:
00320 typedef struct
00321 {
00322 GLuint name;
00323 BOOL used;
00324 } NameEntry;
00325
00326 struct CompareUsed
00327 {
00328 bool operator()(const NameEntry& lhs, const NameEntry& rhs)
00329 {
00330 return lhs.used < rhs.used;
00331 }
00332 };
00333
00334 typedef std::vector<NameEntry> name_list_t;
00335 name_list_t mNameList;
00336
00337 LLGLNamePool();
00338 virtual ~LLGLNamePool();
00339
00340 void upkeep();
00341 void cleanup();
00342
00343 GLuint allocate();
00344 void release(GLuint name);
00345
00346 static void registerPool(LLGLNamePool* pool);
00347 static void upkeepPools();
00348 static void cleanupPools();
00349
00350 protected:
00351 typedef std::vector<LLGLNamePool*> pool_list_t;
00352 static pool_list_t sInstances;
00353
00354 virtual GLuint allocateName() = 0;
00355 virtual void releaseName(GLuint name) = 0;
00356 };
00357
00358 extern LLMatrix4 gGLObliqueProjectionInverse;
00359
00360 #include "llglstates.h"
00361
00362 void init_glstates();
00363 void enable_vertex_weighting(const S32 index);
00364 void disable_vertex_weighting(const S32 index);
00365 void enable_binormals(const S32 index);
00366 void disable_binormals(const S32 index);
00367 void enable_cloth_weights(const S32 index);
00368 void disable_cloth_weights(const S32 index);
00369 void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights);
00370 void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights);
00371 void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals);
00372 void set_palette(U8* palette_data);
00373 void parse_gl_version( S32* major, S32* minor, S32* release, LLString* vendor_specific );
00374
00375 extern BOOL gClothRipple;
00376 extern BOOL gNoRender;
00377 #endif // LL_LLGL_H