Merge lp:~smspillaz/compiz/compiz.feature_1069112.cubeaddon into lp:compiz/0.9.9

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~smspillaz/compiz/compiz.feature_1069112.cubeaddon
Merge into: lp:compiz/0.9.9
Diff against target: 885 lines (+336/-198)
5 files modified
debian/compiz-plugins.install (+2/-0)
plugins/CMakeLists.txt (+0/-1)
plugins/cubeaddon/src/cubeaddon.cpp (+316/-183)
plugins/cubeaddon/src/cubeaddon.h (+17/-13)
plugins/opengl/src/screen.cpp (+1/-1)
To merge this branch: bzr merge lp:~smspillaz/compiz/compiz.feature_1069112.cubeaddon
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Daniel van Vugt Needs Resubmitting
MC Return Approve
Review via email: mp+141258@code.launchpad.net

This proposal supersedes a proposal from 2012-12-26.

This proposal has been superseded by a proposal from 2013-01-04.

Commit message

Port cubeaddon plugin to use new OpenGL plugin API.
(LP: #1020823)

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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote :

\o/

GREAT JOB! Compiles and works perfectly.

(Had to remove #set (COMPIZ_DISABLE_PLUGIN_CUBEADDON ON) from plugins/CMakeLists.txt completely though.)

Awesome to see long-time Compiz features come back !!!

review: Approve
3533. By Sam Spilsbury

Adjust buildsystem

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
3534. By Sam Spilsbury

Install images too

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

BUILD_GLES fails:
/home/dan/bzr/compiz/tmp.112/plugins/cubeaddon/src/cubeaddon.cpp: In member function ‘void CubeaddonScreen::CubeCap::load(bool, bool, bool)’:
/home/dan/bzr/compiz/tmp.112/plugins/cubeaddon/src/cubeaddon.cpp:114:9: error: ‘GL_CLAMP_TO_BORDER’ was not declared in this scope
make[2]: *** [plugins/cubeaddon/CMakeFiles/cubeaddon.dir/src/cubeaddon.cpp.o] Error 1
make[1]: *** [plugins/cubeaddon/CMakeFiles/cubeaddon.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

----
Clang also fails:
In file included from /home/dan/bzr/compiz/tmp.112/plugins/cubeaddon/src/cubeaddon.cpp:26:
/home/dan/bzr/compiz/tmp.112/plugins/cubeaddon/src/cubeaddon.h:170:7: error:
      'CubeaddonWindow::glDraw' hides overloaded virtual function
      [-Werror,-Woverloaded-virtual]
        bool glDraw (const GLMatrix&, GLWindowPaintAttrib&,
             ^
/home/dan/bzr/compiz/tmp.112/plugins/cubeaddon/../opengl/include/opengl/opengl.h:849:15: note:
      hidden overloaded virtual function 'GLWindowInterface::glDraw' declared
      here
        virtual bool glDraw (const GLMatrix &matrix,
                     ^
In file included from /home/dan/bzr/compiz/tmp.112/plugins/cubeaddon/src/cubeaddon.cpp:26:
/home/dan/bzr/compiz/tmp.112/plugins/cubeaddon/src/cubeaddon.h:175:7: error:
      'CubeaddonWindow::glDrawTexture' hides overloaded virtual function
      [-Werror,-Woverloaded-virtual]
        void glDrawTexture (GLTexture *,
             ^
/home/dan/bzr/compiz/tmp.112/plugins/cubeaddon/../opengl/include/opengl/opengl.h:875:15: note:
      hidden overloaded virtual function 'GLWindowInterface::glDrawTexture'
      declared here
        virtual void glDrawTexture (GLTexture *texture, const GLMatrix &,
                     ^
2 errors generated.

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Ah, thanks. I'll handle that now.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

(A note that we really really really really really really really need to have CI do BUILD_GLES and clang, the fact that reviewers are building code is silly)

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Fixed.

3535. By Sam Spilsbury

Merge compiz.fix_1095915

3536. By Sam Spilsbury

Fix build errors with clang / gles

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Not fixed. Latest revision on this branch is 26 December still :)

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Ah of course, branch aliases -.-

Really fixed.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

gcc 4.7.2 (quantal) BUILD_GLES:
/home/dan/bzr/compiz/tmp.112/plugins/opengl/src/screen.cpp: In member function ‘bool GLScreen::glInitContext(XVisualInfo*)’:
/home/dan/bzr/compiz/tmp.112/plugins/opengl/src/screen.cpp:547:24: error: invalid conversion from ‘void (*)(GLuint, GLsizei, const GLchar**, const GLint*) {aka void (*)(unsigned int, int, const char**, const int*)}’ to ‘GL::GLShaderSourceProc {aka void (*)(unsigned int, int, const char* const*, const int*)}’ [-fpermissive]

Seems to be the same change from:
https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1095915/+merge/141851
so please add a prereq on that one.

review: Needs Resubmitting
3537. By Sam Spilsbury

Merge compiz.fix_1095915

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
3538. By Sam Spilsbury

Use array instead of vector

3539. By Sam Spilsbury

Add cubeaddon to compiz-plugins.install.arm*

Unmerged revisions

Preview Diff

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

Subscribers

People subscribed via source and target branches