aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawpoolsimple.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lldrawpoolsimple.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/lldrawpoolsimple.cpp')
-rw-r--r--linden/indra/newview/lldrawpoolsimple.cpp246
1 files changed, 246 insertions, 0 deletions
diff --git a/linden/indra/newview/lldrawpoolsimple.cpp b/linden/indra/newview/lldrawpoolsimple.cpp
new file mode 100644
index 0000000..031c170
--- /dev/null
+++ b/linden/indra/newview/lldrawpoolsimple.cpp
@@ -0,0 +1,246 @@
1/**
2 * @file lldrawpoolsimple.cpp
3 * @brief LLDrawPoolSimple class implementation
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "lldrawpoolsimple.h"
31
32#include "llagent.h"
33#include "llagparray.h"
34#include "lldrawable.h"
35#include "llface.h"
36#include "llsky.h"
37#include "pipeline.h"
38
39S32 LLDrawPoolSimple::sDiffTex = 0;
40
41LLDrawPoolSimple::LLDrawPoolSimple(LLViewerImage *texturep) :
42 LLDrawPool(POOL_SIMPLE,
43 DATA_SIMPLE_IL_MASK | DATA_COLORS_MASK,
44 DATA_SIMPLE_NIL_MASK), // ady temp
45 mTexturep(texturep)
46{
47}
48
49LLDrawPool *LLDrawPoolSimple::instancePool()
50{
51 return new LLDrawPoolSimple(mTexturep);
52}
53
54BOOL LLDrawPoolSimple::match(LLFace* last_face, LLFace* facep)
55{
56 if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_CHAIN_FACES) &&
57 !last_face->isState(LLFace::LIGHT | LLFace::FULLBRIGHT) &&
58 !facep->isState(LLFace::LIGHT | LLFace::FULLBRIGHT) &&
59 facep->getIndicesStart() == last_face->getIndicesStart()+last_face->getIndicesCount() &&
60 facep->getRenderColor() == last_face->getRenderColor())
61 {
62 if (facep->isState(LLFace::GLOBAL))
63 {
64 if (last_face->isState(LLFace::GLOBAL))
65 {
66 return TRUE;
67 }
68 }
69 else
70 {
71 if (!last_face->isState(LLFace::GLOBAL))
72 {
73 if (last_face->getRenderMatrix() == facep->getRenderMatrix())
74 {
75 return TRUE;
76 }
77 }
78 }
79 }
80
81 return FALSE;
82}
83
84void LLDrawPoolSimple::prerender()
85{
86 mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_OBJECT);
87}
88
89void LLDrawPoolSimple::beginRenderPass(S32 pass)
90{
91 glEnableClientState(GL_VERTEX_ARRAY);
92 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
93 glEnableClientState(GL_NORMAL_ARRAY);
94 if (gPipeline.getLightingDetail() >= 2)
95 {
96 glEnableClientState(GL_COLOR_ARRAY);
97 }
98
99 if (mVertexShaderLevel > 0)
100 {
101 S32 scatterTex = gPipeline.mObjectSimpleProgram.enableTexture(LLPipeline::GLSL_SCATTER_MAP);
102 LLViewerImage::bindTexture(gSky.mVOSkyp->getScatterMap(), scatterTex);
103 sDiffTex = gPipeline.mObjectSimpleProgram.enableTexture(LLPipeline::GLSL_DIFFUSE_MAP);
104 }
105}
106
107
108void LLDrawPoolSimple::render(S32 pass)
109{
110 LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE);
111 if (mDrawFace.empty())
112 {
113 return;
114 }
115
116 bindGLVertexPointer();
117 bindGLTexCoordPointer();
118 bindGLNormalPointer();
119 if (gPipeline.getLightingDetail() >= 2)
120 {
121 bindGLColorPointer();
122 }
123
124 LLViewerImage* tex = getTexture();
125 LLGLState alpha_test(GL_ALPHA_TEST, FALSE);
126 LLGLState blend(GL_BLEND, FALSE);
127
128 if (tex)
129 {
130 LLViewerImage::bindTexture(tex,sDiffTex);
131 if (tex->getPrimaryFormat() == GL_ALPHA)
132 {
133 // Enable Invisibility Hack
134 alpha_test.enable();
135 blend.enable();
136 }
137 }
138 else
139 {
140 LLImageGL::unbindTexture(sDiffTex, GL_TEXTURE_2D);
141 }
142
143 drawLoop();
144}
145
146void LLDrawPoolSimple::endRenderPass(S32 pass)
147{
148 if (mVertexShaderLevel > 0)
149 {
150 gPipeline.mObjectSimpleProgram.disableTexture(LLPipeline::GLSL_SCATTER_MAP);
151 gPipeline.mObjectSimpleProgram.disableTexture(LLPipeline::GLSL_DIFFUSE_MAP);
152 glActiveTextureARB(GL_TEXTURE0_ARB);
153 glEnable(GL_TEXTURE_2D);
154 }
155
156 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
157 glDisableClientState(GL_NORMAL_ARRAY);
158 if (gPipeline.getLightingDetail() >= 2)
159 {
160 glDisableClientState(GL_COLOR_ARRAY);
161 }
162}
163
164void LLDrawPoolSimple::renderForSelect()
165{
166 if (mDrawFace.empty() || !mMemory.count())
167 {
168 return;
169 }
170
171 glEnableClientState ( GL_VERTEX_ARRAY );
172
173 bindGLVertexPointer();
174
175 for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
176 iter != mDrawFace.end(); iter++)
177 {
178 LLFace *facep = *iter;
179 LLDrawable *drawable = facep->getDrawable();
180 if (drawable && !drawable->isDead() && (facep->getViewerObject()->mGLName))
181 {
182 facep->renderForSelect();
183 }
184 }
185}
186
187
188void LLDrawPoolSimple::renderFaceSelected(LLFace *facep,
189 LLImageGL *image,
190 const LLColor4 &color,
191 const S32 index_offset, const S32 index_count)
192{
193 facep->renderSelected(image, color, index_offset, index_count);
194}
195
196
197void LLDrawPoolSimple::dirtyTexture(const LLViewerImage *texturep)
198{
199 if (mTexturep == texturep)
200 {
201 for (std::vector<LLFace*>::iterator iter = mReferences.begin();
202 iter != mReferences.end(); iter++)
203 {
204 LLFace *facep = *iter;
205 gPipeline.markTextured(facep->getDrawable());
206 }
207 }
208}
209
210LLViewerImage *LLDrawPoolSimple::getTexture()
211{
212 return mTexturep;
213}
214
215LLViewerImage *LLDrawPoolSimple::getDebugTexture()
216{
217 return mTexturep;
218}
219
220LLColor3 LLDrawPoolSimple::getDebugColor() const
221{
222 return LLColor3(1.f, 1.f, 1.f);
223}
224
225S32 LLDrawPoolSimple::getMaterialAttribIndex()
226{
227 return gPipeline.mObjectSimpleProgram.mAttribute[LLPipeline::GLSL_MATERIAL_COLOR];
228}
229
230// virtual
231void LLDrawPoolSimple::enableShade()
232{
233 glDisableClientState(GL_COLOR_ARRAY);
234}
235
236// virtual
237void LLDrawPoolSimple::disableShade()
238{
239 glEnableClientState(GL_COLOR_ARRAY);
240}
241
242// virtual
243void LLDrawPoolSimple::setShade(F32 shade)
244{
245 glColor4f(0,0,0,shade);
246}