1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
/**
* @file lldrawpoolsimple.cpp
* @brief LLDrawPoolSimple class implementation
*
* Copyright (c) 2002-$CurrentYear$, Linden Research, Inc.
* $License$
*/
#include "llviewerprecompiledheaders.h"
#include "lldrawpoolsimple.h"
#include "llagent.h"
#include "llagparray.h"
#include "lldrawable.h"
#include "llface.h"
#include "llsky.h"
#include "pipeline.h"
S32 LLDrawPoolSimple::sDiffTex = 0;
LLDrawPoolSimple::LLDrawPoolSimple(LLViewerImage *texturep) :
LLDrawPool(POOL_SIMPLE,
DATA_SIMPLE_IL_MASK | DATA_COLORS_MASK,
DATA_SIMPLE_NIL_MASK), // ady temp
mTexturep(texturep)
{
}
LLDrawPool *LLDrawPoolSimple::instancePool()
{
return new LLDrawPoolSimple(mTexturep);
}
BOOL LLDrawPoolSimple::match(LLFace* last_face, LLFace* facep)
{
if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_CHAIN_FACES) &&
!last_face->isState(LLFace::LIGHT | LLFace::FULLBRIGHT) &&
!facep->isState(LLFace::LIGHT | LLFace::FULLBRIGHT) &&
facep->getIndicesStart() == last_face->getIndicesStart()+last_face->getIndicesCount() &&
facep->getRenderColor() == last_face->getRenderColor())
{
if (facep->isState(LLFace::GLOBAL))
{
if (last_face->isState(LLFace::GLOBAL))
{
return TRUE;
}
}
else
{
if (!last_face->isState(LLFace::GLOBAL))
{
if (last_face->getRenderMatrix() == facep->getRenderMatrix())
{
return TRUE;
}
}
}
}
return FALSE;
}
void LLDrawPoolSimple::prerender()
{
mVertexShaderLevel = gPipeline.getVertexShaderLevel(LLPipeline::SHADER_OBJECT);
}
void LLDrawPoolSimple::beginRenderPass(S32 pass)
{
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
if (gPipeline.getLightingDetail() >= 2)
{
glEnableClientState(GL_COLOR_ARRAY);
}
if (mVertexShaderLevel > 0)
{
S32 scatterTex = gPipeline.mObjectSimpleProgram.enableTexture(LLPipeline::GLSL_SCATTER_MAP);
LLViewerImage::bindTexture(gSky.mVOSkyp->getScatterMap(), scatterTex);
sDiffTex = gPipeline.mObjectSimpleProgram.enableTexture(LLPipeline::GLSL_DIFFUSE_MAP);
}
}
void LLDrawPoolSimple::render(S32 pass)
{
LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE);
if (mDrawFace.empty())
{
return;
}
bindGLVertexPointer();
bindGLTexCoordPointer();
bindGLNormalPointer();
if (gPipeline.getLightingDetail() >= 2)
{
bindGLColorPointer();
}
LLViewerImage* tex = getTexture();
LLGLState alpha_test(GL_ALPHA_TEST, FALSE);
LLGLState blend(GL_BLEND, FALSE);
if (tex)
{
LLViewerImage::bindTexture(tex,sDiffTex);
if (tex->getPrimaryFormat() == GL_ALPHA)
{
// Enable Invisibility Hack
alpha_test.enable();
blend.enable();
}
}
else
{
LLImageGL::unbindTexture(sDiffTex, GL_TEXTURE_2D);
}
drawLoop();
}
void LLDrawPoolSimple::endRenderPass(S32 pass)
{
if (mVertexShaderLevel > 0)
{
gPipeline.mObjectSimpleProgram.disableTexture(LLPipeline::GLSL_SCATTER_MAP);
gPipeline.mObjectSimpleProgram.disableTexture(LLPipeline::GLSL_DIFFUSE_MAP);
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
}
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
if (gPipeline.getLightingDetail() >= 2)
{
glDisableClientState(GL_COLOR_ARRAY);
}
}
void LLDrawPoolSimple::renderForSelect()
{
if (mDrawFace.empty() || !mMemory.count())
{
return;
}
glEnableClientState ( GL_VERTEX_ARRAY );
bindGLVertexPointer();
for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
iter != mDrawFace.end(); iter++)
{
LLFace *facep = *iter;
LLDrawable *drawable = facep->getDrawable();
if (drawable && !drawable->isDead() && (facep->getViewerObject()->mGLName))
{
facep->renderForSelect();
}
}
}
void LLDrawPoolSimple::renderFaceSelected(LLFace *facep,
LLImageGL *image,
const LLColor4 &color,
const S32 index_offset, const S32 index_count)
{
facep->renderSelected(image, color, index_offset, index_count);
}
void LLDrawPoolSimple::dirtyTexture(const LLViewerImage *texturep)
{
if (mTexturep == texturep)
{
for (std::vector<LLFace*>::iterator iter = mReferences.begin();
iter != mReferences.end(); iter++)
{
LLFace *facep = *iter;
gPipeline.markTextured(facep->getDrawable());
}
}
}
LLViewerImage *LLDrawPoolSimple::getTexture()
{
return mTexturep;
}
LLViewerImage *LLDrawPoolSimple::getDebugTexture()
{
return mTexturep;
}
LLColor3 LLDrawPoolSimple::getDebugColor() const
{
return LLColor3(1.f, 1.f, 1.f);
}
S32 LLDrawPoolSimple::getMaterialAttribIndex()
{
return gPipeline.mObjectSimpleProgram.mAttribute[LLPipeline::GLSL_MATERIAL_COLOR];
}
// virtual
void LLDrawPoolSimple::enableShade()
{
glDisableClientState(GL_COLOR_ARRAY);
}
// virtual
void LLDrawPoolSimple::disableShade()
{
glEnableClientState(GL_COLOR_ARRAY);
}
// virtual
void LLDrawPoolSimple::setShade(F32 shade)
{
glColor4f(0,0,0,shade);
}
|