aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llrender.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/llrender.h124
1 files changed, 101 insertions, 23 deletions
diff --git a/linden/indra/llrender/llrender.h b/linden/indra/llrender/llrender.h
index 15360a3..8c648f3 100644
--- a/linden/indra/llrender/llrender.h
+++ b/linden/indra/llrender/llrender.h
@@ -37,14 +37,39 @@
37#ifndef LL_LLGLRENDER_H 37#ifndef LL_LLGLRENDER_H
38#define LL_LLGLRENDER_H 38#define LL_LLGLRENDER_H
39 39
40#include "stdtypes.h" 40//#include "linden_common.h"
41#include "llgltypes.h" 41
42#include "v2math.h"
43#include "v3math.h"
44#include "v4coloru.h"
45#include "llstrider.h"
46#include "llmemory.h"
42#include "llglheaders.h" 47#include "llglheaders.h"
43#include "llvertexbuffer.h" 48
49class LLVertexBuffer;
50class LLCubeMap;
51class LLImageGL;
52class LLRenderTarget;
44 53
45class LLTexUnit 54class LLTexUnit
46{ 55{
56 friend class LLRender;
47public: 57public:
58 typedef enum
59 {
60 TT_TEXTURE = 0, // Standard 2D Texture
61 TT_RECT_TEXTURE, // Non power of 2 texture
62 TT_CUBE_MAP, // 6-sided cube map texture
63 TT_NONE // No texture type is currently enabled
64 } eTextureType;
65
66 typedef enum
67 {
68 TAM_WRAP = 0, // Standard 2D Texture
69 TAM_MIRROR, // Non power of 2 texture
70 TAM_CLAMP // No texture type is currently enabled
71 } eTextureAddressMode;
72
48 typedef enum 73 typedef enum
49 { 74 {
50 TB_REPLACE = 0, 75 TB_REPLACE = 0,
@@ -93,15 +118,36 @@ public:
93 TBS_ONE_MINUS_CONST_ALPHA 118 TBS_ONE_MINUS_CONST_ALPHA
94 } eTextureBlendSrc; 119 } eTextureBlendSrc;
95 120
96 LLTexUnit(U32 index); 121 LLTexUnit(S32 index);
97 U32 getIndex(void); 122
123 // Refreshes renderer state of the texture unit to the cached values
124 // Needed when the render context has changed and invalidated the current state
125 void refreshState(void);
126
127 // returns the index of this texture unit
128 S32 getIndex(void) const { return mIndex; }
98 129
99 void enable(void); 130 // Sets this tex unit to be the currently active one
100 void disable(void); 131 void activate(void);
101 void activate(void); 132
133 // Enables this texture unit for the given texture type (automatically disables any previously enabled texture type)
134 void enable(eTextureType type);
135 // Disables the current texture unit
136 void disable(void);
137
138 // Binds the LLImageGL to this texture unit (automatically enables the unit for the LLImageGL's texture type)
139 bool bind(const LLImageGL* texture);
140 // Binds a cubemap to this texture unit (automatically enables the texture unit for cubemaps)
141 bool bind(LLCubeMap* cubeMap);
142 // Binds a render target to this texture unit (automatically enables the texture unit for the RT's texture type)
143 bool bind(LLRenderTarget * renderTarget, bool bindDepth = false);
144 // Manually binds a texture to the texture unit (automatically enables the tex unit for the given texture type)
145 bool bindManual(eTextureType type, U32 texture);
146
147 // Unbinds the currently bound texture of the given type (only if there's a texture of the given type currently bound)
148 void unbind(eTextureType type);
102 149
103 void bindTexture(const LLImageGL* texture); 150 void setTextureAddressMode(eTextureAddressMode mode);
104 void unbindTexture(void);
105 151
106 void setTextureBlendType(eTextureBlendType type); 152 void setTextureBlendType(eTextureBlendType type);
107 153
@@ -110,11 +156,14 @@ public:
110 156
111 // NOTE: If *_COLOR enums are passed to src1 or src2, the corresponding *_ALPHA enum will be used instead. 157 // NOTE: If *_COLOR enums are passed to src1 or src2, the corresponding *_ALPHA enum will be used instead.
112 inline void setTextureAlphaBlend(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2 = TBS_PREV_ALPHA) 158 inline void setTextureAlphaBlend(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2 = TBS_PREV_ALPHA)
113 { setTextureCombiner(op, src1, src2, true); } 159 { setTextureCombiner(op, src1, src2, true); }
114 160
115private: 161 static U32 getInternalType(eTextureType type);
116 U32 mIndex; 162
117 bool mIsEnabled; 163protected:
164 S32 mIndex;
165 U32 mCurrTexture;
166 eTextureType mCurrTexType;
118 eTextureBlendType mCurrBlendType; 167 eTextureBlendType mCurrBlendType;
119 eTextureBlendOp mCurrColorOp; 168 eTextureBlendOp mCurrColorOp;
120 eTextureBlendSrc mCurrColorSrc1; 169 eTextureBlendSrc mCurrColorSrc1;
@@ -137,6 +186,19 @@ class LLRender
137{ 186{
138 friend class LLTexUnit; 187 friend class LLTexUnit;
139public: 188public:
189
190 typedef enum {
191 TRIANGLES = 0,
192 TRIANGLE_STRIP,
193 TRIANGLE_FAN,
194 POINTS,
195 LINES,
196 LINE_STRIP,
197 QUADS,
198 LINE_LOOP,
199 NUM_MODES
200 } eGeomModes;
201
140 typedef enum 202 typedef enum
141 { 203 {
142 CF_NEVER = 0, 204 CF_NEVER = 0,
@@ -178,6 +240,10 @@ public:
178 ~LLRender(); 240 ~LLRender();
179 void shutdown(); 241 void shutdown();
180 242
243 // Refreshes renderer state to the cached values
244 // Needed when the render context has changed and invalidated the current state
245 void refreshState(void);
246
181 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z); 247 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
182 void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z); 248 void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
183 void pushMatrix(); 249 void pushMatrix();
@@ -214,7 +280,13 @@ public:
214 280
215 LLTexUnit* getTexUnit(U32 index); 281 LLTexUnit* getTexUnit(U32 index);
216 282
217 typedef struct Vertex 283 U32 getCurrentTexUnitIndex(void) const { return mCurrTextureUnitIndex; }
284
285 bool verifyTexUnitActive(U32 unitToVerify);
286
287 void debugTexUnits(void);
288
289 struct Vertex
218 { 290 {
219 GLfloat v[3]; 291 GLfloat v[3];
220 GLubyte c[4]; 292 GLubyte c[4];
@@ -224,14 +296,20 @@ public:
224public: 296public:
225 297
226private: 298private:
227 U32 mCount; 299 bool mDirty;
228 U32 mMode; 300 U32 mCount;
229 U32 mCurrTextureUnitIndex; 301 U32 mMode;
230 LLPointer<LLVertexBuffer> mBuffer; 302 U32 mCurrTextureUnitIndex;
231 LLStrider<LLVector3> mVerticesp; 303 bool mCurrColorMask[4];
232 LLStrider<LLVector2> mTexcoordsp; 304 eCompareFunc mCurrAlphaFunc;
233 LLStrider<LLColor4U> mColorsp; 305 F32 mCurrAlphaFuncVal;
234 std::vector<LLTexUnit*> mTexUnits; 306
307 LLPointer<LLVertexBuffer> mBuffer;
308 LLStrider<LLVector3> mVerticesp;
309 LLStrider<LLVector2> mTexcoordsp;
310 LLStrider<LLColor4U> mColorsp;
311 std::vector<LLTexUnit*> mTexUnits;
312 LLTexUnit* mDummyTexUnit;
235}; 313};
236 314
237extern F64 gGLModelView[16]; 315extern F64 gGLModelView[16];