Project

General

Profile

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

library / src / main / java / org / distorted / library / effect / VertexEffect.java @ 041b6dee

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
// VERTEX EFFECTS
24

    
25
public abstract class VertexEffect extends Effect
26
  {
27
  public static final int NUM_UNIFORMS = 12; // 5 per-effect interpolated values, 3-dimensional center, 4-dimensional Region
28
  private static String mGLSL = "";
29
  private static int mNumEnabled = 0;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
  VertexEffect(EffectName name)
34
    {
35
    super(name);
36
    }
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
  static void addEffect(EffectName name, String code)
41
    {
42
    int effect = name.ordinal();
43

    
44
    if( mEnabled[effect] ) return;
45

    
46
    mEnabled[effect] = true;
47
    mNumEnabled ++;
48

    
49
    mGLSL +=
50

    
51
        "if( vName[i]=="+effect+")\n" +
52
          "{\n" +
53
           code +"\n" +
54
          "}\n" +
55
        "else\n";
56
    }
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

    
60
  public static String getGLSL()
61
    {
62
    return mGLSL + "{}";
63
    }
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

    
67
  public static int getNumEnabled()
68
    {
69
    return mNumEnabled;
70
    }
71

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

    
74
  public static void onDestroy()
75
    {
76
    mNumEnabled = 0;
77
    mGLSL = "";
78
    }
79
  }
(19-19/25)