Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/generic/GenericRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.generic; |
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 GenericRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
56 |
class GenericRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
53 | 57 |
{ |
54 | 58 |
private static final float FOV = 30.0f; |
55 | 59 |
private static final float NEAR = 0.1f; |
56 | 60 |
|
57 | 61 |
private final GLSurfaceView mView; |
62 |
private final Resources mResources; |
|
58 | 63 |
private final DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture; |
59 | 64 |
private final DistortedEffects mObjectEffects; |
60 | 65 |
private final DistortedScreen mScreen; |
... | ... | |
76 | 81 |
GenericRenderer(GLSurfaceView v) |
77 | 82 |
{ |
78 | 83 |
mView = v; |
84 |
mResources = v.getResources(); |
|
79 | 85 |
|
80 | 86 |
GenericActivity2 act = (GenericActivity2)v.getContext(); |
81 | 87 |
|
... | ... | |
320 | 326 |
Effect.enableEffects(EffectType.POSTPROCESS); |
321 | 327 |
|
322 | 328 |
DistortedLibrary.needTransformFeedback(); |
323 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
|
329 |
DistortedLibrary.onSurfaceCreated(this); |
|
324 | 330 |
} |
325 | 331 |
|
326 | 332 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
329 | 335 |
{ |
330 | 336 |
android.util.Log.e("Generic", ex.getMessage() ); |
331 | 337 |
} |
338 |
|
|
339 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
340 |
|
|
341 |
public int openGlVersion() |
|
342 |
{ |
|
343 |
Context context = mView.getContext(); |
|
344 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
345 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
346 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
347 |
int major = glESversion >> 16; |
|
348 |
int minor = glESversion & 0xff; |
|
349 |
|
|
350 |
return 100*major + 10*minor; |
|
351 |
} |
|
352 |
|
|
353 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
354 |
|
|
355 |
public InputStream localFile(int fileID) |
|
356 |
{ |
|
357 |
return mResources.openRawResource(fileID); |
|
358 |
} |
|
359 |
|
|
360 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
361 |
|
|
362 |
public void logMessage(String message) |
|
363 |
{ |
|
364 |
android.util.Log.e("Generic", message ); |
|
365 |
} |
|
332 | 366 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.