Project

General

Profile

« Previous | Next » 

Revision da9b3f07

Added by Leszek Koltunski almost 7 years ago

Progress with support for Effect classes.

The library compiles now!

View differences:

src/main/java/org/distorted/library/effect/Effect.java
23 23

  
24 24
public abstract class Effect
25 25
  {
26
  private final static int MAX_UNITY_DIM = 4;
27
  private final static int NUM_EFFECTS = EffectName.size();
28

  
26 29
  private final long mID;
27
  private final int mType;
28
  private final int mName;
30
  private final EffectType mType;
31
  private final EffectName mName;
29 32
  private final int mDimension;
30 33
  private final boolean mSupportsR;
31 34
  private final boolean mSupportsC;
32
  private final String mStr;
33 35

  
34 36
  private static long mNextID = 0;
35 37

  
36
  public static final int MATRIX      = 0;
37
  public static final int VERTEX      = 1;
38
  public static final int FRAGMENT    = 2;
39
  public static final int POSTPROCESS = 3;
40

  
41
  public static final int LENGTH = 4;           // The number of effect types above.
42
  public static final int MASK= (1<<LENGTH)-1;  // Needed when we do bitwise operations on Effect Types.
43
  static final int MAX_EFFECTS = 1000;          // The can be no more than MAX_EFFECTS effects of a given type.
38
  private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS];
39
  private final static int[]   mUnityDim = new int[NUM_EFFECTS];
44 40

  
45 41
///////////////////////////////////////////////////////////////////////////////////////////////////
46 42

  
......
55 51

  
56 52
///////////////////////////////////////////////////////////////////////////////////////////////////
57 53

  
58
  public static void reset(int[] maxtable)
54
  public boolean isUnity(float[] buffer, int index)
59 55
    {
60
    maxtable[0] = MatrixEffect.MAX;
61
    maxtable[1] = VertexEffect.MAX;
62
    maxtable[2] = FragmentEffect.MAX;
63
    maxtable[3] = PostprocessEffect.MAX;
56
    int name = mName.ordinal();
57

  
58
    switch(mUnityDim[name])
59
      {
60
      case 0: return true;
61
      case 1: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ];
62
      case 2: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
63
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1];
64
      case 3: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
65
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
66
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2];
67
      case 4: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
68
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
69
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2] &&
70
                     buffer[index+3]==mUnity[MAX_UNITY_DIM*name+3];
71
      }
72

  
73
    return false;
64 74
    }
65

  
66 75
///////////////////////////////////////////////////////////////////////////////////////////////////
67 76

  
68
  public static int getType(int name)
69
    {
70
    return name/MAX_EFFECTS;
71
    }
72

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

  
75
  public int getType()
77
  public EffectType getType()
76 78
    {
77 79
    return mType;
78 80
    }
79 81

  
80 82
///////////////////////////////////////////////////////////////////////////////////////////////////
81 83

  
82
  public int getName()
84
  public EffectName getName()
83 85
    {
84 86
    return mName;
85 87
    }
......
95 97

  
96 98
  public String getString()
97 99
    {
98
    return mStr;
100
    return mName.name();
99 101
    }
100 102

  
101 103
///////////////////////////////////////////////////////////////////////////////////////////////////
......
121 123

  
122 124
///////////////////////////////////////////////////////////////////////////////////////////////////
123 125

  
124
  Effect(int type, int name, int dimension, boolean center, boolean region, final String str)
126
  Effect(EffectType type, EffectName name, int dimension, boolean center, boolean region, float[] unity)
125 127
    {
126 128
    mID        = mNextID++;
127 129

  
......
130 132
    mDimension = dimension;
131 133
    mSupportsC = center;
132 134
    mSupportsR = region;
133
    mStr       = str;
135

  
136
    int n = name.ordinal();
137
    int l = unity.length;
138

  
139
    for(int i=0; i<l; i++)
140
      {
141
      mUnity[n*MAX_UNITY_DIM+i] = unity[i];
142
      }
143

  
144
    mUnityDim[n] = l;
134 145
    }
135 146
  }

Also available in: Unified diff