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 GLSurfaceView mView;
|
41
|
private final Resources mResources;
|
42
|
private final DistortedScreen mScreen;
|
43
|
|
44
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
45
|
|
46
|
FlatBlurRenderer(GLSurfaceView v)
|
47
|
{
|
48
|
mView = v;
|
49
|
mResources = v.getResources();
|
50
|
mScreen = new DistortedScreen();
|
51
|
}
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
public void onDrawFrame(GL10 glUnused)
|
56
|
{
|
57
|
mScreen.render(System.currentTimeMillis());
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
63
|
{
|
64
|
mScreen.resize(width,height);
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
|
69
|
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
70
|
{
|
71
|
OverlayStars.enableEffects();
|
72
|
DistortedLibrary.onSurfaceCreated(this);
|
73
|
}
|
74
|
|
75
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76
|
|
77
|
public void button1()
|
78
|
{
|
79
|
OverlayStars stars = new OverlayStars();
|
80
|
stars.startOverlay(mScreen);
|
81
|
}
|
82
|
|
83
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
84
|
|
85
|
public void button2()
|
86
|
{
|
87
|
|
88
|
}
|
89
|
|
90
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
91
|
|
92
|
public void distortedException(Exception ex)
|
93
|
{
|
94
|
android.util.Log.e("FlatBlur", ex.getMessage() );
|
95
|
}
|
96
|
|
97
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
98
|
|
99
|
public InputStream localFile(int fileID)
|
100
|
{
|
101
|
return mResources.openRawResource(fileID);
|
102
|
}
|
103
|
|
104
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
105
|
|
106
|
public void logMessage(String message)
|
107
|
{
|
108
|
android.util.Log.e("Blur", message );
|
109
|
}
|
110
|
}
|