Merge lp:~mc-return/compiz/compiz.merge-fix1106270-showmouse-plugin-needs-port-to-GLES into lp:compiz/0.9.9
- compiz.merge-fix1106270-showmouse-plugin-needs-port-to-GLES
- Merge into 0.9.9
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Timo Jyrinki | ||||
Approved revision: | 3591 | ||||
Merged at revision: | 3590 | ||||
Proposed branch: | lp:~mc-return/compiz/compiz.merge-fix1106270-showmouse-plugin-needs-port-to-GLES | ||||
Merge into: | lp:compiz/0.9.9 | ||||
Diff against target: |
506 lines (+176/-213) 5 files modified
debian/compiz-plugins.install.armel (+2/-0) debian/compiz-plugins.install.armhf (+2/-0) plugins/CMakeLists.txt (+0/-1) plugins/showmouse/src/showmouse.cpp (+164/-197) plugins/showmouse/src/showmouse.h (+8/-15) |
||||
To merge this branch: | bzr merge lp:~mc-return/compiz/compiz.merge-fix1106270-showmouse-plugin-needs-port-to-GLES | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Timo Jyrinki | Approve | ||
Michail Bitzes (community) | Approve | ||
MC Return | Needs Resubmitting | ||
Sam Spilsbury | Approve | ||
PS Jenkins bot | continuous-integration | Pending | |
Review via email: mp+145069@code.launchpad.net |
Commit message
Showmouse plugin OpenGL|ES port.
Thanks go to Michail Bitzes for porting Firepaint first,
as those 2 plugins share a lot of code, his work made this
job here possible in the first place.
Build showmouse for OpenGL|ES as well.
Also install showmouse on armel and armhf.
(LP: #1106270)
Description of the change
Sam Spilsbury (smspillaz) wrote : | # |
Sam Spilsbury (smspillaz) : | # |
MC Return (mc-return) wrote : | # |
> Again, well done, thanks for the effort.
>
Most credit in this case goes to Michail Bitzes.
> The only things I would point out are:
>
> 1. You probably need to update .install.armhf too (only .install.armel is
> updated)
Seems I forgot to save the file before the commit. Thanks for noticing. Fixed.
> 2. Coding style: spaces between both brackets () and operators foo + bar not
> foo+ bar
I hope I got them all. We need to fix those for firepaint as well then, seems
they slipped through there as well...
Sam Spilsbury (smspillaz) wrote : | # |
Not able to test it at the moment but code wise this is a +1 from me.
Michail Bitzes (bitzesmichail) wrote : | # |
Line 83 in showmouse.cpp:
I think it's:
if (particles.size () * 6 * 3 > vertices_cache.size ())
Not:
if (particles.size () > vertices_cache.size ())
vertices_cache needs space for 6 vertices, 3 for each triangle(2 triangles per particle), each vertex is stored as 3 GLfloats.
It could be inverted like that(and similarly for the rest caches):
if (vertices_
it makes reading it a bit clearer.
- 3590. By MC Return
-
Fixed wrong calculation in if condition, vertices_cache needs place for 6 vertices
(3 for each triangle, 2 triangles per particle)
Also inverted the statements in the if conditions checking cache_size to improve
readability
Credits & thanks (once again): Michail Bitzes - 3591. By MC Return
-
Fixed indentation
MC Return (mc-return) wrote : | # |
> Line 83 in showmouse.cpp:
>
> I think it's:
> if (particles.size () * 6 * 3 > vertices_cache.size ())
> Not:
> if (particles.size () > vertices_cache.size ())
>
> vertices_cache needs space for 6 vertices, 3 for each triangle(2 triangles per
> particle), each vertex is stored as 3 GLfloats.
>
> It could be inverted like that(and similarly for the rest caches):
> if (vertices_
> it makes reading it a bit clearer.
Hopefully fixed now. :) Thanks for noticing.
Michail, could you (and do you want to) do some wizard GLES magic as well ?
Michail Bitzes (bitzesmichail) wrote : | # |
Yes, I will look at wizard soon.
You can also fix the C++-style comments in showmouse.cpp, there are several, including the ones in my code ("//first triangle" etc)
(http://
MC Return (mc-return) wrote : | # |
> Yes, I will look at wizard soon.
>
Cool, that are awesome news :)
> You can also fix the C++-style comments in showmouse.cpp, there are several,
> including the ones in my code ("//first triangle" etc)
>
> (http://
> should be used)
I think it is no big deal to use "//" comments for one-liners, not sure if those
really need fixing...
Michail Bitzes (bitzesmichail) : | # |
Timo Jyrinki (timo-jyrinki) wrote : | # |
Looks and builds fine for me.
Preview Diff
1 | === modified file 'debian/compiz-plugins.install.armel' | |||
2 | --- debian/compiz-plugins.install.armel 2013-01-24 08:14:41 +0000 | |||
3 | +++ debian/compiz-plugins.install.armel 2013-01-27 19:37:21 +0000 | |||
4 | @@ -33,6 +33,8 @@ | |||
5 | 33 | debian/tmp/usr/*/compiz/*shelf.* | 33 | debian/tmp/usr/*/compiz/*shelf.* |
6 | 34 | debian/tmp/usr/*/compiz/*shift.* | 34 | debian/tmp/usr/*/compiz/*shift.* |
7 | 35 | debian/tmp/usr/*/compiz/*showdesktop.* | 35 | debian/tmp/usr/*/compiz/*showdesktop.* |
8 | 36 | debian/tmp/usr/*/compiz/*showmouse.* | ||
9 | 37 | debian/tmp/usr/share/compiz/showmouse | ||
10 | 36 | debian/tmp/usr/*/compiz/*switcher.* | 38 | debian/tmp/usr/*/compiz/*switcher.* |
11 | 37 | debian/tmp/usr/*/compiz/*text.* | 39 | debian/tmp/usr/*/compiz/*text.* |
12 | 38 | debian/tmp/usr/*/compiz/*titleinfo.* | 40 | debian/tmp/usr/*/compiz/*titleinfo.* |
13 | 39 | 41 | ||
14 | === modified file 'debian/compiz-plugins.install.armhf' | |||
15 | --- debian/compiz-plugins.install.armhf 2013-01-24 08:14:41 +0000 | |||
16 | +++ debian/compiz-plugins.install.armhf 2013-01-27 19:37:21 +0000 | |||
17 | @@ -33,6 +33,8 @@ | |||
18 | 33 | debian/tmp/usr/*/compiz/*shelf.* | 33 | debian/tmp/usr/*/compiz/*shelf.* |
19 | 34 | debian/tmp/usr/*/compiz/*shift.* | 34 | debian/tmp/usr/*/compiz/*shift.* |
20 | 35 | debian/tmp/usr/*/compiz/*showdesktop.* | 35 | debian/tmp/usr/*/compiz/*showdesktop.* |
21 | 36 | debian/tmp/usr/*/compiz/*showmouse.* | ||
22 | 37 | debian/tmp/usr/share/compiz/showmouse | ||
23 | 36 | debian/tmp/usr/*/compiz/*switcher.* | 38 | debian/tmp/usr/*/compiz/*switcher.* |
24 | 37 | debian/tmp/usr/*/compiz/*text.* | 39 | debian/tmp/usr/*/compiz/*text.* |
25 | 38 | debian/tmp/usr/*/compiz/*titleinfo.* | 40 | debian/tmp/usr/*/compiz/*titleinfo.* |
26 | 39 | 41 | ||
27 | === modified file 'plugins/CMakeLists.txt' | |||
28 | --- plugins/CMakeLists.txt 2013-01-20 11:15:20 +0000 | |||
29 | +++ plugins/CMakeLists.txt 2013-01-27 19:37:21 +0000 | |||
30 | @@ -46,7 +46,6 @@ | |||
31 | 46 | set (COMPIZ_DISABLE_PLUGIN_BENCH ON) | 46 | set (COMPIZ_DISABLE_PLUGIN_BENCH ON) |
32 | 47 | set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON) | 47 | set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON) |
33 | 48 | set (COMPIZ_DISABLE_PLUGIN_WIDGET ON) | 48 | set (COMPIZ_DISABLE_PLUGIN_WIDGET ON) |
34 | 49 | set (COMPIZ_DISABLE_PLUGIN_SHOWMOUSE ON) | ||
35 | 50 | set (COMPIZ_DISABLE_PLUGIN_SPLASH ON) | 49 | set (COMPIZ_DISABLE_PLUGIN_SPLASH ON) |
36 | 51 | set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON) | 50 | set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON) |
37 | 52 | set (COMPIZ_DISABLE_PLUGIN_WIZARD ON) | 51 | set (COMPIZ_DISABLE_PLUGIN_WIZARD ON) |
38 | 53 | 52 | ||
39 | === modified file 'plugins/showmouse/src/showmouse.cpp' | |||
40 | --- plugins/showmouse/src/showmouse.cpp 2013-01-07 19:48:41 +0000 | |||
41 | +++ plugins/showmouse/src/showmouse.cpp 2013-01-27 19:37:21 +0000 | |||
42 | @@ -84,20 +84,10 @@ | |||
43 | 84 | darken = 0; | 84 | darken = 0; |
44 | 85 | 85 | ||
45 | 86 | // Initialize cache | 86 | // Initialize cache |
60 | 87 | vertices_cache.cache = NULL; | 87 | vertices_cache.clear (); |
61 | 88 | colors_cache.cache = NULL; | 88 | coords_cache.clear (); |
62 | 89 | coords_cache.cache = NULL; | 89 | colors_cache.clear (); |
63 | 90 | dcolors_cache.cache = NULL; | 90 | dcolors_cache.clear (); |
50 | 91 | |||
51 | 92 | vertices_cache.count = 0; | ||
52 | 93 | colors_cache.count = 0; | ||
53 | 94 | coords_cache.count = 0; | ||
54 | 95 | dcolors_cache.count = 0; | ||
55 | 96 | |||
56 | 97 | vertices_cache.size = 0; | ||
57 | 98 | colors_cache.size = 0; | ||
58 | 99 | coords_cache.size = 0; | ||
59 | 100 | dcolors_cache.size = 0; | ||
64 | 101 | 91 | ||
65 | 102 | for (int i = 0; i < f_numParticles; i++) | 92 | for (int i = 0; i < f_numParticles; i++) |
66 | 103 | { | 93 | { |
67 | @@ -108,14 +98,23 @@ | |||
68 | 108 | } | 98 | } |
69 | 109 | 99 | ||
70 | 110 | void | 100 | void |
72 | 111 | ParticleSystem::drawParticles () | 101 | ParticleSystem::drawParticles (const GLMatrix &transform) |
73 | 112 | { | 102 | { |
80 | 113 | GLfloat *dcolors; | 103 | int i, j, k, l; |
81 | 114 | GLfloat *vertices; | 104 | |
82 | 115 | GLfloat *coords; | 105 | /* Check that the cache is big enough */ |
83 | 116 | GLfloat *colors; | 106 | if (vertices_cache.size () < particles.size () * 6 * 3) |
84 | 117 | 107 | vertices_cache.resize (particles.size () * 6 * 3); | |
85 | 118 | glPushMatrix (); | 108 | |
86 | 109 | if (coords_cache.size () < particles.size () * 6 * 2) | ||
87 | 110 | coords_cache.resize (particles.size () * 6 * 2); | ||
88 | 111 | |||
89 | 112 | if (colors_cache.size () < particles.size () * 6 * 4) | ||
90 | 113 | colors_cache.resize (particles.size () * 6 * 4); | ||
91 | 114 | |||
92 | 115 | if (darken > 0) | ||
93 | 116 | if (dcolors_cache.size () < particles.size () * 6 * 4) | ||
94 | 117 | dcolors_cache.resize (particles.size () * 6 * 4); | ||
95 | 119 | 118 | ||
96 | 120 | glEnable (GL_BLEND); | 119 | glEnable (GL_BLEND); |
97 | 121 | 120 | ||
98 | @@ -125,172 +124,171 @@ | |||
99 | 125 | glEnable (GL_TEXTURE_2D); | 124 | glEnable (GL_TEXTURE_2D); |
100 | 126 | } | 125 | } |
101 | 127 | 126 | ||
152 | 128 | glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 127 | i = j = k = l = 0; |
153 | 129 | 128 | ||
154 | 130 | /* Check that the cache is big enough */ | 129 | /* use 2 triangles per particle */ |
105 | 131 | |||
106 | 132 | if (particles.size () > vertices_cache.count) | ||
107 | 133 | { | ||
108 | 134 | vertices_cache.cache = (GLfloat *) realloc (vertices_cache.cache, | ||
109 | 135 | particles.size () * 4 * 3 * | ||
110 | 136 | sizeof (GLfloat)); | ||
111 | 137 | vertices_cache.size = particles.size () * 4 * 3; | ||
112 | 138 | vertices_cache.count = particles.size (); | ||
113 | 139 | } | ||
114 | 140 | |||
115 | 141 | if (particles.size () > coords_cache.count) | ||
116 | 142 | { | ||
117 | 143 | coords_cache.cache = (GLfloat *) realloc (coords_cache.cache, | ||
118 | 144 | particles.size () * 4 * 2 * | ||
119 | 145 | sizeof (GLfloat)); | ||
120 | 146 | coords_cache.size = particles.size () * 4 * 2; | ||
121 | 147 | coords_cache.count = particles.size (); | ||
122 | 148 | } | ||
123 | 149 | |||
124 | 150 | if (particles.size () > colors_cache.count) | ||
125 | 151 | { | ||
126 | 152 | colors_cache.cache = (GLfloat *) realloc (colors_cache.cache, | ||
127 | 153 | particles.size () * 4 * 4 * | ||
128 | 154 | sizeof (GLfloat)); | ||
129 | 155 | colors_cache.size = particles.size () * 4 * 4; | ||
130 | 156 | colors_cache.count = particles.size (); | ||
131 | 157 | } | ||
132 | 158 | |||
133 | 159 | if (darken > 0) | ||
134 | 160 | { | ||
135 | 161 | if (dcolors_cache.count < particles.size ()) | ||
136 | 162 | { | ||
137 | 163 | dcolors_cache.cache = (GLfloat *) realloc (dcolors_cache.cache, | ||
138 | 164 | particles.size () * 4 * 4 * | ||
139 | 165 | sizeof (GLfloat)); | ||
140 | 166 | dcolors_cache.size = particles.size () * 4 * 4; | ||
141 | 167 | dcolors_cache.count = particles.size (); | ||
142 | 168 | } | ||
143 | 169 | } | ||
144 | 170 | |||
145 | 171 | dcolors = dcolors_cache.cache; | ||
146 | 172 | vertices = vertices_cache.cache; | ||
147 | 173 | coords = coords_cache.cache; | ||
148 | 174 | colors = colors_cache.cache; | ||
149 | 175 | |||
150 | 176 | int numActive = 0; | ||
151 | 177 | |||
155 | 178 | foreach (Particle &part, particles) | 130 | foreach (Particle &part, particles) |
156 | 179 | { | 131 | { |
157 | 180 | if (part.life > 0.0f) | 132 | if (part.life > 0.0f) |
158 | 181 | { | 133 | { |
159 | 182 | numActive += 4; | ||
160 | 183 | |||
161 | 184 | float w = part.width / 2; | 134 | float w = part.width / 2; |
162 | 185 | float h = part.height / 2; | 135 | float h = part.height / 2; |
163 | 186 | 136 | ||
164 | 137 | GLushort r, g, b, a, dark_a; | ||
165 | 138 | |||
166 | 139 | r = part.r * 65535.0f; | ||
167 | 140 | g = part.g * 65535.0f; | ||
168 | 141 | b = part.b * 65535.0f; | ||
169 | 142 | a = part.life * part.a * 65535.0f; | ||
170 | 143 | dark_a = part.life * part.a * darken * 65535.0f; | ||
171 | 144 | |||
172 | 187 | w += (w * part.w_mod) * part.life; | 145 | w += (w * part.w_mod) * part.life; |
173 | 188 | h += (h * part.h_mod) * part.life; | 146 | h += (h * part.h_mod) * part.life; |
174 | 189 | 147 | ||
227 | 190 | vertices[0] = part.x - w; | 148 | //first triangle |
228 | 191 | vertices[1] = part.y - h; | 149 | vertices_cache[i + 0] = part.x - w; |
229 | 192 | vertices[2] = part.z; | 150 | vertices_cache[i + 1] = part.y - h; |
230 | 193 | 151 | vertices_cache[i + 2] = part.z; | |
231 | 194 | vertices[3] = part.x - w; | 152 | |
232 | 195 | vertices[4] = part.y + h; | 153 | vertices_cache[i + 3] = part.x - w; |
233 | 196 | vertices[5] = part.z; | 154 | vertices_cache[i + 4] = part.y + h; |
234 | 197 | 155 | vertices_cache[i + 5] = part.z; | |
235 | 198 | vertices[6] = part.x + w; | 156 | |
236 | 199 | vertices[7] = part.y + h; | 157 | vertices_cache[i + 6] = part.x + w; |
237 | 200 | vertices[8] = part.z; | 158 | vertices_cache[i + 7] = part.y + h; |
238 | 201 | 159 | vertices_cache[i + 8] = part.z; | |
239 | 202 | vertices[9] = part.x + w; | 160 | |
240 | 203 | vertices[10] = part.y - h; | 161 | //second triangle |
241 | 204 | vertices[11] = part.z; | 162 | vertices_cache[i + 9] = part.x + w; |
242 | 205 | 163 | vertices_cache[i + 10] = part.y + h; | |
243 | 206 | vertices += 12; | 164 | vertices_cache[i + 11] = part.z; |
244 | 207 | 165 | ||
245 | 208 | coords[0] = 0.0; | 166 | vertices_cache[i + 12] = part.x + w; |
246 | 209 | coords[1] = 0.0; | 167 | vertices_cache[i + 13] = part.y - h; |
247 | 210 | 168 | vertices_cache[i + 14] = part.z; | |
248 | 211 | coords[2] = 0.0; | 169 | |
249 | 212 | coords[3] = 1.0; | 170 | vertices_cache[i + 15] = part.x - w; |
250 | 213 | 171 | vertices_cache[i + 16] = part.y - h; | |
251 | 214 | coords[4] = 1.0; | 172 | vertices_cache[i + 17] = part.z; |
252 | 215 | coords[5] = 1.0; | 173 | |
253 | 216 | 174 | i += 18; | |
254 | 217 | coords[6] = 1.0; | 175 | |
255 | 218 | coords[7] = 0.0; | 176 | coords_cache[j + 0] = 0.0; |
256 | 219 | 177 | coords_cache[j + 1] = 0.0; | |
257 | 220 | coords += 8; | 178 | |
258 | 221 | 179 | coords_cache[j + 2] = 0.0; | |
259 | 222 | colors[0] = part.r; | 180 | coords_cache[j + 3] = 1.0; |
260 | 223 | colors[1] = part.g; | 181 | |
261 | 224 | colors[2] = part.b; | 182 | coords_cache[j + 4] = 1.0; |
262 | 225 | colors[3] = part.life * part.a; | 183 | coords_cache[j + 5] = 1.0; |
263 | 226 | colors[4] = part.r; | 184 | |
264 | 227 | colors[5] = part.g; | 185 | //second |
265 | 228 | colors[6] = part.b; | 186 | coords_cache[j + 6] = 1.0; |
266 | 229 | colors[7] = part.life * part.a; | 187 | coords_cache[j + 7] = 1.0; |
267 | 230 | colors[8] = part.r; | 188 | |
268 | 231 | colors[9] = part.g; | 189 | coords_cache[j + 8] = 1.0; |
269 | 232 | colors[10] = part.b; | 190 | coords_cache[j + 9] = 0.0; |
270 | 233 | colors[11] = part.life * part.a; | 191 | |
271 | 234 | colors[12] = part.r; | 192 | coords_cache[j + 10] = 0.0; |
272 | 235 | colors[13] = part.g; | 193 | coords_cache[j + 11] = 0.0; |
273 | 236 | colors[14] = part.b; | 194 | |
274 | 237 | colors[15] = part.life * part.a; | 195 | j += 12; |
275 | 238 | 196 | ||
276 | 239 | colors += 16; | 197 | colors_cache[k + 0] = r; |
277 | 240 | 198 | colors_cache[k + 1] = g; | |
278 | 241 | if (darken > 0) | 199 | colors_cache[k + 2] = b; |
279 | 200 | colors_cache[k + 3] = a; | ||
280 | 201 | |||
281 | 202 | colors_cache[k + 4] = r; | ||
282 | 203 | colors_cache[k + 5] = g; | ||
283 | 204 | colors_cache[k + 6] = b; | ||
284 | 205 | colors_cache[k + 7] = a; | ||
285 | 206 | |||
286 | 207 | colors_cache[k + 8] = r; | ||
287 | 208 | colors_cache[k + 9] = g; | ||
288 | 209 | colors_cache[k + 10] = b; | ||
289 | 210 | colors_cache[k + 11] = a; | ||
290 | 211 | |||
291 | 212 | //second | ||
292 | 213 | colors_cache[k + 12] = r; | ||
293 | 214 | colors_cache[k + 13] = g; | ||
294 | 215 | colors_cache[k + 14] = b; | ||
295 | 216 | colors_cache[k + 15] = a; | ||
296 | 217 | |||
297 | 218 | colors_cache[k + 16] = r; | ||
298 | 219 | colors_cache[k + 17] = g; | ||
299 | 220 | colors_cache[k + 18] = b; | ||
300 | 221 | colors_cache[k + 19] = a; | ||
301 | 222 | |||
302 | 223 | colors_cache[k + 20] = r; | ||
303 | 224 | colors_cache[k + 21] = g; | ||
304 | 225 | colors_cache[k + 22] = b; | ||
305 | 226 | colors_cache[k + 23] = a; | ||
306 | 227 | |||
307 | 228 | k += 24; | ||
308 | 229 | |||
309 | 230 | if(darken > 0) | ||
310 | 242 | { | 231 | { |
330 | 243 | 232 | dcolors_cache[l + 0] = r; | |
331 | 244 | dcolors[0] = part.r; | 233 | dcolors_cache[l + 1] = g; |
332 | 245 | dcolors[1] = part.g; | 234 | dcolors_cache[l + 2] = b; |
333 | 246 | dcolors[2] = part.b; | 235 | dcolors_cache[l + 3] = dark_a; |
334 | 247 | dcolors[3] = part.life * part.a * darken; | 236 | |
335 | 248 | dcolors[4] = part.r; | 237 | dcolors_cache[l + 4] = r; |
336 | 249 | dcolors[5] = part.g; | 238 | dcolors_cache[l + 5] = g; |
337 | 250 | dcolors[6] = part.b; | 239 | dcolors_cache[l + 6] = b; |
338 | 251 | dcolors[7] = part.life * part.a * darken; | 240 | dcolors_cache[l + 7] = dark_a; |
339 | 252 | dcolors[8] = part.r; | 241 | |
340 | 253 | dcolors[9] = part.g; | 242 | dcolors_cache[l + 8] = r; |
341 | 254 | dcolors[10] = part.b; | 243 | dcolors_cache[l + 9] = g; |
342 | 255 | dcolors[11] = part.life * part.a * darken; | 244 | dcolors_cache[l + 10] = b; |
343 | 256 | dcolors[12] = part.r; | 245 | dcolors_cache[l + 11] = dark_a; |
344 | 257 | dcolors[13] = part.g; | 246 | |
345 | 258 | dcolors[14] = part.b; | 247 | //second |
346 | 259 | dcolors[15] = part.life * part.a * darken; | 248 | dcolors_cache[l + 12] = r; |
347 | 260 | 249 | dcolors_cache[l + 13] = g; | |
348 | 261 | dcolors += 16; | 250 | dcolors_cache[l + 14] = b; |
349 | 251 | dcolors_cache[l + 15] = dark_a; | ||
350 | 252 | |||
351 | 253 | dcolors_cache[l + 16] = r; | ||
352 | 254 | dcolors_cache[l + 17] = g; | ||
353 | 255 | dcolors_cache[l + 18] = b; | ||
354 | 256 | dcolors_cache[l + 19] = dark_a; | ||
355 | 257 | |||
356 | 258 | dcolors_cache[l + 20] = r; | ||
357 | 259 | dcolors_cache[l + 21] = g; | ||
358 | 260 | dcolors_cache[l + 22] = b; | ||
359 | 261 | dcolors_cache[l + 23] = dark_a; | ||
360 | 262 | |||
361 | 263 | l += 24; | ||
362 | 262 | } | 264 | } |
363 | 263 | } | 265 | } |
364 | 264 | } | 266 | } |
373 | 265 | glEnableClientState (GL_VERTEX_ARRAY); | 267 | |
374 | 266 | glEnableClientState (GL_TEXTURE_COORD_ARRAY); | 268 | GLVertexBuffer *stream = GLVertexBuffer::streamingBuffer (); |
367 | 267 | glEnableClientState (GL_COLOR_ARRAY); | ||
368 | 268 | |||
369 | 269 | glTexCoordPointer (2, GL_FLOAT, 2 * sizeof (GLfloat), coords_cache.cache); | ||
370 | 270 | glVertexPointer (3, GL_FLOAT, 3 * sizeof (GLfloat), vertices_cache.cache); | ||
371 | 271 | |||
372 | 272 | // darken the background | ||
375 | 273 | 269 | ||
376 | 274 | if (darken > 0) | 270 | if (darken > 0) |
377 | 275 | { | 271 | { |
378 | 276 | glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); | 272 | glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA); |
381 | 277 | glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), dcolors_cache.cache); | 273 | stream->begin (GL_TRIANGLES); |
382 | 278 | glDrawArrays (GL_QUADS, 0, numActive); | 274 | stream->addVertices (i / 3, &vertices_cache[0]); |
383 | 275 | stream->addTexCoords (0, j / 2, &coords_cache[0]); | ||
384 | 276 | stream->addColors (l / 4, &dcolors_cache[0]); | ||
385 | 277 | |||
386 | 278 | if (stream->end ()) | ||
387 | 279 | stream->render (transform); | ||
388 | 279 | } | 280 | } |
389 | 280 | 281 | ||
390 | 281 | // draw particles | 282 | // draw particles |
391 | 282 | glBlendFunc (GL_SRC_ALPHA, blendMode); | 283 | glBlendFunc (GL_SRC_ALPHA, blendMode); |
403 | 283 | 284 | stream->begin (GL_TRIANGLES); | |
404 | 284 | glColorPointer (4, GL_FLOAT, 4 * sizeof (GLfloat), colors_cache.cache); | 285 | |
405 | 285 | glDrawArrays (GL_QUADS, 0, numActive); | 286 | stream->addVertices (i / 3, &vertices_cache[0]); |
406 | 286 | glDisableClientState (GL_COLOR_ARRAY); | 287 | stream->addTexCoords (0, j / 2, &coords_cache[0]); |
407 | 287 | glDisableClientState (GL_TEXTURE_COORD_ARRAY); | 288 | stream->addColors (k / 4, &colors_cache[0]); |
408 | 288 | glDisableClientState (GL_VERTEX_ARRAY); | 289 | |
409 | 289 | 290 | if (stream->end ()) | |
410 | 290 | glPopMatrix (); | 291 | stream->render (transform); |
400 | 291 | glColor4usv (defaultColor); | ||
401 | 292 | |||
402 | 293 | GLScreen::get(screen)->setTexEnvMode (GL_REPLACE); // ??? | ||
411 | 294 | 292 | ||
412 | 295 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | 293 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); |
413 | 296 | glDisable (GL_TEXTURE_2D); | 294 | glDisable (GL_TEXTURE_2D); |
414 | @@ -333,30 +331,6 @@ | |||
415 | 333 | 331 | ||
416 | 334 | if (tex) | 332 | if (tex) |
417 | 335 | glDeleteTextures (1, &tex); | 333 | glDeleteTextures (1, &tex); |
418 | 336 | |||
419 | 337 | if (vertices_cache.cache) | ||
420 | 338 | { | ||
421 | 339 | free (vertices_cache.cache); | ||
422 | 340 | vertices_cache.cache = NULL; | ||
423 | 341 | } | ||
424 | 342 | |||
425 | 343 | if (colors_cache.cache) | ||
426 | 344 | { | ||
427 | 345 | free (colors_cache.cache); | ||
428 | 346 | colors_cache.cache = NULL; | ||
429 | 347 | } | ||
430 | 348 | |||
431 | 349 | if (coords_cache.cache) | ||
432 | 350 | { | ||
433 | 351 | free (coords_cache.cache); | ||
434 | 352 | coords_cache.cache = NULL; | ||
435 | 353 | } | ||
436 | 354 | |||
437 | 355 | if (dcolors_cache.cache) | ||
438 | 356 | { | ||
439 | 357 | free (dcolors_cache.cache); | ||
440 | 358 | dcolors_cache.cache = NULL; | ||
441 | 359 | } | ||
442 | 360 | } | 334 | } |
443 | 361 | 335 | ||
444 | 362 | static void | 336 | static void |
445 | @@ -591,14 +565,7 @@ | |||
446 | 591 | 565 | ||
447 | 592 | sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); | 566 | sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); |
448 | 593 | 567 | ||
457 | 594 | glPushMatrix (); | 568 | ps.drawParticles (sTransform); |
450 | 595 | glLoadMatrixf (sTransform.getMatrix ()); | ||
451 | 596 | |||
452 | 597 | ps.drawParticles (); | ||
453 | 598 | |||
454 | 599 | glPopMatrix(); | ||
455 | 600 | |||
456 | 601 | glColor4usv (defaultColor); | ||
458 | 602 | 569 | ||
459 | 603 | return status; | 570 | return status; |
460 | 604 | } | 571 | } |
461 | 605 | 572 | ||
462 | === modified file 'plugins/showmouse/src/showmouse.h' | |||
463 | --- plugins/showmouse/src/showmouse.h 2012-09-04 15:33:44 +0000 | |||
464 | +++ plugins/showmouse/src/showmouse.h 2013-01-27 19:37:21 +0000 | |||
465 | @@ -62,15 +62,6 @@ | |||
466 | 62 | float zo; /* orginal Z position */ | 62 | float zo; /* orginal Z position */ |
467 | 63 | }; | 63 | }; |
468 | 64 | 64 | ||
469 | 65 | class ParticleCache | ||
470 | 66 | { | ||
471 | 67 | public: | ||
472 | 68 | |||
473 | 69 | GLfloat *cache; | ||
474 | 70 | unsigned int count; | ||
475 | 71 | unsigned int size; | ||
476 | 72 | }; | ||
477 | 73 | |||
478 | 74 | class ParticleSystem | 65 | class ParticleSystem |
479 | 75 | { | 66 | { |
480 | 76 | public: | 67 | public: |
481 | @@ -87,17 +78,19 @@ | |||
482 | 87 | float darken; | 78 | float darken; |
483 | 88 | GLuint blendMode; | 79 | GLuint blendMode; |
484 | 89 | 80 | ||
490 | 90 | /* Moved from drawParticles to get rid of spurious malloc's */ | 81 | /* Cache used in drawParticles |
491 | 91 | ParticleCache vertices_cache; | 82 | It's here to avoid multiple mem allocation |
492 | 92 | ParticleCache coords_cache; | 83 | during drawing */ |
493 | 93 | ParticleCache colors_cache; | 84 | std::vector<GLfloat> vertices_cache; |
494 | 94 | ParticleCache dcolors_cache; | 85 | std::vector<GLfloat> coords_cache; |
495 | 86 | std::vector<GLushort> colors_cache; | ||
496 | 87 | std::vector<GLushort> dcolors_cache; | ||
497 | 95 | 88 | ||
498 | 96 | void | 89 | void |
499 | 97 | initParticles (int f_numParticles); | 90 | initParticles (int f_numParticles); |
500 | 98 | 91 | ||
501 | 99 | void | 92 | void |
503 | 100 | drawParticles (); | 93 | drawParticles (const GLMatrix &transform); |
504 | 101 | 94 | ||
505 | 102 | void | 95 | void |
506 | 103 | updateParticles (float time); | 96 | updateParticles (float time); |
Again, well done, thanks for the effort.
The only things I would point out are:
1. You probably need to update .install.armhf too (only .install.armel is updated)
2. Coding style: spaces between both brackets () and operators foo + bar not foo+ bar