Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
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
  private final long mID;
27
  private final int mType;
28
  private final int mName;
29
  private final int mDimension;
30
  private final boolean mSupportsR;
31
  private final boolean mSupportsC;
32
  private final String mStr;
33

    
34
  private static long mNextID = 0;
35

    
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.
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  public abstract boolean compute(float[] uniforms, int index, long currentDuration, long step );
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
  public static void onDestroy()
52
    {
53
    mNextID = 0;
54
    }
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

    
58
  public static void reset(int[] maxtable)
59
    {
60
    maxtable[0] = MatrixEffect.MAX;
61
    maxtable[1] = VertexEffect.MAX;
62
    maxtable[2] = FragmentEffect.MAX;
63
    maxtable[3] = PostprocessEffect.MAX;
64
    }
65

    
66
///////////////////////////////////////////////////////////////////////////////////////////////////
67

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

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

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

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
  public int getName()
83
    {
84
    return mName;
85
    }
86

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

    
89
  public long getID()
90
    {
91
    return mID;
92
    }
93

    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95

    
96
  public String getString()
97
    {
98
    return mStr;
99
    }
100

    
101
///////////////////////////////////////////////////////////////////////////////////////////////////
102

    
103
  public boolean supportsCenter()
104
    {
105
    return mSupportsC;
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  public boolean supportsRegion()
111
    {
112
    return mSupportsR;
113
    }
114

    
115
///////////////////////////////////////////////////////////////////////////////////////////////////
116

    
117
  public int getDimension()
118
    {
119
    return mDimension;
120
    }
121

    
122
///////////////////////////////////////////////////////////////////////////////////////////////////
123

    
124
  Effect(int type, int name, int dimension, boolean center, boolean region, final String str)
125
    {
126
    mID        = mNextID++;
127

    
128
    mName      = name;
129
    mType      = type;
130
    mDimension = dimension;
131
    mSupportsC = center;
132
    mSupportsR = region;
133
    mStr       = str;
134
    }
135
  }
(1-1/23)