Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/flag/FlagRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.flag; |
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; |
... | ... | |
47 | 51 |
|
48 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
49 | 53 |
|
50 |
class FlagRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
54 |
class FlagRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
51 | 55 |
{ |
52 |
private GLSurfaceView mView; |
|
53 |
private DistortedTexture mTexture; |
|
54 |
private DistortedScreen mScreen; |
|
55 |
private Dynamic5D mWaveDyn; |
|
56 |
private Static5D mWaveSta1, mWaveSta2; |
|
57 |
private int mObjWidth, mObjHeight, mObjDepth; |
|
58 |
private Static3D mScale; |
|
56 |
private final GLSurfaceView mView; |
|
57 |
private final DistortedTexture mTexture; |
|
58 |
private final DistortedScreen mScreen; |
|
59 |
private final Dynamic5D mWaveDyn; |
|
60 |
private final Static5D mWaveSta1, mWaveSta2; |
|
61 |
private final int mObjWidth, mObjHeight, mObjDepth; |
|
62 |
private final Static3D mScale; |
|
63 |
private final Resources mResources; |
|
59 | 64 |
|
60 | 65 |
Static4D mQuat1, mQuat2; |
61 | 66 |
int mScreenMin; |
... | ... | |
65 | 70 |
FlagRenderer(GLSurfaceView v) |
66 | 71 |
{ |
67 | 72 |
mView = v; |
73 |
mResources = v.getResources(); |
|
68 | 74 |
|
69 | 75 |
final int GRIDX = 50; |
70 | 76 |
final int GRIDY = 30; |
... | ... | |
191 | 197 |
VertexEffectScale.enable(); |
192 | 198 |
VertexEffectWave.enable(); |
193 | 199 |
|
194 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
|
200 |
DistortedLibrary.onSurfaceCreated(this); |
|
195 | 201 |
} |
196 | 202 |
|
197 | 203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
200 | 206 |
{ |
201 | 207 |
android.util.Log.e("Flag", ex.getMessage() ); |
202 | 208 |
} |
209 |
|
|
210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
211 |
|
|
212 |
public int openGlVersion() |
|
213 |
{ |
|
214 |
Context context = mView.getContext(); |
|
215 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
216 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
217 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
218 |
int major = glESversion >> 16; |
|
219 |
int minor = glESversion & 0xff; |
|
220 |
|
|
221 |
return 100*major + 10*minor; |
|
222 |
} |
|
223 |
|
|
224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
225 |
|
|
226 |
public InputStream localFile(int fileID) |
|
227 |
{ |
|
228 |
return mResources.openRawResource(fileID); |
|
229 |
} |
|
230 |
|
|
231 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
232 |
|
|
233 |
public void logMessage(String message) |
|
234 |
{ |
|
235 |
android.util.Log.e("Flag", message ); |
|
236 |
} |
|
203 | 237 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.