Project

General

Profile

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

examples / src / main / java / org / distorted / examples / flatblur2 / FlatBlur2Renderer.java @ 395cabff

1 29fdea14 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 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.examples.flatblur2;
21
22
import android.opengl.GLSurfaceView;
23
24
import org.distorted.library.main.DistortedLibrary;
25
import org.distorted.library.main.DistortedScreen;
26
27
import javax.microedition.khronos.egl.EGLConfig;
28
import javax.microedition.khronos.opengles.GL10;
29
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31
32
class FlatBlur2Renderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
33
{
34
    private final GLSurfaceView mView;
35
    private final DistortedScreen mScreen;
36 395cabff Leszek Koltunski
    private OverlayStars mStars;
37 29fdea14 Leszek Koltunski
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40
    FlatBlur2Renderer(GLSurfaceView v)
41
      {
42
      mView = v;
43
      mScreen = new DistortedScreen();
44
      }
45
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47
48
    public void onDrawFrame(GL10 glUnused) 
49
      {
50
      mScreen.render(System.currentTimeMillis());
51
      }
52
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54
55
    public void onSurfaceChanged(GL10 glUnused, int width, int height)
56
      {
57
      mScreen.resize(width,height);
58
      }
59
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61
    
62
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
63
      {
64
      OverlayStars.enableEffects();
65
      DistortedLibrary.onSurfaceCreated( mView.getContext(), this);
66
      }
67
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69
70
    public void distortedException(Exception ex)
71
      {
72
      android.util.Log.e("FlatBlur2", ex.getMessage() );
73
      }
74
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76
77
    public void button1()
78
      {
79 395cabff Leszek Koltunski
      mStars = new OverlayStars();
80
      mStars.startOverlay(mScreen);
81 29fdea14 Leszek Koltunski
      }
82
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84
85
    public void button2()
86
      {
87 395cabff Leszek Koltunski
      if( mStars!=null )
88
        {
89
        mStars.button2();
90
        }
91 29fdea14 Leszek Koltunski
      }
92
}