aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llrender.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/llrender.h129
1 files changed, 106 insertions, 23 deletions
diff --git a/linden/indra/llrender/llrender.h b/linden/indra/llrender/llrender.h
index ef495ed..e949190 100644
--- a/linden/indra/llrender/llrender.h
+++ b/linden/indra/llrender/llrender.h
@@ -9,7 +9,7 @@
9 * 9 *
10 * $LicenseInfo:firstyear=2001&license=viewergpl$ 10 * $LicenseInfo:firstyear=2001&license=viewergpl$
11 * 11 *
12 * Copyright (c) 2001-2008, Linden Research, Inc. 12 * Copyright (c) 2001-2009, Linden Research, Inc.
13 * 13 *
14 * Second Life Viewer Source Code 14 * Second Life Viewer Source Code
15 * The source code in this file ("Source Code") is provided by Linden Lab 15 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -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,41 @@ 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);
98 122
99 void enable(void); 123 // Refreshes renderer state of the texture unit to the cached values
100 void disable(void); 124 // Needed when the render context has changed and invalidated the current state
101 void activate(void); 125 void refreshState(void);
102 126
103 void bindTexture(const LLImageGL* texture); 127 // returns the index of this texture unit
104 void unbindTexture(void); 128 S32 getIndex(void) const { return mIndex; }
129
130 // Sets this tex unit to be the currently active one
131 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
139 // (automatically enables the unit for the LLImageGL's texture type)
140 bool bind(const LLImageGL* texture, bool forceBind = false);
141
142 // Binds a cubemap to this texture unit
143 // (automatically enables the texture unit for cubemaps)
144 bool bind(LLCubeMap* cubeMap);
145
146 // Binds a render target to this texture unit (automatically enables the texture unit for the RT's texture type)
147 bool bind(LLRenderTarget * renderTarget, bool bindDepth = false);
148
149 // Manually binds a texture to the texture unit (automatically enables the tex unit for the given texture type)
150 bool bindManual(eTextureType type, U32 texture);
151
152 // Unbinds the currently bound texture of the given type (only if there's a texture of the given type currently bound)
153 void unbind(eTextureType type);
154
155 void setTextureAddressMode(eTextureAddressMode mode);
105 156
106 void setTextureBlendType(eTextureBlendType type); 157 void setTextureBlendType(eTextureBlendType type);
107 158
@@ -110,11 +161,14 @@ public:
110 161
111 // NOTE: If *_COLOR enums are passed to src1 or src2, the corresponding *_ALPHA enum will be used instead. 162 // 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) 163 inline void setTextureAlphaBlend(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2 = TBS_PREV_ALPHA)
113 { setTextureCombiner(op, src1, src2, true); } 164 { setTextureCombiner(op, src1, src2, true); }
114 165
115private: 166 static U32 getInternalType(eTextureType type);
116 U32 mIndex; 167
117 bool mIsEnabled; 168protected:
169 S32 mIndex;
170 U32 mCurrTexture;
171 eTextureType mCurrTexType;
118 eTextureBlendType mCurrBlendType; 172 eTextureBlendType mCurrBlendType;
119 eTextureBlendOp mCurrColorOp; 173 eTextureBlendOp mCurrColorOp;
120 eTextureBlendSrc mCurrColorSrc1; 174 eTextureBlendSrc mCurrColorSrc1;
@@ -137,6 +191,19 @@ class LLRender
137{ 191{
138 friend class LLTexUnit; 192 friend class LLTexUnit;
139public: 193public:
194
195 typedef enum {
196 TRIANGLES = 0,
197 TRIANGLE_STRIP,
198 TRIANGLE_FAN,
199 POINTS,
200 LINES,
201 LINE_STRIP,
202 QUADS,
203 LINE_LOOP,
204 NUM_MODES
205 } eGeomModes;
206
140 typedef enum 207 typedef enum
141 { 208 {
142 CF_NEVER = 0, 209 CF_NEVER = 0,
@@ -178,6 +245,10 @@ public:
178 ~LLRender(); 245 ~LLRender();
179 void shutdown(); 246 void shutdown();
180 247
248 // Refreshes renderer state to the cached values
249 // Needed when the render context has changed and invalidated the current state
250 void refreshState(void);
251
181 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z); 252 void translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
182 void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z); 253 void scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z);
183 void pushMatrix(); 254 void pushMatrix();
@@ -214,6 +285,12 @@ public:
214 285
215 LLTexUnit* getTexUnit(U32 index); 286 LLTexUnit* getTexUnit(U32 index);
216 287
288 U32 getCurrentTexUnitIndex(void) const { return mCurrTextureUnitIndex; }
289
290 bool verifyTexUnitActive(U32 unitToVerify);
291
292 void debugTexUnits(void);
293
217 struct Vertex 294 struct Vertex
218 { 295 {
219 GLfloat v[3]; 296 GLfloat v[3];
@@ -224,14 +301,20 @@ public:
224public: 301public:
225 302
226private: 303private:
227 U32 mCount; 304 bool mDirty;
228 U32 mMode; 305 U32 mCount;
229 U32 mCurrTextureUnitIndex; 306 U32 mMode;
230 LLPointer<LLVertexBuffer> mBuffer; 307 U32 mCurrTextureUnitIndex;
231 LLStrider<LLVector3> mVerticesp; 308 bool mCurrColorMask[4];
232 LLStrider<LLVector2> mTexcoordsp; 309 eCompareFunc mCurrAlphaFunc;
233 LLStrider<LLColor4U> mColorsp; 310 F32 mCurrAlphaFuncVal;
234 std::vector<LLTexUnit*> mTexUnits; 311
312 LLPointer<LLVertexBuffer> mBuffer;
313 LLStrider<LLVector3> mVerticesp;
314 LLStrider<LLVector2> mTexcoordsp;
315 LLStrider<LLColor4U> mColorsp;
316 std::vector<LLTexUnit*> mTexUnits;
317 LLTexUnit* mDummyTexUnit;
235}; 318};
236 319
237extern F64 gGLModelView[16]; 320extern F64 gGLModelView[16];