Project

General

Profile

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

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

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 310e14fb leszek
// FRAGMENT EFFECTS
24 0dd98279 Leszek Koltunski
25 8eccf334 Leszek Koltunski
26
public abstract class FragmentEffect extends Effect
27
  {
28 0dd98279 Leszek Koltunski
  public static final int NUM_UNIFORMS = 8; // 4-per effect interpolated values, 4 dimensional Region.
29 7cd24173 leszek
  private static String mGLSL = "";
30
  private static int mNumEnabled = 0;
31 15aa7d94 Leszek Koltunski
32 b547aaba leszek
///////////////////////////////////////////////////////////////////////////////////////////////////
33
34 a0d5e302 Leszek Koltunski
  FragmentEffect(EffectName name)
35 b547aaba leszek
    {
36 9d0d8530 leszek
    super(name);
37 b547aaba leszek
    }
38 7cd24173 leszek
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40
41
  static void addEffect(EffectName not_smooth, EffectName yes_smooth, String code)
42
    {
43 9af837e8 leszek
    int effect1 = not_smooth.ordinal();
44
    int effect2 = yes_smooth.ordinal();
45
46
    if( mEnabled[effect1] ) return;
47
48
    mEnabled[effect1] = true;
49 7cd24173 leszek
    mNumEnabled ++;
50
51
    mGLSL +=
52
53 9af837e8 leszek
         "if( fName[i]=="+effect1+")\n"
54 7cd24173 leszek
        +  "{\n"
55
        +  "degree = sign(degree); \n"
56
        +   code +"\n"
57
        +  "}\n"
58
        +"else\n"
59 9af837e8 leszek
        +"if( fName[i]=="+effect2+")\n"
60 7cd24173 leszek
        +  "{\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 8eccf334 Leszek Koltunski
  }