Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/glow/GlowRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.glow; |
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.graphics.Bitmap; |
23 | 27 |
import android.graphics.BitmapFactory; |
24 | 28 |
import android.opengl.GLSurfaceView; |
... | ... | |
44 | 48 |
|
45 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 50 |
|
47 |
class GlowRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
51 |
class GlowRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
48 | 52 |
{ |
49 | 53 |
private static final float HALO_TO_RADIUS = 0.2f; |
50 | 54 |
|
51 | 55 |
private final GLSurfaceView mView; |
56 |
private final Resources mResources; |
|
52 | 57 |
private final DistortedTexture mLeaf; |
53 | 58 |
private final DistortedScreen mScreen; |
54 | 59 |
private final PostprocessEffectGlow mGlow; |
... | ... | |
61 | 66 |
GlowRenderer(GLSurfaceView v) |
62 | 67 |
{ |
63 | 68 |
mView = v; |
69 |
mResources = v.getResources(); |
|
64 | 70 |
|
65 | 71 |
mLeaf = new DistortedTexture(); |
66 | 72 |
mScale = new Static3D(1,1,1); |
... | ... | |
147 | 153 |
|
148 | 154 |
PostprocessEffectGlow.enable(); |
149 | 155 |
|
150 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
|
156 |
DistortedLibrary.onSurfaceCreated(this); |
|
151 | 157 |
} |
152 | 158 |
|
153 | 159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
156 | 162 |
{ |
157 | 163 |
android.util.Log.e("Glow", ex.getMessage() ); |
158 | 164 |
} |
165 |
|
|
166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
167 |
|
|
168 |
public int openGlVersion() |
|
169 |
{ |
|
170 |
Context context = mView.getContext(); |
|
171 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
172 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
173 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
174 |
int major = glESversion >> 16; |
|
175 |
int minor = glESversion & 0xff; |
|
176 |
|
|
177 |
return 100*major + 10*minor; |
|
178 |
} |
|
179 |
|
|
180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
181 |
|
|
182 |
public InputStream localFile(int fileID) |
|
183 |
{ |
|
184 |
return mResources.openRawResource(fileID); |
|
185 |
} |
|
186 |
|
|
187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
188 |
|
|
189 |
public void logMessage(String message) |
|
190 |
{ |
|
191 |
android.util.Log.e("Glow", message ); |
|
192 |
} |
|
159 | 193 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.