Project

General

Profile

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

library / src / main / java / org / distorted / library / effect / Effect.java @ 15aa7d94

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 8eccf334 Leszek Koltunski
33
  private static long mNextID = 0;
34
35 b547aaba leszek
  public static final int MATRIX      = 0;
36
  public static final int VERTEX      = 1;
37
  public static final int FRAGMENT    = 2;
38
  public static final int POSTPROCESS = 3;
39
40
  public static final int LENGTH = 4;           // The number of effect types above.
41
  public static final int MASK= (1<<LENGTH)-1;  // Needed when we do bitwise operations on Effect Types.
42 8eccf334 Leszek Koltunski
43 15aa7d94 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
44
45
  public abstract boolean compute(float[] uniforms, int index, long currentDuration, long step );
46
47 8eccf334 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
48
49 b547aaba leszek
  public static void onDestroy()
50 8eccf334 Leszek Koltunski
    {
51 b547aaba leszek
    mNextID = 0;
52 8eccf334 Leszek Koltunski
    }
53
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
56 b547aaba leszek
  public static void reset(int[] maxtable)
57 8eccf334 Leszek Koltunski
    {
58 b547aaba leszek
    maxtable[0] = MatrixEffect.MAX;
59
    maxtable[1] = VertexEffect.MAX;
60
    maxtable[2] = FragmentEffect.MAX;
61
    maxtable[3] = PostprocessEffect.MAX;
62
    }
63 8eccf334 Leszek Koltunski
64 b547aaba leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
65 8eccf334 Leszek Koltunski
66 b547aaba leszek
  public int getType()
67
    {
68
    return mType;
69
    }
70 8eccf334 Leszek Koltunski
71 6d62a900 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
72
73
  public int getName()
74
    {
75
    return mName;
76
    }
77
78 b547aaba leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
79 8eccf334 Leszek Koltunski
80 b547aaba leszek
  public long getID()
81
    {
82
    return mID;
83 8eccf334 Leszek Koltunski
    }
84
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86
87 b547aaba leszek
  public boolean supportsCenter()
88 8eccf334 Leszek Koltunski
    {
89 b547aaba leszek
    return mSupportsC;
90 8eccf334 Leszek Koltunski
    }
91
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93
94 b547aaba leszek
  public boolean supportsRegion()
95 8eccf334 Leszek Koltunski
    {
96 b547aaba leszek
    return mSupportsR;
97 8eccf334 Leszek Koltunski
    }
98
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100
101 b547aaba leszek
  public int getDimension()
102 8eccf334 Leszek Koltunski
    {
103 b547aaba leszek
    return mDimension;
104 8eccf334 Leszek Koltunski
    }
105
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107
108 c828808d Leszek Koltunski
  Effect(int type, int name, int dimension, boolean center, boolean region)
109 8eccf334 Leszek Koltunski
    {
110 b547aaba leszek
    mID        = mNextID++;
111 6d62a900 Leszek Koltunski
112
    mName      = name;
113 b547aaba leszek
    mType      = type;
114
    mDimension = dimension;
115
    mSupportsC = center;
116
    mSupportsR = region;
117 8eccf334 Leszek Koltunski
    }
118
  }