lldrawpool.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLDRAWPOOL_H
00033 #define LL_LLDRAWPOOL_H
00034 
00035 #include "v4coloru.h"
00036 #include "v2math.h"
00037 #include "v3math.h"
00038 #include "llvertexbuffer.h"
00039 
00040 class LLFace;
00041 class LLImageGL;
00042 class LLViewerImage;
00043 class LLSpatialGroup;
00044 class LLDrawInfo;
00045 
00046 #define DEFAULT_MAX_VERTICES 65535
00047 
00048 class LLDrawPool
00049 {
00050 public:
00051         static S32 sNumDrawPools;
00052 
00053         enum
00054         {
00055                 // Correspond to LLPipeline render type
00056                 POOL_SKY = 1,
00057                 POOL_STARS,
00058                 POOL_GROUND,
00059                 POOL_TERRAIN,   
00060                 POOL_SIMPLE,
00061                 POOL_BUMP,
00062                 POOL_AVATAR,
00063                 POOL_TREE,
00064                 POOL_GLOW,
00065                 POOL_ALPHA,
00066                 POOL_WATER,
00067                 POOL_ALPHA_POST_WATER,
00068                 NUM_POOL_TYPES,
00069         };
00070         
00071         LLDrawPool(const U32 type);
00072         virtual ~LLDrawPool();
00073 
00074         virtual BOOL isDead() = 0;
00075 
00076         S32 getId() const { return mId; }
00077         U32 getType() const { return mType; }
00078 
00079         virtual LLViewerImage *getDebugTexture();
00080         virtual void beginRenderPass( S32 pass );
00081         virtual void endRenderPass( S32 pass );
00082         virtual S32      getNumPasses() { return 1; }
00083         virtual void render(S32 pass = 0) = 0;
00084         virtual void prerender() = 0;
00085         virtual S32 getMaterialAttribIndex() = 0;
00086         virtual U32 getVertexDataMask() = 0;
00087         virtual BOOL verify() const { return TRUE; }            // Verify that all data in the draw pool is correct!
00088         virtual S32 getVertexShaderLevel() const { return mVertexShaderLevel; }
00089         
00090         static LLDrawPool* createPool(const U32 type, LLViewerImage *tex0 = NULL);
00091         virtual LLDrawPool *instancePool() = 0; // Create an empty new instance of the pool.
00092         virtual LLViewerImage* getTexture() = 0;
00093         virtual BOOL isFacePool() { return FALSE; }
00094         virtual void resetDrawOrders() = 0;
00095 
00096         U32     getTrianglesDrawn() const;
00097         void resetTrianglesDrawn();
00098         void addIndicesDrawn(const U32 indices);
00099 
00100 protected:
00101         S32 mVertexShaderLevel;
00102         S32     mId;
00103         U32 mType;                              // Type of draw pool
00104         S32     mIndicesDrawn;
00105 };
00106 
00107 class LLRenderPass : public LLDrawPool
00108 {
00109 public:
00110         enum
00111         {
00112                 PASS_SIMPLE = NUM_POOL_TYPES,
00113                 PASS_GLOW,
00114                 PASS_FULLBRIGHT,
00115                 PASS_INVISIBLE,
00116                 PASS_SHINY,
00117                 PASS_BUMP,
00118                 PASS_GRASS,
00119                 PASS_ALPHA,
00120                 NUM_RENDER_TYPES,
00121         };
00122 
00123         LLRenderPass(const U32 type);
00124         virtual ~LLRenderPass();
00125         /*virtual*/ LLDrawPool* instancePool();
00126         /*vritual*/ S32 getMaterialAttribIndex() { return -1; }
00127         /*virtual*/ LLViewerImage* getDebugTexture() { return NULL; }
00128         LLViewerImage* getTexture() { return NULL; }
00129         BOOL isDead() { return FALSE; }
00130         void resetDrawOrders() { }
00131 
00132         virtual void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture);
00133         virtual void renderGroup(LLSpatialGroup* group, U32 type, U32 mask, BOOL texture = TRUE);
00134         virtual void renderStatic(U32 type, U32 mask, BOOL texture = TRUE);
00135         virtual void renderActive(U32 type, U32 mask, BOOL texture = TRUE);
00136         virtual void renderInvisible(U32 mask);
00137         virtual void renderTexture(U32 type, U32 mask);
00138 
00139 };
00140 
00141 class LLFacePool : public LLDrawPool
00142 {
00143 public:
00144         typedef std::vector<LLFace*> face_array_t;
00145         
00146         enum
00147         {
00148                 SHADER_LEVEL_SCATTERING = 2
00149         };
00150 
00151 public:
00152         LLFacePool(const U32 type);
00153         virtual ~LLFacePool();
00154         
00155         virtual void renderForSelect() = 0;
00156         BOOL isDead() { return mReferences.empty(); }
00157         virtual void renderFaceSelected(LLFace *facep, LLImageGL *image, const LLColor4 &color,
00158                                                                         const S32 index_offset = 0, const S32 index_count = 0);
00159 
00160         virtual LLViewerImage *getTexture();
00161         virtual void dirtyTextures(const std::set<LLViewerImage*>& textures);
00162 
00163         virtual void enqueue(LLFace *face);
00164         virtual BOOL addFace(LLFace *face);
00165         virtual BOOL removeFace(LLFace *face);
00166 
00167         virtual BOOL verify() const;            // Verify that all data in the draw pool is correct!
00168         
00169         virtual void resetDrawOrders();
00170         void resetAll();
00171 
00172         BOOL moveFace(LLFace *face, LLDrawPool *poolp, BOOL copy_data = FALSE);
00173 
00174         void destroy();
00175 
00176         void buildEdges();
00177 
00178         static S32 drawLoop(face_array_t& face_list);
00179         static S32 drawLoopSetTex(face_array_t& face_list, S32 stage);
00180         void drawLoop();
00181 
00182         void renderVisibility();
00183 
00184         void addFaceReference(LLFace *facep);
00185         void removeFaceReference(LLFace *facep);
00186 
00187         void printDebugInfo() const;
00188         
00189         BOOL isFacePool() { return TRUE; }
00190 
00191         friend class LLFace;
00192         friend class LLPipeline;
00193 public:
00194         face_array_t    mDrawFace;
00195         face_array_t    mMoveFace;
00196         face_array_t    mReferences;
00197 
00198 public:
00199         class LLOverrideFaceColor
00200         {
00201         public:
00202                 LLOverrideFaceColor(LLDrawPool* pool)
00203                         : mOverride(sOverrideFaceColor), mPool(pool)
00204                 {
00205                         sOverrideFaceColor = TRUE;
00206                 }
00207                 LLOverrideFaceColor(LLDrawPool* pool, const LLColor4& color)
00208                         : mOverride(sOverrideFaceColor), mPool(pool)
00209                 {
00210                         sOverrideFaceColor = TRUE;
00211                         setColor(color);
00212                 }
00213                 LLOverrideFaceColor(LLDrawPool* pool, const LLColor4U& color)
00214                         : mOverride(sOverrideFaceColor), mPool(pool)
00215                 {
00216                         sOverrideFaceColor = TRUE;
00217                         setColor(color);
00218                 }
00219                 LLOverrideFaceColor(LLDrawPool* pool, F32 r, F32 g, F32 b, F32 a)
00220                         : mOverride(sOverrideFaceColor), mPool(pool)
00221                 {
00222                         sOverrideFaceColor = TRUE;
00223                         setColor(r, g, b, a);
00224                 }
00225                 ~LLOverrideFaceColor()
00226                 {
00227                         sOverrideFaceColor = mOverride;
00228                 }
00229                 void setColor(const LLColor4& color);
00230                 void setColor(const LLColor4U& color);
00231                 void setColor(F32 r, F32 g, F32 b, F32 a);
00232                 BOOL mOverride;
00233                 LLDrawPool* mPool;
00234                 static BOOL sOverrideFaceColor;
00235         };
00236 };
00237 
00238 #endif //LL_LLDRAWPOOL_H

Generated on Thu Jul 1 06:08:25 2010 for Second Life Viewer by  doxygen 1.4.7