Project

General

Profile

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

library / src / main / java / org / distorted / library / effect / FragmentEffect.java @ 8e28b6ff

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

    
25

    
26
public abstract class FragmentEffect extends Effect
27
  {
28
  public static final int NUM_UNIFORMS = 8; // 4-per effect interpolated values, 4 dimensional Region.
29
  private static String mGLSL = "";
30
  private static int mNumEnabled = 0;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
  FragmentEffect(EffectName name)
35
    {
36
    super(name);
37
    }
38

    
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

    
41
  static void addEffect(EffectName not_smooth, EffectName yes_smooth, String code)
42
    {
43
    int effect1 = not_smooth.ordinal();
44
    int effect2 = yes_smooth.ordinal();
45

    
46
    if( mEnabled[effect1] ) return;
47

    
48
    mEnabled[effect1] = true;
49
    mNumEnabled ++;
50

    
51
    mGLSL +=
52

    
53
         "if( fName[i]=="+effect1+")\n"
54
        +  "{\n"
55
        +  "degree = sign(degree); \n"
56
        +   code +"\n"
57
        +  "}\n"
58
        +"else\n"
59
        +"if( fName[i]=="+effect2+")\n"
60
        +  "{\n"
61
        +   code +"\n"
62
        +  "}\n"
63
        +"else\n";
64
    }
65

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

    
68
  public static String getGLSL()
69
    {
70
    return mGLSL + "{}";
71
    }
72

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

    
75
  public static int getNumEnabled()
76
    {
77
    return mNumEnabled;
78
    }
79

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

    
82
  public static void onDestroy()
83
    {
84
    mNumEnabled = 0;
85
    mGLSL = "";
86
    }
87
  }
(4-4/25)