Merge lp:~smspillaz/compiz/compiz.animationaddon-returns into lp:compiz/0.9.12

Proposed by Sam Spilsbury
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 4030
Merged at revision: 4062
Proposed branch: lp:~smspillaz/compiz/compiz.animationaddon-returns
Merge into: lp:compiz/0.9.12
Diff against target: 1931 lines (+594/-428)
27 files modified
debian/compiz-dev.install (+1/-0)
debian/compiz-plugins.install (+2/-0)
debian/compiz-plugins.install.armel (+2/-0)
debian/compiz-plugins.install.armhf (+2/-0)
plugins/CMakeLists.txt (+0/-1)
plugins/animation/include/animation/animeffect.h (+5/-2)
plugins/animation/include/animation/grid.h (+0/-1)
plugins/animation/include/animation/multi.h (+19/-9)
plugins/animation/src/animation.cpp (+17/-24)
plugins/animation/src/glide.cpp (+1/-1)
plugins/animation/src/grid.cpp (+0/-6)
plugins/animation/src/private.h (+1/-1)
plugins/animationaddon/CMakeLists.txt (+1/-4)
plugins/animationaddon/include/animationaddon/animationaddon.h (+17/-11)
plugins/animationaddon/src/airplane.cpp (+47/-36)
plugins/animationaddon/src/animationaddon.cpp (+2/-2)
plugins/animationaddon/src/dissolve.cpp (+11/-2)
plugins/animationaddon/src/particle.cpp (+52/-40)
plugins/animationaddon/src/polygon.cpp (+259/-250)
plugins/animationaddon/src/private.h (+3/-2)
plugins/opengl/include/opengl/matrix.h (+27/-0)
plugins/opengl/include/opengl/opengl.h (+6/-0)
plugins/opengl/include/opengl/vertexbuffer.h (+20/-2)
plugins/opengl/src/paint.cpp (+1/-10)
plugins/opengl/src/privatevertexbuffer.h (+6/-2)
plugins/opengl/src/vertexbuffer.cpp (+77/-22)
plugins/opengl/src/window.cpp (+15/-0)
To merge this branch: bzr merge lp:~smspillaz/compiz/compiz.animationaddon-returns
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Eleni Maria Stea Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+295497@code.launchpad.net

Commit message

animationaddon: Port the animationaddon plugin to use modern GL API.

This involved a lot of changes:
 - Removal of glPush/glPop. State is assumed to be off in newer versions
   of compiz, so switch off whatever gets switched on.
 - Switch from glVertexPointer/glDrawArrays/glDrawElements to GLVertexBuffer
 - Changes in primitive assembly: GL_POLYGON doesn't exist in GLES
   so switch to using GL_TRIANGLES. This meant that the indices
   for all the animatons needed to be re-tesselated. That was done
   by hand using a winding rule which just duplicates the first and
   third vertex around the fourth.
 - Dropping of glTexEnv calls.
 - Reworking of the depth test, since writes to the depth buffer
   have been disabled by default.

Description of the change

animationaddon: Port the animationaddon plugin to use modern GL API.

This involved a lot of changes:
 - Removal of glPush/glPop. State is assumed to be off in newer versions
   of compiz, so switch off whatever gets switched on.
 - Switch from glVertexPointer/glDrawArrays/glDrawElements to GLVertexBuffer
 - Changes in primitive assembly: GL_POLYGON doesn't exist in GLES
   so switch to using GL_TRIANGLES. This meant that the indices
   for all the animatons needed to be re-tesselated. That was done
   by hand using a winding rule which just duplicates the first and
   third vertex around the fourth.
 - Dropping of glTexEnv calls.
 - Reworking of the depth test, since writes to the depth buffer
   have been disabled by default.

Some things still don't work:
 - Anything depending on clipping planes: glClipPlane and friends
   were removed on GLES20 and they are quite difficult to implement
   using other methods.
 - Drawing of decoration textures - these appear to be stretched
   and skewed incorrectly.
 - Lighting. This will require special shaders.

To post a comment you must log in.
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

good work! but you missed an else in one of your render functions (see comment in the code), you either use glDrawArrays or glDrawElements.

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

Thanks for the review and for the catch!

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

Do you have any ideas as to how we could re-implement clipping planes? I remember when I did it for the expo plugin we had to resort to using the stencil buffer which feels like overkill.

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

I believe you mean clipping that is gles2 compatible. I needed that for the 3d windows but never had the time to implement it properly. Here's the shader you can use (look at the 3d.cpp) It's tested and it works well:

http://bazaar.launchpad.net/~hikiko/compiz/compiz.fixed-3d-windows-in-gles2/revision/3984#plugins/opengl/src/paint.cpp

How it works:
The trick is done in the pixel shader. You first calculate which pixels would be clipped if you could support clipping and then you discard them in the pixel shader.

The reason I never merged that change was that compiz shader class needed some additions before it works. https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/1024208/comments/14 (I can't remember what was the main problem though because a year has passed... sorry! I'll look at it if you want)

It will be great if you have the time to get a look at it and make compiz use the shader because many plugins will work in ES2! (+thanks a lot!!! :D)

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

+1 for the change

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

Interesting. That's the other solution that I've seen posted in various places online. I guess if you have to discard individual fragments then its going to be just as expensive or more expensive than using the stencil buffer (though I suppose using the stencil buffer means that the pipeline is blocked on the stencil buffer update).

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ah, even for this please, include animationaddons in debian/compiz-plugins.install now that is built by default

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

The stencil buffer is used for 2d clipping, to achieve a visual result similar to the glScissors. We usually use it when we need to clip more complex 2d shapes than those that Scissors can clip.

The shaders above perform clipping in 3d space (to clip some garbage around the rotating 3d cube for example).

I don't know if the pipeline is blocked during the update, to be honest. The redbook says that "clearing the buffer is one of the most expensive operations", though.

So, the decision depends on the visual result you want to achieve: you need 2d or 3d clipping? are your shapes so complex that you really need to make use of the stencil buffer?

Also, note that the 3d clipping in the shaders above might be a bit slow in some opengl implementations (but it's fine for most cases).

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

> The stencil buffer is used for 2d clipping, to achieve a visual result similar
> to the glScissors. We usually use it when we need to clip more complex 2d
> shapes than those that Scissors can clip.
>
> The shaders above perform clipping in 3d space (to clip some garbage around
> the rotating 3d cube for example).
>
> I don't know if the pipeline is blocked during the update, to be honest. The
> redbook says that "clearing the buffer is one of the most expensive
> operations", though.
>
> So, the decision depends on the visual result you want to achieve: you need 2d
> or 3d clipping? are your shapes so complex that you really need to make use of
> the stencil buffer?

For the expo plugin we were able to get away with 2D clipping. I imagine that for the 3D windows plugin you needed 3D clipping for instance.

I'm actually not sure why animationaddon used clip planes. I suspect clip planes may have fixed the issues I was seeing with decorations being rendered incorrectly during polygon animations.

>
> Also, note that the 3d clipping in the shaders above might be a bit slow in
> some opengl implementations (but it's fine for most cases).

Indeed - I remember that was my main concern as I looked into doing something similar for expo - it was going to be an additional fragment shader pass with a loop and if statements (quite slow at the time!)

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

> Ah, even for this please, include animationaddons in debian/compiz-
> plugins.install now that is built by default

Done - (though there's going to be "conflicts, conflicts everywhere" after three plugins starting with animation* are merged in ;-))

Revision history for this message
Eleni Maria Stea (hikiko) wrote :

sorry, I think top approved the branch before the 4024 change...

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ouch, some problems when building the debian package.

Please apply this: http://pastebin.com/0yKGwL67

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

Ah, thanks - I'll apply it ASAP.

Are the CI bots for merge requests disabled at the moment?

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Yeah, CI has to be reimplemented in a different way, but I'm not sure this will happen for the unity7 stack, since we've to prioritize the new one.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Better, but we still fail in armhf as this doesn't build there for missing dependency.

Can you please get rid of the lines in debian/compiz-plugins.install.armhf (and define a new compiz-dev.install.armhf without the compiz-animationaddon.pc file)?

Sorry for the hassle, but... You know :)

See https://launchpadlibrarian.net/262557615/buildlog_ubuntu-yakkety-armhf.compiz_1%3A0.9.12.2+16.10.20160531-0ubuntu1_BUILDING.txt.gz

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

Heh, no worries.

This should work fine on GLES, though as it turns out gluProject isn't available there. I've re-implemented the same thing in matrix.h and removed the dependency, so it should compile fine this time.

4026. By Sam Spilsbury <email address hidden>

Merge lp:~smspillaz/compiz/compiz.animationaddon-returns

4027. By Sam Spilsbury <email address hidden>

animationaddon: Completely remove clip planes

(Until a different solution can be found)

4028. By Sam Spilsbury <email address hidden>

animationaddon: Don't use glClearDepth on GLES (use glClearDepthf)

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

Marco - I've added a new commit and done a local build-test with BUILD_GLES. Hopefully this should pass ci-train now. Sorry about that hassle!

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Not sure why this includes 'plugins/animationjc/compiz-animationjc.pc.in' too, so it fails building becaus it's not in compiz-dev thing. I guess you've merged this with animationjc branch, and that's broken too.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Hey, can you check these set of branches again? I'd like them to be merged...

I can do that if you're busy.

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

Yeah I was going to have a look at them yesterday and ran out of time.

I'll take a look today. Sorry about the breakage!

Sam.
On 21 Jun 2016 02:40, "Marco Trevisan (Treviño)" <mail@3v1n0.net> wrote:

> Hey, can you check these set of branches again? I'd like them to be
> merged...
>
> I can do that if you're busy.
> --
>
> https://code.launchpad.net/~smspillaz/compiz/compiz.animationaddon-returns/+merge/295497
> You are the owner of lp:~smspillaz/compiz/compiz.animationaddon-returns.
>

4029. By Sam Spilsbury <email address hidden>

Merge lp:compiz

4030. By Sam Spilsbury <email address hidden>

Revert addition of animationjc

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

That should fix the issue

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Yay! I guess I need to update the .install files for the other branches too?

On Tue, Jun 28, 2016 at 9:34 AM, Marco Trevisan (Treviño)
<mail@3v1n0.net> wrote:
> The proposal to merge lp:~smspillaz/compiz/compiz.animationaddon-returns into lp:compiz has been updated.
>
> Status: Needs review => Approved
>
> For more details, see:
> https://code.launchpad.net/~smspillaz/compiz/compiz.animationaddon-returns/+merge/295497
> --
> You are the owner of lp:~smspillaz/compiz/compiz.animationaddon-returns.

--
Sam Spilsbury

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/compiz-dev.install'
2--- debian/compiz-dev.install 2014-11-24 22:25:07 +0000
3+++ debian/compiz-dev.install 2016-06-22 01:26:00 +0000
4@@ -1,6 +1,7 @@
5 debian/tmp/usr/include/compiz/[!d]*
6 debian/tmp/usr/lib/*/libcompiz_core.so
7 debian/tmp/usr/lib/*/pkgconfig/compiz-animation.pc
8+debian/tmp/usr/lib/*/pkgconfig/compiz-animationaddon.pc
9 debian/tmp/usr/lib/*/pkgconfig/compiz-compiztoolbox.pc
10 debian/tmp/usr/lib/*/pkgconfig/compiz-composite.pc
11 debian/tmp/usr/lib/*/pkgconfig/compiz-cube.pc
12
13=== modified file 'debian/compiz-plugins.install'
14--- debian/compiz-plugins.install 2016-05-13 09:45:31 +0000
15+++ debian/compiz-plugins.install 2016-06-22 01:26:00 +0000
16@@ -2,6 +2,8 @@
17 usr/share/compiz/*addhelper.*
18 usr/lib/*/compiz/*annotate.*
19 usr/share/compiz/*annotate.*
20+usr/lib/*/compiz/*animationaddon.*
21+usr/share/compiz/*animationaddon.*
22 usr/lib/*/compiz/*bench.*
23 usr/share/compiz/*bench.*
24 usr/lib/*/compiz/*blur.*
25
26=== modified file 'debian/compiz-plugins.install.armel'
27--- debian/compiz-plugins.install.armel 2014-12-02 14:42:34 +0000
28+++ debian/compiz-plugins.install.armel 2016-06-22 01:26:00 +0000
29@@ -2,6 +2,8 @@
30 usr/share/compiz/*addhelper.*
31 usr/lib/*/compiz/*annotate.*
32 usr/share/compiz/*annotate.*
33+usr/lib/*/compiz/*animationaddon.*
34+usr/share/compiz/*animationaddon.*
35 usr/lib/*/compiz/*clone.*
36 usr/share/compiz/*clone.*
37 usr/lib/*/compiz/*crashhandler.*
38
39=== modified file 'debian/compiz-plugins.install.armhf'
40--- debian/compiz-plugins.install.armhf 2014-12-02 14:42:34 +0000
41+++ debian/compiz-plugins.install.armhf 2016-06-22 01:26:00 +0000
42@@ -2,6 +2,8 @@
43 usr/share/compiz/*addhelper.*
44 usr/lib/*/compiz/*annotate.*
45 usr/share/compiz/*annotate.*
46+usr/lib/*/compiz/*animationaddon.*
47+usr/share/compiz/*animationaddon.*
48 usr/lib/*/compiz/*clone.*
49 usr/share/compiz/*clone.*
50 usr/lib/*/compiz/*crashhandler.*
51
52=== modified file 'plugins/CMakeLists.txt'
53--- plugins/CMakeLists.txt 2016-05-13 06:42:58 +0000
54+++ plugins/CMakeLists.txt 2016-06-22 01:26:00 +0000
55@@ -10,7 +10,6 @@
56 include_directories (${COMPIZ_INTERNAL_INCLUDES})
57
58 # temporarily disable plugins that aren't ported yet
59-set (COMPIZ_DISABLE_PLUGIN_ANIMATIONADDON ON)
60 set (COMPIZ_DISABLE_PLUGIN_BICUBIC ON)
61 set (COMPIZ_DISABLE_PLUGIN_COLORFILTER ON)
62 set (COMPIZ_DISABLE_PLUGIN_GROUP ON)
63
64=== modified file 'plugins/animation/include/animation/animeffect.h'
65--- plugins/animation/include/animation/animeffect.h 2015-03-01 21:55:10 +0000
66+++ plugins/animation/include/animation/animeffect.h 2016-06-22 01:26:00 +0000
67@@ -142,7 +142,7 @@
68 virtual void updateAttrib (GLWindowPaintAttrib &) {}
69 virtual void updateTransform (GLMatrix &) {}
70 virtual void prePaintWindow () {}
71- virtual void postPaintWindow () {}
72+ virtual void postPaintWindow (const GLMatrix &) {}
73 virtual bool postPaintWindowUsed () { return false; }
74
75 /// Returns true if the animation is still in progress.
76@@ -174,7 +174,10 @@
77 const CompRegion &clip,
78 unsigned int maxGridWidth,
79 unsigned int maxGridHeight);
80- virtual void drawGeometry ();
81+ virtual void drawGeometry (GLTexture *texture,
82+ const GLMatrix &transform,
83+ const GLWindowPaintAttrib &attrib,
84+ unsigned int mask);
85
86 virtual bool paintWindowUsed () { return false; }
87 virtual bool paintWindow (GLWindow *gWindow,
88
89=== modified file 'plugins/animation/include/animation/grid.h'
90--- plugins/animation/include/animation/grid.h 2012-08-14 06:33:22 +0000
91+++ plugins/animation/include/animation/grid.h 2016-06-22 01:26:00 +0000
92@@ -101,6 +101,5 @@
93 const CompRegion &clip,
94 unsigned int maxGridWidth,
95 unsigned int maxGridHeight);
96- void drawGeometry ();
97 };
98 #endif
99
100=== modified file 'plugins/animation/include/animation/multi.h'
101--- plugins/animation/include/animation/multi.h 2013-04-25 11:07:54 +0000
102+++ plugins/animation/include/animation/multi.h 2016-06-22 01:26:00 +0000
103@@ -1,6 +1,8 @@
104 #ifndef ANIMATION_MULTI_H
105 #define ANIMATION_MULTI_H
106 #include "animation.h"
107+#include <opengl/opengl.h>
108+#include <composite/composite.h>
109 /// Special class, allows multiple copies of an animation to happen
110 /// at any one time. Create your "single copy" animation class first
111 /// and then create a new animation which derives from this template
112@@ -140,9 +142,8 @@
113 foreach (SingleAnim *a, animList)
114 {
115 setCurrAnimNumber (mAWindow, count);
116- GLWindowPaintAttrib attr (attrib);
117- a->updateAttrib (attr);
118- mGlPaintAttribs.at (count) = attr;
119+ mGlPaintAttribs[count] = attrib;
120+ a->updateAttrib (mGlPaintAttribs[count]);
121 ++count;
122 }
123 }
124@@ -172,14 +173,14 @@
125 }
126 }
127
128- void postPaintWindow ()
129+ void postPaintWindow (const GLMatrix &transform)
130 {
131 int count = 0;
132 foreach (SingleAnim *a, animList)
133 {
134 setCurrAnimNumber (mAWindow, count);
135 ++count;
136- a->postPaintWindow ();
137+ a->postPaintWindow (transform);
138 }
139 }
140
141@@ -377,11 +378,20 @@
142 ++count;
143
144 if (animList.at (currentAnim)->paintWindowUsed ())
145- status |= animList.at (currentAnim)->paintWindow
146- (gWindow, wAttrib, wTransform, region, mask);
147+ status |= animList.at (currentAnim)->paintWindow (gWindow,
148+ wAttrib,
149+ wTransform,
150+ region,
151+ mask);
152 else
153- status |= gWindow->glPaint
154- (wAttrib, wTransform, region, mask);
155+ {
156+ unsigned int index = gWindow->glPaintGetCurrentIndex ();
157+ status |= gWindow->glPaint (wAttrib,
158+ wTransform,
159+ region,
160+ mask);
161+ gWindow->glPaintSetCurrentIndex (index);
162+ }
163 }
164
165 return status;
166
167=== modified file 'plugins/animation/src/animation.cpp'
168--- plugins/animation/src/animation.cpp 2015-03-16 18:45:33 +0000
169+++ plugins/animation/src/animation.cpp 2016-06-22 01:26:00 +0000
170@@ -1632,20 +1632,20 @@
171 if (mCurAnimation)
172 mCurAnimation->setCurPaintAttrib (attrib);
173
174- gWindow->glDrawTexture (texture, transform, attrib, mask);
175+ if (mCurAnimation)
176+ {
177+ if (mCurAnimation->initialized ())
178+ mCurAnimation->drawGeometry (texture, transform, attrib, mask);
179+ }
180+ else
181+ gWindow->glDrawTexture (texture, transform, attrib, mask);
182 }
183
184 #if 0 // Not ported yet
185 void
186 PrivateAnimWindow::glDrawGeometry ()
187 {
188- if (mCurAnimation)
189- {
190- if (mCurAnimation->initialized ())
191- mCurAnimation->drawGeometry ();
192- }
193- else
194- gWindow->glDrawGeometry ();
195+
196 }
197 #endif
198
199@@ -1658,11 +1658,15 @@
200 }
201
202 void
203-Animation::drawGeometry ()
204+Animation::drawGeometry (GLTexture *texture,
205+ const GLMatrix &transform,
206+ const GLWindowPaintAttrib &attrib,
207+ unsigned int mask)
208 {
209-#if 0 // Not ported yet
210- mAWindow->priv->gWindow->glDrawGeometry ();
211-#endif
212+ GLWindow::get (mAWindow->mWindow)->glDrawTexture (texture,
213+ transform,
214+ attrib,
215+ mask);
216 }
217
218 bool
219@@ -1731,18 +1735,7 @@
220 status = gWindow->glPaint (wAttrib, wTransform, region, mask);
221
222 if (mCurAnimation->postPaintWindowUsed ())
223- {
224-#if 0 // Not ported yet
225- // Transform to make post-paint coincide with the window
226- glPushMatrix ();
227- glLoadMatrixf (wTransform.getMatrix ());
228-#endif
229- mCurAnimation->postPaintWindow ();
230-
231-#if 0 // Not ported yet
232- glPopMatrix ();
233-#endif
234- }
235+ mCurAnimation->postPaintWindow (wTransform);
236
237 return status;
238 }
239
240=== modified file 'plugins/animation/src/glide.cpp'
241--- plugins/animation/src/glide.cpp 2015-03-02 08:48:27 +0000
242+++ plugins/animation/src/glide.cpp 2016-06-22 01:26:00 +0000
243@@ -167,7 +167,7 @@
244 }
245
246 void
247-GlideAnim::postPaintWindow ()
248+GlideAnim::postPaintWindow (const GLMatrix &transform)
249 {
250 if (90 < glideModRotAngle &&
251 glideModRotAngle < 270)
252
253=== modified file 'plugins/animation/src/grid.cpp'
254--- plugins/animation/src/grid.cpp 2013-07-24 17:36:47 +0000
255+++ plugins/animation/src/grid.cpp 2016-06-22 01:26:00 +0000
256@@ -388,12 +388,6 @@
257 }
258 }
259
260-void
261-GridAnim::drawGeometry ()
262-{
263- // Deprecated
264-}
265-
266 GridTransformAnim::GridTransformAnim (CompWindow *w,
267 WindowEvent curWindowEvent,
268 float duration,
269
270=== modified file 'plugins/animation/src/private.h'
271--- plugins/animation/src/private.h 2013-10-31 15:59:14 +0000
272+++ plugins/animation/src/private.h 2016-06-22 01:26:00 +0000
273@@ -588,7 +588,7 @@
274
275 void prePaintWindow ();
276 inline bool postPaintWindowUsed () { return true; }
277- void postPaintWindow ();
278+ void postPaintWindow (const GLMatrix &);
279 void adjustDuration ();
280 bool zoomToIcon ();
281 void applyTransform ();
282
283=== modified file 'plugins/animationaddon/CMakeLists.txt'
284--- plugins/animationaddon/CMakeLists.txt 2012-05-21 08:50:26 +0000
285+++ plugins/animationaddon/CMakeLists.txt 2016-06-22 01:26:00 +0000
286@@ -1,7 +1,4 @@
287 find_package (Compiz REQUIRED)
288 include (CompizPlugin)
289-include (FindOpenGL)
290
291-if (OPENGL_GLU_FOUND)
292- compiz_plugin (animationaddon PLUGINDEPS composite opengl animation LIBRARIES ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
293-endif (OPENGL_GLU_FOUND)
294+compiz_plugin (animationaddon PLUGINDEPS composite opengl animation)
295
296=== modified file 'plugins/animationaddon/include/animationaddon/animationaddon.h'
297--- plugins/animationaddon/include/animationaddon/animationaddon.h 2010-01-27 16:32:40 +0000
298+++ plugins/animationaddon/include/animationaddon/animationaddon.h 2016-06-22 01:26:00 +0000
299@@ -97,7 +97,7 @@
300 GLuint blendMode);
301 ~ParticleSystem ();
302
303- void draw (int offsetX = 0, int offsetY = 0);
304+ void draw (const GLMatrix &transform, int offsetX = 0, int offsetY = 0);
305 void update (float time);
306 vector<Particle> &particles () { return mParticles; }
307 void activate () { mActive = true; }
308@@ -120,8 +120,8 @@
309
310 vector<GLfloat> mVerticesCache;
311 vector<GLfloat> mCoordsCache;
312- vector<GLfloat> mColorsCache;
313- vector<GLfloat> mDColorsCache;
314+ vector<GLushort> mColorsCache;
315+ vector<GLushort> mDColorsCache;
316 };
317
318 class ParticleAnim :
319@@ -135,7 +135,7 @@
320 const AnimEffect info,
321 const CompRect &icon);
322 ~ParticleAnim () {}
323- void postPaintWindow ();
324+ void postPaintWindow (const GLMatrix &);
325 bool postPaintWindowUsed () { return true; }
326 void updateBB (CompOutput &output);
327 bool updateBBUsed () { return true; }
328@@ -259,14 +259,17 @@
329
330 void step ();
331 void prePaintWindow ();
332- void postPaintWindow ();
333+ void postPaintWindow (const GLMatrix &);
334 bool postPaintWindowUsed () { return true; }
335 void addGeometry (const GLTexture::MatrixList &matrix,
336 const CompRegion &region,
337 const CompRegion &clipRegion,
338 unsigned int maxGridWidth,
339 unsigned int maxGridHeight);
340- void drawGeometry ();
341+ void drawGeometry (GLTexture *texture,
342+ const GLMatrix &transform,
343+ const GLWindowPaintAttrib &attrib,
344+ unsigned int mask);
345 virtual void updateBB (CompOutput &output);
346 bool updateBBUsed () { return true; }
347 bool prePreparePaint (int msSinceLastPaint);
348@@ -274,7 +277,8 @@
349
350 virtual void stepPolygon (PolygonObject *p,
351 float forwardProgress);
352- virtual void transformPolygon (const PolygonObject *p) {}
353+ virtual void transformPolygon (GLMatrix &matrix,
354+ const PolygonObject *p) {}
355
356 /// For effects that have decel. motion
357 virtual bool deceleratingMotion () { return false; }
358@@ -301,7 +305,8 @@
359 void processIntersectingPolygons ();
360 virtual void freePolygonObjects ();
361 void freeClipsPolygons ();
362- void prepareDrawingForAttrib (GLFragment::Attrib &attrib);
363+ void prepareDrawingForAttrib (GLWindowPaintAttrib &attrib,
364+ GLVertexBuffer &vertexBuffer);
365
366 int mNumDrawGeometryCalls;
367 int mNumClipsPassed; /**< # of clips passed to animAddWindowGeometry so far
368@@ -327,15 +332,16 @@
369 bool mIncludeShadows; ///< Whether to include shadows in polygon
370
371 private:
372- inline void drawPolygonClipIntersection (const PolygonObject *p,
373+ inline void drawPolygonClipIntersection (GLTexture *texture,
374+ const GLMatrix &transform,
375+ const PolygonObject *p,
376 const Clip4Polygons &c,
377 const GLfloat *vertexTexCoords,
378 int pass,
379 float forwardProgress,
380- GLdouble clipPlane[4][4],
381 const CompOutput &output,
382 float newOpacity,
383 bool decelerates,
384- GLfloat skewMat[16]);
385+ GLMatrix &skewMat);
386 };
387 #endif
388
389=== modified file 'plugins/animationaddon/src/airplane.cpp'
390--- plugins/animationaddon/src/airplane.cpp 2013-02-27 11:33:10 +0000
391+++ plugins/animationaddon/src/airplane.cpp 2016-06-22 01:26:00 +0000
392@@ -271,8 +271,8 @@
393 pv[22] = topLeftY;
394 pv[23] = -halfThick;
395
396- // 16 indices for 4 sides (for quad strip)
397- p->sideIndices = (GLushort *) calloc (4 * 4, sizeof (GLushort));
398+ // 24 indices for 4 sides (for triangle strip)
399+ p->sideIndices = (GLushort *) calloc (6 * 4, sizeof (GLushort));
400 if (!p->sideIndices)
401 {
402 compLogMessage ("animation", CompLogLevelError,
403@@ -287,22 +287,30 @@
404 ind[id++] = 0;
405 ind[id++] = 7;
406 ind[id++] = 6;
407- ind[id++] = 1;
408-
409- ind[id++] = 1;
410- ind[id++] = 6;
411- ind[id++] = 5;
412- ind[id++] = 2;
413-
414- ind[id++] = 2;
415- ind[id++] = 5;
416- ind[id++] = 4;
417- ind[id++] = 3;
418-
419- ind[id++] = 3;
420- ind[id++] = 4;
421- ind[id++] = 7;
422- ind[id++] = 0;
423+ ind[id++] = 0;
424+ ind[id++] = 1;
425+ ind[id++] = 6;
426+
427+ ind[id++] = 1;
428+ ind[id++] = 6;
429+ ind[id++] = 5;
430+ ind[id++] = 1;
431+ ind[id++] = 2;
432+ ind[id++] = 5;
433+
434+ ind[id++] = 2;
435+ ind[id++] = 5;
436+ ind[id++] = 4;
437+ ind[id++] = 2;
438+ ind[id++] = 3;
439+ ind[id++] = 4;
440+
441+ ind[id++] = 3;
442+ ind[id++] = 4;
443+ ind[id++] = 7;
444+ ind[id++] = 3;
445+ ind[id++] = 0;
446+ ind[id++] = 7;
447
448 if (i < 4)
449 {
450@@ -318,6 +326,8 @@
451 p->boundingBox.x2 = ceil (p->centerPos.x () + bottomRightX);
452 p->boundingBox.y2 = ceil (p->centerPos.y () + bottomLeftY);
453 }
454+
455+ p->normals = NULL;
456
457 i++;
458 }
459@@ -692,41 +702,42 @@
460 }
461
462 void
463-AirplaneAnim::transformPolygon (const PolygonObject *pol)
464+AirplaneAnim::transformPolygon (GLMatrix &matrix,
465+ const PolygonObject *pol)
466 {
467 AirplanePolygonObject *p = (AirplanePolygonObject *) pol;
468
469- glRotatef (p->flyRotation.x (), 1, 0, 0); //rotate on axis X
470- glRotatef (-p->flyRotation.y (), 0, 1, 0); // rotate on axis Y
471- glRotatef (p->flyRotation.z (), 0, 0, 1); // rotate on axis Z
472+ matrix.rotate (p->flyRotation.x (), 1, 0, 0); //rotate on axis X
473+ matrix.rotate (-p->flyRotation.y (), 0, 1, 0); // rotate on axis Y
474+ matrix.rotate (p->flyRotation.z (), 0, 0, 1); // rotate on axis Z
475
476- glScalef (1.0 / (1.0 + p->flyScale),
477- 1.0 / (1.0 + p->flyScale), 1.0 / (1.0 + p->flyScale));
478+ matrix.scale (1.0 / (1.0 + p->flyScale),
479+ 1.0 / (1.0 + p->flyScale), 1.0 / (1.0 + p->flyScale));
480
481 // Move by "rotation axis offset A"
482- glTranslatef (p->rotAxisOffsetA.x (), p->rotAxisOffsetA.y (),
483- p->rotAxisOffsetA.z ());
484+ matrix.translate (p->rotAxisOffsetA.x (), p->rotAxisOffsetA.y (),
485+ p->rotAxisOffsetA.z ());
486
487 // Rotate by desired angle A
488- glRotatef (p->rotAngleA, p->rotAxisA.x (), p->rotAxisA.y (),
489- p->rotAxisA.z ());
490+ matrix.rotate (p->rotAngleA, p->rotAxisA.x (), p->rotAxisA.y (),
491+ p->rotAxisA.z ());
492
493 // Move back to center from A
494- glTranslatef (-p->rotAxisOffsetA.x (), -p->rotAxisOffsetA.y (),
495- -p->rotAxisOffsetA.z ());
496+ matrix.translate (-p->rotAxisOffsetA.x (), -p->rotAxisOffsetA.y (),
497+ -p->rotAxisOffsetA.z ());
498
499
500 // Move by "rotation axis offset B"
501- glTranslatef (p->rotAxisOffsetB.x (), p->rotAxisOffsetB.y (),
502- p->rotAxisOffsetB.z ());
503+ matrix.translate (p->rotAxisOffsetB.x (), p->rotAxisOffsetB.y (),
504+ p->rotAxisOffsetB.z ());
505
506 // Rotate by desired angle B
507- glRotatef (p->rotAngleB, p->rotAxisB.x (), p->rotAxisB.y (),
508- p->rotAxisB.z ());
509+ matrix.rotate (p->rotAngleB, p->rotAxisB.x (), p->rotAxisB.y (),
510+ p->rotAxisB.z ());
511
512 // Move back to center from B
513- glTranslatef (-p->rotAxisOffsetB.x (), -p->rotAxisOffsetB.y (),
514- -p->rotAxisOffsetB.z ());
515+ matrix.translate (-p->rotAxisOffsetB.x (), -p->rotAxisOffsetB.y (),
516+ -p->rotAxisOffsetB.z ());
517 }
518
519
520
521=== modified file 'plugins/animationaddon/src/animationaddon.cpp'
522--- plugins/animationaddon/src/animationaddon.cpp 2013-05-09 13:43:07 +0000
523+++ plugins/animationaddon/src/animationaddon.cpp 2016-06-22 01:26:00 +0000
524@@ -81,7 +81,7 @@
525 #include "private.h"
526
527 class AnimAddonPluginVTable :
528- public CompPlugin::VTableForScreenAndWindow<AnimAddonScreen, AnimAddonWindow>
529+ public CompPlugin::VTableForScreenAndWindow<AnimAddonScreen, AnimAddonWindow, ANIMATIONADDON_ABI>
530 {
531 public:
532 bool init ();
533@@ -232,7 +232,7 @@
534 }
535
536 AnimAddonWindow::AnimAddonWindow (CompWindow *w) :
537- PluginClassHandler<AnimAddonWindow, CompWindow> (w),
538+ PluginClassHandler<AnimAddonWindow, CompWindow, ANIMATIONADDON_ABI> (w),
539 mWindow (w),
540 aWindow (AnimWindow::get (w))
541 {
542
543=== modified file 'plugins/animationaddon/src/dissolve.cpp'
544--- plugins/animationaddon/src/dissolve.cpp 2010-08-23 03:24:20 +0000
545+++ plugins/animationaddon/src/dissolve.cpp 2016-06-22 01:26:00 +0000
546@@ -33,7 +33,7 @@
547 float o = 0.2;
548 float factor = (4 - layer) * o;
549
550- attrib.opacity *= o / (1.0 - factor);
551+ attrib.opacity *= (o / (1.0 - factor)) * (1.0 - getDissolveSingleProgress ());
552 }
553
554 void
555@@ -62,5 +62,14 @@
556 void
557 DissolveSingleAnim::updateBB (CompOutput &output)
558 {
559- mAWindow->expandBBWithWindow ();
560+ CompRect outRect (mAWindow->mWindow->outputRect ());
561+
562+ Box windowBox =
563+ {
564+ static_cast <short int> (outRect.x () - 4),
565+ static_cast <short int> (outRect.x () + outRect.width () + 4),
566+ static_cast <short int> (outRect.y () - 4),
567+ static_cast <short int> (outRect.y () + outRect.height () + 4)
568+ };
569+ mAWindow->expandBBWithBox (windowBox);
570 }
571
572=== modified file 'plugins/animationaddon/src/particle.cpp'
573--- plugins/animationaddon/src/particle.cpp 2013-02-27 11:33:10 +0000
574+++ plugins/animationaddon/src/particle.cpp 2016-06-22 01:26:00 +0000
575@@ -81,7 +81,7 @@
576 }
577
578 void
579-ParticleSystem::draw (int offsetX, int offsetY)
580+ParticleSystem::draw (const GLMatrix &transform, int offsetX, int offsetY)
581 {
582 // TODO
583 // The part below should ideally be done in ParticleSystem constructor
584@@ -95,9 +95,8 @@
585 GL_RGBA, GL_UNSIGNED_BYTE, fireTex);
586 glBindTexture (GL_TEXTURE_2D, 0);
587
588-
589- glPushMatrix ();
590- glTranslated (offsetX - mX, offsetY - mY, 0);
591+ GLMatrix translatedMatrix (transform);
592+ //translatedMatrix.translate (offsetX - mX, offsetY - mY, 0);
593
594 glEnable (GL_BLEND);
595 if (mTex)
596@@ -105,26 +104,27 @@
597 glBindTexture (GL_TEXTURE_2D, mTex);
598 glEnable (GL_TEXTURE_2D);
599 }
600- mGScreen->setTexEnvMode (GL_MODULATE);
601
602- mVerticesCache.resize (4 * 3 * mParticles.size ());
603- mCoordsCache.resize (4 * 2 * mParticles.size ());
604- mColorsCache.resize (4 * 4 * mParticles.size ());
605+ mVerticesCache.resize (6 * 3 * mParticles.size ());
606+ mCoordsCache.resize (6 * 2 * mParticles.size ());
607+ mColorsCache.resize (6 * 4 * mParticles.size ());
608 if (mDarkenAmount > 0)
609- mDColorsCache.resize (4 * 4 * mParticles.size ());
610+ mDColorsCache.resize (6 * 4 * mParticles.size ());
611
612- GLfloat *dcolors = &mDColorsCache[0];
613+ GLushort *dcolors = &mDColorsCache[0];
614 GLfloat *vertices = &mVerticesCache[0];
615 GLfloat *coords = &mCoordsCache[0];
616- GLfloat *colors = &mColorsCache[0];
617+ GLushort *colors = &mColorsCache[0];
618
619- int cornersSize = sizeof (GLfloat) * 8;
620+ int cornersSize = sizeof (GLfloat) * 12;
621 int colorSize = sizeof (GLfloat) * 4;
622
623- GLfloat cornerCoords[8] = {0.0, 0.0,
624+ GLfloat cornerCoords[12] = {0.0, 0.0,
625 0.0, 1.0,
626 1.0, 1.0,
627- 1.0, 0.0};
628+ 1.0, 1.0,
629+ 1.0, 0.0,
630+ 0.0, 0.0};
631
632 int numActive = 0;
633
634@@ -133,7 +133,7 @@
635 if (part.life <= 0.0f) // Ignore dead particles
636 continue;
637
638- numActive += 4;
639+ numActive += 6;
640
641 float w = part.width / 2;
642 float h = part.height / 2;
643@@ -154,24 +154,34 @@
644 vertices[8] = part.z;
645
646 vertices[9] = part.x + w;
647- vertices[10] = part.y - h;
648+ vertices[10] = part.y + h;
649 vertices[11] = part.z;
650
651- vertices += 12;
652+ vertices[12] = part.x + w;
653+ vertices[13] = part.y - h;
654+ vertices[14] = part.z;
655+
656+ vertices[15] = part.x - w;
657+ vertices[16] = part.y - h;
658+ vertices[17] = part.z;
659+
660+ vertices += 18;
661
662 memcpy (coords, cornerCoords, cornersSize);
663
664- coords += 8;
665+ coords += 12;
666
667- colors[0] = part.r;
668- colors[1] = part.g;
669- colors[2] = part.b;
670- colors[3] = part.life * part.a;
671+ colors[0] = part.r * COLOR;
672+ colors[1] = part.g * COLOR;
673+ colors[2] = part.b * COLOR;
674+ colors[3] = part.life * part.a * COLOR;
675 memcpy (colors + 4, colors, colorSize);
676 memcpy (colors + 8, colors, colorSize);
677 memcpy (colors + 12, colors, colorSize);
678+ memcpy (colors + 16, colors, colorSize);
679+ memcpy (colors + 20, colors, colorSize);
680
681- colors += 16;
682+ colors += 24;
683
684 if (mDarkenAmount > 0)
685 {
686@@ -182,34 +192,35 @@
687 memcpy (dcolors + 4, dcolors, colorSize);
688 memcpy (dcolors + 8, dcolors, colorSize);
689 memcpy (dcolors + 12, dcolors, colorSize);
690+ memcpy (dcolors + 16, dcolors, colorSize);
691+ memcpy (dcolors + 20, dcolors, colorSize);
692
693- dcolors += 16;
694+ dcolors += 24;
695 }
696 }
697
698- glEnableClientState (GL_COLOR_ARRAY);
699-
700- glTexCoordPointer (2, GL_FLOAT, 2 * sizeof (GLfloat), &mCoordsCache[0]);
701- glVertexPointer (3, GL_FLOAT, 3 * sizeof (GLfloat), &mVerticesCache[0]);
702+ GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer ();
703
704 // darken the background
705 if (mDarkenAmount > 0)
706 {
707 glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
708- glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), &mDColorsCache[0]);
709- glDrawArrays (GL_QUADS, 0, numActive);
710+ stream->begin (GL_TRIANGLES);
711+ stream->addTexCoords (0, numActive, &mCoordsCache[0]);
712+ stream->addVertices (numActive, &mVerticesCache[0]);
713+ stream->addColors (numActive, &mDColorsCache[0]);
714+ if (stream->end ())
715+ stream->render (translatedMatrix);
716 }
717 // draw particles
718 glBlendFunc (GL_SRC_ALPHA, mBlendMode);
719
720- glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), &mColorsCache[0]);
721- glDrawArrays (GL_QUADS, 0, numActive);
722- glDisableClientState (GL_COLOR_ARRAY);
723-
724- glPopMatrix ();
725- glColor4usv (defaultColor);
726-
727- mGScreen->setTexEnvMode (GL_REPLACE);
728+ stream->begin (GL_TRIANGLES);
729+ stream->addTexCoords (0, numActive, &mCoordsCache[0]);
730+ stream->addVertices (numActive, &mVerticesCache[0]);
731+ stream->addColors (numActive, &mColorsCache[0]);
732+ if (stream->end ())
733+ stream->render (translatedMatrix);
734
735 glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
736 glDisable (GL_TEXTURE_2D);
737@@ -217,12 +228,13 @@
738 }
739
740 void
741-ParticleAnim::postPaintWindow ()
742+ParticleAnim::postPaintWindow (const GLMatrix &transform)
743 {
744 foreach (ParticleSystem &ps, mParticleSystems)
745 if (ps.active ())
746 // offset by window pos.
747- ps.draw (mWindow->x () - mWindow->output ().left,
748+ ps.draw (transform,
749+ mWindow->x () - mWindow->output ().left,
750 mWindow->y () - mWindow->output ().top);
751 }
752
753
754=== modified file 'plugins/animationaddon/src/polygon.cpp'
755--- plugins/animationaddon/src/polygon.cpp 2013-02-27 11:33:10 +0000
756+++ plugins/animationaddon/src/polygon.cpp 2016-06-22 01:26:00 +0000
757@@ -34,7 +34,6 @@
758 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
759 */
760
761-#include <GL/glu.h>
762 #include "private.h"
763
764 static const unsigned short MIN_WINDOW_GRID_SIZE = 10;
765@@ -256,8 +255,8 @@
766 pv[22] = -halfH;
767 pv[23] = -halfThick;
768
769- // 16 indices for 4 sides (for quads)
770- p->sideIndices = (GLushort *)calloc (4 * 4, sizeof (GLushort));
771+ // 24 indices for 4 sides (for triangles)
772+ p->sideIndices = (GLushort *)calloc (6 * 4, sizeof (GLushort));
773 if (!p->sideIndices)
774 {
775 compLogMessage ("animationaddon", CompLogLevelError,
776@@ -275,6 +274,8 @@
777 ind[id++] = 6; // First vertex
778 ind[id++] = 1;
779 ind[id++] = 0;
780+ ind[id++] = 6;
781+ ind[id++] = 0;
782 ind[id++] = 7;
783 nor[6 * 3 + 0] = -1; // Flat shading only uses 1st vertex's normal
784 nor[6 * 3 + 1] = 0; // in a polygon, vertex 6 for this face.
785@@ -284,16 +285,20 @@
786 ind[id++] = 1;
787 ind[id++] = 6;
788 ind[id++] = 5;
789+ ind[id++] = 5;
790 ind[id++] = 2;
791+ ind[id++] = 1;
792 nor[1 * 3 + 0] = 0;
793 nor[1 * 3 + 1] = 1;
794 nor[1 * 3 + 2] = 0;
795
796 // Right face
797+ ind[id++] = 5;
798 ind[id++] = 2;
799+ ind[id++] = 3;
800 ind[id++] = 5;
801+ ind[id++] = 3;
802 ind[id++] = 4;
803- ind[id++] = 3;
804 nor[2 * 3 + 0] = 1;
805 nor[2 * 3 + 1] = 0;
806 nor[2 * 3 + 2] = 0;
807@@ -302,7 +307,9 @@
808 ind[id++] = 7;
809 ind[id++] = 0;
810 ind[id++] = 3;
811+ ind[id++] = 3;
812 ind[id++] = 4;
813+ ind[id++] = 7;
814 nor[7 * 3 + 0] = 0;
815 nor[7 * 3 + 1] = -1;
816 nor[7 * 3 + 2] = 0;
817@@ -541,8 +548,8 @@
818 pv[34] = topY;
819 pv[35] = -halfThick;
820
821- // 24 indices per 6 sides (for quads)
822- p->sideIndices = (GLushort *)calloc (4 * 6, sizeof (GLushort));
823+ // 36 indices per 6 sides (for triangles)
824+ p->sideIndices = (GLushort *)calloc (6 * 6, sizeof (GLushort));
825 if (!p->sideIndices)
826 {
827 compLogMessage ("animationaddon", CompLogLevelError,
828@@ -562,7 +569,9 @@
829 ind[id++] = 11; // First vertex
830 ind[id++] = 10;
831 ind[id++] = 1;
832+ ind[id++] = 1;
833 ind[id++] = 0;
834+ ind[id++] = 11;
835 nor[11 * 3 + 0] = -1; // Flat shading only uses 1st vertex's normal
836 nor[11 * 3 + 1] = -1; // in a polygon, vertex 11 for this face.
837 nor[11 * 3 + 2] = 0;
838@@ -573,7 +582,9 @@
839 ind[id++] = 1;
840 ind[id++] = 10;
841 ind[id++] = 9;
842+ ind[id++] = 9;
843 ind[id++] = 2;
844+ ind[id++] = 1;
845 nor[1 * 3 + 0] = -1;
846 nor[1 * 3 + 1] = 0;
847 nor[1 * 3 + 2] = 0;
848@@ -582,7 +593,9 @@
849 ind[id++] = 2;
850 ind[id++] = 9;
851 ind[id++] = 8;
852+ ind[id++] = 8;
853 ind[id++] = 3;
854+ ind[id++] = 2;
855 nor[2 * 3 + 0] = -1;
856 nor[2 * 3 + 1] = 1;
857 nor[2 * 3 + 2] = 0;
858@@ -593,7 +606,9 @@
859 ind[id++] = 3;
860 ind[id++] = 8;
861 ind[id++] = 7;
862+ ind[id++] = 7;
863 ind[id++] = 4;
864+ ind[id++] = 3;
865 nor[3 * 3 + 0] = 1;
866 nor[3 * 3 + 1] = 1;
867 nor[3 * 3 + 2] = 0;
868@@ -604,7 +619,9 @@
869 ind[id++] = 4;
870 ind[id++] = 7;
871 ind[id++] = 6;
872+ ind[id++] = 6;
873 ind[id++] = 5;
874+ ind[id++] = 4;
875 nor[4 * 3 + 0] = 1;
876 nor[4 * 3 + 1] = 0;
877 nor[4 * 3 + 2] = 0;
878@@ -613,7 +630,9 @@
879 ind[id++] = 5;
880 ind[id++] = 6;
881 ind[id++] = 11;
882+ ind[id++] = 11;
883 ind[id++] = 0;
884+ ind[id++] = 5;
885 nor[5 * 3 + 0] = 1;
886 nor[5 * 3 + 1] = -1;
887 nor[5 * 3 + 2] = 0;
888@@ -946,8 +965,8 @@
889 pv[22] = -shards[yc][xc].centerY + shards[yc][xc].pt3Y;
890 pv[23] = -halfThick;
891
892- // 16 indices for 4 sides (for quads)
893- p->sideIndices = (GLushort *)calloc (4 * 4, sizeof (GLushort));
894+ // 24 indices for 4 sides (for triangles)
895+ p->sideIndices = (GLushort *)calloc (6 * 4, sizeof (GLushort));
896 if (!p->sideIndices)
897 {
898 compLogMessage ("animationaddon",
899@@ -965,7 +984,9 @@
900 ind[id++] = 6; // First vertex
901 ind[id++] = 1;
902 ind[id++] = 0;
903+ ind[id++] = 6;
904 ind[id++] = 7;
905+ ind[id++] = 0;
906 nor[6 * 3 + 0] = -1; // Flat shading only uses 1st vertex's normal
907 nor[6 * 3 + 1] = 0; // in a polygon, vertex 6 for this face.
908 nor[6 * 3 + 2] = 0;
909@@ -974,7 +995,9 @@
910 ind[id++] = 1;
911 ind[id++] = 6;
912 ind[id++] = 5;
913+ ind[id++] = 1;
914 ind[id++] = 2;
915+ ind[id++] = 5;
916 nor[1 * 3 + 0] = 0;
917 nor[1 * 3 + 1] = 1;
918 nor[1 * 3 + 2] = 0;
919@@ -983,7 +1006,9 @@
920 ind[id++] = 2;
921 ind[id++] = 5;
922 ind[id++] = 4;
923+ ind[id++] = 2;
924 ind[id++] = 3;
925+ ind[id++] = 4;
926 nor[2 * 3 + 0] = 1;
927 nor[2 * 3 + 1] = 0;
928 nor[2 * 3 + 2] = 0;
929@@ -992,7 +1017,9 @@
930 ind[id++] = 7;
931 ind[id++] = 0;
932 ind[id++] = 3;
933+ ind[id++] = 7;
934 ind[id++] = 4;
935+ ind[id++] = 3;
936 nor[7 * 3 + 0] = 0;
937 nor[7 * 3 + 1] = -1;
938 nor[7 * 3 + 2] = 0;
939@@ -1067,8 +1094,11 @@
940 if (!matrix.size ())
941 return;
942
943- GLWindow::Geometry &geometry = GLWindow::get (mWindow)->geometry ();
944- geometry.vCount = 1; // Force glDrawGeometry to be called
945+ /* Force glDrawTexture to be called by pushing a single vertex into the
946+ * window's vertex buffer */
947+ GLWindow *gWindow = GLWindow::get (mWindow);
948+ GLfloat vertexData[3] = {0.0f, 0.0f, 0.0f};
949+ gWindow->vertexBuffer ()->addVertices (1, vertexData);
950
951 bool dontStoreClips = true;
952
953@@ -1298,56 +1328,62 @@
954 }
955
956 void
957-PolygonAnim::prepareDrawingForAttrib (GLFragment::Attrib &attrib)
958-{
959- if (GL::canDoSaturated && attrib.getSaturation () != COLOR)
960- {
961- GLfloat constant[4];
962-
963- if (GL::canDoSlightlySaturated && attrib.getSaturation () > 0)
964- {
965- constant[3] = attrib.getOpacity () / 65535.0f;
966- constant[0] = constant[1] = constant[2] = constant[3] *
967- attrib.getBrightness () / 65535.0f;
968-
969- glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
970- }
971- else
972- {
973- constant[3] = attrib.getOpacity () / 65535.0f;
974- constant[0] = constant[1] = constant[2] = constant[3] *
975- attrib.getBrightness () / 65535.0f;
976-
977- constant[0] = 0.5f + 0.5f * RED_SATURATION_WEIGHT * constant[0];
978- constant[1] = 0.5f + 0.5f * GREEN_SATURATION_WEIGHT * constant[1];
979- constant[2] = 0.5f + 0.5f * BLUE_SATURATION_WEIGHT * constant[2];
980-
981- glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
982- }
983- }
984- else
985- {
986- attrib.setBrightness (0.76 * attrib.getBrightness ());
987-
988- GLushort color =
989- (attrib.getOpacity () * attrib.getBrightness ()) >> 16;
990-
991- mGScreen->setTexEnvMode (GL_MODULATE);
992- glColor4us (color, color, color, attrib.getOpacity ());
993+PolygonAnim::prepareDrawingForAttrib (GLWindowPaintAttrib &attrib,
994+ GLVertexBuffer &vertexBuffer)
995+{
996+ // Disabled for now until lighting can be re-written
997+ // attrib.brightness *= 0.76;
998+ GLushort color = (attrib.brightness * attrib.opacity) >> 16;
999+ GLfloat colorNormalized = color / static_cast <GLfloat> (COLOR);
1000+
1001+ vertexBuffer.color4f (colorNormalized,
1002+ colorNormalized,
1003+ colorNormalized,
1004+ attrib.opacity / static_cast <GLfloat> (COLOR));
1005+}
1006+
1007+namespace
1008+{
1009+ enum class Winding : int
1010+ {
1011+ Clockwise = 0,
1012+ Counterclockwise = 1
1013+ };
1014+
1015+ /* This function assumes that indices is large enough to
1016+ * hold a polygon of nSides sides */
1017+ unsigned int determineIndicesForPolygon (GLushort *indices,
1018+ GLushort nSides,
1019+ Winding direction)
1020+ {
1021+ unsigned int index = 0;
1022+ bool front = direction == Winding::Counterclockwise;
1023+
1024+ for (GLushort i = 2; i < nSides; ++i)
1025+ {
1026+ indices[index] = 0;
1027+ indices[index + 1] = (front ? (i - 1) : i);
1028+ indices[index + 2] = (front ? i : (i - 1));
1029+
1030+ index += 3;
1031+ }
1032+
1033+ return index;
1034 }
1035 }
1036
1037 inline void
1038-PolygonAnim::drawPolygonClipIntersection (const PolygonObject *p,
1039+PolygonAnim::drawPolygonClipIntersection (GLTexture *texture,
1040+ const GLMatrix &transform,
1041+ const PolygonObject *p,
1042 const Clip4Polygons &c,
1043 const GLfloat *vertexTexCoords,
1044 int pass,
1045 float forwardProgress,
1046- GLdouble clipPlanes[4][4],
1047 const CompOutput &output,
1048 float newOpacity,
1049 bool decelerates,
1050- GLfloat skewMat[16])
1051+ GLMatrix &skewMat)
1052 {
1053 int nSides = p->nSides;
1054 float newOpacityPolygon = newOpacity;
1055@@ -1386,52 +1422,56 @@
1056 else if (newOpacityPolygon > 0.9999) // if fully opaque
1057 return; // draw only non-opaque ones in pass 1
1058
1059- glPushMatrix ();
1060+ GLMatrix polygonTransform (transform);
1061
1062 if (mCorrectPerspective == CorrectPerspectivePolygon)
1063- getPerspectiveCorrectionMat (p, skewMat, NULL, output);
1064+ getPerspectiveCorrectionMat (p, NULL, &skewMat, output);
1065
1066 if (mCorrectPerspective != CorrectPerspectiveNone)
1067- glMultMatrixf (skewMat);
1068+ polygonTransform *= skewMat;
1069
1070 // Center
1071- glTranslatef (p->centerPos.x (),
1072- p->centerPos.y (),
1073- p->centerPos.z ());
1074+ polygonTransform.translate (p->centerPos.x (),
1075+ p->centerPos.y (),
1076+ p->centerPos.z ());
1077
1078 // Scale z first
1079- glScalef (1.0f, 1.0f, 1.0f / ::screen->width ());
1080+ polygonTransform.scale (1.0f, 1.0f, 1.0f / ::screen->width ());
1081
1082- transformPolygon (p);
1083+ transformPolygon (polygonTransform, p);
1084
1085 // Move by "rotation axis offset"
1086- glTranslatef (p->rotAxisOffset.x (),
1087- p->rotAxisOffset.y (),
1088- p->rotAxisOffset.z ());
1089+ polygonTransform.translate (p->rotAxisOffset.x (),
1090+ p->rotAxisOffset.y (),
1091+ p->rotAxisOffset.z ());
1092
1093 // Rotate by desired angle
1094- glRotatef (p->rotAngle,
1095- p->rotAxis.x (), p->rotAxis.y (), p->rotAxis.z ());
1096+ polygonTransform.rotate (p->rotAngle,
1097+ p->rotAxis.x (),
1098+ p->rotAxis.y (),
1099+ p->rotAxis.z ());
1100
1101 // Move back to center
1102- glTranslatef (-p->rotAxisOffset.x (),
1103- -p->rotAxisOffset.y (),
1104- -p->rotAxisOffset.z ());
1105+ polygonTransform.translate (-p->rotAxisOffset.x (),
1106+ -p->rotAxisOffset.y (),
1107+ -p->rotAxisOffset.z ());
1108
1109 // Scale back
1110- glScalef (1.0f, 1.0f, ::screen->width ());
1111-
1112- clipPlanes[0][3] = -(c.boxf.x1 - p->centerPosStart.x ());
1113- clipPlanes[1][3] = -(c.boxf.y1 - p->centerPosStart.y ());
1114- clipPlanes[2][3] = (c.boxf.x2 - p->centerPosStart.x ());
1115- clipPlanes[3][3] = (c.boxf.y2 - p->centerPosStart.y ());
1116- glClipPlane (GL_CLIP_PLANE0, clipPlanes[0]);
1117- glClipPlane (GL_CLIP_PLANE1, clipPlanes[1]);
1118- glClipPlane (GL_CLIP_PLANE2, clipPlanes[2]);
1119- glClipPlane (GL_CLIP_PLANE3, clipPlanes[3]);
1120-
1121- for (int k = 0; k < 4; k++)
1122- glEnable (GL_CLIP_PLANE0 + k);
1123+ polygonTransform.scale (1.0f, 1.0f, ::screen->width ());
1124+
1125+ // clipPlanes[0][3] = -(c.boxf.x1 - p->centerPosStart.x ());
1126+ // clipPlanes[1][3] = -(c.boxf.y1 - p->centerPosStart.y ());
1127+ // clipPlanes[2][3] = (c.boxf.x2 - p->centerPosStart.x ());
1128+ // clipPlanes[3][3] = (c.boxf.y2 - p->centerPosStart.y ());
1129+ // Clip planes are not supported on Modern OpenGL
1130+ //
1131+ // glClipPlane (GL_CLIP_PLANE0, clipPlanes[0]);
1132+ // glClipPlane (GL_CLIP_PLANE1, clipPlanes[1]);
1133+ // glClipPlane (GL_CLIP_PLANE2, clipPlanes[2]);
1134+ // glClipPlane (GL_CLIP_PLANE3, clipPlanes[3]);
1135+ // for (int k = 0; k < 4; k++)
1136+ // glEnable (GL_CLIP_PLANE0 + k);
1137+
1138 bool fadeBackAndSides =
1139 mBackAndSidesFadeDur > 0 &&
1140 forwardProgress <= mBackAndSidesFadeDur;
1141@@ -1445,56 +1485,92 @@
1142 (forwardProgress / mBackAndSidesFadeDur);
1143 }
1144
1145- GLFragment::Attrib attrib = mCurPaintAttrib;
1146- attrib.setOpacity (newOpacityPolygon2 * OPAQUE);
1147+ GLWindowPaintAttrib attrib = mCurPaintAttrib;
1148+ attrib.opacity = newOpacityPolygon2 * OPAQUE;
1149
1150- prepareDrawingForAttrib (attrib);
1151+ GLVertexBuffer *streamingVertexBuffer = GLVertexBuffer::streamingBuffer ();
1152
1153 // Draw back face
1154- glVertexPointer (3, GL_FLOAT, 0, p->vertices + 3 * nSides);
1155- if (mThickness > 0)
1156- glNormalPointer (GL_FLOAT, 0, p->normals + 3 * nSides);
1157- else
1158- glNormal3f (0.0f, 0.0f, -1.0f);
1159- glTexCoordPointer (2, GL_FLOAT, 0, &vertexTexCoords[2 * nSides]);
1160- glDrawArrays (GL_POLYGON, 0, nSides);
1161+ glActiveTexture (GL_TEXTURE0);
1162+ texture->enable (GLTexture::Fast);
1163+ streamingVertexBuffer->begin (GL_TRIANGLES);
1164+ streamingVertexBuffer->addVertices (nSides, p->vertices + 3 * nSides);
1165+ if (p->normals)
1166+ streamingVertexBuffer->addNormals (nSides, p->normals + 3 * nSides);
1167+ streamingVertexBuffer->addTexCoords (0, nSides, &vertexTexCoords[2 * nSides]);
1168+ if (streamingVertexBuffer->end ())
1169+ {
1170+ GLushort indices[64];
1171+ unsigned int nIndices = determineIndicesForPolygon (indices,
1172+ nSides,
1173+ Winding::Counterclockwise);
1174+ streamingVertexBuffer->render (polygonTransform,
1175+ attrib,
1176+ indices,
1177+ nIndices);
1178+ }
1179
1180- // Vertex coords
1181- glVertexPointer (3, GL_FLOAT, 0, p->vertices);
1182- if (mThickness > 0)
1183- glNormalPointer (GL_FLOAT, 0, p->normals);
1184- else
1185- glNormal3f (0.0f, 0.0f, 1.0f);
1186- glTexCoordPointer (2, GL_FLOAT, 0, vertexTexCoords);
1187+ // GL_QUADS uses a different vertex normal than the first
1188+ // so I use GL_TRIANGLES to make sure the normals are right.
1189+ texture->disable ();
1190+ streamingVertexBuffer->begin (GL_TRIANGLES);
1191+ streamingVertexBuffer->addVertices (p->nVertices, p->vertices);
1192+ prepareDrawingForAttrib (attrib, *streamingVertexBuffer);
1193+ if (mThickness > 0 && p->normals)
1194+ streamingVertexBuffer->addNormals (nSides, p->normals);
1195
1196 // Draw quads for sides
1197- for (int k = 0; k < nSides; k++)
1198+ if (streamingVertexBuffer->end ())
1199 {
1200- // GL_QUADS uses a different vertex normal than the first
1201- // so I use GL_POLYGON to make sure the normals are right.
1202- glDrawElements (GL_POLYGON, 4,
1203- GL_UNSIGNED_SHORT,
1204- p->sideIndices + k * 4);
1205+ for (int k = 0; k < nSides; k++)
1206+ streamingVertexBuffer->render (polygonTransform,
1207+ attrib,
1208+ p->sideIndices + k * 6,
1209+ 6);
1210 }
1211
1212+ streamingVertexBuffer->colorDefault ();
1213+
1214+ texture->enable (GLTexture::Fast);
1215+ streamingVertexBuffer->begin (GL_TRIANGLES);
1216 // if opacity was changed just above
1217 if (fadeBackAndSides)
1218 {
1219 // Go back to normal opacity for front face
1220 attrib = mCurPaintAttrib;
1221- attrib.setOpacity (newOpacityPolygon * OPAQUE);
1222- prepareDrawingForAttrib (attrib);
1223- }
1224- // Draw front face
1225- glDrawArrays (GL_POLYGON, 0, nSides);
1226- for (int k = 0; k < 4; k++)
1227- glDisable (GL_CLIP_PLANE0 + k);
1228-
1229- glPopMatrix ();
1230+ attrib.opacity = newOpacityPolygon * OPAQUE;
1231+ }
1232+ streamingVertexBuffer->addVertices (nSides, p->vertices);
1233+ if (p->normals)
1234+ streamingVertexBuffer->addNormals (nSides, p->normals);
1235+ streamingVertexBuffer->addTexCoords (0, nSides, vertexTexCoords);
1236+ if (streamingVertexBuffer->end ())
1237+ {
1238+ GLushort indices[64];
1239+ unsigned int nIndices = determineIndicesForPolygon (indices,
1240+ nSides,
1241+ Winding::Counterclockwise);
1242+ streamingVertexBuffer->render (polygonTransform,
1243+ attrib,
1244+ indices,
1245+ nIndices);
1246+ }
1247+
1248+ streamingVertexBuffer->colorDefault ();
1249+
1250+ texture->disable ();
1251+
1252+ // Clip planes are not supported on Modern OpenGL
1253+ //
1254+ // for (int k = 0; k < 4; k++)
1255+ // glDisable (GL_CLIP_PLANE0 + k);
1256 }
1257
1258 void
1259-PolygonAnim::drawGeometry ()
1260+PolygonAnim::drawGeometry (GLTexture *texture,
1261+ const GLMatrix &transform,
1262+ const GLWindowPaintAttrib &attrib,
1263+ unsigned int mask)
1264 {
1265 mNumDrawGeometryCalls++;
1266
1267@@ -1540,96 +1616,52 @@
1268
1269 // OpenGL stuff starts here
1270
1271- GLboolean normalArrayWas = false;
1272-
1273- if (mThickness > 0)
1274- {
1275- glPushAttrib (GL_NORMALIZE);
1276- glEnable (GL_NORMALIZE);
1277-
1278- normalArrayWas = glIsEnabled (GL_NORMAL_ARRAY);
1279- glEnableClientState (GL_NORMAL_ARRAY);
1280- }
1281-
1282- if (mDoLighting)
1283- {
1284- glPushAttrib (GL_SHADE_MODEL);
1285- glShadeModel (GL_FLAT);
1286-
1287- glPushAttrib (GL_LIGHT0);
1288- glPushAttrib (GL_COLOR_MATERIAL);
1289- glPushAttrib (GL_LIGHTING);
1290- glEnable (GL_COLOR_MATERIAL);
1291- glEnable (GL_LIGHTING);
1292-
1293- GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 0.3f };
1294- GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };
1295- GLfloat light0Position[] = { -0.5f, 0.5f, 9.0f, 0.0f };
1296-
1297- glLightfv (GL_LIGHT0, GL_AMBIENT, ambientLight);
1298- glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuseLight);
1299- glLightfv (GL_LIGHT0, GL_POSITION, light0Position);
1300- }
1301-
1302- glPushMatrix ();
1303-
1304- glPushAttrib (GL_STENCIL_BUFFER_BIT);
1305- glDisable (GL_STENCIL_TEST);
1306+ // Lighting will require special shaders, which aren't
1307+ // implemented right now, so disable it.
1308+ //
1309+ // if (mDoLighting)
1310+ // {
1311+ // glPushAttrib (GL_SHADE_MODEL);
1312+ // glShadeModel (GL_FLAT);
1313+ //
1314+ // glPushAttrib (GL_LIGHT0);
1315+ // glPushAttrib (GL_COLOR_MATERIAL);
1316+ // glPushAttrib (GL_LIGHTING);
1317+ // glEnable (GL_COLOR_MATERIAL);
1318+ // glEnable (GL_LIGHTING);
1319+ //
1320+ // GLfloat ambientLight[] = { 0.3f, 0.3f, 0.3f, 0.3f };
1321+ // GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };
1322+ // GLfloat light0Position[] = { -0.5f, 0.5f, 9.0f, 0.0f };
1323+ //
1324+ // glLightfv (GL_LIGHT0, GL_AMBIENT, ambientLight);
1325+ // glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuseLight);
1326+ // glLightfv (GL_LIGHT0, GL_POSITION, light0Position);
1327+ // }
1328
1329 if (mDoDepthTest)
1330 {
1331 // Depth test
1332- glPushAttrib (GL_DEPTH_FUNC);
1333- glPushAttrib (GL_DEPTH_TEST);
1334 glDepthFunc (GL_LEQUAL);
1335+ glDepthMask (GL_TRUE);
1336 glEnable (GL_DEPTH_TEST);
1337 }
1338
1339 // Clip planes
1340- GLdouble clipPlanes[4][4] = {{ 1, 0, 0, 0 },
1341- { 0, 1, 0, 0 },
1342- { -1, 0, 0, 0 },
1343- { 0, -1, 0, 0 }};
1344-
1345- // Save old color values
1346- GLfloat oldColor[4];
1347-
1348- glGetFloatv (GL_CURRENT_COLOR, oldColor);
1349-
1350- // Determine where we are called from in paint.c's drawWindowTexture
1351- // to find out how we should change the opacity
1352- GLint prevActiveTexture = GL_TEXTURE0_ARB;
1353- bool saturationFull = true;
1354-
1355- if (GL::canDoSaturated && mCurPaintAttrib.getSaturation () != COLOR)
1356- {
1357- saturationFull = false;
1358- if (GL::canDoSlightlySaturated &&
1359- mCurPaintAttrib.getSaturation () > 0)
1360- {
1361- if (mCurPaintAttrib.getOpacity () < OPAQUE ||
1362- mCurPaintAttrib.getBrightness () != BRIGHT)
1363- prevActiveTexture = GL_TEXTURE3_ARB;
1364- else
1365- prevActiveTexture = GL_TEXTURE2_ARB;
1366- }
1367- else
1368- prevActiveTexture = GL_TEXTURE1_ARB;
1369- }
1370-
1371- float opacity = mCurPaintAttrib.getOpacity () / 65535.0;
1372+ // GLdouble clipPlanes[4][4] = {{ 1, 0, 0, 0 },
1373+ // { 0, 1, 0, 0 },
1374+ // { -1, 0, 0, 0 },
1375+ // { 0, -1, 0, 0 }};
1376+
1377+ float opacity = mCurPaintAttrib.opacity / 65535.0;
1378
1379 float newOpacity = opacity;
1380 float fadePassedBy;
1381
1382 bool decelerates = deceleratingMotion ();
1383
1384- glPushAttrib (GL_BLEND);
1385 glEnable (GL_BLEND);
1386
1387- if (saturationFull)
1388- mGScreen->setTexEnvMode (GL_MODULATE);
1389-
1390 // if fade-out duration is not specified per polygon
1391 if (mAllFadeDuration > -1.0f)
1392 {
1393@@ -1657,9 +1689,9 @@
1394 static_cast<ExtensionPluginAnimAddon*> (getExtensionPluginInfo ())->
1395 output ();
1396
1397- GLfloat skewMat[16];
1398+ GLMatrix skewMat;
1399 if (mCorrectPerspective == CorrectPerspectiveWindow)
1400- getPerspectiveCorrectionMat (NULL, skewMat, NULL, *output);
1401+ getPerspectiveCorrectionMat (NULL, NULL, &skewMat, *output);
1402
1403 // pass: 0: draw opaque ones
1404 // 1: draw transparent ones
1405@@ -1673,10 +1705,12 @@
1406 const GLfloat *vTexCoords = &c->polygonVertexTexCoords[0];
1407 foreach (const PolygonObject *p, mPolygons)
1408 {
1409- drawPolygonClipIntersection (p, *c,
1410+ drawPolygonClipIntersection (texture,
1411+ transform,
1412+ p, *c,
1413 vTexCoords,
1414 pass, forwardProgress,
1415- clipPlanes, *output,
1416+ *output,
1417 newOpacity,
1418 decelerates,
1419 skewMat);
1420@@ -1688,10 +1722,12 @@
1421 foreach (const PolygonClipInfo *pci,
1422 c->intersectingPolygonInfos)
1423 {
1424- drawPolygonClipIntersection (pci->p, *c,
1425+ drawPolygonClipIntersection (texture,
1426+ transform,
1427+ pci->p, *c,
1428 &pci->vertexTexCoords[0],
1429 pass, forwardProgress,
1430- clipPlanes, *output,
1431+ *output,
1432 newOpacity,
1433 decelerates,
1434 skewMat);
1435@@ -1702,45 +1738,24 @@
1436 // Restore
1437 // -----------------------------------------
1438
1439- // Restore old color values
1440- glColor4f (oldColor[0], oldColor[1], oldColor[2], oldColor[3]);
1441-
1442- glPopAttrib (); // GL_BLEND
1443+ glDisable (GL_BLEND);
1444
1445 if (mDoDepthTest)
1446 {
1447- glPopAttrib (); // GL_DEPTH_TEST
1448- glPopAttrib (); // GL_DEPTH_FUNC
1449- }
1450-
1451- glPopAttrib (); // GL_STENCIL_BUFFER_BIT
1452-
1453- // Restore texture stuff
1454- if (saturationFull)
1455- mGScreen->setTexEnvMode (GL_REPLACE);
1456-
1457- glPopMatrix ();
1458- (GL::activeTexture) (prevActiveTexture);
1459-
1460- if (mDoLighting)
1461- {
1462- glPopAttrib (); // GL_LIGHTING
1463- glPopAttrib (); // GL_COLOR_MATERIAL
1464- glPopAttrib (); // GL_LIGHT0
1465- glPopAttrib (); // GL_SHADE_MODEL
1466- }
1467-
1468- if (mThickness > 0)
1469- {
1470- glPopAttrib (); // GL_NORMALIZE
1471-
1472- if (normalArrayWas)
1473- glEnableClientState (GL_NORMAL_ARRAY);
1474- else
1475- glDisableClientState (GL_NORMAL_ARRAY);
1476- }
1477- else
1478- glNormal3f (0.0f, 0.0f, -1.0f);
1479+ glDisable (GL_DEPTH_TEST);
1480+ glDepthMask (GL_FALSE);
1481+ }
1482+
1483+ // Lighting will require special shaders whcih
1484+ // are not implemented for now.
1485+ //
1486+ // if (mDoLighting)
1487+ // {
1488+ // glPopAttrib (); // GL_LIGHTING
1489+ // glPopAttrib (); // GL_COLOR_MATERIAL
1490+ // glPopAttrib (); // GL_LIGHT0
1491+ // glPopAttrib (); // GL_SHADE_MODEL
1492+ // }
1493
1494 if (mClipsUpdated) // set the end mark for this group of clips
1495 mLastClipInGroup.push_back (lastClip);
1496@@ -1760,7 +1775,7 @@
1497 }
1498
1499 void
1500-PolygonAnim::postPaintWindow ()
1501+PolygonAnim::postPaintWindow (const GLMatrix &)
1502 {
1503 if (mClipsUpdated && // clips should be dropped only in the 1st step
1504 mNumDrawGeometryCalls == 0) // if clips not drawn
1505@@ -1842,20 +1857,7 @@
1506
1507 prepareTransform (output, wTransform, wTransform2);
1508
1509- const float *screenProjection = gScreen->projectionMatrix ();
1510- GLdouble dModel[16];
1511- GLdouble dProjection[16];
1512- for (int i = 0; i < 16; i++)
1513- {
1514- dProjection[i] = screenProjection[i];
1515- }
1516- GLint viewport[4] =
1517- {output.region ()->extents.x1,
1518- output.region ()->extents.y1,
1519- output.width (),
1520- output.height ()};
1521- GLdouble px, py, pz;
1522-
1523+ GLMatrix *screenProjection = gScreen->projectionMatrix ();
1524 GLMatrix *modelViewTransform = &wTransform;
1525
1526 GLMatrix skewMat;
1527@@ -1878,9 +1880,6 @@
1528
1529 // if modelViewTransform == wTransform2, then
1530 // it changes for each polygon
1531- const float *modelViewMatrix = modelViewTransform->getMatrix ();
1532- for (int j = 0; j < 16; j++)
1533- dModel[j] = modelViewMatrix[j];
1534
1535 Point3d center = p->centerPos;
1536 float radius = p->boundSphereRadius + 2;
1537@@ -1924,13 +1923,16 @@
1538 Point3d *pnt = cubeCorners;
1539 for (int j = 0; j < N_POINTS; j++, pnt++)
1540 {
1541- if (!gluProject (pnt->x (), pnt->y (), pnt->z (),
1542- dModel, dProjection, viewport,
1543- &px, &py, &pz))
1544- return;
1545+ namespace com = compiz::opengl::matrix;
1546+ CompPoint p (com::projectIntoViewport(*screenProjection,
1547+ *modelViewTransform,
1548+ output,
1549+ GLVector (pnt->x (),
1550+ pnt->y (),
1551+ pnt->z ())));
1552
1553- py = ::screen->height () - py;
1554- mAWindow->expandBBWithPoint (px + 0.5, py + 0.5);
1555+ p.setY (::screen->height () - p.y ());
1556+ mAWindow->expandBBWithPoint (p.x () + 0.5, p.y () + 0.5);
1557 }
1558 #undef N_POINTS
1559 }
1560@@ -1988,9 +1990,16 @@
1561 }
1562 }
1563 }
1564+
1565 if (depthUsed)
1566 {
1567+#ifdef USE_GLES
1568+ glClearDepthf (1000.0f);
1569+#else
1570 glClearDepth (1000.0f);
1571+#endif
1572+ glDepthMask (GL_TRUE);
1573 glClear (GL_DEPTH_BUFFER_BIT);
1574+ glDepthMask (GL_FALSE);
1575 }
1576 }
1577
1578=== modified file 'plugins/animationaddon/src/private.h'
1579--- plugins/animationaddon/src/private.h 2013-10-31 15:59:14 +0000
1580+++ plugins/animationaddon/src/private.h 2016-06-22 01:26:00 +0000
1581@@ -70,7 +70,7 @@
1582 };
1583
1584 class AnimAddonWindow :
1585- public PluginClassHandler<AnimAddonWindow, CompWindow>
1586+ public PluginClassHandler<AnimAddonWindow, CompWindow, ANIMATIONADDON_ABI>
1587 {
1588 public:
1589 AnimAddonWindow (CompWindow *);
1590@@ -224,7 +224,8 @@
1591 init ();
1592
1593 void
1594- transformPolygon (const PolygonObject *p);
1595+ transformPolygon (GLMatrix &matrix,
1596+ const PolygonObject *p);
1597
1598 bool
1599 tesselateIntoAirplane ();
1600
1601=== modified file 'plugins/opengl/include/opengl/matrix.h'
1602--- plugins/opengl/include/opengl/matrix.h 2012-08-02 11:57:41 +0000
1603+++ plugins/opengl/include/opengl/matrix.h 2016-06-22 01:26:00 +0000
1604@@ -26,6 +26,8 @@
1605 #ifndef _GLMATRIX_H
1606 #define _GLMATRIX_H
1607
1608+#include <core/point.h>
1609+#include <core/rect.h>
1610 #include <opengl/vector.h>
1611
1612 class CompOutput;
1613@@ -65,4 +67,29 @@
1614 float m[16];
1615 };
1616
1617+namespace compiz
1618+{
1619+ namespace opengl
1620+ {
1621+ namespace matrix
1622+ {
1623+ /* This function returns co-ordinates into viewport space. In order
1624+ * to convert into something like damage rectangles please remember
1625+ * to flip on the y axis. */
1626+ inline CompPoint projectIntoViewport (const GLMatrix &modelview,
1627+ const GLMatrix &projection,
1628+ const CompRect &vp,
1629+ const GLVector &vector)
1630+ {
1631+ GLVector projected (projection * modelview * vector);
1632+ projected.homogenize ();
1633+ projected[0] = projected[0] * 0.5 + 0.5;
1634+ projected[1] = projected[1] * 0.5 + 0.5;
1635+ return CompPoint (projected[0] * vp.width () + vp.x (),
1636+ projected[1] * vp.height () + vp.y ());
1637+ }
1638+ }
1639+ }
1640+}
1641+
1642 #endif
1643
1644=== modified file 'plugins/opengl/include/opengl/opengl.h'
1645--- plugins/opengl/include/opengl/opengl.h 2016-05-13 07:57:01 +0000
1646+++ plugins/opengl/include/opengl/opengl.h 2016-06-22 01:26:00 +0000
1647@@ -1036,6 +1036,12 @@
1648 std::string vertex_shader,
1649 std::string fragment_shader);
1650
1651+ /**
1652+ * Use this if overriding glDrawTexture completely - used to clear
1653+ * out any internal shader caches.
1654+ */
1655+ void clearShaders ();
1656+
1657 GLTexture *getIcon (int width, int height);
1658
1659 WRAPABLE_HND (0, GLWindowInterface, bool, glPaint,
1660
1661=== modified file 'plugins/opengl/include/opengl/vertexbuffer.h'
1662--- plugins/opengl/include/opengl/vertexbuffer.h 2016-05-12 06:16:56 +0000
1663+++ plugins/opengl/include/opengl/vertexbuffer.h 2016-06-22 01:26:00 +0000
1664@@ -113,12 +113,30 @@
1665
1666 int render (const GLMatrix &modelview);
1667
1668+ int render (const GLushort *indices,
1669+ GLuint nIndices);
1670+
1671+ int render (const GLMatrix &modelview,
1672+ const GLushort *indices,
1673+ GLuint nIndices);
1674+
1675 int render (const GLMatrix &modelview,
1676 const GLWindowPaintAttrib &attrib);
1677
1678+ int render (const GLMatrix &modelview,
1679+ const GLWindowPaintAttrib &attrib,
1680+ const GLushort *indices,
1681+ GLuint nIndices);
1682+
1683 int render (const GLMatrix &projection,
1684- const GLMatrix &modelview,
1685- const GLWindowPaintAttrib &attrib);
1686+ const GLMatrix &modelview,
1687+ const GLWindowPaintAttrib &attrib);
1688+
1689+ int render (const GLMatrix &projection,
1690+ const GLMatrix &modelview,
1691+ const GLWindowPaintAttrib &attrib,
1692+ const GLushort *indices,
1693+ GLuint nIndices);
1694
1695 void setVertexOffset (GLuint vOffset);
1696 void setMaxVertices (GLint vMax);
1697
1698=== modified file 'plugins/opengl/src/paint.cpp'
1699--- plugins/opengl/src/paint.cpp 2016-05-17 02:52:47 +0000
1700+++ plugins/opengl/src/paint.cpp 2016-06-22 01:26:00 +0000
1701@@ -1298,16 +1298,7 @@
1702 priv->vertexBuffer->render (transform, attrib);
1703 #endif
1704
1705- for (std::list<const GLShaderData*>::const_iterator it = priv->shaders.begin();
1706- it != priv->shaders.end();
1707- ++it)
1708- {
1709- if ((*it)->isCached != true)
1710- {
1711- delete *it;
1712- }
1713- }
1714- priv->shaders.clear ();
1715+ clearShaders ();
1716 texture->disable ();
1717
1718 if (mask & PAINT_WINDOW_BLEND_MASK)
1719
1720=== modified file 'plugins/opengl/src/privatevertexbuffer.h'
1721--- plugins/opengl/src/privatevertexbuffer.h 2013-10-31 15:59:14 +0000
1722+++ plugins/opengl/src/privatevertexbuffer.h 2016-06-22 01:26:00 +0000
1723@@ -109,10 +109,14 @@
1724
1725 int render (const GLMatrix *projection,
1726 const GLMatrix *modelview,
1727- const GLWindowPaintAttrib *attrib);
1728+ const GLWindowPaintAttrib *attrib,
1729+ const GLushort *indices,
1730+ GLuint nIndices);
1731 int legacyRender (const GLMatrix &projection,
1732 const GLMatrix &modelview,
1733- const GLWindowPaintAttrib &attrib);
1734+ const GLWindowPaintAttrib &attrib,
1735+ const GLushort *indices,
1736+ GLuint nIndices);
1737
1738 public:
1739 static GLVertexBuffer *streamingBuffer;
1740
1741=== modified file 'plugins/opengl/src/vertexbuffer.cpp'
1742--- plugins/opengl/src/vertexbuffer.cpp 2016-05-12 05:17:55 +0000
1743+++ plugins/opengl/src/vertexbuffer.cpp 2016-06-22 01:26:00 +0000
1744@@ -343,7 +343,16 @@
1745 int GLVertexBuffer::render ()
1746 {
1747 if (enabled ())
1748- return priv->render (NULL, NULL, NULL);
1749+ return priv->render (NULL, NULL, NULL, NULL, 0);
1750+ else
1751+ return -1;
1752+}
1753+
1754+int GLVertexBuffer::render (const GLushort *indices,
1755+ GLuint nIndices)
1756+{
1757+ if (enabled ())
1758+ return priv->render (NULL, NULL, NULL, indices, nIndices);
1759 else
1760 return -1;
1761 }
1762@@ -355,15 +364,42 @@
1763 return render (modelview, attrib);
1764 }
1765
1766+int GLVertexBuffer::render (const GLMatrix &modelview,
1767+ const GLushort *indices,
1768+ GLuint nIndices)
1769+{
1770+ const GLWindowPaintAttrib attrib = { OPAQUE, BRIGHT, COLOR, 0, 0, 0, 0 };
1771+
1772+ return render (modelview, attrib, indices, nIndices);
1773+}
1774+
1775 int GLVertexBuffer::render (const GLMatrix &modelview,
1776 const GLWindowPaintAttrib &attrib)
1777 {
1778 GLScreen *gScreen = GLScreen::get (screen);
1779 GLMatrix *projection = gScreen->projectionMatrix ();
1780
1781- return render (*projection, modelview, attrib);
1782-}
1783-
1784+ return render (*projection, modelview, attrib, NULL, 0);
1785+}
1786+
1787+
1788+int GLVertexBuffer::render (const GLMatrix &modelview,
1789+ const GLWindowPaintAttrib &attrib,
1790+ const GLushort *indices,
1791+ GLuint nIndices)
1792+{
1793+ GLScreen *gScreen = GLScreen::get (screen);
1794+ GLMatrix *projection = gScreen->projectionMatrix ();
1795+
1796+ return render (*projection, modelview, attrib, indices, nIndices);
1797+}
1798+
1799+int GLVertexBuffer::render (const GLMatrix &projection,
1800+ const GLMatrix &modelview,
1801+ const GLWindowPaintAttrib &attrib)
1802+{
1803+ return render (projection, modelview, attrib, NULL, 0);
1804+}
1805
1806 #if 0
1807 #define PRINT_MATRIX(m) printMatrix ((m), #m)
1808@@ -378,9 +414,11 @@
1809 #define PRINT_MATRIX(m)
1810 #endif
1811
1812-int GLVertexBuffer::render (const GLMatrix &projection,
1813- const GLMatrix &modelview,
1814- const GLWindowPaintAttrib &attrib)
1815+int GLVertexBuffer::render (const GLMatrix &projection,
1816+ const GLMatrix &modelview,
1817+ const GLWindowPaintAttrib &attrib,
1818+ const GLushort *indices,
1819+ GLuint nIndices)
1820 {
1821 if (!priv->vertexData.size ())
1822 return -1;
1823@@ -389,9 +427,9 @@
1824 PRINT_MATRIX(projection);
1825
1826 if (enabled ())
1827- return priv->render (&projection, &modelview, &attrib);
1828+ return priv->render (&projection, &modelview, &attrib, indices, nIndices);
1829 else
1830- return priv->legacyRender (projection, modelview, attrib);
1831+ return priv->legacyRender (projection, modelview, attrib, indices, nIndices);
1832 }
1833
1834 PrivateVertexBuffer::PrivateVertexBuffer () :
1835@@ -431,9 +469,11 @@
1836 }
1837 }
1838
1839-int PrivateVertexBuffer::render (const GLMatrix *projection,
1840- const GLMatrix *modelview,
1841- const GLWindowPaintAttrib *attrib)
1842+int PrivateVertexBuffer::render (const GLMatrix *projection,
1843+ const GLMatrix *modelview,
1844+ const GLWindowPaintAttrib *attrib,
1845+ const GLushort *indices,
1846+ GLuint nIndices)
1847 {
1848 GLfloat attribs[3] = {1, 1, 1};
1849 GLint positionIndex = -1;
1850@@ -552,11 +592,16 @@
1851 tmpProgram->setUniform3f ("paintAttrib", attribs[0], attribs[1], attribs[2]);
1852 }
1853
1854-
1855- glDrawArrays (primitiveType, vertexOffset, maxVertices > 0 ?
1856- std::min (static_cast <int> (vertexData.size () / 3),
1857- maxVertices) :
1858- vertexData.size () / 3);
1859+ const GLuint nVerticesToDraw = maxVertices > 0 ?
1860+ std::min (static_cast <int> (vertexData.size () / 3),
1861+ maxVertices) :
1862+ vertexData.size () / 3;
1863+
1864+ if (nIndices && indices)
1865+ glDrawElements (primitiveType, nIndices, GL_UNSIGNED_SHORT, indices);
1866+ else
1867+ glDrawArrays (primitiveType, vertexOffset, nVerticesToDraw);
1868+
1869 for (int i = 0; i < 4; ++i)
1870 {
1871 if (texCoordIndex[i] != -1)
1872@@ -578,7 +623,9 @@
1873
1874 int PrivateVertexBuffer::legacyRender (const GLMatrix &projection,
1875 const GLMatrix &modelview,
1876- const GLWindowPaintAttrib &attrib)
1877+ const GLWindowPaintAttrib &attrib,
1878+ const GLushort *indices,
1879+ GLuint nIndices)
1880 {
1881 #ifndef USE_GLES
1882 glMatrixMode (GL_PROJECTION);
1883@@ -626,10 +673,18 @@
1884 glTexCoordPointer (2, GL_FLOAT, 0, &textureData[i][0]);
1885 }
1886
1887- glDrawArrays (primitiveType, vertexOffset, maxVertices > 0 ?
1888- std::min (static_cast <int> (vertexData.size () / 3),
1889- maxVertices) :
1890- vertexData.size () / 3);
1891+ const GLuint nVerticesToDraw = maxVertices > 0 ?
1892+ std::min (static_cast <int> (vertexData.size () / 3),
1893+ maxVertices) :
1894+ vertexData.size () / 3;
1895+
1896+ if (indices && nIndices)
1897+ glDrawElements (primitiveType,
1898+ nIndices,
1899+ GL_UNSIGNED_SHORT,
1900+ indices);
1901+ else
1902+ glDrawArrays (primitiveType, vertexOffset, nVerticesToDraw);
1903
1904 glDisableClientState (GL_VERTEX_ARRAY);
1905 glDisableClientState (GL_NORMAL_ARRAY);
1906
1907=== modified file 'plugins/opengl/src/window.cpp'
1908--- plugins/opengl/src/window.cpp 2016-05-13 06:41:03 +0000
1909+++ plugins/opengl/src/window.cpp 2016-06-22 01:26:00 +0000
1910@@ -375,6 +375,21 @@
1911 }
1912
1913 void
1914+GLWindow::clearShaders ()
1915+{
1916+ for (std::list<const GLShaderData*>::const_iterator it = priv->shaders.begin();
1917+ it != priv->shaders.end();
1918+ ++it)
1919+ {
1920+ if ((*it)->isCached != true)
1921+ {
1922+ delete *it;
1923+ }
1924+ }
1925+ priv->shaders.clear ();
1926+}
1927+
1928+void
1929 PrivateGLWindow::updateFrameRegion (CompRegion &region)
1930 {
1931 window->updateFrameRegion (region);

Subscribers

People subscribed via source and target branches