Revision dc10a48d
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/examples/TableOfContents.java | ||
---|---|---|
88 | 88 |
|
89 | 89 |
private enum Application |
90 | 90 |
{ |
91 |
FLATBLUR2 (R.drawable.icon_example_flatblur , R.string.example_flatblur , R.string.example_flatblur_subtitle , FlatBlur2Activity.class ), |
|
92 |
|
|
93 | 91 |
MONALISA (R.drawable.icon_example_monalisa , R.string.example_monalisa , R.string.example_monalisa_subtitle , MonaLisaActivity.class), |
94 | 92 |
SINK (R.drawable.icon_example_sink , R.string.example_sink , R.string.example_sink_subtitle , SinkActivity.class), |
95 | 93 |
BEAN (R.drawable.icon_example_bean , R.string.example_bean , R.string.example_bean_subtitle , BeanActivity.class), |
... | ... | |
131 | 129 |
DEFERREDJOB (R.drawable.icon_example_deferredjob , R.string.example_deferredjob , R.string.example_deferredjob_subtitle , DeferredJobActivity.class), |
132 | 130 |
SINGLEMESH (R.drawable.icon_example_singlemesh , R.string.example_singlemesh , R.string.example_singlemesh_subtitle , SingleMeshActivity.class), |
133 | 131 |
MESHFILE (R.drawable.icon_example_meshfile , R.string.example_meshfile , R.string.example_meshfile_subtitle , MeshFileActivity.class), |
134 |
FLATBLUR (R.drawable.icon_example_flatblur , R.string.example_flatblur , R.string.example_flatblur_subtitle , FlatBlurActivity.class ), |
|
135 |
|
|
132 |
FLATBLUR2 (R.drawable.icon_example_flatblur , R.string.example_flatblur , R.string.example_flatblur_subtitle , FlatBlur2Activity.class ), |
|
136 | 133 |
; |
137 | 134 |
|
138 | 135 |
final int icon, title, subtitle; |
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.aroundtheworld; |
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; |
... | ... | |
48 | 52 |
|
49 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 54 |
|
51 |
class AroundTheWorldRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
55 |
class AroundTheWorldRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
52 | 56 |
{ |
53 |
private GLSurfaceView mView; |
|
54 |
private DistortedEffects mEffects; |
|
57 |
private final GLSurfaceView mView; |
|
58 |
private final Resources mResources; |
|
59 |
private final DistortedEffects mEffects; |
|
60 |
private final DistortedScreen mScreen; |
|
61 |
private final AroundTheWorldEffectsManager mManager; |
|
62 |
private final Static3D mScaleMatrix, mScaleVertex; |
|
63 |
|
|
55 | 64 |
private DistortedTexture mTexture; |
56 |
private DistortedScreen mScreen; |
|
57 | 65 |
private MeshSquare mMesh; |
58 |
private AroundTheWorldEffectsManager mManager; |
|
59 |
private Static3D mScaleMatrix, mScaleVertex; |
|
60 | 66 |
|
61 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
62 | 68 |
|
63 | 69 |
AroundTheWorldRenderer(GLSurfaceView view) |
64 | 70 |
{ |
71 |
mView = view; |
|
72 |
mResources = view.getResources(); |
|
73 |
|
|
65 | 74 |
mScaleMatrix= new Static3D(1,1,1); |
66 | 75 |
mScaleVertex= new Static3D(1,1,1); |
67 | 76 |
|
68 |
mView = view; |
|
69 | 77 |
mManager = new AroundTheWorldEffectsManager(); |
70 | 78 |
mEffects = new DistortedEffects(); |
71 | 79 |
mEffects.apply(new MatrixEffectScale(mScaleMatrix)); |
... | ... | |
119 | 127 |
{ |
120 | 128 |
is.close(); |
121 | 129 |
} |
122 |
catch(IOException e) { }
|
|
130 |
catch(IOException ignored) { }
|
|
123 | 131 |
} |
124 | 132 |
|
125 | 133 |
int objWidth = bitmap.getWidth(); |
... | ... | |
145 | 153 |
FragmentEffectChroma.enable(); |
146 | 154 |
FragmentEffectContrast.enable(); |
147 | 155 |
|
148 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this);
|
|
156 |
DistortedLibrary.onSurfaceCreated(this); |
|
149 | 157 |
} |
150 | 158 |
|
151 | 159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
154 | 162 |
{ |
155 | 163 |
android.util.Log.e("AroundTheWorld", ex.getMessage() ); |
156 | 164 |
} |
165 |
|
|
166 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
167 |
|
|
168 |
public int openGlVersion() |
|
169 |
{ |
|
170 |
Context context = mView.getContext(); |
|
171 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
172 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
173 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
174 |
int major = glESversion >> 16; |
|
175 |
int minor = glESversion & 0xff; |
|
176 |
|
|
177 |
return 100*major + 10*minor; |
|
178 |
} |
|
179 |
|
|
180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
181 |
|
|
182 |
public InputStream localFile(int fileID) |
|
183 |
{ |
|
184 |
return mResources.openRawResource(fileID); |
|
185 |
} |
|
186 |
|
|
187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
188 |
|
|
189 |
public void logMessage(String message) |
|
190 |
{ |
|
191 |
android.util.Log.e("AroundTheWorld", message ); |
|
192 |
} |
|
157 | 193 |
} |
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
38 | 38 |
import org.distorted.library.type.Static3D; |
39 | 39 |
import org.distorted.library.type.Static4D; |
40 | 40 |
|
41 |
import android.app.ActivityManager; |
|
42 |
import android.content.Context; |
|
43 |
import android.content.pm.ConfigurationInfo; |
|
44 |
import android.content.res.Resources; |
|
41 | 45 |
import android.graphics.Bitmap; |
42 | 46 |
import android.graphics.BitmapFactory; |
43 | 47 |
import android.opengl.GLSurfaceView; |
44 | 48 |
|
45 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 50 |
|
47 |
class BeanRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
51 |
class BeanRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
48 | 52 |
{ |
49 |
private GLSurfaceView mView; |
|
50 |
private DistortedEffects mEffects; |
|
51 |
private DistortedScreen mScreen; |
|
52 |
private DistortedTexture mTexture; |
|
53 |
private final GLSurfaceView mView; |
|
54 |
private final Resources mResources; |
|
55 |
private final DistortedEffects mEffects; |
|
56 |
private final DistortedScreen mScreen; |
|
57 |
private final DistortedTexture mTexture; |
|
58 |
private final Static3D mScale; |
|
59 |
|
|
53 | 60 |
private MeshSquare mMesh; |
54 |
private Static3D mScale; |
|
55 | 61 |
private float mBmpRatio; |
56 | 62 |
|
57 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
60 | 66 |
BeanRenderer(GLSurfaceView v) |
61 | 67 |
{ |
62 | 68 |
mView = v; |
63 |
|
|
69 |
mResources = v.getResources(); |
|
70 |
|
|
64 | 71 |
Static3D pointLeft = new Static3D(-85/366.0f, 57/480.0f, 0); |
65 | 72 |
Static3D pointRight = new Static3D( 50/366.0f, 100/480.0f, 0); |
66 | 73 |
Static4D regionLeft = new Static4D( -3/366.0f, 33/480.0f, 0, 47/400.0f); |
... | ... | |
162 | 169 |
|
163 | 170 |
VertexEffectDistort.enable(); |
164 | 171 |
|
165 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this);
|
|
172 |
DistortedLibrary.onSurfaceCreated(this); |
|
166 | 173 |
} |
167 | 174 |
|
168 | 175 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
171 | 178 |
{ |
172 | 179 |
android.util.Log.e("Bean", ex.getMessage() ); |
173 | 180 |
} |
181 |
|
|
182 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
183 |
|
|
184 |
public int openGlVersion() |
|
185 |
{ |
|
186 |
Context context = mView.getContext(); |
|
187 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
188 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
189 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
190 |
int major = glESversion >> 16; |
|
191 |
int minor = glESversion & 0xff; |
|
192 |
|
|
193 |
return 100*major + 10*minor; |
|
194 |
} |
|
195 |
|
|
196 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
197 |
|
|
198 |
public InputStream localFile(int fileID) |
|
199 |
{ |
|
200 |
return mResources.openRawResource(fileID); |
|
201 |
} |
|
202 |
|
|
203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
204 |
|
|
205 |
public void logMessage(String message) |
|
206 |
{ |
|
207 |
android.util.Log.e("Bean", message ); |
|
208 |
} |
|
174 | 209 |
} |
src/main/java/org/distorted/examples/blur/BlurRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.blur; |
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; |
... | ... | |
45 | 49 |
|
46 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
47 | 51 |
|
48 |
class BlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
52 |
class BlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
49 | 53 |
{ |
50 | 54 |
private final static int SIZE = 500; |
51 | 55 |
private final static float PART = 0.5f; |
52 | 56 |
|
53 |
private GLSurfaceView mView; |
|
57 |
private final GLSurfaceView mView; |
|
58 |
private final Resources mResources; |
|
59 |
private final DistortedEffects mEffects, mBufferEffects; |
|
60 |
private final DistortedScreen mScreen; |
|
61 |
private final DistortedFramebuffer mBuffer; |
|
62 |
private final MeshSquare mMesh, mMeshBuffer; |
|
63 |
private final Static2D mHaloRadiusSta; |
|
64 |
private final Static3D mMove, mScale, mBufferScale; |
|
65 |
|
|
54 | 66 |
private DistortedTexture mTexture; |
55 |
private DistortedEffects mEffects, mBufferEffects; |
|
56 |
private DistortedScreen mScreen; |
|
57 |
private DistortedFramebuffer mBuffer; |
|
58 |
private MeshSquare mMesh, mMeshBuffer; |
|
59 |
private Static2D mHaloRadiusSta; |
|
60 |
private Static3D mMove, mScale, mBufferScale; |
|
61 | 67 |
|
62 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 69 |
|
64 | 70 |
BlurRenderer(GLSurfaceView v) |
65 | 71 |
{ |
66 |
mView = v; |
|
72 |
mView = v; |
|
73 |
mResources = v.getResources(); |
|
74 |
|
|
67 | 75 |
mMesh = new MeshSquare(1,1); |
68 | 76 |
mMeshBuffer = new MeshSquare(1,1); |
69 | 77 |
mScreen = new DistortedScreen(); |
... | ... | |
156 | 164 |
{ |
157 | 165 |
is.close(); |
158 | 166 |
} |
159 |
catch(IOException e) { }
|
|
167 |
catch(IOException ignored) { }
|
|
160 | 168 |
} |
161 | 169 |
|
162 | 170 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
... | ... | |
170 | 178 |
|
171 | 179 |
PostprocessEffectBlur.enable(); |
172 | 180 |
|
173 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this);
|
|
181 |
DistortedLibrary.onSurfaceCreated(this); |
|
174 | 182 |
} |
175 | 183 |
|
176 | 184 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
179 | 187 |
{ |
180 | 188 |
android.util.Log.e("Blur", ex.getMessage() ); |
181 | 189 |
} |
190 |
|
|
191 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
192 |
|
|
193 |
public int openGlVersion() |
|
194 |
{ |
|
195 |
Context context = mView.getContext(); |
|
196 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
197 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
198 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
199 |
int major = glESversion >> 16; |
|
200 |
int minor = glESversion & 0xff; |
|
201 |
|
|
202 |
return 100*major + 10*minor; |
|
203 |
} |
|
204 |
|
|
205 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
206 |
|
|
207 |
public InputStream localFile(int fileID) |
|
208 |
{ |
|
209 |
return mResources.openRawResource(fileID); |
|
210 |
} |
|
211 |
|
|
212 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
213 |
|
|
214 |
public void logMessage(String message) |
|
215 |
{ |
|
216 |
android.util.Log.e("Blur", message ); |
|
217 |
} |
|
182 | 218 |
} |
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
42 | 42 |
import org.distorted.library.type.Static1D; |
43 | 43 |
import org.distorted.library.type.Static3D; |
44 | 44 |
|
45 |
import android.app.ActivityManager; |
|
46 |
import android.content.Context; |
|
47 |
import android.content.pm.ConfigurationInfo; |
|
48 |
import android.content.res.Resources; |
|
45 | 49 |
import android.graphics.Bitmap; |
46 | 50 |
import android.graphics.BitmapFactory; |
47 | 51 |
import android.opengl.GLSurfaceView; |
48 | 52 |
|
49 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 54 |
|
51 |
class CatAndDogRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
55 |
class CatAndDogRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
52 | 56 |
{ |
53 |
private GLSurfaceView mView; |
|
54 |
private DistortedTexture mTexture; |
|
55 |
private DistortedScreen mScreen; |
|
56 |
private Static3D mScaleStart, mScaleEnd, mMoveStart, mMoveEnd; |
|
57 |
private final GLSurfaceView mView; |
|
58 |
private final Resources mResources; |
|
59 |
private final DistortedTexture mTexture; |
|
60 |
private final DistortedScreen mScreen; |
|
61 |
private final Static3D mScaleStart, mScaleEnd, mMoveStart, mMoveEnd; |
|
62 |
|
|
57 | 63 |
private float mBmpRatio; |
58 | 64 |
|
59 | 65 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
64 | 70 |
final int DURATION_MATRIX_EFFECTS = 10000; |
65 | 71 |
|
66 | 72 |
mView = v; |
73 |
mResources = v.getResources(); |
|
67 | 74 |
|
68 | 75 |
DistortedEffects effects = new DistortedEffects(); |
69 | 76 |
|
... | ... | |
114 | 121 |
{ |
115 | 122 |
final float SCALE_START = 0.3f; |
116 | 123 |
final float SCALE_END = 0.6f; |
117 |
float min= (width>height ? height : width);
|
|
124 |
float min= (Math.min(width,height));
|
|
118 | 125 |
|
119 | 126 |
mScaleStart.set( SCALE_START*min, SCALE_START*min*mBmpRatio, 1 ); |
120 | 127 |
mScaleEnd .set( SCALE_END *min, SCALE_END *min*mBmpRatio, 1 ); |
... | ... | |
149 | 156 |
{ |
150 | 157 |
is.close(); |
151 | 158 |
} |
152 |
catch(IOException e) { }
|
|
159 |
catch(IOException ignored) { }
|
|
153 | 160 |
} |
154 | 161 |
|
155 | 162 |
mBmpRatio = (float)bitmap.getHeight()/bitmap.getWidth(); |
... | ... | |
158 | 165 |
FragmentEffectChroma.enable(); |
159 | 166 |
FragmentEffectAlpha.enable(); |
160 | 167 |
|
161 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this);
|
|
168 |
DistortedLibrary.onSurfaceCreated(this); |
|
162 | 169 |
} |
163 | 170 |
|
164 | 171 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
167 | 174 |
{ |
168 | 175 |
android.util.Log.e("CatAndDog", ex.getMessage() ); |
169 | 176 |
} |
177 |
|
|
178 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
179 |
|
|
180 |
public int openGlVersion() |
|
181 |
{ |
|
182 |
Context context = mView.getContext(); |
|
183 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
184 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
185 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
186 |
int major = glESversion >> 16; |
|
187 |
int minor = glESversion & 0xff; |
|
188 |
|
|
189 |
return 100*major + 10*minor; |
|
190 |
} |
|
191 |
|
|
192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
193 |
|
|
194 |
public InputStream localFile(int fileID) |
|
195 |
{ |
|
196 |
return mResources.openRawResource(fileID); |
|
197 |
} |
|
198 |
|
|
199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
200 |
|
|
201 |
public void logMessage(String message) |
|
202 |
{ |
|
203 |
android.util.Log.e("CatAndDog", message ); |
|
204 |
} |
|
170 | 205 |
} |
src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
---|---|---|
44 | 44 |
import org.distorted.library.type.Static4D; |
45 | 45 |
import org.distorted.library.type.Dynamic1D; |
46 | 46 |
|
47 |
import android.app.ActivityManager; |
|
47 | 48 |
import android.app.AlertDialog; |
48 | 49 |
import android.content.Context; |
49 | 50 |
import android.content.DialogInterface; |
51 |
import android.content.pm.ConfigurationInfo; |
|
52 |
import android.content.res.Resources; |
|
50 | 53 |
import android.graphics.Bitmap; |
51 | 54 |
import android.graphics.BitmapFactory; |
52 | 55 |
import android.opengl.GLES31; |
... | ... | |
55 | 58 |
|
56 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 60 |
|
58 |
class CheckRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
61 |
class CheckRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
59 | 62 |
{ |
60 | 63 |
private static String compilationResult; |
61 | 64 |
private static String compilationTitle; |
62 | 65 |
|
63 |
private GLSurfaceView mView; |
|
64 |
private DistortedEffects mEffects; |
|
66 |
private final GLSurfaceView mView; |
|
67 |
private final Resources mResources; |
|
68 |
private final DistortedEffects mEffects; |
|
69 |
private final DistortedScreen mScreen; |
|
70 |
private final Static3D mScaleMatrix, mScaleVertex, mSwirl1, mSwirl2, mDeform1, mDeform2; |
|
71 |
private final Static1D mRadius; |
|
72 |
|
|
65 | 73 |
private DistortedTexture mTexture; |
66 | 74 |
private MeshSquare mMesh; |
67 |
private DistortedScreen mScreen; |
|
68 | 75 |
private int mObjHeight, mObjWidth; |
69 |
private Static3D mScaleMatrix, mScaleVertex, mSwirl1, mSwirl2, mDeform1, mDeform2; |
|
70 |
private Static1D mRadius; |
|
71 | 76 |
|
72 | 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
73 | 78 |
|
74 | 79 |
CheckRenderer(GLSurfaceView view) |
75 | 80 |
{ |
76 | 81 |
mView = view; |
82 |
mResources = view.getResources(); |
|
77 | 83 |
|
78 | 84 |
CheckActivity act = (CheckActivity)mView.getContext(); |
79 | 85 |
|
... | ... | |
180 | 186 |
{ |
181 | 187 |
is.close(); |
182 | 188 |
} |
183 |
catch(IOException e) { }
|
|
189 |
catch(IOException ignored) { }
|
|
184 | 190 |
} |
185 | 191 |
|
186 | 192 |
mObjHeight = bitmap.getHeight(); |
... | ... | |
201 | 207 |
mDeform1.set( 0, 0, 0); |
202 | 208 |
mDeform2.set( 0, mObjHeight, 0); |
203 | 209 |
|
204 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this);
|
|
210 |
DistortedLibrary.onSurfaceCreated(this); |
|
205 | 211 |
} |
206 | 212 |
|
207 | 213 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
252 | 258 |
} |
253 | 259 |
}); |
254 | 260 |
} |
261 |
|
|
262 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
263 |
|
|
264 |
public int openGlVersion() |
|
265 |
{ |
|
266 |
Context context = mView.getContext(); |
|
267 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
268 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
269 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
270 |
int major = glESversion >> 16; |
|
271 |
int minor = glESversion & 0xff; |
|
272 |
|
|
273 |
return 100*major + 10*minor; |
|
274 |
} |
|
275 |
|
|
276 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
277 |
|
|
278 |
public InputStream localFile(int fileID) |
|
279 |
{ |
|
280 |
return mResources.openRawResource(fileID); |
|
281 |
} |
|
282 |
|
|
283 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
284 |
|
|
285 |
public void logMessage(String message) |
|
286 |
{ |
|
287 |
android.util.Log.e("Check", message ); |
|
288 |
} |
|
255 | 289 |
} |
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 |
} |
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
40 | 40 |
import org.distorted.library.type.Static3D; |
41 | 41 |
import org.distorted.library.type.Static4D; |
42 | 42 |
|
43 |
import android.app.ActivityManager; |
|
44 |
import android.content.Context; |
|
45 |
import android.content.pm.ConfigurationInfo; |
|
46 |
import android.content.res.Resources; |
|
43 | 47 |
import android.graphics.Bitmap; |
44 | 48 |
import android.graphics.Canvas; |
45 | 49 |
import android.graphics.Paint; |
46 | 50 |
import android.graphics.Paint.Style; |
47 | 51 |
import android.opengl.GLSurfaceView; |
48 | 52 |
|
53 |
import java.io.InputStream; |
|
54 |
|
|
49 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 56 |
|
51 |
class DeformRenderer implements GLSurfaceView.Renderer, EffectListener, DistortedLibrary.ExceptionListener
|
|
57 |
class DeformRenderer implements GLSurfaceView.Renderer, EffectListener, DistortedLibrary.LibraryUser
|
|
52 | 58 |
{ |
53 | 59 |
private static final int NUM_VECTORS = 8; |
54 | 60 |
private static final int NUM_LINES = 10; |
55 | 61 |
private static final float QUOT = 0.6f; |
56 | 62 |
|
57 |
private GLSurfaceView mView; |
|
58 |
private DistortedTexture mTexture; |
|
59 |
private DistortedEffects mEffects; |
|
60 |
private MeshBase mMesh; |
|
61 |
private DistortedScreen mScreen; |
|
62 |
private Static3D mTouchPoint, mScale; |
|
63 |
|
|
64 |
private Static3D[] vDistort; |
|
65 |
private Static3D[] vDeform; |
|
66 |
private Static3D[] vShear; |
|
63 |
private final GLSurfaceView mView; |
|
64 |
private final Resources mResources; |
|
65 |
private final DistortedTexture mTexture; |
|
66 |
private final DistortedEffects mEffects; |
|
67 |
private final DistortedScreen mScreen; |
|
68 |
private final Static3D mTouchPoint, mScale; |
|
69 |
private final Static3D[] vDistort, vDeform, vShear; |
|
70 |
private final Static4D mRegion; |
|
71 |
private final MatrixEffectShear mMovingShear, mReleasedShear; |
|
72 |
private final VertexEffectDistort mMovingDistort, mReleasedDistort; |
|
73 |
private final VertexEffectDeform mMovingDeform, mReleasedDeform; |
|
74 |
private final Dynamic3D mReleasedDistortDynamic, mReleasedDeformDynamic, mReleasedShearDynamic; |
|
67 | 75 |
|
68 |
private Static4D mRegion; |
|
76 |
private MeshBase mMesh; |
|
77 |
private EffectName mMode = EffectName.DISTORT; |
|
69 | 78 |
private int scrHeight, scrWidth; |
70 | 79 |
private int textureWidth, textureHeight; |
71 | 80 |
private float mRadius; |
72 |
|
|
73 |
private EffectName mMode = EffectName.DISTORT; |
|
74 | 81 |
private long mLastEffect = -1; |
75 | 82 |
|
76 |
private MatrixEffectShear mMovingShear, mReleasedShear; |
|
77 |
private VertexEffectDistort mMovingDistort, mReleasedDistort; |
|
78 |
private VertexEffectDeform mMovingDeform, mReleasedDeform; |
|
79 |
|
|
80 |
private Dynamic3D mReleasedDistortDynamic, mReleasedDeformDynamic, mReleasedShearDynamic; |
|
81 |
|
|
82 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
83 | 84 |
|
84 | 85 |
DeformRenderer(GLSurfaceView view) |
85 | 86 |
{ |
86 | 87 |
mView = view; |
88 |
mResources = view.getResources(); |
|
87 | 89 |
|
88 | 90 |
mTexture = new DistortedTexture(); |
89 | 91 |
mEffects = new DistortedEffects(); |
... | ... | |
233 | 235 |
VertexEffectDistort.enable(); |
234 | 236 |
VertexEffectDeform.enable(); |
235 | 237 |
|
236 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this); |
|
237 |
} |
|
238 |
|
|
239 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
240 |
|
|
241 |
public void distortedException(Exception ex) |
|
242 |
{ |
|
243 |
android.util.Log.e("Deform", ex.getMessage() ); |
|
238 |
DistortedLibrary.onSurfaceCreated(this); |
|
244 | 239 |
} |
245 | 240 |
|
246 | 241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
327 | 322 |
break; |
328 | 323 |
} |
329 | 324 |
} |
325 |
|
|
326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
327 |
|
|
328 |
public void distortedException(Exception ex) |
|
329 |
{ |
|
330 |
android.util.Log.e("Deform", ex.getMessage() ); |
|
331 |
} |
|
332 |
|
|
333 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
334 |
|
|
335 |
public int openGlVersion() |
|
336 |
{ |
|
337 |
Context context = mView.getContext(); |
|
338 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
339 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
340 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
341 |
int major = glESversion >> 16; |
|
342 |
int minor = glESversion & 0xff; |
|
343 |
|
|
344 |
return 100*major + 10*minor; |
|
345 |
} |
|
346 |
|
|
347 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
348 |
|
|
349 |
public InputStream localFile(int fileID) |
|
350 |
{ |
|
351 |
return mResources.openRawResource(fileID); |
|
352 |
} |
|
353 |
|
|
354 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
355 |
|
|
356 |
public void logMessage(String message) |
|
357 |
{ |
|
358 |
android.util.Log.e("Deform", message ); |
|
359 |
} |
|
330 | 360 |
} |
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
---|---|---|
42 | 42 |
import org.distorted.library.type.Static3D; |
43 | 43 |
import org.distorted.library.type.Static4D; |
44 | 44 |
|
45 |
import android.app.ActivityManager; |
|
46 |
import android.content.Context; |
|
47 |
import android.content.pm.ConfigurationInfo; |
|
48 |
import android.content.res.Resources; |
|
45 | 49 |
import android.graphics.Bitmap; |
46 | 50 |
import android.graphics.BitmapFactory; |
47 | 51 |
import android.opengl.GLSurfaceView; |
48 | 52 |
|
49 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
50 | 54 |
|
51 |
class DifferentBitmapsRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
55 |
class DifferentBitmapsRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
52 | 56 |
{ |
53 | 57 |
private static final int[] bitmap = { R.raw.dog, R.raw.face, R.raw.cat }; |
54 | 58 |
private static final int NUM = bitmap.length; |
55 | 59 |
|
56 |
private GLSurfaceView mView; |
|
57 |
private DistortedEffects[] mEffects; |
|
60 |
private final GLSurfaceView mView; |
|
61 |
private final DistortedEffects[] mEffects; |
|
62 |
private final DistortedScreen mScreen; |
|
63 |
private final Static3D mScaleMatrix, mScaleVertex; |
|
64 |
private final Static3D[] mMove; |
|
65 |
private final Resources mResources; |
|
58 | 66 |
private DistortedTexture[] mTexture; |
59 | 67 |
private MeshSquare mMesh; |
60 |
private DistortedScreen mScreen; |
|
61 |
private Static3D mScaleMatrix, mScaleVertex; |
|
62 |
private Static3D[] mMove; |
|
63 | 68 |
|
64 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
65 | 70 |
|
66 | 71 |
DifferentBitmapsRenderer(GLSurfaceView v) |
67 | 72 |
{ |
68 | 73 |
mView = v; |
69 |
|
|
74 |
mResources = v.getResources(); |
|
75 |
|
|
70 | 76 |
Dynamic3D dDistort = new Dynamic3D(3000,0.0f); |
71 | 77 |
dDistort.add(new Static3D( 25,0,0)); |
72 | 78 |
dDistort.add(new Static3D(-25,0,0)); |
... | ... | |
168 | 174 |
VertexEffectSink.enable(); |
169 | 175 |
VertexEffectDistort.enable(); |
170 | 176 |
|
171 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this); |
|
172 |
} |
|
173 |
|
|
174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 |
|
|
176 |
public void distortedException(Exception ex) |
|
177 |
{ |
|
178 |
android.util.Log.e("DifferentBitmaps", ex.getMessage() ); |
|
177 |
DistortedLibrary.onSurfaceCreated(this); |
|
179 | 178 |
} |
180 | 179 |
|
181 | 180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
195 | 194 |
{ |
196 | 195 |
is.close(); |
197 | 196 |
} |
198 |
catch(IOException e) { }
|
|
197 |
catch(IOException ignored) { }
|
|
199 | 198 |
} |
200 | 199 |
|
201 | 200 |
return bitmap; |
202 | 201 |
} |
203 | 202 |
|
203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
204 |
|
|
205 |
public void distortedException(Exception ex) |
|
206 |
{ |
|
207 |
android.util.Log.e("DifferentBitmaps", ex.getMessage() ); |
|
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("DifferentBitmaps", message ); |
|
236 |
} |
|
204 | 237 |
} |
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 |
} |
src/main/java/org/distorted/examples/dynamic/DynamicRenderer.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; |
... | ... | |
36 | 40 |
import org.distorted.library.main.DistortedLibrary; |
37 | 41 |
import org.distorted.library.type.Static3D; |
38 | 42 |
|
43 |
import java.io.InputStream; |
|
44 |
|
|
39 | 45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
40 | 46 |
|
41 |
class DynamicRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
47 |
class DynamicRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
42 | 48 |
{ |
43 |
private DynamicSurfaceView mView; |
|
44 |
private DistortedTexture mTexture; |
|
45 |
private DistortedEffects mEffects; |
|
46 |
private DistortedScreen mScreen; |
|
47 |
private MeshSquare mMesh; |
|
49 |
private final DynamicSurfaceView mView; |
|
50 |
private final Resources mResources; |
|
51 |
private final DistortedTexture mTexture; |
|
52 |
private final DistortedEffects mEffects; |
|
53 |
private final DistortedScreen mScreen; |
|
54 |
private final MeshSquare mMesh; |
|
55 |
private final Paint mPaint; |
|
56 |
private final Static3D mScale; |
|
57 |
|
|
48 | 58 |
private Canvas mCanvas; |
49 | 59 |
private Bitmap mBitmap; |
50 |
private Paint mPaint; |
|
51 |
private Static3D mScale; |
|
60 |
|
|
52 | 61 |
private static int texW, texH; |
53 | 62 |
|
54 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 64 |
|
56 | 65 |
DynamicRenderer(DynamicSurfaceView v) |
57 |
{ |
|
66 |
{ |
|
67 |
mView = v; |
|
68 |
mResources = v.getResources(); |
|
69 |
|
|
58 | 70 |
mPaint = new Paint(); |
59 | 71 |
mPaint.setAntiAlias(true); |
60 | 72 |
mPaint.setFakeBoldText(true); |
61 | 73 |
mPaint.setColor(0xff447da7); |
62 | 74 |
mPaint.setStyle(Style.FILL); |
63 |
|
|
64 |
mView = v; |
|
75 |
|
|
65 | 76 |
mMesh = new MeshSquare(1,1); |
66 | 77 |
mScreen = new DistortedScreen(); |
67 | 78 |
mEffects = new DistortedEffects(); |
... | ... | |
106 | 117 |
|
107 | 118 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
108 | 119 |
{ |
109 |
DistortedLibrary.onSurfaceCreated(mView.getContext(),this);
|
|
120 |
DistortedLibrary.onSurfaceCreated(this); |
|
110 | 121 |
} |
111 | 122 |
|
112 | 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
115 | 126 |
{ |
116 | 127 |
android.util.Log.e("Dynamic", ex.getMessage() ); |
117 | 128 |
} |
129 |
|
|
130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
131 |
|
|
132 |
public int openGlVersion() |
|
133 |
{ |
|
134 |
Context context = mView.getContext(); |
|
135 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
136 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
137 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
138 |
int major = glESversion >> 16; |
|
139 |
int minor = glESversion & 0xff; |
|
140 |
|
|
141 |
return 100*major + 10*minor; |
|
142 |
} |
|
143 |
|
|
144 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
145 |
|
|
146 |
public InputStream localFile(int fileID) |
|
147 |
{ |
|
148 |
return mResources.openRawResource(fileID); |
|
149 |
} |
|
150 |
|
|
151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
152 |
|
|
153 |
public void logMessage(String message) |
|
154 |
{ |
|
155 |
android.util.Log.e("Dynamic", message ); |
|
156 |
} |
|
118 | 157 |
} |
src/main/java/org/distorted/examples/earth/EarthRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.earth; |
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; |
... | ... | |
62 | 66 |
|
63 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
64 | 68 |
|
65 |
class EarthRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
69 |
class EarthRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
66 | 70 |
{ |
67 | 71 |
private static final float RADIUS_V= 1.0f/ 8; |
68 | 72 |
private static final float RADIUS_F= 1.0f/15; |
... | ... | |
71 | 75 |
private static final float NEAR = 0.1f; |
72 | 76 |
private static final float SCALE = 1.10f; |
73 | 77 |
|
74 |
private GLSurfaceView mView; |
|
75 |
private DistortedTexture mTexture; |
|
76 |
private DistortedEffects mEffects; |
|
77 |
private MeshBase mMesh; |
|
78 |
private DistortedScreen mScreen; |
|
79 |
private float mObjWidth, mObjHeight, mObjDepth; |
|
80 |
private Static3D mMove, mScaleFactor; |
|
78 |
private final GLSurfaceView mView; |
|
79 |
private final Resources mResources; |
|
80 |
private final DistortedTexture mTexture; |
|
81 |
private final DistortedEffects mEffects; |
|
82 |
private final MeshBase mMesh; |
|
83 |
private final DistortedScreen mScreen; |
|
84 |
private final Static1D mStrength, mSwirl; |
|
85 |
private final Static3D mMove, mScaleFactor, mColor,mRegionF,mPinch; |
|
86 |
private final Static4D mRegionV; |
|
87 |
private final float mObjWidth, mObjHeight, mObjDepth; |
|
81 | 88 |
|
82 | 89 |
private int mScrWidth, mScrHeight; |
83 | 90 |
private float mLevel; |
84 | 91 |
|
85 |
private Static3D mColor; |
|
86 |
private Static3D mRegionF; |
|
87 |
private Static4D mRegionV; |
|
88 |
private Static1D mStrength; |
|
89 |
private Static3D mPinch; |
|
90 |
private Static1D mSwirl; |
|
91 |
|
|
92 | 92 |
Static4D mQuat1, mQuat2; |
93 | 93 |
int mScreenMin; |
94 | 94 |
|
... | ... | |
97 | 97 |
EarthRenderer(GLSurfaceView v) |
98 | 98 |
{ |
99 | 99 |
mView = v; |
100 |
mResources = v.getResources(); |
|
100 | 101 |
|
101 | 102 |
mLevel = SCALE; |
102 | 103 |
|
... | ... | |
204 | 205 |
|
205 | 206 |
switch(name) |
206 | 207 |
{ |
207 |
case DISTORT : vector = new Static3D( +x*mObjWidth/CORR, +y*mObjHeight/CORR, +z*mObjDepth/CORR);
|
|
208 |
case DISTORT : vector = new Static3D( x*mObjWidth/CORR, y*mObjHeight/CORR, z*mObjDepth/CORR);
|
|
208 | 209 |
effect = new VertexEffectDistort( vector, center, mRegionV); break; |
209 |
case DEFORM : vector = new Static3D( +x*mObjWidth/CORR, +y*mObjHeight/CORR, +z*mObjDepth/CORR);
|
|
210 |
case DEFORM : vector = new Static3D( x*mObjWidth/CORR, y*mObjHeight/CORR, z*mObjDepth/CORR);
|
|
210 | 211 |
Static1D radius = new Static1D(mObjWidth/2); |
211 | 212 |
effect = new VertexEffectDeform ( vector, radius, center, mRegionV); break; |
212 | 213 |
case SINK : effect = new VertexEffectSink (mStrength, center, mRegionV); break; |
... | ... | |
232 | 233 |
case CONTRAST : effect = new FragmentEffectContrast (mStrength, center, mRegionF, false); break; |
233 | 234 |
case SMOOTH_CONTRAST : effect = new FragmentEffectContrast (mStrength, center, mRegionF, true ); break; |
234 | 235 |
|
235 |
default : android.util.Log.e("EarthRenderer", "unexpected effect: "+name.toString() );
|
|
236 |
default : android.util.Log.e("EarthRenderer", "unexpected effect: "+name ); |
|
236 | 237 |
} |
237 | 238 |
|
238 | 239 |
if( effect!=null ) |
... | ... | |
276 | 277 |
|
277 | 278 |
Effect.enableEffects(EffectType.FRAGMENT); |
278 | 279 |
Effect.enableEffects(EffectType.VERTEX); |
279 |
|
|
280 | 280 |
DistortedLibrary.setMax(EffectType.FRAGMENT, 20); |
281 |
|
|
282 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this); |
|
281 |
DistortedLibrary.onSurfaceCreated(this); |
|
283 | 282 |
} |
284 | 283 |
|
285 | 284 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
288 | 287 |
{ |
289 | 288 |
android.util.Log.e("Earth", ex.getMessage() ); |
290 | 289 |
} |
290 |
|
|
291 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
292 |
|
|
293 |
public int openGlVersion() |
|
294 |
{ |
|
295 |
Context context = mView.getContext(); |
|
296 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
297 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
298 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
299 |
int major = glESversion >> 16; |
|
300 |
int minor = glESversion & 0xff; |
|
301 |
|
|
302 |
return 100*major + 10*minor; |
|
303 |
} |
|
304 |
|
|
305 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
306 |
|
|
307 |
public InputStream localFile(int fileID) |
|
308 |
{ |
|
309 |
return mResources.openRawResource(fileID); |
|
310 |
} |
|
311 |
|
|
312 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
313 |
|
|
314 |
public void logMessage(String message) |
|
315 |
{ |
|
316 |
android.util.Log.e("Earth", message ); |
|
317 |
} |
|
291 | 318 |
} |
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.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; |
... | ... | |
42 | 46 |
import org.distorted.library.message.EffectListener; |
43 | 47 |
import org.distorted.library.type.Static3D; |
44 | 48 |
|
49 |
import java.io.InputStream; |
|
50 |
|
|
45 | 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 52 |
|
47 |
class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener, DistortedLibrary.ExceptionListener
|
|
53 |
class EffectQueueRenderer implements GLSurfaceView.Renderer, EffectListener, DistortedLibrary.LibraryUser
|
|
48 | 54 |
{ |
49 | 55 |
private static final int NUMLINES = 10; |
50 | 56 |
private static final int MESH_QUALITY = 100; |
51 | 57 |
static final int BWID = 600; |
52 | 58 |
static final int BHEI = 600; |
53 |
|
|
54 |
private EffectQueueSurfaceView mView; |
|
55 |
private Paint mPaint; |
|
56 |
private int texWidth, texHeight; |
|
57 |
private Static3D mScale; |
|
58 | 59 |
|
59 |
private DistortedTexture mTexture; |
|
60 |
private MeshSquare mMesh; |
|
61 |
private DistortedEffects mEffects; |
|
62 |
private DistortedScreen mScreen; |
|
60 |
private final EffectQueueSurfaceView mView; |
|
61 |
private final Resources mResources; |
|
62 |
private final DistortedTexture mTexture; |
|
63 |
private final MeshSquare mMesh; |
|
64 |
private final DistortedEffects mEffects; |
|
65 |
private final DistortedScreen mScreen; |
|
66 |
private final Paint mPaint; |
|
67 |
private final Static3D mScale; |
|
68 |
private final int texWidth, texHeight; |
|
63 | 69 |
|
64 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
65 | 71 |
|
66 | 72 |
EffectQueueRenderer(EffectQueueSurfaceView v) |
67 |
{ |
|
73 |
{ |
|
74 |
mView = v; |
|
75 |
mResources = v.getResources(); |
|
76 |
|
|
68 | 77 |
mPaint = new Paint(); |
69 | 78 |
mPaint.setAntiAlias(true); |
70 | 79 |
mPaint.setFakeBoldText(true); |
71 | 80 |
mPaint.setStyle(Style.FILL); |
72 |
|
|
73 |
mView = v; |
|
74 |
|
|
81 |
|
|
75 | 82 |
texWidth = BWID; |
76 | 83 |
texHeight= BHEI; |
77 | 84 |
mScale = new Static3D(1,1,1); |
... | ... | |
141 | 148 |
FragmentEffectChroma.enable(); |
142 | 149 |
FragmentEffectSaturation.enable(); |
143 | 150 |
|
144 |
DistortedLibrary.onSurfaceCreated(mView.getContext(), this); |
|
151 |
DistortedLibrary.onSurfaceCreated(this); |
|
152 |
} |
|
153 |
|
|
154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
155 |
|
|
156 |
public void effectFinished(final long effectID) |
|
157 |
{ |
|
158 |
EffectQueueActivity act = (EffectQueueActivity)mView.getContext(); |
|
159 |
act.effectFinished(effectID); |
|
145 | 160 |
} |
146 | 161 |
|
147 | 162 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
153 | 168 |
|
154 | 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
155 | 170 |
|
156 |
public void effectFinished(final long effectID)
|
|
171 |
public int openGlVersion()
|
|
157 | 172 |
{ |
158 |
EffectQueueActivity act = (EffectQueueActivity)mView.getContext(); |
|
159 |
act.effectFinished(effectID); |
|
173 |
Context context = mView.getContext(); |
|
174 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
175 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
176 |
int glESversion = configurationInfo.reqGlEsVersion; |
|
177 |
int major = glESversion >> 16; |
|
178 |
int minor = glESversion & 0xff; |
|
179 |
|
|
180 |
return 100*major + 10*minor; |
|
181 |
} |
|
182 |
|
|
183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
184 |
|
|
185 |
public InputStream localFile(int fileID) |
|
186 |
{ |
|
187 |
return mResources.openRawResource(fileID); |
|
188 |
} |
|
189 |
|
|
190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
191 |
|
|
192 |
public void logMessage(String message) |
|
193 |
{ |
|
194 |
android.util.Log.e("EffectQueue", message ); |
|
160 | 195 |
} |
161 | 196 |
} |
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 |
} |
src/main/java/org/distorted/examples/flatblur/FlatBlurRenderer.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.flatblur; |
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.opengl.GLSurfaceView; |
23 | 27 |
|
24 | 28 |
import org.distorted.library.main.DistortedLibrary; |
25 | 29 |
import org.distorted.library.main.DistortedScreen; |
26 | 30 |
|
31 |
import java.io.InputStream; |
|
32 |
|
|
27 | 33 |
import javax.microedition.khronos.egl.EGLConfig; |
28 | 34 |
import javax.microedition.khronos.opengles.GL10; |
29 | 35 |
|
30 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
31 | 37 |
|
32 |
class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
|
|
38 |
class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
|
|
33 | 39 |
{ |
34 | 40 |
private final GLSurfaceView mView; |
41 |
private final Resources mResources; |
|
35 | 42 |
private final DistortedScreen mScreen; |
36 | 43 |
|
37 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
39 | 46 |
FlatBlurRenderer(GLSurfaceView v) |
40 | 47 |
{ |
41 | 48 |
mView = v; |
49 |
mResources = v.getResources(); |
|
42 | 50 |
mScreen = new DistortedScreen(); |
43 | 51 |
} |
44 | 52 |
|
... | ... | |
61 | 69 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
62 | 70 |
{ |
63 | 71 |
OverlayStars.enableEffects(); |
64 |
DistortedLibrary.onSurfaceCreated( mView.getContext(), this); |
|
72 |
DistortedLibrary.onSurfaceCreated(this); |
|
73 |
} |
|
74 |
|
|
75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
76 |
|
|
77 |
public void button1() |
|
78 |
{ |
|
79 |
OverlayStars stars = new OverlayStars(); |
|
80 |
stars.startOverlay(mScreen); |
|
81 |
} |
|
82 |
|
|
83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
84 |
|
|
85 |
public void button2() |
|
86 |
{ |
|
87 |
|
|
65 | 88 |
} |
66 | 89 |
|
67 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Decouple (to a large degree) the OpenGL Library from Android.