Revision b3618cb5
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/library/DistortedObject.java | ||
---|---|---|
10 | 10 |
*/ |
11 | 11 |
public abstract class DistortedObject |
12 | 12 |
{ |
13 |
static final int TYPE_NUM = 3;
|
|
13 |
static final int TYPE_NUM = 4;
|
|
14 | 14 |
private static final int TYPE_MASK= (1<<TYPE_NUM)-1; |
15 | 15 |
private static float[] mViewMatrix = new float[16]; |
16 | 16 |
|
17 |
protected EffectListMatrix mM; |
|
18 |
protected EffectListFragment mF; |
|
19 |
protected EffectListVertex mV; |
|
17 |
protected EffectListPreShader mM; |
|
18 |
protected EffectListFragment mF; |
|
19 |
protected EffectListVertex mV; |
|
20 |
protected EffectListPostShader mP; |
|
20 | 21 |
|
21 | 22 |
protected boolean matrixCloned, vertexCloned, fragmentCloned; |
22 | 23 |
|
... | ... | |
54 | 55 |
|
55 | 56 |
protected void initializeEffectLists(DistortedObject d, int flags) |
56 | 57 |
{ |
57 |
if( (flags & Distorted.CLONE_MATRIX) != 0 )
|
|
58 |
if( (flags & Distorted.CLONE_PRESHADER) != 0 )
|
|
58 | 59 |
{ |
59 | 60 |
mM = d.mM; |
60 | 61 |
matrixCloned = true; |
61 | 62 |
} |
62 | 63 |
else |
63 | 64 |
{ |
64 |
mM = new EffectListMatrix(d);
|
|
65 |
mM = new EffectListPreShader(d);
|
|
65 | 66 |
matrixCloned = false; |
66 | 67 |
} |
67 | 68 |
|
... | ... | |
86 | 87 |
mF = new EffectListFragment(d); |
87 | 88 |
fragmentCloned = false; |
88 | 89 |
} |
90 |
|
|
91 |
mP = new EffectListPostShader(d); // PostShader effects are never cloned. |
|
89 | 92 |
} |
90 | 93 |
|
91 | 94 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
130 | 133 |
mF.send(); |
131 | 134 |
|
132 | 135 |
mGrid.draw(); |
136 |
|
|
137 |
mP.send(); |
|
133 | 138 |
} |
134 | 139 |
|
135 | 140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
151 | 156 |
if( vertexCloned ==false) mV.abortAll(); |
152 | 157 |
if( fragmentCloned==false) mF.abortAll(); |
153 | 158 |
|
159 |
mP.abortAll(); |
|
160 |
|
|
154 | 161 |
mBmp = null; |
155 | 162 |
mGrid = null; |
156 | 163 |
mM = null; |
157 | 164 |
mV = null; |
158 | 165 |
mF = null; |
166 |
mP = null; |
|
159 | 167 |
mTextureDataH = null; |
160 | 168 |
} |
161 | 169 |
|
... | ... | |
184 | 192 |
* |
185 | 193 |
* @param dc Source object to create our object from |
186 | 194 |
* @param flags A bitmask of values specifying what to copy. |
187 |
* For example, CLONE_BITMAP | CLONE_MATRIX.
|
|
195 |
* For example, CLONE_BITMAP | CLONE_PRESHADER.
|
|
188 | 196 |
*/ |
189 | 197 |
public DistortedObject(DistortedObject dc, int flags) |
190 | 198 |
{ |
... | ... | |
283 | 291 |
mV.addListener(el); |
284 | 292 |
mF.addListener(el); |
285 | 293 |
mM.addListener(el); |
294 |
mP.addListener(el); |
|
286 | 295 |
} |
287 | 296 |
|
288 | 297 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
296 | 305 |
mV.removeListener(el); |
297 | 306 |
mF.removeListener(el); |
298 | 307 |
mM.removeListener(el); |
308 |
mP.removeListener(el); |
|
299 | 309 |
} |
300 | 310 |
|
301 | 311 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
351 | 361 |
mM.abortAll(); |
352 | 362 |
mV.abortAll(); |
353 | 363 |
mF.abortAll(); |
364 |
mP.abortAll(); |
|
354 | 365 |
} |
355 | 366 |
|
356 | 367 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
357 | 368 |
/** |
358 | 369 |
* Aborts a subset of Effects. |
359 | 370 |
* |
360 |
* @param mask Bitmask of the types of effects we want to abort, e.g. TYPE_MATR | TYPE_VERT | TYPE_FRAG.
|
|
371 |
* @param mask Bitmask of the types of effects we want to abort, e.g. TYPE_PRE | TYPE_VERT | TYPE_FRAG.
|
|
361 | 372 |
*/ |
362 | 373 |
public void abortAllEffects(int mask) |
363 | 374 |
{ |
364 |
if( (mask & Distorted.TYPE_MATR) != 0 ) mM.abortAll();
|
|
375 |
if( (mask & Distorted.TYPE_PRE ) != 0 ) mM.abortAll();
|
|
365 | 376 |
if( (mask & Distorted.TYPE_VERT) != 0 ) mV.abortAll(); |
366 | 377 |
if( (mask & Distorted.TYPE_FRAG) != 0 ) mF.abortAll(); |
378 |
if( (mask & Distorted.TYPE_POST) != 0 ) mP.abortAll(); |
|
367 | 379 |
} |
368 | 380 |
|
369 | 381 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
377 | 389 |
{ |
378 | 390 |
switch( (int)(id&TYPE_MASK) ) |
379 | 391 |
{ |
380 |
case Distorted.TYPE_MATR: return mM.removeByID(id>>TYPE_NUM);
|
|
392 |
case Distorted.TYPE_PRE : return mM.removeByID(id>>TYPE_NUM);
|
|
381 | 393 |
case Distorted.TYPE_VERT: return mV.removeByID(id>>TYPE_NUM); |
382 | 394 |
case Distorted.TYPE_FRAG: return mF.removeByID(id>>TYPE_NUM); |
395 |
case Distorted.TYPE_POST: return mP.removeByID(id>>TYPE_NUM); |
|
383 | 396 |
default : return false; |
384 | 397 |
} |
385 | 398 |
} |
... | ... | |
395 | 408 |
{ |
396 | 409 |
switch(effectType.getType()) |
397 | 410 |
{ |
398 |
case Distorted.TYPE_MATR: return mM.removeByType(effectType);
|
|
411 |
case Distorted.TYPE_PRE : return mM.removeByType(effectType);
|
|
399 | 412 |
case Distorted.TYPE_VERT: return mV.removeByType(effectType); |
400 | 413 |
case Distorted.TYPE_FRAG: return mF.removeByType(effectType); |
414 |
case Distorted.TYPE_POST: return mP.removeByType(effectType); |
|
401 | 415 |
default : return false; |
402 | 416 |
} |
403 | 417 |
} |
... | ... | |
414 | 428 |
{ |
415 | 429 |
switch( (int)(id&TYPE_MASK) ) |
416 | 430 |
{ |
417 |
case Distorted.TYPE_MATR: return mM.printByID(id>>TYPE_NUM);
|
|
431 |
case Distorted.TYPE_PRE : return mM.printByID(id>>TYPE_NUM);
|
|
418 | 432 |
case Distorted.TYPE_VERT: return mV.printByID(id>>TYPE_NUM); |
419 | 433 |
case Distorted.TYPE_FRAG: return mF.printByID(id>>TYPE_NUM); |
434 |
case Distorted.TYPE_POST: return mP.printByID(id>>TYPE_NUM); |
|
420 | 435 |
default : return false; |
421 | 436 |
} |
422 | 437 |
} |
Also available in: Unified diff
Beginnings of support for PostShader effects (SavePNG, SaveMP4)