Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/postprocesstree/PostprocessTreeRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.postprocesstree; |
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; |
... | ... | |
49 | 53 |
|
50 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
51 | 55 |
|
52 |
class PostprocessTreeRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
56 |
class PostprocessTreeRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
53 | 57 |
{ |
54 | 58 |
private static final int LEAF_SIZE = 100; |
55 | 59 |
private static final int NUM_LEAVES = 8; |
56 | 60 |
|
57 |
private GLSurfaceView mView; |
|
58 |
private DistortedTexture mLeaf; |
|
59 |
private DistortedScreen mScreen; |
|
60 |
private Static3D mScale; |
|
61 |
private Static2D mHaloRadius; |
|
61 |
private final GLSurfaceView mView; |
|
62 |
private final Resources mResources; |
|
63 |
private final DistortedTexture mLeaf; |
|
64 |
private final DistortedScreen mScreen; |
|
65 |
private final Static3D mScale; |
|
66 |
private final Static2D mHaloRadius; |
|
62 | 67 |
|
63 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
64 | 69 |
|
65 | 70 |
PostprocessTreeRenderer(GLSurfaceView v) |
66 | 71 |
{ |
67 | 72 |
mView = v; |
73 |
mResources = v.getResources(); |
|
68 | 74 |
|
69 | 75 |
final int OUTER = 9; |
70 | 76 |
final int INNER = 4; |
... | ... | |
177 | 183 |
{ |
178 | 184 |
is.close(); |
179 | 185 |
} |
180 |
catch(IOException e) { }
|
|
186 |
catch(IOException ignored) { }
|
|
181 | 187 |
} |
182 | 188 |
|
183 | 189 |
mLeaf.setTexture(leaf); |
... | ... | |
185 | 191 |
FragmentEffectChroma.enable(); |
186 | 192 |
PostprocessEffectBlur.enable(); |
187 | 193 |
|
188 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
|
194 |
DistortedLibrary.onSurfaceCreated(this); |
|
189 | 195 |
} |
190 | 196 |
|
191 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
194 | 200 |
{ |
195 | 201 |
android.util.Log.e("PostprocessTree", ex.getMessage() ); |
196 | 202 |
} |
203 |
|
|
204 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
205 |
|
|
206 |
public int openGlVersion() |
|
207 |
{ |
|
208 |
Context context = mView.getContext(); |
|
209 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
210 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
211 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
212 |
int major = glESversion >> 16; |
|
213 |
int minor = glESversion & 0xff; |
|
214 |
|
|
215 |
return 100*major + 10*minor; |
|
216 |
} |
|
217 |
|
|
218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
219 |
|
|
220 |
public InputStream localFile(int fileID) |
|
221 |
{ |
|
222 |
return mResources.openRawResource(fileID); |
|
223 |
} |
|
224 |
|
|
225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
226 |
|
|
227 |
public void logMessage(String message) |
|
228 |
{ |
|
229 |
android.util.Log.e("PostprocessTree", message ); |
|
230 |
} |
|
197 | 231 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.