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

Generated on Fri May 16 08:33:17 2008 for SecondLife by  doxygen 1.5.5