Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
---|---|---|
44 | 44 |
import org.distorted.library.type.Static3D; |
45 | 45 |
import org.distorted.library.type.Static4D; |
46 | 46 |
|
47 |
import android.app.ActivityManager; |
|
48 |
import android.content.Context; |
|
49 |
import android.content.pm.ConfigurationInfo; |
|
50 |
import android.content.res.Resources; |
|
47 | 51 |
import android.graphics.Bitmap; |
48 | 52 |
import android.graphics.BitmapFactory; |
49 | 53 |
import android.opengl.GLSurfaceView; |
50 | 54 |
|
51 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
52 | 56 |
|
53 |
class DifferentEffectsRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
57 |
class DifferentEffectsRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
54 | 58 |
{ |
55 | 59 |
private static final int NUM = 3; |
56 | 60 |
|
57 |
private GLSurfaceView mView; |
|
58 |
private DistortedEffects[] mEffects; |
|
61 |
private final GLSurfaceView mView; |
|
62 |
private final Resources mResources; |
|
63 |
private final DistortedEffects[] mEffects; |
|
64 |
private final DistortedScreen mScreen; |
|
65 |
private final Static3D mScale, mScaleBitmap; |
|
66 |
private final Static3D[] mMove; |
|
67 |
|
|
59 | 68 |
private DistortedTexture mTexture; |
60 | 69 |
private MeshSquare mMesh; |
61 |
private DistortedScreen mScreen; |
|
62 |
private Static3D mScale, mScaleBitmap; |
|
63 |
private Static3D[] mMove; |
|
64 | 70 |
private int mBmpWidth, mBmpHeight; |
65 | 71 |
|
66 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
68 | 74 |
DifferentEffectsRenderer(GLSurfaceView v) |
69 | 75 |
{ |
70 | 76 |
mView = v; |
71 |
|
|
77 |
mResources = v.getResources(); |
|
78 |
|
|
72 | 79 |
// mEffects[0] effects |
73 | 80 |
Static3D pLeft = new Static3D(214 - 594/2, 394 - 600/2, 0); |
74 | 81 |
Static3D pRight= new Static3D(390 - 594/2, 388 - 600/2, 0); |
... | ... | |
188 | 195 |
VertexEffectDistort.enable(); |
189 | 196 |
FragmentEffectChroma.enable(); |
190 | 197 |
|
191 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
|
198 |
DistortedLibrary.onSurfaceCreated(this); |
|
192 | 199 |
} |
193 | 200 |
|
194 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
197 | 204 |
{ |
198 | 205 |
android.util.Log.e("DifferentEffects", ex.getMessage() ); |
199 | 206 |
} |
207 |
|
|
208 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
209 |
|
|
210 |
public int openGlVersion() |
|
211 |
{ |
|
212 |
Context context = mView.getContext(); |
|
213 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
214 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
215 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
216 |
int major = glESversion >> 16; |
|
217 |
int minor = glESversion & 0xff; |
|
218 |
|
|
219 |
return 100*major + 10*minor; |
|
220 |
} |
|
221 |
|
|
222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
223 |
|
|
224 |
public InputStream localFile(int fileID) |
|
225 |
{ |
|
226 |
return mResources.openRawResource(fileID); |
|
227 |
} |
|
228 |
|
|
229 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
230 |
|
|
231 |
public void logMessage(String message) |
|
232 |
{ |
|
233 |
android.util.Log.e("DifferentEffects", message ); |
|
234 |
} |
|
200 | 235 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.