Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/flatblur2/FlatBlur2Renderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.flatblur2; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
23 |
import android.content.Context; |
|
24 |
import android.content.pm.ConfigurationInfo; |
|
22 | 25 |
import android.content.res.Resources; |
23 | 26 |
import android.graphics.Bitmap; |
24 | 27 |
import android.graphics.BitmapFactory; |
... | ... | |
55 | 58 |
|
56 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 60 |
|
58 |
class FlatBlur2Renderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener, ListenerOverlay, EffectListener
|
|
61 |
class FlatBlur2Renderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser, ListenerOverlay, EffectListener
|
|
59 | 62 |
{ |
60 | 63 |
private final GLSurfaceView mView; |
64 |
private final Resources mResources; |
|
61 | 65 |
private final DistortedScreen mScreen; |
62 | 66 |
private Static3D mScale1, mScale2, mMove; |
63 | 67 |
private DistortedNode mNode; |
... | ... | |
68 | 72 |
FlatBlur2Renderer(GLSurfaceView v) |
69 | 73 |
{ |
70 | 74 |
mView = v; |
75 |
mResources = v.getResources(); |
|
71 | 76 |
mScreen = new DistortedScreen(); |
72 | 77 |
} |
73 | 78 |
|
... | ... | |
151 | 156 |
effects.apply((mv)); |
152 | 157 |
|
153 | 158 |
OverlayStars.enableEffects(); |
154 |
DistortedLibrary.onSurfaceCreated( mView.getContext(), this); |
|
155 |
} |
|
156 |
|
|
157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
158 |
|
|
159 |
public void distortedException(Exception ex) |
|
160 |
{ |
|
161 |
android.util.Log.e("FlatBlur2", ex.getMessage() ); |
|
159 |
DistortedLibrary.onSurfaceCreated(this); |
|
162 | 160 |
} |
163 | 161 |
|
164 | 162 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
186 | 184 |
|
187 | 185 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
188 | 186 |
|
189 |
private PostprocessEffectGlow constructGlow() |
|
187 |
private PostprocessEffectGlow constructGlow()
|
|
190 | 188 |
{ |
191 | 189 |
final int DUR_GLO = 3000; |
192 | 190 |
Dynamic2D haloRadius = new Dynamic2D(DUR_GLO,0.5f); |
... | ... | |
223 | 221 |
DistortedEffects effects = mNode.getEffects(); |
224 | 222 |
effects.abortByType(EffectType.POSTPROCESS); |
225 | 223 |
} |
224 |
|
|
225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
226 |
|
|
227 |
public void distortedException(Exception ex) |
|
228 |
{ |
|
229 |
android.util.Log.e("FlatBlur2", ex.getMessage() ); |
|
230 |
} |
|
231 |
|
|
232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
233 |
|
|
234 |
public int openGlVersion() |
|
235 |
{ |
|
236 |
Context context = mView.getContext(); |
|
237 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
238 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
239 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
240 |
int major = glESversion >> 16; |
|
241 |
int minor = glESversion & 0xff; |
|
242 |
|
|
243 |
return 100*major + 10*minor; |
|
244 |
} |
|
245 |
|
|
246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
247 |
|
|
248 |
public InputStream localFile(int fileID) |
|
249 |
{ |
|
250 |
return mResources.openRawResource(fileID); |
|
251 |
} |
|
252 |
|
|
253 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
254 |
|
|
255 |
public void logMessage(String message) |
|
256 |
{ |
|
257 |
android.util.Log.e("FlatBlur2", message ); |
|
258 |
} |
|
226 | 259 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.