Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/flatblur/FlatBlurRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.flatblur; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
23 |
import android.content.Context; |
|
24 |
import android.content.pm.ConfigurationInfo; |
|
25 |
import android.content.res.Resources; |
|
22 | 26 |
import android.opengl.GLSurfaceView; |
23 | 27 |
|
24 | 28 |
import org.distorted.library.main.DistortedLibrary; |
25 | 29 |
import org.distorted.library.main.DistortedScreen; |
26 | 30 |
|
31 |
import java.io.InputStream; |
|
32 |
|
|
27 | 33 |
import javax.microedition.khronos.egl.EGLConfig; |
28 | 34 |
import javax.microedition.khronos.opengles.GL10; |
29 | 35 |
|
30 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
31 | 37 |
|
32 |
class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
38 |
class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
33 | 39 |
{ |
34 | 40 |
private final GLSurfaceView mView; |
41 |
private final Resources mResources; |
|
35 | 42 |
private final DistortedScreen mScreen; |
36 | 43 |
|
37 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
39 | 46 |
FlatBlurRenderer(GLSurfaceView v) |
40 | 47 |
{ |
41 | 48 |
mView = v; |
49 |
mResources = v.getResources(); |
|
42 | 50 |
mScreen = new DistortedScreen(); |
43 | 51 |
} |
44 | 52 |
|
... | ... | |
61 | 69 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
62 | 70 |
{ |
63 | 71 |
OverlayStars.enableEffects(); |
64 |
DistortedLibrary.onSurfaceCreated( mView.getContext(), this); |
|
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 |
|
|
65 | 88 |
} |
66 | 89 |
|
67 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
73 | 96 |
|
74 | 97 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | 98 |
|
76 |
public void button1()
|
|
99 |
public int openGlVersion()
|
|
77 | 100 |
{ |
78 |
OverlayStars stars = new OverlayStars(); |
|
79 |
stars.startOverlay(mScreen); |
|
101 |
Context context = mView.getContext(); |
|
102 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
103 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
104 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
105 |
int major = glESversion >> 16; |
|
106 |
int minor = glESversion & 0xff; |
|
107 |
|
|
108 |
return 100*major + 10*minor; |
|
80 | 109 |
} |
81 | 110 |
|
82 | 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
83 | 112 |
|
84 |
public void button2()
|
|
113 |
public InputStream localFile(int fileID)
|
|
85 | 114 |
{ |
115 |
return mResources.openRawResource(fileID); |
|
116 |
} |
|
86 | 117 |
|
118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
119 |
|
|
120 |
public void logMessage(String message) |
|
121 |
{ |
|
122 |
android.util.Log.e("Blur", message ); |
|
87 | 123 |
} |
88 | 124 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.