Project

General

Profile

« Previous | Next » 

Revision 1e438fc7

Added by Leszek Koltunski almost 8 years ago

Introduce ENUM EffectTypes

View differences:

src/main/java/org/distorted/library/DistortedObject.java
9 9
 * All Objects to which Distorted Graphics effects can be applied need to be extended from here.
10 10
 */
11 11
public abstract class DistortedObject 
12
{ 
13
    static final int TYPE_NUM = 4;
14
    private static final int TYPE_MASK= (1<<TYPE_NUM)-1;
12
{
15 13
    private static float[] mViewMatrix = new float[16];
16 14
   
17
    protected EffectListPreShader  mM;
15
    protected EffectListMatrix     mM;
18 16
    protected EffectListFragment   mF;
19 17
    protected EffectListVertex     mV;
20
    protected EffectListPostShader mP;
18
    protected EffectListOther      mO;
21 19

  
22 20
    protected boolean matrixCloned, vertexCloned, fragmentCloned;
23 21
 
......
62 60
        } 
63 61
      else
64 62
        {
65
        mM = new EffectListPreShader(d);
63
        mM = new EffectListMatrix(d);
66 64
        matrixCloned = false;  
67 65
        }
68 66
    
......
88 86
        fragmentCloned = false;   
89 87
        }
90 88

  
91
      mP = new EffectListPostShader(d); // PostShader effects are never cloned.
89
      mO= new EffectListOther(d); // Other effects are never cloned.
92 90
      }
93 91
    
94 92
///////////////////////////////////////////////////////////////////////////////////////////////////
......
134 132
       
135 133
      mGrid.draw();
136 134

  
137
      mP.send();
135
      mO.send();
138 136
      }
139 137

  
140 138
///////////////////////////////////////////////////////////////////////////////////////////////////
......
156 154
      if( vertexCloned  ==false) mV.abortAll();
157 155
      if( fragmentCloned==false) mF.abortAll();
158 156

  
159
      mP.abortAll();
157
      mO.abortAll();
160 158

  
161 159
      mBmp          = null;
162 160
      mGrid         = null;
163 161
      mM            = null;
164 162
      mV            = null;
165 163
      mF            = null;
166
      mP            = null;
164
      mO            = null;
167 165
      mTextureDataH = null;
168 166
      }
169 167
 
......
291 289
     mV.addListener(el);
292 290
     mF.addListener(el);
293 291
     mM.addListener(el);
294
     mP.addListener(el);
292
     mO.addListener(el);
295 293
     }
296 294

  
297 295
///////////////////////////////////////////////////////////////////////////////////////////////////
......
305 303
     mV.removeListener(el);
306 304
     mF.removeListener(el);
307 305
     mM.removeListener(el);
308
     mP.removeListener(el);
306
     mO.removeListener(el);
309 307
     }
310 308
   
311 309
///////////////////////////////////////////////////////////////////////////////////////////////////
......
361 359
      mM.abortAll();
362 360
      mV.abortAll();
363 361
      mF.abortAll();
364
      mP.abortAll();
362
      mO.abortAll();
365 363
      }
366 364

  
367 365
///////////////////////////////////////////////////////////////////////////////////////////////////
......
372 370
 */
373 371
    public void abortAllEffects(int mask)
374 372
      {
375
      if( (mask & Distorted.TYPE_PRE ) != 0 ) mM.abortAll();
376
      if( (mask & Distorted.TYPE_VERT) != 0 ) mV.abortAll();
377
      if( (mask & Distorted.TYPE_FRAG) != 0 ) mF.abortAll();
378
      if( (mask & Distorted.TYPE_POST) != 0 ) mP.abortAll();
373
      if( (mask & EffectTypes.MATRIX.type   ) != 0 ) mM.abortAll();
374
      if( (mask & EffectTypes.VERTEX.type   ) != 0 ) mV.abortAll();
375
      if( (mask & EffectTypes.FRAGMENT.type ) != 0 ) mF.abortAll();
376
      if( (mask & EffectTypes.OTHER.type    ) != 0 ) mO.abortAll();
379 377
      }
380 378
    
381 379
///////////////////////////////////////////////////////////////////////////////////////////////////
......
387 385
 */
388 386
    public boolean abortEffect(long id)
389 387
      {
390
      switch( (int)(id&TYPE_MASK) )
391
        {
392
        case Distorted.TYPE_PRE : return mM.removeByID(id>>TYPE_NUM);
393
        case Distorted.TYPE_VERT: return mV.removeByID(id>>TYPE_NUM);
394
        case Distorted.TYPE_FRAG: return mF.removeByID(id>>TYPE_NUM);
395
        case Distorted.TYPE_POST: return mP.removeByID(id>>TYPE_NUM);
396
        default                 : return false;
397
        }
388
      int type = (int)(id&EffectTypes.MASK);
389

  
390
      if( type==EffectTypes.MATRIX.type   )  return mM.removeByID(id>>EffectTypes.LENGTH);
391
      if( type==EffectTypes.VERTEX.type   )  return mV.removeByID(id>>EffectTypes.LENGTH);
392
      if( type==EffectTypes.FRAGMENT.type )  return mF.removeByID(id>>EffectTypes.LENGTH);
393
      if( type==EffectTypes.OTHER.type    )  return mO.removeByID(id>>EffectTypes.LENGTH);
394

  
395
      return false;
398 396
      }
399 397

  
400 398
///////////////////////////////////////////////////////////////////////////////////////////////////
......
408 406
      {
409 407
      switch(effectType.getType())
410 408
        {
411
        case Distorted.TYPE_PRE : return mM.removeByType(effectType);
412
        case Distorted.TYPE_VERT: return mV.removeByType(effectType);
413
        case Distorted.TYPE_FRAG: return mF.removeByType(effectType);
414
        case Distorted.TYPE_POST: return mP.removeByType(effectType);
415
        default                 : return false;
409
        case MATRIX  : return mM.removeByType(effectType);
410
        case VERTEX  : return mV.removeByType(effectType);
411
        case FRAGMENT: return mF.removeByType(effectType);
412
        case OTHER   : return mO.removeByType(effectType);
413
        default           : return false;
416 414
        }
417 415
      }
418 416
    
......
426 424
    
427 425
    public boolean printEffect(long id)
428 426
      {
429
      switch( (int)(id&TYPE_MASK) )
430
        {
431
        case Distorted.TYPE_PRE : return mM.printByID(id>>TYPE_NUM);
432
        case Distorted.TYPE_VERT: return mV.printByID(id>>TYPE_NUM);
433
        case Distorted.TYPE_FRAG: return mF.printByID(id>>TYPE_NUM);
434
        case Distorted.TYPE_POST: return mP.printByID(id>>TYPE_NUM);
435
        default                 : return false;
436
        }
427
      int type = (int)(id&EffectTypes.MASK);
428

  
429
      if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
430
      if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
431
      if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
432
      if( type==EffectTypes.OTHER.type    )  return mO.printByID(id>>EffectTypes.LENGTH);
433

  
434
      return false;
437 435
      }
438 436
   
439 437
///////////////////////////////////////////////////////////////////////////////////////////////////   

Also available in: Unified diff