Project

General

Profile

« Previous | Next » 

Revision c658e742

Added by Leszek Koltunski over 7 years ago

Add quality levels in Glow APP.

View differences:

src/main/java/org/distorted/examples/glow/GlowActivity.java
22 22
import android.app.Activity;
23 23
import android.opengl.GLSurfaceView;
24 24
import android.os.Bundle;
25
import android.view.View;
25 26
import android.widget.SeekBar;
26 27
import android.widget.TextView;
27 28

  
28 29
import org.distorted.examples.R;
30
import org.distorted.library.effect.EffectQuality;
29 31
import org.distorted.library.main.Distorted;
30 32

  
31 33
///////////////////////////////////////////////////////////////////////////////////////////////////
......
83 85
      super.onDestroy();
84 86
      }
85 87

  
86
///////////////////////////////////////////////////////////////////
88
///////////////////////////////////////////////////////////////////////////////////////////////////
87 89

  
88 90
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
89 91
      {
......
100 102
        }
101 103
      }
102 104

  
103
///////////////////////////////////////////////////////////////////
105
///////////////////////////////////////////////////////////////////////////////////////////////////
104 106

  
105 107
    public void onStartTrackingTouch(SeekBar bar) { }
106 108

  
107
///////////////////////////////////////////////////////////////////
109
///////////////////////////////////////////////////////////////////////////////////////////////////
108 110

  
109 111
    public void onStopTrackingTouch(SeekBar bar)  { }
110 112

  
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

  
115
  public void quality0(View v)
116
    {
117
    GlowSurfaceView view = (GlowSurfaceView) this.findViewById(R.id.glowSurfaceView);
118
    GlowRenderer renderer = view.getRenderer();
119
    renderer.setQuality(EffectQuality.HIGHEST);
120
    }
121

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

  
124
  public void quality1(View v)
125
    {
126
    GlowSurfaceView view = (GlowSurfaceView) this.findViewById(R.id.glowSurfaceView);
127
    GlowRenderer renderer = view.getRenderer();
128
    renderer.setQuality(EffectQuality.HIGH);
129
    }
130

  
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132

  
133
  public void quality2(View v)
134
    {
135
    GlowSurfaceView view = (GlowSurfaceView) this.findViewById(R.id.glowSurfaceView);
136
    GlowRenderer renderer = view.getRenderer();
137
    renderer.setQuality(EffectQuality.MEDIUM);
138
    }
139

  
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

  
142
  public void quality3(View v)
143
    {
144
    GlowSurfaceView view = (GlowSurfaceView) this.findViewById(R.id.glowSurfaceView);
145
    GlowRenderer renderer = view.getRenderer();
146
    renderer.setQuality(EffectQuality.LOW);
147
    }
111 148
}
src/main/java/org/distorted/examples/glow/GlowRenderer.java
52 52
   private GLSurfaceView mView;
53 53
   private DistortedTexture mLeaf;
54 54
   private DistortedScreen mScreen;
55
   private PostprocessEffectGlow mGlow;
55 56
   private int mRootW, mRootH;
56 57
   private Static3D mMove, mScale;
57 58
   private Static1D mRadius;
......
71 72
      mRadius= new Static1D(25);
72 73
      mColor = new Static4D(1.0f,0.0f,0.0f,0.5f); // half-transparent red
73 74

  
74
      PostprocessEffectGlow glow = new PostprocessEffectGlow(mRadius,mColor);
75
      glow.setQuality(EffectQuality.HIGHEST);
75
      mGlow  = new PostprocessEffectGlow(mRadius,mColor);
76 76

  
77 77
      DistortedEffects effects = new DistortedEffects();
78 78
      effects.apply(new MatrixEffectMove(mMove));
79 79
      effects.apply(new MatrixEffectScale(mScale));
80
      effects.apply(glow);
80
      effects.apply(mGlow);
81 81

  
82 82
      mScreen = new DistortedScreen();
83 83
      mScreen.attach(mLeaf, effects, new MeshFlat(1,1) );
......
85 85
      mScreen.setDebug(DistortedScreen.DEBUG_FPS);
86 86
      }
87 87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

  
90
   void setQuality(EffectQuality quality)
91
      {
92
      mGlow.setQuality(quality);
93
      }
94

  
88 95
///////////////////////////////////////////////////////////////////////////////////////////////////
89 96

  
90 97
   int setGlowRadius(int glow)
src/main/res/layout/glowlayout.xml
60 60
                android:paddingRight="10dp" />
61 61
    </LinearLayout>
62 62

  
63
    <LinearLayout
64
        android:id="@+id/linearLayout3"
65
        android:layout_width="fill_parent"
66
        android:layout_height="wrap_content"
67
        android:gravity="center|fill_horizontal"
68
        android:orientation="horizontal"
69
        android:background="@color/blue"
70
        android:paddingBottom="10dp"
71
        android:paddingTop="10dp" >
72

  
73
        <RadioGroup
74
            android:id="@+id/glowRadioGroup"
75
            android:layout_width="match_parent"
76
            android:layout_height="wrap_content"
77
            android:orientation="horizontal">
78

  
79
            <RadioButton
80
                android:id="@+id/glowRadioQuality0"
81
                android:layout_width="match_parent"
82
                android:layout_height="wrap_content"
83
                android:layout_weight="1"
84
                android:checked="true"
85
                android:onClick="quality0"
86
                android:text="@string/quality0"
87
                android:textSize="14sp"/>
88

  
89
            <RadioButton
90
                android:id="@+id/glowRadioQuality1"
91
                android:layout_width="match_parent"
92
                android:layout_height="wrap_content"
93
                android:layout_weight="1"
94
                android:onClick="quality1"
95
                android:text="@string/quality1"
96
                android:textSize="14sp"/>
97

  
98
            <RadioButton
99
                android:id="@+id/glowRadioQuality2"
100
                android:layout_width="match_parent"
101
                android:layout_height="wrap_content"
102
                android:layout_weight="1"
103
                android:onClick="quality2"
104
                android:text="@string/quality2"
105
                android:textSize="14sp"/>
106

  
107
            <RadioButton
108
                android:id="@+id/glowRadioQuality3"
109
                android:layout_width="match_parent"
110
                android:layout_height="wrap_content"
111
                android:layout_weight="1"
112
                android:onClick="quality3"
113
                android:text="@string/quality3"
114
                android:textSize="14sp"/>
115

  
116
        </RadioGroup>
117

  
118
    </LinearLayout>
119

  
63 120
</LinearLayout>

Also available in: Unified diff