Project

General

Profile

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

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

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

    
33
  private static long mNextID = 0;
34

    
35
  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

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44

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

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  public static void onDestroy()
50
    {
51
    mNextID = 0;
52
    }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55

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

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

    
66
  public int getType()
67
    {
68
    return mType;
69
    }
70

    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

    
73
  public int getName()
74
    {
75
    return mName;
76
    }
77

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

    
80
  public long getID()
81
    {
82
    return mID;
83
    }
84

    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86

    
87
  public boolean supportsCenter()
88
    {
89
    return mSupportsC;
90
    }
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
  public boolean supportsRegion()
95
    {
96
    return mSupportsR;
97
    }
98

    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

    
101
  public int getDimension()
102
    {
103
    return mDimension;
104
    }
105

    
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

    
108
  Effect(int type, int name, int dimension, boolean center, boolean region)
109
    {
110
    mID        = mNextID++;
111

    
112
    mName      = name;
113
    mType      = type;
114
    mDimension = dimension;
115
    mSupportsC = center;
116
    mSupportsR = region;
117
    }
118
  }
(1-1/23)