Project

General

Profile

Download (4.95 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / effect / Effect.java @ 6bb59aad

1 8eccf334 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2017 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20
package org.distorted.library.effect;
21
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23
24
public abstract class Effect
25
  {
26 b547aaba leszek
  private final long mID;
27
  private final int mType;
28 6d62a900 Leszek Koltunski
  private final int mName;
29 b547aaba leszek
  private final int mDimension;
30
  private final boolean mSupportsR;
31
  private final boolean mSupportsC;
32 6bb59aad Leszek Koltunski
  private final String mStr;
33 8eccf334 Leszek Koltunski
34
  private static long mNextID = 0;
35
36 b547aaba leszek
  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 6bb59aad Leszek Koltunski
  static final int MAX_EFFECTS = 1000;          // The can be no more than MAX_EFFECTS effects of a given type.
44 8eccf334 Leszek Koltunski
45 15aa7d94 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
46
47
  public abstract boolean compute(float[] uniforms, int index, long currentDuration, long step );
48
49 8eccf334 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
50
51 b547aaba leszek
  public static void onDestroy()
52 8eccf334 Leszek Koltunski
    {
53 b547aaba leszek
    mNextID = 0;
54 8eccf334 Leszek Koltunski
    }
55
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
58 b547aaba leszek
  public static void reset(int[] maxtable)
59 8eccf334 Leszek Koltunski
    {
60 b547aaba leszek
    maxtable[0] = MatrixEffect.MAX;
61
    maxtable[1] = VertexEffect.MAX;
62
    maxtable[2] = FragmentEffect.MAX;
63
    maxtable[3] = PostprocessEffect.MAX;
64
    }
65 8eccf334 Leszek Koltunski
66 6bb59aad Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
67
68
  public static int getType(int name)
69
    {
70
    return name/MAX_EFFECTS;
71
    }
72
73 b547aaba leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
74 8eccf334 Leszek Koltunski
75 b547aaba leszek
  public int getType()
76
    {
77
    return mType;
78
    }
79 8eccf334 Leszek Koltunski
80 6d62a900 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
81
82
  public int getName()
83
    {
84
    return mName;
85
    }
86
87 b547aaba leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
88 8eccf334 Leszek Koltunski
89 b547aaba leszek
  public long getID()
90
    {
91
    return mID;
92 8eccf334 Leszek Koltunski
    }
93
94 6bb59aad Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
95
96
  public String getString()
97
    {
98
    return mStr;
99
    }
100
101 8eccf334 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
102
103 b547aaba leszek
  public boolean supportsCenter()
104 8eccf334 Leszek Koltunski
    {
105 b547aaba leszek
    return mSupportsC;
106 8eccf334 Leszek Koltunski
    }
107
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109
110 b547aaba leszek
  public boolean supportsRegion()
111 8eccf334 Leszek Koltunski
    {
112 b547aaba leszek
    return mSupportsR;
113 8eccf334 Leszek Koltunski
    }
114
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116
117 b547aaba leszek
  public int getDimension()
118 8eccf334 Leszek Koltunski
    {
119 b547aaba leszek
    return mDimension;
120 8eccf334 Leszek Koltunski
    }
121
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123
124 6bb59aad Leszek Koltunski
  Effect(int type, int name, int dimension, boolean center, boolean region, final String str)
125 8eccf334 Leszek Koltunski
    {
126 b547aaba leszek
    mID        = mNextID++;
127 6d62a900 Leszek Koltunski
128
    mName      = name;
129 b547aaba leszek
    mType      = type;
130
    mDimension = dimension;
131
    mSupportsC = center;
132
    mSupportsR = region;
133 6bb59aad Leszek Koltunski
    mStr       = str;
134 8eccf334 Leszek Koltunski
    }
135
  }