Merge lp:~smspillaz/compiz/compiz.feature_1069112 into lp:compiz/0.9.9
- compiz.feature_1069112
- Merge into 0.9.9
Status: | Superseded |
---|---|
Proposed branch: | lp:~smspillaz/compiz/compiz.feature_1069112 |
Merge into: | lp:compiz/0.9.9 |
Diff against target: |
836 lines (+326/-192) 3 files modified
plugins/CMakeLists.txt (+1/-1) plugins/cubeaddon/src/cubeaddon.cpp (+308/-178) plugins/cubeaddon/src/cubeaddon.h (+17/-13) |
To merge this branch: | bzr merge lp:~smspillaz/compiz/compiz.feature_1069112 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Compiz Maintainers | Pending | ||
Review via email: mp+141257@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-12-26.
Commit message
Port cubeaddon plugin to use new OpenGL plugin API.
Since the arrangement of the vertex data assumes quad usage, and GL_QUADS primitives are not available in OpenGL|ES, the option "deform caps" will be nonfunctional in OpenGL|ES builds.
Description of the change
Port cubeaddon plugin to use new OpenGL plugin API.
Since the arrangement of the vertex data assumes quad usage, and GL_QUADS primitives are not available in OpenGL|ES, the option "deform caps" will be nonfunctional in OpenGL|ES builds.
- 3533. By Sam Spilsbury
-
Adjust buildsystem
- 3534. By Sam Spilsbury
-
Install images too
- 3535. By Sam Spilsbury
-
Merge compiz.fix_1095915
- 3536. By Sam Spilsbury
-
Fix build errors with clang / gles
- 3537. By Sam Spilsbury
-
Merge compiz.fix_1095915
- 3538. By Sam Spilsbury
-
Use array instead of vector
- 3539. By Sam Spilsbury
-
Add cubeaddon to compiz-
plugins. install. arm*
Unmerged revisions
Preview Diff
1 | === modified file 'plugins/CMakeLists.txt' |
2 | --- plugins/CMakeLists.txt 2012-07-20 13:28:42 +0000 |
3 | +++ plugins/CMakeLists.txt 2012-12-26 13:01:22 +0000 |
4 | @@ -30,7 +30,7 @@ |
5 | set (COMPIZ_DISABLE_PLUGIN_BICUBIC ON) |
6 | set (COMPIZ_DISABLE_PLUGIN_BLUR ON) |
7 | set (COMPIZ_DISABLE_PLUGIN_COLORFILTER ON) |
8 | -set (COMPIZ_DISABLE_PLUGIN_CUBEADDON ON) |
9 | +#set (COMPIZ_DISABLE_PLUGIN_CUBEADDON ON) |
10 | set (COMPIZ_DISABLE_PLUGIN_GEARS ON) |
11 | set (COMPIZ_DISABLE_PLUGIN_GROUP ON) |
12 | set (COMPIZ_DISABLE_PLUGIN_LOGINOUT ON) |
13 | |
14 | === modified file 'plugins/cubeaddon/src/cubeaddon.cpp' |
15 | --- plugins/cubeaddon/src/cubeaddon.cpp 2012-11-18 00:26:33 +0000 |
16 | +++ plugins/cubeaddon/src/cubeaddon.cpp 2012-12-26 13:01:22 +0000 |
17 | @@ -27,15 +27,7 @@ |
18 | |
19 | COMPIZ_PLUGIN_20090315 (cubeaddon, CubeaddonPluginVTable); |
20 | |
21 | -const unsigned short CUBEADDON_GRID_SIZE = 100; |
22 | -const unsigned short CAP_ELEMENTS = 15; |
23 | -const unsigned int CAP_NVERTEX = (((CAP_ELEMENTS * (CAP_ELEMENTS + 1)) + 2) * 3); |
24 | -const unsigned int CAP_NIDX = (CAP_ELEMENTS * (CAP_ELEMENTS - 1) * 4); |
25 | - |
26 | -const unsigned int CAP_NIMGVERTEX = (((CAP_ELEMENTS + 1) * (CAP_ELEMENTS + 1)) * 5); |
27 | -const unsigned int CAP_NIMGIDX = (CAP_ELEMENTS * CAP_ELEMENTS * 4); |
28 | - |
29 | -const float RAD2I1024 = 162.9746617f; |
30 | +unsigned short COLORMAX = 0xffff; |
31 | |
32 | /* |
33 | * Initiate a CubeCap |
34 | @@ -213,42 +205,62 @@ |
35 | { |
36 | float i; |
37 | |
38 | - glPushMatrix (); |
39 | - |
40 | glEnable (GL_BLEND); |
41 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
42 | - |
43 | - glLoadIdentity (); |
44 | - glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA); |
45 | - |
46 | i = optionGetIntensity () * 2; |
47 | |
48 | - glBegin (GL_QUADS); |
49 | - glColor4f (0.0, 0.0, 0.0, MAX (0.0, 1.0 - i) ); |
50 | - glVertex2f (0.5, 0.0); |
51 | - glVertex2f (-0.5, 0.0); |
52 | - glColor4f (0.0, 0.0, 0.0, MIN (1.0, 1.0 - (i - 1.0) ) ); |
53 | - glVertex2f (-0.5, -0.5); |
54 | - glVertex2f (0.5, -0.5); |
55 | - glEnd (); |
56 | + GLMatrix transform; |
57 | + transform.translate (0.0f, 0.0f, -DEFAULT_Z_CAMERA); |
58 | + |
59 | + GLfloat ground1Vertices[] = |
60 | + { |
61 | + -0.5, -0.5, 0.0, |
62 | + 0.5, -0.5, 0.0, |
63 | + -0.5, 0.0, 0.0, |
64 | + 0.5, 0.0, 0.0 |
65 | + }; |
66 | + |
67 | + unsigned short maxG1Color = MAX (0.0f, 1.0f - i) * 65535; |
68 | + unsigned short minG1Color = MIN (1.0, 1.0 - (i - 1.0)) * 65535; |
69 | + |
70 | + GLushort ground1Colors[] = |
71 | + { |
72 | + 0, 0, 0, maxG1Color, |
73 | + 0, 0, 0, maxG1Color, |
74 | + 0, 0, 0, minG1Color, |
75 | + 0, 0, 0, minG1Color |
76 | + }; |
77 | + |
78 | + GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer (); |
79 | + streamingBuffer->begin (GL_TRIANGLE_STRIP); |
80 | + |
81 | + streamingBuffer->addVertices (4, ground1Vertices); |
82 | + streamingBuffer->addColors (4, ground1Colors); |
83 | + if (streamingBuffer->end ()) |
84 | + streamingBuffer->render (transform); |
85 | |
86 | if (optionGetGroundSize () > 0.0) |
87 | { |
88 | - glBegin (GL_QUADS); |
89 | - glColor4usv (optionGetGroundColor1 () ); |
90 | - glVertex2f (-0.5, -0.5); |
91 | - glVertex2f (0.5, -0.5); |
92 | - glColor4usv (optionGetGroundColor2 () ); |
93 | - glVertex2f (0.5, -0.5 + optionGetGroundSize () ); |
94 | - glVertex2f (-0.5, -0.5 + optionGetGroundSize () ); |
95 | - glEnd (); |
96 | + GLfloat ground2Vertices[] = |
97 | + { |
98 | + -0.5, -0.5, 0.0, |
99 | + 0.5, -0.5, 0.0, |
100 | + -0.5, static_cast <GLfloat> (-0.5 + optionGetGroundSize ()), 0.0, |
101 | + 0.5, static_cast <GLfloat> (-0.5 + optionGetGroundSize ()), 0.0 |
102 | + }; |
103 | + |
104 | + streamingBuffer->begin (GL_TRIANGLE_STRIP); |
105 | + streamingBuffer->addColors (1, optionGetGroundColor1 ()); |
106 | + streamingBuffer->addColors (1, optionGetGroundColor1 ()); |
107 | + streamingBuffer->addColors (1, optionGetGroundColor2 ()); |
108 | + streamingBuffer->addColors (1, optionGetGroundColor2 ()); |
109 | + streamingBuffer->addVertices (4, ground2Vertices); |
110 | + if (streamingBuffer->end ()) |
111 | + streamingBuffer->render (transform); |
112 | } |
113 | |
114 | - glColor4usv (defaultColor); |
115 | - |
116 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
117 | glDisable (GL_BLEND); |
118 | - glPopMatrix (); |
119 | } |
120 | |
121 | bool |
122 | @@ -410,7 +422,6 @@ |
123 | |
124 | opacity = cubeScreen->desktopOpacity () * color[3] / 0xffff; |
125 | |
126 | - glPushMatrix (); |
127 | glEnable (GL_BLEND); |
128 | |
129 | if (top) |
130 | @@ -424,31 +435,29 @@ |
131 | cAspect = optionGetBottomAspect (); |
132 | } |
133 | |
134 | - |
135 | - glDisableClientState (GL_TEXTURE_COORD_ARRAY); |
136 | - |
137 | - if (optionGetDeformation () == DeformationSphere && |
138 | - optionGetDeformCaps ()) |
139 | - glEnableClientState (GL_NORMAL_ARRAY); |
140 | - |
141 | - glVertexPointer (3, GL_FLOAT, 0, mCapFill); |
142 | - |
143 | glEnable(GL_CULL_FACE); |
144 | |
145 | for (l = 0; l < ((cubeScreen->invert () == 1) ? 2 : 1); l++) |
146 | { |
147 | - if (optionGetDeformation () == DeformationSphere && |
148 | - optionGetDeformCaps ()) |
149 | - { |
150 | - glNormalPointer (GL_FLOAT, 0, (l == 0) ? mCapFill : mCapFillNorm); |
151 | - } |
152 | - else |
153 | - glNormal3f (0.0, (l == 0) ? 1.0 : -1.0, 0.0); |
154 | - |
155 | glCullFace(((l == 1) ^ top) ? cullInv : cullNorm); |
156 | |
157 | for (i = 0; i < size; i++) |
158 | { |
159 | + GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer (); |
160 | + |
161 | + streamingBuffer->begin (GL_TRIANGLE_FAN); |
162 | + |
163 | + if (optionGetDeformation () == DeformationSphere && |
164 | + optionGetDeformCaps ()) |
165 | + { |
166 | + streamingBuffer->addNormals (CAP_NVERTEX / 3, (l == 0) ? mCapFill : mCapFillNorm); |
167 | + } |
168 | + else |
169 | + { |
170 | + GLfloat nonDeformNormals[] = { 0.0f, (l == 0) ? 1.0f : -1.0f, 0.0f }; |
171 | + streamingBuffer->addNormals (1, nonDeformNormals); |
172 | + } |
173 | + |
174 | sa = sAttrib; |
175 | sTransform = transform; |
176 | if (cubeScreen->invert () == 1) |
177 | @@ -468,33 +477,77 @@ |
178 | |
179 | gScreen->glApplyTransform (sa, output, &sTransform); |
180 | |
181 | - glLoadMatrixf (sTransform.getMatrix ()); |
182 | - glTranslatef (cubeScreen->outputXOffset (), -cubeScreen->outputYOffset (), 0.0f); |
183 | - glScalef (cubeScreen->outputXScale (), cubeScreen->outputYScale (), 1.0f); |
184 | - |
185 | - glScalef (1.0, cInv, 1.0); |
186 | - |
187 | - glColor4us (color[0] * opacity / 0xffff, |
188 | - color[1] * opacity / 0xffff, |
189 | - color[2] * opacity / 0xffff, |
190 | - opacity); |
191 | - |
192 | - glDrawArrays (GL_TRIANGLE_FAN, 0, CAP_ELEMENTS + 2); |
193 | + GLMatrix cTransform (sTransform); |
194 | + cTransform.translate (cubeScreen->outputXOffset (), -cubeScreen->outputYOffset (), 0.0f); |
195 | + cTransform.scale (cubeScreen->outputXScale (), cubeScreen->outputYScale (), 1.0f); |
196 | + cTransform.scale (1.0, cInv, 1.0); |
197 | + |
198 | + float normalizedOpacity = opacity / static_cast <float> (OPAQUE); |
199 | + float premultColors[] = |
200 | + { |
201 | + (color[0] / OPAQUE) * normalizedOpacity, |
202 | + (color[1] / OPAQUE) * normalizedOpacity, |
203 | + (color[2] / OPAQUE) * normalizedOpacity |
204 | + }; |
205 | + |
206 | + streamingBuffer->color4f (premultColors[0], |
207 | + premultColors[1], |
208 | + premultColors[2], |
209 | + normalizedOpacity); |
210 | + |
211 | + streamingBuffer->addVertices (CAP_ELEMENTS + 2, mCapFill); |
212 | + if (streamingBuffer->end ()) |
213 | + streamingBuffer->render (cTransform); |
214 | + |
215 | if (optionGetDeformation () == DeformationSphere && |
216 | optionGetDeformCaps ()) |
217 | - glDrawElements (GL_QUADS, CAP_NIDX, GL_UNSIGNED_SHORT, |
218 | - mCapFillIdx); |
219 | + { |
220 | +#ifndef USE_GLES |
221 | + streamingBuffer->begin (GL_QUADS); |
222 | + streamingBuffer->color4f (premultColors[0], |
223 | + premultColors[1], |
224 | + premultColors[2], |
225 | + normalizedOpacity); |
226 | + streamingBuffer->addNormals (CAP_NVERTEX / 3, (l == 0) ? mCapFill : mCapFillNorm); |
227 | + |
228 | + GLushort *idx = mCapFillIdx; |
229 | + std::vector <GLfloat> capVertices; |
230 | + |
231 | + capVertices.reserve (CAP_NIDX * 3); |
232 | + |
233 | + for (unsigned int i = 0; i < CAP_NIDX; ++i) |
234 | + { |
235 | + unsigned int vertexIndex = idx[i] * 3; |
236 | + |
237 | + capVertices.push_back (mCapFill[vertexIndex]); |
238 | + capVertices.push_back (mCapFill[vertexIndex + 1]); |
239 | + capVertices.push_back (mCapFill[vertexIndex + 2]); |
240 | + } |
241 | + |
242 | + streamingBuffer->addVertices (CAP_NIDX, &capVertices[0]); |
243 | + |
244 | + if (streamingBuffer->end ()) |
245 | + streamingBuffer->render (cTransform); |
246 | +#endif |
247 | + } |
248 | |
249 | if (cap->mLoaded) |
250 | { |
251 | - float s_gen[4], t_gen[4]; |
252 | + GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer (); |
253 | GLMatrix texMat = cap->mTexMat; |
254 | |
255 | if (cubeScreen->invert () != 1) |
256 | texMat.scale (-1.0, 1.0, 1.0); |
257 | |
258 | - glColor4us (cubeScreen->desktopOpacity (), cubeScreen->desktopOpacity (), |
259 | - cubeScreen->desktopOpacity (), cubeScreen->desktopOpacity ()); |
260 | + streamingBuffer->begin (GL_TRIANGLE_FAN); |
261 | + |
262 | + float normalizedOpacity = cubeScreen->desktopOpacity () / OPAQUE; |
263 | + |
264 | + streamingBuffer->color4f (normalizedOpacity, |
265 | + normalizedOpacity, |
266 | + normalizedOpacity, |
267 | + normalizedOpacity); |
268 | + |
269 | cap->mTexture[0]->enable (GLTexture::Good); |
270 | |
271 | if (cAspect) |
272 | @@ -525,61 +578,124 @@ |
273 | |
274 | texMat.rotate (-(360.0f / size) * i, 0.0, 0.0, 1.0); |
275 | |
276 | - s_gen[0] = texMat[0]; |
277 | - s_gen[1] = texMat[8]; |
278 | - s_gen[2] = texMat[4]; |
279 | - s_gen[3] = texMat[12]; |
280 | - t_gen[0] = texMat[1]; |
281 | - t_gen[1] = texMat[9]; |
282 | - t_gen[2] = texMat[5]; |
283 | - t_gen[3] = texMat[13]; |
284 | - |
285 | - glTexGenfv(GL_T, GL_OBJECT_PLANE, t_gen); |
286 | - glTexGenfv(GL_S, GL_OBJECT_PLANE, s_gen); |
287 | - |
288 | - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); |
289 | - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); |
290 | - |
291 | - glEnable(GL_TEXTURE_GEN_S); |
292 | - glEnable(GL_TEXTURE_GEN_T); |
293 | - |
294 | - glDrawArrays (GL_TRIANGLE_FAN, 0, CAP_ELEMENTS + 2); |
295 | + GLVector sGen (texMat[0], texMat[8], texMat[4], texMat[12]); |
296 | + GLVector tGen (texMat[1], texMat[9], texMat[5], texMat[13]); |
297 | + |
298 | + std::vector <GLfloat> texCoords; |
299 | + |
300 | + /* Generate texCoords for the top section of the |
301 | + * cap */ |
302 | + texCoords.reserve ((CAP_ELEMENTS + 2) * 2); |
303 | + |
304 | + for (unsigned int i = 0; i < CAP_ELEMENTS + 2; i++) |
305 | + { |
306 | + GLVector v (mCapFill[i * 3], |
307 | + mCapFill[i * 3 + 1], |
308 | + mCapFill[i * 3 + 2], |
309 | + 1.0f); |
310 | + float s = v * sGen; |
311 | + float t = v * tGen; |
312 | + |
313 | + texCoords.push_back (s); |
314 | + texCoords.push_back (t); |
315 | + } |
316 | + |
317 | + streamingBuffer->addTexCoords (0, CAP_NVERTEX / 3, &texCoords[0]); |
318 | + streamingBuffer->addVertices (CAP_NVERTEX / 3, mCapFill); |
319 | + streamingBuffer->setMaxVertices (CAP_ELEMENTS + 2); |
320 | + if (streamingBuffer->end ()) |
321 | + streamingBuffer->render (cTransform); |
322 | + |
323 | if (optionGetDeformation () == DeformationSphere && |
324 | optionGetDeformCaps ()) |
325 | - glDrawElements (GL_QUADS, CAP_NIDX, GL_UNSIGNED_SHORT, |
326 | - mCapFillIdx); |
327 | - |
328 | - glDisable(GL_TEXTURE_GEN_S); |
329 | - glDisable(GL_TEXTURE_GEN_T); |
330 | + { |
331 | +#ifndef USE_GLES |
332 | + streamingBuffer->begin (GL_QUADS); |
333 | + streamingBuffer->color4f (normalizedOpacity, |
334 | + normalizedOpacity, |
335 | + normalizedOpacity, |
336 | + normalizedOpacity); |
337 | + streamingBuffer->addNormals (CAP_NVERTEX / 3, (l == 0) ? mCapFill : mCapFillNorm); |
338 | + |
339 | + /* Generate texCoords and vertices for the |
340 | + * curvature around the top section of the cap |
341 | + * |
342 | + * This is a little more inefficient than it should be. |
343 | + * |
344 | + * The previous implementation used glDrawElements with |
345 | + * and IBO to ensure that we didn't send lots of redundant |
346 | + * geometry to the GPU, however GLVertexBuffer doesn't have |
347 | + * any concept of indexed rendering, and instead takes a vertex |
348 | + * buffer with all the geometry. |
349 | + * |
350 | + * FIXME: This code uses GL_QUADS, so its not compatible with |
351 | + * OpenGL|ES at the moment |
352 | + */ |
353 | + GLushort *idx = mCapFillIdx; |
354 | + std::vector <GLfloat> capVertices; |
355 | + |
356 | + /* Clear old texCoords buffer */ |
357 | + texCoords.clear (); |
358 | + |
359 | + /* Reserve enough space */ |
360 | + capVertices.reserve (CAP_NIDX * 3); |
361 | + texCoords.reserve (CAP_NIDX * 2); |
362 | + |
363 | + for (unsigned int i = 0; i < CAP_NIDX; ++i) |
364 | + { |
365 | + unsigned int vertexIndex = idx[i] * 3; |
366 | + |
367 | + GLVector v (mCapFill[vertexIndex], |
368 | + mCapFill[vertexIndex + 1], |
369 | + mCapFill[vertexIndex + 2], |
370 | + 1.0f); |
371 | + |
372 | + capVertices.push_back (v[GLVector::x]); |
373 | + capVertices.push_back (v[GLVector::y]); |
374 | + capVertices.push_back (v[GLVector::z]); |
375 | + |
376 | + /* GL_OBJECT_LINEAR is simulated by doing: |
377 | + * texCoord.s = dot (vec4 (obj, 1.0), sGenPlane) |
378 | + * texCoord.t = dot (vec4 (obj, 1.0), tGenPlane) |
379 | + */ |
380 | + float s = v * sGen; |
381 | + float t = v * tGen; |
382 | + |
383 | + texCoords.push_back (s); |
384 | + texCoords.push_back (t); |
385 | + } |
386 | + |
387 | + streamingBuffer->addVertices (CAP_NIDX, &capVertices[0]); |
388 | + streamingBuffer->addTexCoords (0, CAP_NIDX, &texCoords[0]); |
389 | + |
390 | + if (streamingBuffer->end ()) |
391 | + streamingBuffer->render (cTransform); |
392 | +#endif |
393 | + } |
394 | + |
395 | cap->mTexture[0]->disable (); |
396 | } |
397 | } |
398 | } |
399 | |
400 | - glEnableClientState (GL_TEXTURE_COORD_ARRAY); |
401 | - glDisableClientState (GL_NORMAL_ARRAY); |
402 | glDisable (GL_BLEND); |
403 | - glNormal3f (0.0, -1.0, 0.0); |
404 | |
405 | glCullFace (cullNorm); |
406 | if (!wasCulled) |
407 | glDisable (GL_CULL_FACE); |
408 | - |
409 | - glPopMatrix (); |
410 | - |
411 | - glColor4usv (defaultColor); |
412 | } |
413 | |
414 | void |
415 | CubeaddonScreen::cubePaintTop (const GLScreenPaintAttrib &sAttrib, |
416 | const GLMatrix &transform, |
417 | CompOutput *output, |
418 | - int size) |
419 | + int size, |
420 | + const GLVector &normal) |
421 | { |
422 | if ((!optionGetDrawBottom () && cubeScreen->invert () == -1) || |
423 | (!optionGetDrawTop () && cubeScreen->invert () == 1)) |
424 | { |
425 | - cubeScreen->cubePaintTop (sAttrib, transform, output, size); |
426 | + cubeScreen->cubePaintTop (sAttrib, transform, output, size, normal); |
427 | } |
428 | |
429 | if (!optionGetDrawTop ()) |
430 | @@ -593,12 +709,13 @@ |
431 | CubeaddonScreen::cubePaintBottom (const GLScreenPaintAttrib &sAttrib, |
432 | const GLMatrix &transform, |
433 | CompOutput *output, |
434 | - int size) |
435 | + int size, |
436 | + const GLVector &normal) |
437 | { |
438 | if ((!optionGetDrawBottom () && cubeScreen->invert () == 1) || |
439 | (!optionGetDrawTop () && cubeScreen->invert () == -1)) |
440 | { |
441 | - cubeScreen->cubePaintBottom (sAttrib, transform, output, size); |
442 | + cubeScreen->cubePaintBottom (sAttrib, transform, output, size, normal); |
443 | } |
444 | |
445 | if (!optionGetDrawBottom ()) |
446 | @@ -617,8 +734,8 @@ |
447 | { |
448 | if (caScreen->mDeform > 0.0) |
449 | { |
450 | - GLWindow::Geometry &geometry = gWindow->geometry (); |
451 | - int i, oldVCount = geometry.vCount; |
452 | + GLVertexBuffer *vb = gWindow->vertexBuffer (); |
453 | + int i, oldVCount = vb->countVertices (); |
454 | GLfloat *v; |
455 | int offX = 0, offY = 0; |
456 | int sx1, sx2, sw, sy1, sy2, sh; |
457 | @@ -645,10 +762,12 @@ |
458 | gWindow->glAddGeometry (matrix, region, clip, |
459 | MIN (CUBEADDON_GRID_SIZE, maxGridWidth), |
460 | maxGridHeight); |
461 | + |
462 | + vb = gWindow->vertexBuffer (); |
463 | |
464 | - v = geometry.vertices; |
465 | - v += geometry.vertexStride - 3; |
466 | - v += geometry.vertexStride * oldVCount; |
467 | + v = vb->getVertices (); |
468 | + v += vb->getVertexStride () - 3; |
469 | + v += vb->getVertexStride () * oldVCount; |
470 | |
471 | if (!window->onAllViewports ()) |
472 | { |
473 | @@ -707,7 +826,7 @@ |
474 | { |
475 | float lastX = std::numeric_limits <float>::min (), lastZ = 0.0; |
476 | |
477 | - for (i = oldVCount; i < geometry.vCount; i++) |
478 | + for (i = oldVCount; i < vb->countVertices (); i++) |
479 | { |
480 | if (v[0] == lastX) |
481 | { |
482 | @@ -728,7 +847,7 @@ |
483 | lastX = v[0]; |
484 | lastZ = v[2]; |
485 | |
486 | - v += geometry.vertexStride; |
487 | + v += vb->getVertexStride (); |
488 | } |
489 | } |
490 | else |
491 | @@ -738,20 +857,20 @@ |
492 | last[1][0] = -1000000000.0; |
493 | |
494 | int cLast = 0; |
495 | - for (i = oldVCount; i < geometry.vCount; i++) |
496 | + for (i = oldVCount; i < vb->countVertices (); i++) |
497 | { |
498 | if (last[0][0] == v[0] && last[0][1] == v[1]) |
499 | { |
500 | v[0] = last[0][2]; |
501 | v[2] = last[0][3]; |
502 | - v += geometry.vertexStride; |
503 | + v += vb->getVertexStride (); |
504 | continue; |
505 | } |
506 | else if (last[1][0] == v[0] && last[1][1] == v[1]) |
507 | { |
508 | v[0] = last[1][2]; |
509 | v[2] = last[1][3]; |
510 | - v += geometry.vertexStride; |
511 | + v += vb->getVertexStride (); |
512 | continue; |
513 | } |
514 | |
515 | @@ -777,7 +896,7 @@ |
516 | last[cLast][3] = v[2]; |
517 | cLast = (cLast + 1) & 1; |
518 | } |
519 | - v += geometry.vertexStride; |
520 | + v += vb->getVertexStride (); |
521 | } |
522 | } |
523 | } |
524 | @@ -789,7 +908,7 @@ |
525 | |
526 | bool |
527 | CubeaddonWindow::glDraw (const GLMatrix &transform, |
528 | - GLFragment::Attrib &attrib, |
529 | + GLWindowPaintAttrib &attrib, |
530 | const CompRegion ®ion, |
531 | unsigned int mask) |
532 | { |
533 | @@ -817,7 +936,8 @@ |
534 | |
535 | void |
536 | CubeaddonWindow::glDrawTexture (GLTexture *texture, |
537 | - GLFragment::Attrib& attrib, |
538 | + const GLMatrix &matrix, |
539 | + GLWindowPaintAttrib &attrib, |
540 | unsigned int mask) |
541 | { |
542 | if (caScreen->mDeform > 0.0 && caScreen->gScreen->lighting ()) |
543 | @@ -829,18 +949,20 @@ |
544 | GLfloat *v, *n; |
545 | float inv; |
546 | |
547 | - GLWindow::Geometry &geometry = gWindow->geometry (); |
548 | + GLVertexBuffer *vb = gWindow->vertexBuffer (); |
549 | CubeScreen::MultioutputMode cMOM = cubeScreen->multioutputMode (); |
550 | float cDist = cubeScreen->distance (); |
551 | |
552 | inv = (cubeScreen->invert () == 1) ? 1.0: -1.0; |
553 | ym = (caScreen->optionGetDeformation () == CubeaddonScreen::DeformationCylinder) ? 0.0 : 1.0; |
554 | |
555 | - if ((int) caScreen->mWinNormSize < geometry.vCount * 3) |
556 | + int vertexCount = vb->countVertices (); |
557 | + |
558 | + if ((int) caScreen->mWinNormSize < vertexCount * 3) |
559 | { |
560 | delete [] caScreen->mWinNormals; |
561 | - caScreen->mWinNormals = new GLfloat[geometry.vCount * 3]; |
562 | - caScreen->mWinNormSize = geometry.vCount * 3; |
563 | + caScreen->mWinNormals = new GLfloat[vertexCount * 3]; |
564 | + caScreen->mWinNormSize = vertexCount * 3; |
565 | } |
566 | |
567 | if (!window->onAllViewports ()) |
568 | @@ -891,12 +1013,12 @@ |
569 | } |
570 | } |
571 | |
572 | - v = geometry.vertices + (geometry.vertexStride - 3); |
573 | + v = vb->getVertices () + (vb->getVertexStride () - 3); |
574 | n = caScreen->mWinNormals; |
575 | |
576 | if (cubeScreen->paintOrder () == FTB) |
577 | { |
578 | - for (i = 0; i < geometry.vCount; i++) |
579 | + for (i = 0; i < vertexCount; i++) |
580 | { |
581 | x = (((v[0] + offX - sx1) / (float)sw) - 0.5); |
582 | y = (((v[1] + offY - sy1) / (float)sh) - 0.5); |
583 | @@ -905,12 +1027,12 @@ |
584 | *(n)++ = y / sh * caScreen->mDeform * ym; |
585 | *(n)++ = v[2] + cDist; |
586 | |
587 | - v += geometry.vertexStride; |
588 | + v += vb->getVertexStride (); |
589 | } |
590 | } |
591 | else |
592 | { |
593 | - for (i = 0; i < geometry.vCount; i++) |
594 | + for (i = 0; i < vertexCount; i++) |
595 | { |
596 | x = (((v[0] + offX - sx1) / (float)sw) - 0.5); |
597 | y = (((v[1] + offY - sy1) / (float)sh) - 0.5); |
598 | @@ -919,24 +1041,18 @@ |
599 | *(n)++ = -y / sh * caScreen->mDeform * ym * inv; |
600 | *(n)++ = -(v[2] + cDist); |
601 | |
602 | - v += geometry.vertexStride; |
603 | + v += vb->getVertexStride (); |
604 | } |
605 | } |
606 | - |
607 | - glEnable (GL_NORMALIZE); |
608 | - glNormalPointer (GL_FLOAT,0, caScreen->mWinNormals); |
609 | - |
610 | - glEnableClientState (GL_NORMAL_ARRAY); |
611 | - |
612 | - gWindow->glDrawTexture (texture, attrib, mask); |
613 | - |
614 | - glDisable (GL_NORMALIZE); |
615 | - glDisableClientState (GL_NORMAL_ARRAY); |
616 | - glNormal3f (0.0, 0.0, -1.0); |
617 | + |
618 | + vb->addNormals (caScreen->mWinNormSize / 3, |
619 | + caScreen->mWinNormals); |
620 | + |
621 | + gWindow->glDrawTexture (texture, matrix, attrib, mask); |
622 | return; |
623 | } |
624 | |
625 | - gWindow->glDrawTexture (texture, attrib, mask); |
626 | + gWindow->glDrawTexture (texture, matrix, attrib, mask); |
627 | } |
628 | |
629 | bool |
630 | @@ -956,7 +1072,6 @@ |
631 | CompOutput *output, |
632 | unsigned int mask) |
633 | { |
634 | - static GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f }; |
635 | GLMatrix sTransform = transform; |
636 | float cDist = cubeScreen->distance (); |
637 | float cDist2 = cubeScreen->distance () * cubeScreen->distance (); |
638 | @@ -1257,82 +1372,97 @@ |
639 | rTransform.scale (1.0, -1.0, 1.0); |
640 | } |
641 | |
642 | - glPushMatrix (); |
643 | - glLoadIdentity (); |
644 | - glScalef (1.0, -1.0, 1.0); |
645 | - glLightfv (GL_LIGHT0, GL_POSITION, light0Position); |
646 | - glPopMatrix (); |
647 | glCullFace (GL_FRONT); |
648 | |
649 | gScreen->glPaintTransformedOutput (sAttrib, rTransform, |
650 | region, output, mask); |
651 | |
652 | glCullFace (GL_BACK); |
653 | - glPushMatrix (); |
654 | - glLoadIdentity (); |
655 | - glLightfv (GL_LIGHT0, GL_POSITION, light0Position); |
656 | - glPopMatrix (); |
657 | |
658 | if (optionGetMode () == ModeAbove && mVRot > 0.0) |
659 | { |
660 | int j; |
661 | float i, c; |
662 | float v = MIN (1.0, mVRot / 30.0); |
663 | - float col1[4], col2[4]; |
664 | - |
665 | - glPushMatrix (); |
666 | + unsigned short col1[4], col2[4]; |
667 | + |
668 | + GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer (); |
669 | + |
670 | + GLMatrix gTransform; |
671 | |
672 | glEnable (GL_BLEND); |
673 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
674 | |
675 | - glLoadIdentity (); |
676 | - glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA); |
677 | + gTransform.translate (0, 0, -DEFAULT_Z_CAMERA); |
678 | |
679 | i = optionGetIntensity () * 2; |
680 | c = optionGetIntensity (); |
681 | |
682 | - glBegin (GL_QUADS); |
683 | - glColor4f (0.0, 0.0, 0.0, |
684 | - ((1 - v) * MAX (0.0, 1.0 - i)) + (v * c)); |
685 | - glVertex2f (0.5, v / 2.0); |
686 | - glVertex2f (-0.5, v / 2.0); |
687 | - glColor4f (0.0, 0.0, 0.0, |
688 | - ((1 - v) * MIN (1.0, 1.0 - (i - 1.0))) + (v * c)); |
689 | - glVertex2f (-0.5, -0.5); |
690 | - glVertex2f (0.5, -0.5); |
691 | - glEnd (); |
692 | + GLfloat vertices[] = |
693 | + { |
694 | + 0.5f, v / 2.0f, 0.0f, |
695 | + -0.5f, v / 2.0f, 0.0f, |
696 | + -0.5f, -0.5f, 0.0f, |
697 | + 0.5f, -0.5f, 0.0f |
698 | + }; |
699 | + |
700 | + unsigned short cMax = MAX (0.0, 1.0 - i) + (v * c); |
701 | + unsigned short cMin = MIN (1.0, 1.0 - (i - 1.0)) + (v * c); |
702 | + |
703 | + GLushort colors[] = |
704 | + { |
705 | + 0, 0, 0, cMax, |
706 | + 0, 0, 0, cMax, |
707 | + 0, 0, 0, cMin, |
708 | + 0, 0, 0, cMin |
709 | + }; |
710 | + |
711 | + streamingBuffer->begin (GL_TRIANGLE_STRIP); |
712 | + streamingBuffer->addColors (4, colors); |
713 | + streamingBuffer->addVertices (4, vertices); |
714 | + if (streamingBuffer->end ()) |
715 | + streamingBuffer->render (gTransform); |
716 | |
717 | for (j = 0; j < 4; j++) |
718 | { |
719 | col1[j] = (1.0 - v) * optionGetGroundColor1 () [j] + |
720 | (v * (optionGetGroundColor1 () [j] + |
721 | optionGetGroundColor2 () [j]) * 0.5); |
722 | - col1[j] /= 0xffff; |
723 | col2[j] = (1.0 - v) * optionGetGroundColor2 () [j] + |
724 | (v * (optionGetGroundColor1 () [j] + |
725 | optionGetGroundColor2 () [j]) * 0.5); |
726 | - col2[j] /= 0xffff; |
727 | } |
728 | |
729 | if (optionGetGroundSize () > 0.0) |
730 | { |
731 | - glBegin (GL_QUADS); |
732 | - glColor4fv (col1); |
733 | - glVertex2f (-0.5, -0.5); |
734 | - glVertex2f (0.5, -0.5); |
735 | - glColor4fv (col2); |
736 | - glVertex2f (0.5, -0.5 + |
737 | - ((1 - v) * optionGetGroundSize ()) + v); |
738 | - glVertex2f (-0.5, -0.5 + |
739 | - ((1 - v) * optionGetGroundSize ()) + v); |
740 | - glEnd (); |
741 | + GLfloat vertices[] = |
742 | + { |
743 | + -0.5f, -0.5f, 0.0f, |
744 | + 0.5f, -0.5f, 0.0f, |
745 | + 0.5f, -0.5f + |
746 | + static_cast <GLfloat> (((1 - v) * optionGetGroundSize ()) + v), |
747 | + -0.5f, -0.5f + |
748 | + static_cast <GLfloat> (((1 - v) * optionGetGroundSize ()) + v) |
749 | + }; |
750 | + |
751 | + GLushort colors[] = |
752 | + { |
753 | + col1[0], col1[1], col1[2], col1[3], |
754 | + col1[0], col1[1], col1[2], col1[3], |
755 | + col2[0], col2[1], col2[2], col2[3], |
756 | + col2[0], col2[1], col2[2], col2[3] |
757 | + }; |
758 | + |
759 | + streamingBuffer->begin (GL_TRIANGLE_STRIP); |
760 | + streamingBuffer->addVertices (4, vertices); |
761 | + streamingBuffer->addColors (4, colors); |
762 | + |
763 | + if (streamingBuffer->end ()) |
764 | + streamingBuffer->render (gTransform); |
765 | } |
766 | |
767 | - glColor4usv (defaultColor); |
768 | - |
769 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
770 | glDisable (GL_BLEND); |
771 | - glPopMatrix (); |
772 | } |
773 | else |
774 | drawBasicGround (); |
775 | |
776 | === modified file 'plugins/cubeaddon/src/cubeaddon.h' |
777 | --- plugins/cubeaddon/src/cubeaddon.h 2012-09-07 22:37:20 +0000 |
778 | +++ plugins/cubeaddon/src/cubeaddon.h 2012-12-26 13:01:22 +0000 |
779 | @@ -39,15 +39,15 @@ |
780 | |
781 | #include "cubeaddon_options.h" |
782 | |
783 | -extern const unsigned short CUBEADDON_GRID_SIZE; |
784 | -extern const unsigned short CAP_ELEMENTS; |
785 | -extern const unsigned int CAP_NVERTEX; |
786 | -extern const unsigned int CAP_NIDX; |
787 | - |
788 | -extern const unsigned int CAP_NIMGVERTEX; |
789 | -extern const unsigned int CAP_NIMGIDX; |
790 | - |
791 | -extern const float RAD2I1024 = 162.9746617f; |
792 | +const unsigned short CUBEADDON_GRID_SIZE = 100; |
793 | +const unsigned short CAP_ELEMENTS = 15; |
794 | +const unsigned int CAP_NVERTEX = (((CAP_ELEMENTS * (CAP_ELEMENTS + 1)) + 2) * 3); |
795 | +const unsigned int CAP_NIDX = (CAP_ELEMENTS * (CAP_ELEMENTS - 1) * 4); |
796 | + |
797 | +const unsigned int CAP_NIMGVERTEX = (((CAP_ELEMENTS + 1) * (CAP_ELEMENTS + 1)) * 5); |
798 | +const unsigned int CAP_NIMGIDX = (CAP_ELEMENTS * CAP_ELEMENTS * 4); |
799 | + |
800 | +const float RAD2I1024 = 162.9746617f; |
801 | |
802 | class CubeaddonScreen : |
803 | public CompositeScreenInterface, |
804 | @@ -76,11 +76,13 @@ |
805 | void cubePaintTop (const GLScreenPaintAttrib &sAttrib, |
806 | const GLMatrix &transform, |
807 | CompOutput *output, |
808 | - int size); |
809 | + int size, |
810 | + const GLVector &normal); |
811 | void cubePaintBottom (const GLScreenPaintAttrib &sAttrib, |
812 | const GLMatrix &transform, |
813 | CompOutput *output, |
814 | - int size); |
815 | + int size, |
816 | + const GLVector &normal); |
817 | bool cubeCheckOrientation (const GLScreenPaintAttrib &sAttrib, |
818 | const GLMatrix &transform, |
819 | CompOutput *output, |
820 | @@ -165,12 +167,14 @@ |
821 | public: |
822 | CubeaddonWindow (CompWindow *); |
823 | |
824 | - bool glDraw (const GLMatrix&, GLFragment::Attrib&, |
825 | + bool glDraw (const GLMatrix&, GLWindowPaintAttrib&, |
826 | const CompRegion&, unsigned int); |
827 | void glAddGeometry (const GLTexture::MatrixList&, |
828 | const CompRegion&, const CompRegion&, |
829 | unsigned int, unsigned int); |
830 | - void glDrawTexture (GLTexture *, GLFragment::Attrib& attrib, |
831 | + void glDrawTexture (GLTexture *, |
832 | + const GLMatrix &matrix, |
833 | + GLWindowPaintAttrib& attrib, |
834 | unsigned int); |
835 | |
836 | CompWindow *window; |