1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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.flatblur;
|
21
|
|
22
|
import android.app.ActivityManager;
|
23
|
import android.content.Context;
|
24
|
import android.content.pm.ConfigurationInfo;
|
25
|
import android.content.res.Resources;
|
26
|
import android.opengl.GLSurfaceView;
|
27
|
|
28
|
import org.distorted.library.main.DistortedLibrary;
|
29
|
import org.distorted.library.main.DistortedScreen;
|
30
|
|
31
|
import java.io.InputStream;
|
32
|
|
33
|
import javax.microedition.khronos.egl.EGLConfig;
|
34
|
import javax.microedition.khronos.opengles.GL10;
|
35
|
|
36
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37
|
|
38
|
class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
39
|
{
|
40
|
private final Resources mResources;
|
41
|
private final DistortedScreen mScreen;
|
42
|
|
43
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
44
|
|
45
|
FlatBlurRenderer(GLSurfaceView v)
|
46
|
{
|
47
|
mResources = v.getResources();
|
48
|
mScreen = new DistortedScreen();
|
49
|
}
|
50
|
|
51
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
52
|
|
53
|
public void onDrawFrame(GL10 glUnused)
|
54
|
{
|
55
|
mScreen.render(System.currentTimeMillis());
|
56
|
}
|
57
|
|
58
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
59
|
|
60
|
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
61
|
{
|
62
|
mScreen.resize(width,height);
|
63
|
}
|
64
|
|
65
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66
|
|
67
|
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
68
|
{
|
69
|
OverlayStars.enableEffects();
|
70
|
DistortedLibrary.onSurfaceCreated(this);
|
71
|
}
|
72
|
|
73
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74
|
|
75
|
public void button1()
|
76
|
{
|
77
|
OverlayStars stars = new OverlayStars();
|
78
|
stars.startOverlay(mScreen);
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
public void button2()
|
84
|
{
|
85
|
|
86
|
}
|
87
|
|
88
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89
|
|
90
|
public void distortedException(Exception ex)
|
91
|
{
|
92
|
android.util.Log.e("FlatBlur", ex.getMessage() );
|
93
|
}
|
94
|
|
95
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96
|
|
97
|
public InputStream localFile(int fileID)
|
98
|
{
|
99
|
return mResources.openRawResource(fileID);
|
100
|
}
|
101
|
|
102
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
103
|
|
104
|
public void logMessage(String message)
|
105
|
{
|
106
|
android.util.Log.e("Blur", message );
|
107
|
}
|
108
|
}
|