Revision dc10a48d
Added by Leszek Koltunski about 1 year ago
src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
---|---|---|
22 | 22 |
import javax.microedition.khronos.egl.EGLConfig; |
23 | 23 |
import javax.microedition.khronos.opengles.GL10; |
24 | 24 |
|
25 |
import android.app.ActivityManager; |
|
26 |
import android.content.Context; |
|
27 |
import android.content.pm.ConfigurationInfo; |
|
28 |
import android.content.res.Resources; |
|
25 | 29 |
import android.graphics.Bitmap; |
26 | 30 |
import android.graphics.Canvas; |
27 | 31 |
import android.graphics.Paint; |
... | ... | |
44 | 48 |
import org.distorted.library.mesh.MeshSquare; |
45 | 49 |
import org.distorted.library.type.Static3D; |
46 | 50 |
|
51 |
import java.io.InputStream; |
|
52 |
|
|
47 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
48 | 54 |
|
49 |
class MovingEffectsRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
55 |
class MovingEffectsRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
50 | 56 |
{ |
51 |
private MovingEffectsSurfaceView mView; |
|
57 |
private final MovingEffectsSurfaceView mView; |
|
58 |
private final DistortedEffects mEffects; |
|
59 |
private final DistortedTexture mTexture; |
|
60 |
private final DistortedScreen mScreen; |
|
61 |
private final Static3D mScaleMatrix, mScaleVertex; |
|
62 |
private final Paint mPaint; |
|
63 |
private final Resources mResources; |
|
64 |
|
|
65 |
private MeshSquare mMesh; |
|
52 | 66 |
private Canvas mCanvas; |
53 | 67 |
private Bitmap mBitmap; |
54 |
private Paint mPaint; |
|
55 | 68 |
private int texW, texH; |
56 |
|
|
57 |
private DistortedEffects mEffects; |
|
58 |
private DistortedTexture mTexture; |
|
59 |
private DistortedScreen mScreen; |
|
60 |
private MeshSquare mMesh; |
|
61 | 69 |
private boolean mRefresh; |
62 |
private Static3D mScaleMatrix, mScaleVertex; |
|
63 | 70 |
|
64 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
65 | 72 |
|
66 | 73 |
MovingEffectsRenderer(MovingEffectsSurfaceView v) |
67 |
{ |
|
74 |
{ |
|
75 |
mView = v; |
|
76 |
mResources = v.getResources(); |
|
77 |
|
|
68 | 78 |
mPaint = new Paint(); |
69 | 79 |
mPaint.setAntiAlias(true); |
70 | 80 |
mPaint.setFakeBoldText(true); |
71 | 81 |
mPaint.setStyle(Style.FILL); |
72 | 82 |
|
73 |
mView = v; |
|
74 | 83 |
mEffects= new DistortedEffects(); |
75 | 84 |
mScreen = new DistortedScreen(); |
76 | 85 |
mTexture= new DistortedTexture(); |
... | ... | |
178 | 187 |
FragmentEffectChroma.enable(); |
179 | 188 |
FragmentEffectAlpha.enable(); |
180 | 189 |
|
181 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
|
190 |
DistortedLibrary.onSurfaceCreated(this); |
|
182 | 191 |
} |
183 | 192 |
|
184 | 193 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
187 | 196 |
{ |
188 | 197 |
android.util.Log.e("MovingEffects", ex.getMessage() ); |
189 | 198 |
} |
199 |
|
|
200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
201 |
|
|
202 |
public int openGlVersion() |
|
203 |
{ |
|
204 |
Context context = mView.getContext(); |
|
205 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
206 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
207 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
208 |
int major = glESversion >> 16; |
|
209 |
int minor = glESversion & 0xff; |
|
210 |
|
|
211 |
return 100*major + 10*minor; |
|
212 |
} |
|
213 |
|
|
214 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
215 |
|
|
216 |
public InputStream localFile(int fileID) |
|
217 |
{ |
|
218 |
return mResources.openRawResource(fileID); |
|
219 |
} |
|
220 |
|
|
221 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
222 |
|
|
223 |
public void logMessage(String message) |
|
224 |
{ |
|
225 |
android.util.Log.e("MovingEffects", message ); |
|
226 |
} |
|
190 | 227 |
} |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.