diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/lldrawpoolsimple.cpp | 234 |
1 files changed, 62 insertions, 172 deletions
diff --git a/linden/indra/newview/lldrawpoolsimple.cpp b/linden/indra/newview/lldrawpoolsimple.cpp index 031c170..ec8929e 100644 --- a/linden/indra/newview/lldrawpoolsimple.cpp +++ b/linden/indra/newview/lldrawpoolsimple.cpp | |||
@@ -30,55 +30,45 @@ | |||
30 | #include "lldrawpoolsimple.h" | 30 | #include "lldrawpoolsimple.h" |
31 | 31 | ||
32 | #include "llagent.h" | 32 | #include "llagent.h" |
33 | #include "llagparray.h" | ||
34 | #include "lldrawable.h" | 33 | #include "lldrawable.h" |
35 | #include "llface.h" | 34 | #include "llface.h" |
36 | #include "llsky.h" | 35 | #include "llsky.h" |
37 | #include "pipeline.h" | 36 | #include "pipeline.h" |
38 | 37 | ||
39 | S32 LLDrawPoolSimple::sDiffTex = 0; | 38 | class LLRenderPassGlow : public LLRenderPass |
40 | |||
41 | LLDrawPoolSimple::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 | { | 39 | { |
47 | } | 40 | public: |
41 | LLRenderPassGlow(): LLRenderPass(LLRenderPass::PASS_GLOW) { } | ||
42 | |||
43 | enum | ||
44 | { | ||
45 | VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX | | ||
46 | LLVertexBuffer::MAP_TEXCOORD | ||
47 | }; | ||
48 | 48 | ||
49 | LLDrawPool *LLDrawPoolSimple::instancePool() | 49 | virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; } |
50 | { | ||
51 | return new LLDrawPoolSimple(mTexturep); | ||
52 | } | ||
53 | 50 | ||
54 | BOOL LLDrawPoolSimple::match(LLFace* last_face, LLFace* facep) | 51 | virtual void prerender() { } |
55 | { | 52 | |
56 | if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_CHAIN_FACES) && | 53 | void render(S32 pass = 0) |
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 | { | 54 | { |
62 | if (facep->isState(LLFace::GLOBAL)) | 55 | LLGLEnable blend(GL_BLEND); |
63 | { | 56 | glBlendFunc(GL_SRC_ALPHA, GL_ONE); |
64 | if (last_face->isState(LLFace::GLOBAL)) | 57 | renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask()); |
65 | { | 58 | renderActive(LLRenderPass::PASS_GLOW, getVertexDataMask()); |
66 | return TRUE; | 59 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
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 | } | 60 | } |
80 | 61 | ||
81 | return FALSE; | 62 | void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture = TRUE) |
63 | { | ||
64 | glColor4ubv(params.mGlowColor.mV); | ||
65 | LLRenderPass::pushBatch(params, mask, texture); | ||
66 | } | ||
67 | }; | ||
68 | |||
69 | LLDrawPoolSimple::LLDrawPoolSimple() : | ||
70 | LLRenderPass(POOL_SIMPLE) | ||
71 | { | ||
82 | } | 72 | } |
83 | 73 | ||
84 | void LLDrawPoolSimple::prerender() | 74 | void LLDrawPoolSimple::prerender() |
@@ -91,156 +81,56 @@ void LLDrawPoolSimple::beginRenderPass(S32 pass) | |||
91 | glEnableClientState(GL_VERTEX_ARRAY); | 81 | glEnableClientState(GL_VERTEX_ARRAY); |
92 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 82 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
93 | glEnableClientState(GL_NORMAL_ARRAY); | 83 | glEnableClientState(GL_NORMAL_ARRAY); |
94 | if (gPipeline.getLightingDetail() >= 2) | 84 | glEnableClientState(GL_COLOR_ARRAY); |
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 | } | 85 | } |
106 | 86 | ||
107 | |||
108 | void LLDrawPoolSimple::render(S32 pass) | 87 | void LLDrawPoolSimple::render(S32 pass) |
109 | { | 88 | { |
110 | LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE); | 89 | LLGLDisable blend(GL_BLEND); |
111 | if (mDrawFace.empty()) | 90 | LLGLDisable alpha_test(GL_ALPHA_TEST); |
112 | { | 91 | |
113 | return; | ||
114 | } | ||
115 | |||
116 | bindGLVertexPointer(); | ||
117 | bindGLTexCoordPointer(); | ||
118 | bindGLNormalPointer(); | ||
119 | if (gPipeline.getLightingDetail() >= 2) | ||
120 | { | 92 | { |
121 | bindGLColorPointer(); | 93 | LLFastTimer t(LLFastTimer::FTM_RENDER_SIMPLE); |
94 | gPipeline.enableLightsDynamic(1.f); | ||
95 | renderTexture(LLRenderPass::PASS_SIMPLE, getVertexDataMask()); | ||
96 | renderActive(LLRenderPass::PASS_SIMPLE, getVertexDataMask()); | ||
122 | } | 97 | } |
123 | 98 | ||
124 | LLViewerImage* tex = getTexture(); | ||
125 | LLGLState alpha_test(GL_ALPHA_TEST, FALSE); | ||
126 | LLGLState blend(GL_BLEND, FALSE); | ||
127 | |||
128 | if (tex) | ||
129 | { | 99 | { |
130 | LLViewerImage::bindTexture(tex,sDiffTex); | 100 | LLFastTimer t(LLFastTimer::FTM_RENDER_GRASS); |
131 | if (tex->getPrimaryFormat() == GL_ALPHA) | 101 | LLGLEnable blend(GL_BLEND); |
132 | { | 102 | LLGLEnable alpha_test(GL_ALPHA_TEST); |
133 | // Enable Invisibility Hack | 103 | glAlphaFunc(GL_GREATER, 0.5f); |
134 | alpha_test.enable(); | 104 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
135 | blend.enable(); | 105 | //render grass |
136 | } | 106 | LLRenderPass::renderTexture(LLRenderPass::PASS_GRASS, getVertexDataMask()); |
107 | glAlphaFunc(GL_GREATER, 0.01f); | ||
137 | } | 108 | } |
138 | else | 109 | |
139 | { | 110 | { |
140 | LLImageGL::unbindTexture(sDiffTex, GL_TEXTURE_2D); | 111 | LLFastTimer t(LLFastTimer::FTM_RENDER_FULLBRIGHT); |
112 | U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD | LLVertexBuffer::MAP_COLOR; | ||
113 | gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); | ||
114 | glDisableClientState(GL_NORMAL_ARRAY); | ||
115 | renderTexture(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask); | ||
116 | renderActive(LLRenderPass::PASS_FULLBRIGHT, fullbright_mask); | ||
141 | } | 117 | } |
142 | 118 | ||
143 | drawLoop(); | ||
144 | } | ||
145 | |||
146 | void 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 | { | 119 | { |
120 | LLFastTimer t(LLFastTimer::FTM_RENDER_GLOW); | ||
160 | glDisableClientState(GL_COLOR_ARRAY); | 121 | glDisableClientState(GL_COLOR_ARRAY); |
122 | LLRenderPassGlow glow; | ||
123 | glow.render(); | ||
161 | } | 124 | } |
162 | } | ||
163 | |||
164 | void 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 | 125 | ||
188 | void 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 | |||
197 | void LLDrawPoolSimple::dirtyTexture(const LLViewerImage *texturep) | ||
198 | { | ||
199 | if (mTexturep == texturep) | ||
200 | { | 126 | { |
201 | for (std::vector<LLFace*>::iterator iter = mReferences.begin(); | 127 | LLFastTimer t(LLFastTimer::FTM_RENDER_INVISIBLE); |
202 | iter != mReferences.end(); iter++) | 128 | U32 invisi_mask = LLVertexBuffer::MAP_VERTEX; |
203 | { | 129 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
204 | LLFace *facep = *iter; | 130 | glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
205 | gPipeline.markTextured(facep->getDrawable()); | 131 | renderInvisible(invisi_mask); |
206 | } | 132 | renderActive(LLRenderPass::PASS_INVISIBLE, invisi_mask); |
133 | glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | ||
207 | } | 134 | } |
208 | } | 135 | } |
209 | 136 | ||
210 | LLViewerImage *LLDrawPoolSimple::getTexture() | ||
211 | { | ||
212 | return mTexturep; | ||
213 | } | ||
214 | |||
215 | LLViewerImage *LLDrawPoolSimple::getDebugTexture() | ||
216 | { | ||
217 | return mTexturep; | ||
218 | } | ||
219 | |||
220 | LLColor3 LLDrawPoolSimple::getDebugColor() const | ||
221 | { | ||
222 | return LLColor3(1.f, 1.f, 1.f); | ||
223 | } | ||
224 | |||
225 | S32 LLDrawPoolSimple::getMaterialAttribIndex() | ||
226 | { | ||
227 | return gPipeline.mObjectSimpleProgram.mAttribute[LLPipeline::GLSL_MATERIAL_COLOR]; | ||
228 | } | ||
229 | |||
230 | // virtual | ||
231 | void LLDrawPoolSimple::enableShade() | ||
232 | { | ||
233 | glDisableClientState(GL_COLOR_ARRAY); | ||
234 | } | ||
235 | |||
236 | // virtual | ||
237 | void LLDrawPoolSimple::disableShade() | ||
238 | { | ||
239 | glEnableClientState(GL_COLOR_ARRAY); | ||
240 | } | ||
241 | |||
242 | // virtual | ||
243 | void LLDrawPoolSimple::setShade(F32 shade) | ||
244 | { | ||
245 | glColor4f(0,0,0,shade); | ||
246 | } | ||