Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/deferredjob/DeferredJobRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.deferredjob; |
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.Canvas; |
24 | 28 |
import android.graphics.Paint; |
25 | 29 |
import android.opengl.GLSurfaceView; |
26 | 30 |
|
27 |
import org.distorted.library.effect.EffectType; |
|
28 | 31 |
import org.distorted.library.effect.MatrixEffectMove; |
29 | 32 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
30 | 33 |
import org.distorted.library.effect.MatrixEffectScale; |
... | ... | |
43 | 46 |
import org.distorted.library.type.Static3D; |
44 | 47 |
import org.distorted.library.type.Static4D; |
45 | 48 |
|
49 |
import java.io.InputStream; |
|
50 |
|
|
46 | 51 |
import javax.microedition.khronos.egl.EGLConfig; |
47 | 52 |
import javax.microedition.khronos.opengles.GL10; |
48 | 53 |
|
49 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 55 |
|
51 |
class DeferredJobRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
56 |
class DeferredJobRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
52 | 57 |
{ |
53 |
private GLSurfaceView mView; |
|
58 |
private final GLSurfaceView mView; |
|
59 |
private final Resources mResources; |
|
60 |
private final DistortedScreen mScreen; |
|
61 |
private final DistortedEffects mEffects; |
|
62 |
private final Static3D mScale; |
|
63 |
private final VertexEffectRotate mRotate; |
|
64 |
private final Dynamic1D mAngleDyn; |
|
65 |
private final Static1D mAngle; |
|
66 |
|
|
54 | 67 |
private DistortedTexture mTexture; |
55 |
private DistortedScreen mScreen; |
|
56 |
private DistortedEffects mEffects; |
|
57 |
private Static3D mScale; |
|
58 | 68 |
private MeshBase mMesh; |
59 |
private VertexEffectRotate mRotate; |
|
60 |
private Dynamic1D mAngleDyn; |
|
61 |
private Static1D mAngle; |
|
62 | 69 |
|
63 | 70 |
Static4D mQuat1, mQuat2; |
64 | 71 |
int mScreenMin; |
... | ... | |
68 | 75 |
DeferredJobRenderer(GLSurfaceView v) |
69 | 76 |
{ |
70 | 77 |
mView = v; |
78 |
mResources = v.getResources(); |
|
79 |
|
|
71 | 80 |
mScreen = new DistortedScreen(); |
72 | 81 |
mScale= new Static3D(1,1,1); |
73 | 82 |
Static3D center=new Static3D(0,0,0); |
... | ... | |
134 | 143 |
|
135 | 144 |
VertexEffectRotate.enable(); |
136 | 145 |
|
137 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this); |
|
138 |
} |
|
139 |
|
|
140 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
141 |
|
|
142 |
public void distortedException(Exception ex) |
|
143 |
{ |
|
144 |
android.util.Log.e("DeferredJob", ex.getMessage() ); |
|
146 |
DistortedLibrary.onSurfaceCreated(this); |
|
145 | 147 |
} |
146 | 148 |
|
147 | 149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
260 | 262 |
return result; |
261 | 263 |
} |
262 | 264 |
|
265 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
266 |
|
|
267 |
public void distortedException(Exception ex) |
|
268 |
{ |
|
269 |
android.util.Log.e("DeferredJob", ex.getMessage() ); |
|
270 |
} |
|
271 |
|
|
272 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
273 |
|
|
274 |
public int openGlVersion() |
|
275 |
{ |
|
276 |
Context context = mView.getContext(); |
|
277 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
278 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
279 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
280 |
int major = glESversion >> 16; |
|
281 |
int minor = glESversion & 0xff; |
|
282 |
|
|
283 |
return 100*major + 10*minor; |
|
284 |
} |
|
285 |
|
|
286 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
287 |
|
|
288 |
public InputStream localFile(int fileID) |
|
289 |
{ |
|
290 |
return mResources.openRawResource(fileID); |
|
291 |
} |
|
292 |
|
|
293 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
294 |
|
|
295 |
public void logMessage(String message) |
|
296 |
{ |
|
297 |
android.util.Log.e("DeferredJob", message ); |
|
298 |
} |
|
263 | 299 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.