diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llrender/llglimmediate.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llrender/llglimmediate.cpp | 264 |
1 files changed, 264 insertions, 0 deletions
diff --git a/linden/indra/llrender/llglimmediate.cpp b/linden/indra/llrender/llglimmediate.cpp index 17c2182..9b60e49 100644 --- a/linden/indra/llrender/llglimmediate.cpp +++ b/linden/indra/llrender/llglimmediate.cpp | |||
@@ -1 +1,265 @@ | |||
1 | <<<<<<< .working | ||
1 | #error This file has been renamed llrender.cpp | 2 | #error This file has been renamed llrender.cpp |
3 | ======= | ||
4 | /** | ||
5 | * @file llglimmediate.cpp | ||
6 | * @brief LLGLImmediate implementation | ||
7 | * | ||
8 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
9 | * | ||
10 | * Copyright (c) 2001-2008, Linden Research, Inc. | ||
11 | * | ||
12 | * Second Life Viewer Source Code | ||
13 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
14 | * to you under the terms of the GNU General Public License, version 2.0 | ||
15 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
16 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
17 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
18 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
19 | * | ||
20 | * There are special exceptions to the terms and conditions of the GPL as | ||
21 | * it is applied to this Source Code. View the full text of the exception | ||
22 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
23 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
24 | * | ||
25 | * By copying, modifying or distributing this software, you acknowledge | ||
26 | * that you have read and understood your obligations described above, | ||
27 | * and agree to abide by those obligations. | ||
28 | * | ||
29 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
30 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
31 | * COMPLETENESS OR PERFORMANCE. | ||
32 | * $/LicenseInfo$ | ||
33 | */ | ||
34 | |||
35 | #include "linden_common.h" | ||
36 | |||
37 | #include "llglimmediate.h" | ||
38 | #include "llvertexbuffer.h" | ||
39 | |||
40 | LLGLImmediate gGL; | ||
41 | |||
42 | const U32 immediate_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXCOORD; | ||
43 | |||
44 | LLGLImmediate::LLGLImmediate() | ||
45 | { | ||
46 | mCount = 0; | ||
47 | mMode = LLVertexBuffer::TRIANGLES; | ||
48 | mBuffer = new LLVertexBuffer(immediate_mask, 0); | ||
49 | mBuffer->allocateBuffer(4096, 0, TRUE); | ||
50 | mBuffer->getVertexStrider(mVerticesp); | ||
51 | mBuffer->getTexCoordStrider(mTexcoordsp); | ||
52 | mBuffer->getColorStrider(mColorsp); | ||
53 | } | ||
54 | |||
55 | void LLGLImmediate::translatef(const GLfloat& x, const GLfloat& y, const GLfloat& z) | ||
56 | { | ||
57 | flush(); | ||
58 | glTranslatef(x,y,z); | ||
59 | } | ||
60 | |||
61 | void LLGLImmediate::scalef(const GLfloat& x, const GLfloat& y, const GLfloat& z) | ||
62 | { | ||
63 | flush(); | ||
64 | glScalef(x,y,z); | ||
65 | } | ||
66 | |||
67 | void LLGLImmediate::pushMatrix() | ||
68 | { | ||
69 | flush(); | ||
70 | glPushMatrix(); | ||
71 | } | ||
72 | |||
73 | void LLGLImmediate::popMatrix() | ||
74 | { | ||
75 | flush(); | ||
76 | glPopMatrix(); | ||
77 | } | ||
78 | |||
79 | void LLGLImmediate::blendFunc(GLenum sfactor, GLenum dfactor) | ||
80 | { | ||
81 | flush(); | ||
82 | glBlendFunc(sfactor, dfactor); | ||
83 | } | ||
84 | |||
85 | void LLGLImmediate::begin(const GLuint& mode) | ||
86 | { | ||
87 | if (mode != mMode) | ||
88 | { | ||
89 | if (mMode == LLVertexBuffer::QUADS || | ||
90 | mMode == LLVertexBuffer::LINES || | ||
91 | mMode == LLVertexBuffer::TRIANGLES || | ||
92 | mMode == LLVertexBuffer::POINTS) | ||
93 | { | ||
94 | flush(); | ||
95 | } | ||
96 | else if (mCount != 0) | ||
97 | { | ||
98 | llerrs << "gGL.begin() called redundantly." << llendl; | ||
99 | } | ||
100 | |||
101 | mMode = mode; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | void LLGLImmediate::end() | ||
106 | { | ||
107 | if (mCount == 0) | ||
108 | { | ||
109 | return; | ||
110 | //IMM_ERRS << "GL begin and end called with no vertices specified." << llendl; | ||
111 | } | ||
112 | |||
113 | if ((mMode != LLVertexBuffer::QUADS && | ||
114 | mMode != LLVertexBuffer::LINES && | ||
115 | mMode != LLVertexBuffer::TRIANGLES && | ||
116 | mMode != LLVertexBuffer::POINTS) || | ||
117 | mCount > 2048) | ||
118 | { | ||
119 | flush(); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | void LLGLImmediate::flush() | ||
124 | { | ||
125 | if (mCount > 0) | ||
126 | { | ||
127 | #if 0 | ||
128 | if (!glIsEnabled(GL_VERTEX_ARRAY)) | ||
129 | { | ||
130 | llerrs << "foo 1" << llendl; | ||
131 | } | ||
132 | |||
133 | if (!glIsEnabled(GL_COLOR_ARRAY)) | ||
134 | { | ||
135 | llerrs << "foo 2" << llendl; | ||
136 | } | ||
137 | |||
138 | if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY)) | ||
139 | { | ||
140 | llerrs << "foo 3" << llendl; | ||
141 | } | ||
142 | |||
143 | if (glIsEnabled(GL_NORMAL_ARRAY)) | ||
144 | { | ||
145 | llerrs << "foo 7" << llendl; | ||
146 | } | ||
147 | |||
148 | GLvoid* pointer; | ||
149 | |||
150 | glGetPointerv(GL_VERTEX_ARRAY_POINTER, &pointer); | ||
151 | if (pointer != &(mBuffer[0].v)) | ||
152 | { | ||
153 | llerrs << "foo 4" << llendl; | ||
154 | } | ||
155 | |||
156 | glGetPointerv(GL_COLOR_ARRAY_POINTER, &pointer); | ||
157 | if (pointer != &(mBuffer[0].c)) | ||
158 | { | ||
159 | llerrs << "foo 5" << llendl; | ||
160 | } | ||
161 | |||
162 | glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &pointer); | ||
163 | if (pointer != &(mBuffer[0].uv)) | ||
164 | { | ||
165 | llerrs << "foo 6" << llendl; | ||
166 | } | ||
167 | #endif | ||
168 | |||
169 | mBuffer->setBuffer(immediate_mask); | ||
170 | mBuffer->drawArrays(mMode, 0, mCount); | ||
171 | |||
172 | mVerticesp[0] = mVerticesp[mCount]; | ||
173 | mTexcoordsp[0] = mTexcoordsp[mCount]; | ||
174 | mColorsp[0] = mColorsp[mCount]; | ||
175 | mCount = 0; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | void LLGLImmediate::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z) | ||
180 | { | ||
181 | if (mCount >= 4096) | ||
182 | { | ||
183 | // llwarns << "GL immediate mode overflow. Some geometry not drawn." << llendl; | ||
184 | return; | ||
185 | } | ||
186 | |||
187 | mVerticesp[mCount] = LLVector3(x,y,z); | ||
188 | mCount++; | ||
189 | if (mCount < 4096) | ||
190 | { | ||
191 | mVerticesp[mCount] = mVerticesp[mCount-1]; | ||
192 | mColorsp[mCount] = mColorsp[mCount-1]; | ||
193 | mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; | ||
194 | } | ||
195 | } | ||
196 | |||
197 | void LLGLImmediate::vertex2i(const GLint& x, const GLint& y) | ||
198 | { | ||
199 | vertex3f((GLfloat) x, (GLfloat) y, 0); | ||
200 | } | ||
201 | |||
202 | void LLGLImmediate::vertex2f(const GLfloat& x, const GLfloat& y) | ||
203 | { | ||
204 | vertex3f(x,y,0); | ||
205 | } | ||
206 | |||
207 | void LLGLImmediate::vertex2fv(const GLfloat* v) | ||
208 | { | ||
209 | vertex3f(v[0], v[1], 0); | ||
210 | } | ||
211 | |||
212 | void LLGLImmediate::vertex3fv(const GLfloat* v) | ||
213 | { | ||
214 | vertex3f(v[0], v[1], v[2]); | ||
215 | } | ||
216 | |||
217 | void LLGLImmediate::texCoord2f(const GLfloat& x, const GLfloat& y) | ||
218 | { | ||
219 | mTexcoordsp[mCount] = LLVector2(x,y); | ||
220 | } | ||
221 | |||
222 | void LLGLImmediate::texCoord2i(const GLint& x, const GLint& y) | ||
223 | { | ||
224 | texCoord2f((GLfloat) x, (GLfloat) y); | ||
225 | } | ||
226 | |||
227 | void LLGLImmediate::texCoord2fv(const GLfloat* tc) | ||
228 | { | ||
229 | texCoord2f(tc[0], tc[1]); | ||
230 | } | ||
231 | |||
232 | void LLGLImmediate::color4ub(const GLubyte& r, const GLubyte& g, const GLubyte& b, const GLubyte& a) | ||
233 | { | ||
234 | mColorsp[mCount] = LLColor4U(r,g,b,a); | ||
235 | } | ||
236 | |||
237 | void LLGLImmediate::color4ubv(const GLubyte* c) | ||
238 | { | ||
239 | color4ub(c[0], c[1], c[2], c[3]); | ||
240 | } | ||
241 | |||
242 | void LLGLImmediate::color4f(const GLfloat& r, const GLfloat& g, const GLfloat& b, const GLfloat& a) | ||
243 | { | ||
244 | color4ub((GLubyte) (llclamp(r, 0.f, 1.f)*255), | ||
245 | (GLubyte) (llclamp(g, 0.f, 1.f)*255), | ||
246 | (GLubyte) (llclamp(b, 0.f, 1.f)*255), | ||
247 | (GLubyte) (llclamp(a, 0.f, 1.f)*255)); | ||
248 | } | ||
249 | |||
250 | void LLGLImmediate::color4fv(const GLfloat* c) | ||
251 | { | ||
252 | color4f(c[0],c[1],c[2],c[3]); | ||
253 | } | ||
254 | |||
255 | void LLGLImmediate::color3f(const GLfloat& r, const GLfloat& g, const GLfloat& b) | ||
256 | { | ||
257 | color4f(r,g,b,1); | ||
258 | } | ||
259 | |||
260 | void LLGLImmediate::color3fv(const GLfloat* c) | ||
261 | { | ||
262 | color4f(c[0],c[1],c[2],1); | ||
263 | } | ||
264 | |||
265 | >>>>>>> .merge-right.r88690 | ||