aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llrender/llglimmediate.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llrender/llglimmediate.cpp117
1 files changed, 33 insertions, 84 deletions
diff --git a/linden/indra/llrender/llglimmediate.cpp b/linden/indra/llrender/llglimmediate.cpp
index da9239d..edc694a 100644
--- a/linden/indra/llrender/llglimmediate.cpp
+++ b/linden/indra/llrender/llglimmediate.cpp
@@ -36,64 +36,19 @@
36 36
37LLGLImmediate gGL; 37LLGLImmediate gGL;
38 38
39#ifdef LL_RELEASE_FOR_DOWNLOAD
40#define IMM_ERRS llwarns
41#else
42#define IMM_ERRS llerrs
43#endif
44
45bool LLGLImmediate::sClever = false; 39bool LLGLImmediate::sClever = false;
46BOOL LLGLImmediate::sStarted = FALSE; 40
41const U32 immediate_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXCOORD;
47 42
48LLGLImmediate::LLGLImmediate() 43LLGLImmediate::LLGLImmediate()
49{ 44{
50 mCount = 0; 45 mCount = 0;
51 mMode = GL_TRIANGLES; 46 mMode = LLVertexBuffer::TRIANGLES;
52 memset(mBuffer, 0, sizeof(Vertex)*4096); 47 mBuffer = new LLVertexBuffer(immediate_mask, 0);
53} 48 mBuffer->allocateBuffer(4096, 0, TRUE);
54 49 mBuffer->getVertexStrider(mVerticesp);
55void LLGLImmediate::start() 50 mBuffer->getTexCoordStrider(mTexcoordsp);
56{ 51 mBuffer->getColorStrider(mColorsp);
57 if(sClever)
58 {
59 if (sStarted)
60 {
61 llerrs << "Redundant start." << llendl;
62 }
63
64 LLVertexBuffer::unbind();
65 sStarted = TRUE;
66
67 glEnableClientState(GL_VERTEX_ARRAY);
68 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
69 glEnableClientState(GL_COLOR_ARRAY);
70
71 const U32 stride = sizeof(Vertex);
72
73 glVertexPointer(3, GL_FLOAT, stride, &(mBuffer[0].v));
74 glTexCoordPointer(2, GL_FLOAT, stride, &(mBuffer[0].uv));
75 glColorPointer(4, GL_UNSIGNED_BYTE, stride, &(mBuffer[0].c));
76
77 color4f(1,1,1,1);
78 }
79}
80
81void LLGLImmediate::stop()
82{
83 if (sClever)
84 {
85 if (!sStarted)
86 {
87 llerrs << "Redundant stop." << llendl;
88 }
89
90 flush();
91
92 sStarted = FALSE;
93
94 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
95 glDisableClientState(GL_COLOR_ARRAY);
96 }
97} 52}
98 53
99void LLGLImmediate::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z) 54void LLGLImmediate::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z)
@@ -116,10 +71,7 @@ void LLGLImmediate::popMatrix()
116 71
117void LLGLImmediate::blendFunc(GLenum sfactor, GLenum dfactor) 72void LLGLImmediate::blendFunc(GLenum sfactor, GLenum dfactor)
118{ 73{
119 if (sStarted) 74 flush();
120 {
121 flush();
122 }
123 glBlendFunc(sfactor, dfactor); 75 glBlendFunc(sfactor, dfactor);
124} 76}
125 77
@@ -129,10 +81,10 @@ void LLGLImmediate::begin(const GLuint& mode)
129 { 81 {
130 if (mode != mMode) 82 if (mode != mMode)
131 { 83 {
132 if (mMode == GL_QUADS || 84 if (mMode == LLVertexBuffer::QUADS ||
133 mMode == GL_LINES || 85 mMode == LLVertexBuffer::LINES ||
134 mMode == GL_TRIANGLES || 86 mMode == LLVertexBuffer::TRIANGLES ||
135 mMode == GL_POINTS) 87 mMode == LLVertexBuffer::POINTS)
136 { 88 {
137 flush(); 89 flush();
138 } 90 }
@@ -146,7 +98,7 @@ void LLGLImmediate::begin(const GLuint& mode)
146 } 98 }
147 else 99 else
148 { 100 {
149 glBegin(mode); 101 glBegin(LLVertexBuffer::sGLMode[mode]);
150 } 102 }
151} 103}
152 104
@@ -156,13 +108,14 @@ void LLGLImmediate::end()
156 { 108 {
157 if (mCount == 0) 109 if (mCount == 0)
158 { 110 {
159 IMM_ERRS << "GL begin and end called with no vertices specified." << llendl; 111 return;
112 //IMM_ERRS << "GL begin and end called with no vertices specified." << llendl;
160 } 113 }
161 114
162 if ((mMode != GL_QUADS && 115 if ((mMode != LLVertexBuffer::QUADS &&
163 mMode != GL_LINES && 116 mMode != LLVertexBuffer::LINES &&
164 mMode != GL_TRIANGLES && 117 mMode != LLVertexBuffer::TRIANGLES &&
165 mMode != GL_POINTS) || 118 mMode != LLVertexBuffer::POINTS) ||
166 mCount > 2048) 119 mCount > 2048)
167 { 120 {
168 flush(); 121 flush();
@@ -221,12 +174,13 @@ void LLGLImmediate::flush()
221 llerrs << "foo 6" << llendl; 174 llerrs << "foo 6" << llendl;
222 } 175 }
223#endif 176#endif
224 if (!sStarted) 177
225 { 178 mBuffer->setBuffer(immediate_mask);
226 llerrs << "Drawing call issued outside start/stop." << llendl; 179 mBuffer->drawArrays(mMode, 0, mCount);
227 } 180
228 glDrawArrays(mMode, 0, mCount); 181 mVerticesp[0] = mVerticesp[mCount];
229 mBuffer[0] = mBuffer[mCount]; 182 mTexcoordsp[0] = mTexcoordsp[mCount];
183 mColorsp[0] = mColorsp[mCount];
230 mCount = 0; 184 mCount = 0;
231 } 185 }
232 } 186 }
@@ -242,13 +196,13 @@ void LLGLImmediate::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat&
242 return; 196 return;
243 } 197 }
244 198
245 mBuffer[mCount].v[0] = x; 199 mVerticesp[mCount] = LLVector3(x,y,z);
246 mBuffer[mCount].v[1] = y;
247 mBuffer[mCount].v[2] = z;
248 mCount++; 200 mCount++;
249 if (mCount < 4096) 201 if (mCount < 4096)
250 { 202 {
251 mBuffer[mCount] = mBuffer[mCount-1]; 203 mVerticesp[mCount] = mVerticesp[mCount-1];
204 mColorsp[mCount] = mColorsp[mCount-1];
205 mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
252 } 206 }
253 } 207 }
254 else 208 else
@@ -281,8 +235,7 @@ void LLGLImmediate::texCoord2f(const GLfloat& x, const GLfloat& y)
281{ 235{
282 if (sClever) 236 if (sClever)
283 { 237 {
284 mBuffer[mCount].uv[0] = x; 238 mTexcoordsp[mCount] = LLVector2(x,y);
285 mBuffer[mCount].uv[1] = y;
286 } 239 }
287 else 240 else
288 { 241 {
@@ -304,10 +257,7 @@ void LLGLImmediate::color4ub(const GLubyte& r, const GLubyte& g, const GLubyte&
304{ 257{
305 if (sClever) 258 if (sClever)
306 { 259 {
307 mBuffer[mCount].c[0] = r; 260 mColorsp[mCount] = LLColor4U(r,g,b,a);
308 mBuffer[mCount].c[1] = g;
309 mBuffer[mCount].c[2] = b;
310 mBuffer[mCount].c[3] = a;
311 } 261 }
312 else 262 else
313 { 263 {
@@ -345,7 +295,6 @@ void LLGLImmediate::color3fv(const GLfloat* c)
345 295
346void LLGLImmediate::setClever(bool do_clever) 296void LLGLImmediate::setClever(bool do_clever)
347{ 297{
348 llassert(!sStarted);
349 llassert(mCount == 0); 298 llassert(mCount == 0);
350 299
351 sClever = do_clever; 300 sClever = do_clever;