Revision e4330c89
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
---|---|---|
71 | 71 |
mEffects.apply(new MatrixEffectScale(mScale)); |
72 | 72 |
|
73 | 73 |
mManager.apply(mEffects); |
74 |
mScreen = new DistortedScreen(mView);
|
|
74 |
mScreen = new DistortedScreen(); |
|
75 | 75 |
mScreen.glClearColor(0.5f, 0.5f, 0.5f, 1.0f); |
76 | 76 |
} |
77 | 77 |
|
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.aroundtheworld; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new AroundTheWorldRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
95 | 95 |
mEffects.apply( new MatrixEffectMove(mMove) ); |
96 | 96 |
mEffects.apply( new MatrixEffectScale(mScale) ); |
97 | 97 |
|
98 |
mScreen = new DistortedScreen(mView);
|
|
98 |
mScreen = new DistortedScreen(); |
|
99 | 99 |
} |
100 | 100 |
|
101 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/bean/BeanSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.bean; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
31 | 33 |
public BeanSurfaceView(Context context) |
32 | 34 |
{ |
33 | 35 |
super(context); |
36 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
37 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
38 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
34 | 39 |
setRenderer(new BeanRenderer(this)); |
35 | 40 |
} |
36 | 41 |
} |
src/main/java/org/distorted/examples/bitmaptree/BitmapTreeRenderer.java | ||
---|---|---|
83 | 83 |
mEffects.apply(new MatrixEffectScale(mScale)); |
84 | 84 |
mEffects.apply(new FragmentEffectChroma(chromaDyn, new Static3D(0,0,1))); |
85 | 85 |
|
86 |
mScreen = new DistortedScreen(mView);
|
|
86 |
mScreen = new DistortedScreen(); |
|
87 | 87 |
} |
88 | 88 |
|
89 | 89 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/bitmaptree/BitmapTreeSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.bitmaptree; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new BitmapTreeRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/blur/BlurRenderer.java | ||
---|---|---|
63 | 63 |
{ |
64 | 64 |
mView = v; |
65 | 65 |
mMesh = new MeshFlat(1,1); |
66 |
mScreen = new DistortedScreen(mView);
|
|
66 |
mScreen = new DistortedScreen(); |
|
67 | 67 |
|
68 | 68 |
mRadiusSta = new Static1D(5); |
69 | 69 |
Dynamic1D radiusDyn = new Dynamic1D(); |
src/main/java/org/distorted/examples/blur/BlurSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.blur; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new BlurRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/catanddog/CatAndDogRenderer.java | ||
---|---|---|
99 | 99 |
mEffects.apply( new MatrixEffectScale(diScale)); |
100 | 100 |
mEffects.apply( new MatrixEffectRotate( diRotate, new Static3D(0,0,1), mRotate) ); |
101 | 101 |
|
102 |
mScreen = new DistortedScreen(mView);
|
|
102 |
mScreen = new DistortedScreen(); |
|
103 | 103 |
} |
104 | 104 |
|
105 | 105 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/catanddog/CatAndDogSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.catanddog; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
31 | 33 |
public CatAndDogSurfaceView(Context context) |
32 | 34 |
{ |
33 | 35 |
super(context); |
36 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
37 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
38 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
34 | 39 |
setRenderer(new CatAndDogRenderer(this)); |
35 | 40 |
} |
36 | 41 |
} |
src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
---|---|---|
131 | 131 |
Log.e("Check", "Failed to add Chroma effect!"); |
132 | 132 |
} |
133 | 133 |
|
134 |
mScreen = new DistortedScreen(mView);
|
|
134 |
mScreen = new DistortedScreen(); |
|
135 | 135 |
} |
136 | 136 |
|
137 | 137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/check/CheckSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.check; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
32 | 34 |
public CheckSurfaceView(Context context, AttributeSet attrs) |
33 | 35 |
{ |
34 | 36 |
super(context, attrs); |
37 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
38 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
39 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
35 | 40 |
if(!isInEditMode()) setRenderer(new CheckRenderer(this)); |
36 | 41 |
} |
37 | 42 |
} |
src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
---|---|---|
92 | 92 |
mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) ); |
93 | 93 |
mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) ); |
94 | 94 |
|
95 |
mScreen = new DistortedScreen(mView);
|
|
95 |
mScreen = new DistortedScreen(); |
|
96 | 96 |
} |
97 | 97 |
|
98 | 98 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/cubes/CubesSurfaceView.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import org.distorted.examples.R; |
23 | 23 |
|
24 |
import android.app.ActivityManager; |
|
24 | 25 |
import android.content.Context; |
26 |
import android.content.pm.ConfigurationInfo; |
|
25 | 27 |
import android.opengl.GLSurfaceView; |
26 | 28 |
import android.util.AttributeSet; |
27 | 29 |
import android.view.MotionEvent; |
... | ... | |
46 | 48 |
if(!isInEditMode()) |
47 | 49 |
{ |
48 | 50 |
mRenderer = new CubesRenderer(this); |
51 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
52 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
53 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
49 | 54 |
setRenderer(mRenderer); |
50 | 55 |
Toast.makeText(context, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show(); |
51 | 56 |
} |
src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
---|---|---|
133 | 133 |
|
134 | 134 |
movingShearDynamic.add(vShear[0]); |
135 | 135 |
|
136 |
mScreen = new DistortedScreen(mView);
|
|
136 |
mScreen = new DistortedScreen(); |
|
137 | 137 |
mScreen.setDebug(DistortedScreen.DEBUG_FPS); |
138 | 138 |
|
139 | 139 |
mMovingDistort = new VertexEffectDistort(movingDistortDynamic, mTouchPoint, mRegion); |
src/main/java/org/distorted/examples/deform/DeformSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.deform; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
import android.view.MotionEvent; |
... | ... | |
40 | 42 |
if(!isInEditMode()) |
41 | 43 |
{ |
42 | 44 |
mRenderer = new DeformRenderer(this); |
45 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
46 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
47 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
43 | 48 |
setRenderer(mRenderer); |
44 | 49 |
} |
45 | 50 |
} |
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java | ||
---|---|---|
98 | 98 |
mEffects[i].apply(scaleEffect); |
99 | 99 |
} |
100 | 100 |
|
101 |
mScreen = new DistortedScreen(mView);
|
|
101 |
mScreen = new DistortedScreen(); |
|
102 | 102 |
mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
103 | 103 |
} |
104 | 104 |
|
... | ... | |
127 | 127 |
|
128 | 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
129 | 129 |
|
130 |
public void onDrawFrame(GL10 glUnused)
|
|
130 |
public void onDrawFrame(GL10 glUnused)
|
|
131 | 131 |
{ |
132 | 132 |
mScreen.render( System.currentTimeMillis() ); |
133 | 133 |
} |
134 | 134 |
|
135 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
136 | 136 |
|
137 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
138 |
{
|
|
139 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width )
|
|
140 |
{
|
|
141 |
int w = (height*bmpWidth)/bmpHeight;
|
|
142 |
float factor = (float)height/bmpHeight;
|
|
143 |
mScale.set(factor,factor,factor);
|
|
144 |
|
|
145 |
for(int i=NUM-1; i>=0; i--)
|
|
146 |
{
|
|
147 |
mMove[i].set((width-NUM*w)/2 +i*w ,0,0);
|
|
148 |
}
|
|
149 |
}
|
|
150 |
else
|
|
151 |
{
|
|
152 |
int w = width/NUM;
|
|
153 |
int h = (width*bmpHeight)/(bmpWidth*NUM);
|
|
154 |
float factor = (float)width/(bmpWidth*NUM);
|
|
155 |
mScale.set(factor,factor,factor);
|
|
156 |
|
|
157 |
for(int i=NUM-1; i>=0; i--)
|
|
158 |
{
|
|
159 |
mMove[i].set(i*w,(height-h)/2,0);
|
|
160 |
}
|
|
161 |
}
|
|
137 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
138 |
{ |
|
139 |
if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width ) |
|
140 |
{ |
|
141 |
int w = (height*bmpWidth)/bmpHeight; |
|
142 |
float factor = (float)height/bmpHeight; |
|
143 |
mScale.set(factor,factor,factor); |
|
144 |
|
|
145 |
for(int i=NUM-1; i>=0; i--)
|
|
146 |
{ |
|
147 |
mMove[i].set((width-NUM*w)/2 +i*w ,0,0); |
|
148 |
} |
|
149 |
} |
|
150 |
else |
|
151 |
{ |
|
152 |
int w = width/NUM;
|
|
153 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
|
154 |
float factor = (float)width/(bmpWidth*NUM); |
|
155 |
mScale.set(factor,factor,factor); |
|
156 |
|
|
157 |
for(int i=NUM-1; i>=0; i--)
|
|
158 |
{ |
|
159 |
mMove[i].set(i*w,(height-h)/2,0); |
|
160 |
} |
|
161 |
} |
|
162 | 162 |
|
163 | 163 |
|
164 |
mScreen.resize(width, height);
|
|
165 |
}
|
|
164 |
mScreen.resize(width, height); |
|
165 |
} |
|
166 | 166 |
|
167 | 167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
168 | 168 |
|
169 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
170 |
{
|
|
171 |
Bitmap bitmap0= readBitmap(R.raw.dog);
|
|
172 |
Bitmap bitmap1= readBitmap(R.raw.face);
|
|
173 |
Bitmap bitmap2= readBitmap(R.raw.cat);
|
|
169 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
170 |
{ |
|
171 |
Bitmap bitmap0= readBitmap(R.raw.dog); |
|
172 |
Bitmap bitmap1= readBitmap(R.raw.face); |
|
173 |
Bitmap bitmap2= readBitmap(R.raw.cat); |
|
174 | 174 |
|
175 |
bmpHeight = bitmap0.getHeight();
|
|
176 |
bmpWidth = bitmap0.getWidth();
|
|
175 |
bmpHeight = bitmap0.getHeight(); |
|
176 |
bmpWidth = bitmap0.getWidth(); |
|
177 | 177 |
|
178 |
if( mTexture==null )
|
|
179 |
{
|
|
180 |
mTexture = new DistortedTexture[NUM];
|
|
178 |
if( mTexture==null ) |
|
179 |
{ |
|
180 |
mTexture = new DistortedTexture[NUM]; |
|
181 | 181 |
|
182 |
for(int i=0; i<NUM; i++)
|
|
183 |
mTexture[i] = new DistortedTexture(bmpWidth,bmpHeight);
|
|
184 |
}
|
|
182 |
for(int i=0; i<NUM; i++) |
|
183 |
mTexture[i] = new DistortedTexture(bmpWidth,bmpHeight); |
|
184 |
} |
|
185 | 185 |
|
186 |
mTexture[0].setTexture(bitmap0);
|
|
187 |
mTexture[1].setTexture(bitmap1);
|
|
188 |
mTexture[2].setTexture(bitmap2);
|
|
186 |
mTexture[0].setTexture(bitmap0); |
|
187 |
mTexture[1].setTexture(bitmap1); |
|
188 |
mTexture[2].setTexture(bitmap2); |
|
189 | 189 |
|
190 |
if( mMesh==null ) mMesh = new MeshFlat(30,30*bmpHeight/bmpWidth);
|
|
190 |
if( mMesh==null ) mMesh = new MeshFlat(30,30*bmpHeight/bmpWidth); |
|
191 | 191 |
|
192 |
mScreen.detachAll();
|
|
193 |
for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture[i], mEffects[i], mMesh);
|
|
192 |
mScreen.detachAll(); |
|
193 |
for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture[i], mEffects[i], mMesh); |
|
194 | 194 |
|
195 |
DistortedEffects.enableEffect(EffectName.SINK);
|
|
196 |
DistortedEffects.enableEffect(EffectName.DISTORT);
|
|
195 |
DistortedEffects.enableEffect(EffectName.SINK); |
|
196 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
197 | 197 |
|
198 |
try
|
|
199 |
{
|
|
200 |
Distorted.onCreate(mView.getContext());
|
|
201 |
}
|
|
202 |
catch(Exception ex)
|
|
203 |
{
|
|
204 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
205 |
}
|
|
206 |
}
|
|
198 |
try |
|
199 |
{ |
|
200 |
Distorted.onCreate(mView.getContext()); |
|
201 |
} |
|
202 |
catch(Exception ex) |
|
203 |
{ |
|
204 |
android.util.Log.e("Renderer", ex.getMessage() ); |
|
205 |
} |
|
206 |
} |
|
207 | 207 |
} |
src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.differentbitmaps; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
31 | 33 |
public DifferentBitmapsSurfaceView(Context context) |
32 | 34 |
{ |
33 | 35 |
super(context); |
36 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
37 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
38 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
34 | 39 |
setRenderer(new DifferentBitmapsRenderer(this)); |
35 | 40 |
} |
36 | 41 |
} |
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
---|---|---|
118 | 118 |
mEffects[i].apply(scaleEffect); |
119 | 119 |
} |
120 | 120 |
|
121 |
mScreen = new DistortedScreen(mView);
|
|
121 |
mScreen = new DistortedScreen(); |
|
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.differenteffects; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
31 | 33 |
public DifferentEffectsSurfaceView(Context context) |
32 | 34 |
{ |
33 | 35 |
super(context); |
36 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
37 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
38 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
34 | 39 |
setRenderer(new DifferentEffectsRenderer(this)); |
35 | 40 |
} |
36 | 41 |
} |
src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
---|---|---|
62 | 62 |
mView = v; |
63 | 63 |
mMesh = new MeshFlat(1,1); |
64 | 64 |
mEffects = new DistortedEffects(); |
65 |
mScreen = new DistortedScreen(mView);
|
|
65 |
mScreen = new DistortedScreen(); |
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/dynamic/DynamicSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.dynamic; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.view.MotionEvent; |
25 | 27 |
import android.util.AttributeSet; |
... | ... | |
109 | 111 |
setFocusable(true); |
110 | 112 |
setFocusableInTouchMode(true); |
111 | 113 |
DynamicRenderer mRenderer = new DynamicRenderer(this); |
114 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
115 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
116 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
112 | 117 |
setRenderer(mRenderer); |
113 | 118 |
} |
114 | 119 |
} |
src/main/java/org/distorted/examples/effectqueue/EffectQueueRenderer.java | ||
---|---|---|
79 | 79 |
mEffects.apply(scaleEffect); |
80 | 80 |
mEffects.registerForMessages(this); |
81 | 81 |
|
82 |
mScreen = new DistortedScreen(mView);
|
|
82 |
mScreen = new DistortedScreen(); |
|
83 | 83 |
} |
84 | 84 |
|
85 | 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/effectqueue/EffectQueueSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.effectqueue; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.view.MotionEvent; |
25 | 27 |
import android.util.AttributeSet; |
... | ... | |
90 | 92 |
setFocusable(true); |
91 | 93 |
setFocusableInTouchMode(true); |
92 | 94 |
mRenderer = new EffectQueueRenderer(this); |
95 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
96 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
97 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
93 | 98 |
setRenderer(mRenderer); |
94 | 99 |
mRegionV= new Static4D(0,0,RADIUS,RADIUS); |
95 | 100 |
setEffect(0); |
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
---|---|---|
110 | 110 |
mCenterNode = new DistortedNode(mCenterTexture, centerEffects, quad); |
111 | 111 |
mRegionNode = new DistortedNode(mRegionTexture, regionEffects, quad); |
112 | 112 |
|
113 |
mScreen = new DistortedScreen(mView);
|
|
113 |
mScreen = new DistortedScreen(); |
|
114 | 114 |
mScreen.setProjection(FOV, NEAR); |
115 | 115 |
mScreen.attach(mBackgroundTexture, backgroundEffects, quad ); |
116 | 116 |
mScreen.attach(mObjectTexture , objectEffects , meshO); |
src/main/java/org/distorted/examples/effects3d/Effects3DSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.effects3d; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
import android.view.MotionEvent; |
... | ... | |
40 | 42 |
if(!isInEditMode()) |
41 | 43 |
{ |
42 | 44 |
mRenderer = new Effects3DRenderer(this); |
45 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
46 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
47 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
43 | 48 |
setRenderer(mRenderer); |
44 | 49 |
} |
45 | 50 |
} |
src/main/java/org/distorted/examples/flag/FlagRenderer.java | ||
---|---|---|
99 | 99 |
mEffects.apply( new MatrixEffectQuaternion(mQuat1, mCenter) ); |
100 | 100 |
mEffects.apply( new MatrixEffectQuaternion(mQuat2, mCenter) ); |
101 | 101 |
|
102 |
mScreen = new DistortedScreen(mView);
|
|
102 |
mScreen = new DistortedScreen(); |
|
103 | 103 |
mScreen.attach(mTexture,mEffects, new MeshCubes(50,30,1) ); |
104 | 104 |
} |
105 | 105 |
|
src/main/java/org/distorted/examples/flag/FlagSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.flag; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
import android.view.MotionEvent; |
... | ... | |
43 | 45 |
if(!isInEditMode()) |
44 | 46 |
{ |
45 | 47 |
mRenderer = new FlagRenderer(this); |
48 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
49 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
50 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
46 | 51 |
setRenderer(mRenderer); |
47 | 52 |
} |
48 | 53 |
} |
src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
---|---|---|
129 | 129 |
mEffects.apply(new MatrixEffectMove(mMove)); |
130 | 130 |
mEffects.apply(new MatrixEffectScale(mScale)); |
131 | 131 |
|
132 |
mScreen = new DistortedScreen(mView);
|
|
132 |
mScreen = new DistortedScreen(); |
|
133 | 133 |
} |
134 | 134 |
|
135 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
166 | 166 |
|
167 | 167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
168 | 168 |
|
169 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
170 |
{
|
|
171 |
if( (float)bmpHeight/bmpWidth > (float)height/width )
|
|
172 |
{
|
|
173 |
int w = (height*bmpWidth)/bmpHeight;
|
|
174 |
float factor = (float)height/bmpHeight;
|
|
175 |
|
|
176 |
mMove.set((width-w)/2,0,0);
|
|
177 |
mScale.set(factor,factor,factor);
|
|
178 |
}
|
|
179 |
else
|
|
180 |
{
|
|
181 |
int h = (width*bmpHeight)/bmpWidth;
|
|
182 |
float factor = (float)width/bmpWidth;
|
|
183 |
|
|
184 |
mMove.set(0,(height-h)/2,0);
|
|
185 |
mScale.set(factor,factor,factor);
|
|
186 |
}
|
|
169 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
170 |
{
|
|
171 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
172 |
{ |
|
173 |
int w = (height*bmpWidth)/bmpHeight; |
|
174 |
float factor = (float)height/bmpHeight; |
|
175 |
|
|
176 |
mMove.set((width-w)/2,0,0); |
|
177 |
mScale.set(factor,factor,factor); |
|
178 |
} |
|
179 |
else |
|
180 |
{ |
|
181 |
int h = (width*bmpHeight)/bmpWidth; |
|
182 |
float factor = (float)width/bmpWidth; |
|
183 |
|
|
184 |
mMove.set(0,(height-h)/2,0); |
|
185 |
mScale.set(factor,factor,factor); |
|
186 |
} |
|
187 | 187 |
|
188 |
mScreen.resize(width, height);
|
|
189 |
}
|
|
188 |
mScreen.resize(width, height); |
|
189 |
} |
|
190 | 190 |
|
191 | 191 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
192 | 192 |
|
193 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
194 |
{
|
|
195 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.girl);
|
|
196 |
Bitmap bitmap;
|
|
193 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
194 |
{ |
|
195 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.girl); |
|
196 |
Bitmap bitmap; |
|
197 | 197 |
|
198 |
try
|
|
199 |
{
|
|
200 |
bitmap = BitmapFactory.decodeStream(is);
|
|
201 |
}
|
|
202 |
finally
|
|
203 |
{
|
|
204 |
try
|
|
205 |
{
|
|
206 |
is.close();
|
|
207 |
}
|
|
208 |
catch(IOException e) { }
|
|
209 |
}
|
|
198 |
try
|
|
199 |
{ |
|
200 |
bitmap = BitmapFactory.decodeStream(is); |
|
201 |
}
|
|
202 |
finally
|
|
203 |
{ |
|
204 |
try
|
|
205 |
{ |
|
206 |
is.close(); |
|
207 |
}
|
|
208 |
catch(IOException e) { } |
|
209 |
}
|
|
210 | 210 |
|
211 |
bmpHeight = bitmap.getHeight();
|
|
212 |
bmpWidth = bitmap.getWidth();
|
|
211 |
bmpHeight = bitmap.getHeight(); |
|
212 |
bmpWidth = bitmap.getWidth(); |
|
213 | 213 |
|
214 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
215 |
mTexture.setTexture(bitmap);
|
|
214 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight); |
|
215 |
mTexture.setTexture(bitmap); |
|
216 | 216 |
|
217 |
if( mMesh==null ) mMesh = new MeshFlat(30,30*bmpHeight/bmpWidth);
|
|
217 |
if( mMesh==null ) mMesh = new MeshFlat(30,30*bmpHeight/bmpWidth); |
|
218 | 218 |
|
219 |
mScreen.detachAll();
|
|
220 |
mScreen.attach(mTexture,mEffects,mMesh);
|
|
219 |
mScreen.detachAll(); |
|
220 |
mScreen.attach(mTexture,mEffects,mMesh); |
|
221 | 221 |
|
222 |
DistortedEffects.enableEffect(EffectName.DISTORT);
|
|
223 |
DistortedEffects.enableEffect(EffectName.SINK);
|
|
224 |
DistortedEffects.enableEffect(EffectName.SWIRL);
|
|
222 |
DistortedEffects.enableEffect(EffectName.DISTORT); |
|
223 |
DistortedEffects.enableEffect(EffectName.SINK); |
|
224 |
DistortedEffects.enableEffect(EffectName.SWIRL); |
|
225 | 225 |
|
226 |
try
|
|
227 |
{
|
|
228 |
Distorted.onCreate(mView.getContext());
|
|
229 |
}
|
|
230 |
catch(Exception ex)
|
|
231 |
{
|
|
232 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
233 |
}
|
|
234 |
}
|
|
226 |
try |
|
227 |
{ |
|
228 |
Distorted.onCreate(mView.getContext()); |
|
229 |
} |
|
230 |
catch(Exception ex) |
|
231 |
{ |
|
232 |
android.util.Log.e("Renderer", ex.getMessage() ); |
|
233 |
} |
|
234 |
} |
|
235 | 235 |
} |
src/main/java/org/distorted/examples/girl/GirlSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.girl; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new GirlRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/glow/GlowRenderer.java | ||
---|---|---|
131 | 131 |
|
132 | 132 |
makeGlow(0); |
133 | 133 |
|
134 |
mScreen = new DistortedScreen(mView);
|
|
134 |
mScreen = new DistortedScreen(); |
|
135 | 135 |
mScreen.attach(root); |
136 | 136 |
} |
137 | 137 |
|
src/main/java/org/distorted/examples/glow/GlowSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.glow; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
29 | 31 |
public GlowSurfaceView(Context context) |
30 | 32 |
{ |
31 | 33 |
super(context); |
34 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
35 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
36 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
32 | 37 |
setRenderer(new GlowRenderer(this)); |
33 | 38 |
} |
34 | 39 |
} |
src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
---|---|---|
71 | 71 |
mView = v; |
72 | 72 |
mEffects = new DistortedEffects(); |
73 | 73 |
mEffects.registerForMessages(this); |
74 |
mScreen = new DistortedScreen(mView);
|
|
74 |
mScreen = new DistortedScreen(); |
|
75 | 75 |
mRnd = new Random(0); |
76 | 76 |
|
77 | 77 |
mMove = new Static3D(0,0,0); |
src/main/java/org/distorted/examples/listener/ListenerSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.listener; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
31 | 33 |
public ListenerSurfaceView(Context context) |
32 | 34 |
{ |
33 | 35 |
super(context); |
36 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
37 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
38 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
34 | 39 |
setRenderer(new ListenerRenderer(this)); |
35 | 40 |
} |
36 | 41 |
} |
src/main/java/org/distorted/examples/matrix3d/Matrix3DRenderer.java | ||
---|---|---|
45 | 45 |
mView = v; |
46 | 46 |
Matrix3DActivity act = (Matrix3DActivity)v.getContext(); |
47 | 47 |
mTexture= act.getTexture(); |
48 |
mScreen = new DistortedScreen(mView);
|
|
48 |
mScreen = new DistortedScreen(); |
|
49 | 49 |
mScreen.attach(mTexture,act.getEffects(),act.getMesh()); |
50 | 50 |
mScreen.setProjection(60.0f,0.1f); |
51 | 51 |
} |
src/main/java/org/distorted/examples/matrix3d/Matrix3DSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.matrix3d; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new Matrix3DRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/mirror/MirrorRenderer.java | ||
---|---|---|
73 | 73 |
{ |
74 | 74 |
mView = view; |
75 | 75 |
mQuad = new MeshFlat(1,1); |
76 |
mScreen = new DistortedScreen(mView);
|
|
76 |
mScreen = new DistortedScreen(); |
|
77 | 77 |
|
78 | 78 |
mEffectsMirror = new DistortedEffects(); |
79 | 79 |
mEffectsHead = new DistortedEffects(); |
src/main/java/org/distorted/examples/mirror/MirrorSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.mirror; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new MirrorRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
82 | 82 |
mEffects.apply(new MatrixEffectMove(mMove)); |
83 | 83 |
mEffects.apply(new MatrixEffectScale(mScale)); |
84 | 84 |
|
85 |
mScreen = new DistortedScreen(mView);
|
|
85 |
mScreen = new DistortedScreen(); |
|
86 | 86 |
} |
87 | 87 |
|
88 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/monalisa/MonaLisaSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.monalisa; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
31 | 33 |
public MonaLisaSurfaceView(Context context) |
32 | 34 |
{ |
33 | 35 |
super(context); |
36 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
37 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
38 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
34 | 39 |
setRenderer(new MonaLisaRenderer(this)); |
35 | 40 |
} |
36 | 41 |
} |
src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java | ||
---|---|---|
62 | 62 |
|
63 | 63 |
mView = v; |
64 | 64 |
mEffects= new DistortedEffects(); |
65 |
mScreen = new DistortedScreen(mView);
|
|
65 |
mScreen = new DistortedScreen(); |
|
66 | 66 |
mRefresh= true; |
67 | 67 |
} |
68 | 68 |
|
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.movingeffects; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.graphics.Canvas; |
24 | 26 |
import android.graphics.Paint; |
25 | 27 |
import android.graphics.Paint.Style; |
... | ... | |
93 | 95 |
mRegionVertex = new Static4D(0,0,0,0); |
94 | 96 |
mDistort = new Static3D(0,0,0); |
95 | 97 |
|
96 |
mRenderer = new MovingEffectsRenderer(this); |
|
97 |
|
|
98 | 98 |
if(!isInEditMode()) |
99 | 99 |
{ |
100 |
mRenderer = new MovingEffectsRenderer(this); |
|
101 |
|
|
100 | 102 |
setFocusable(true); |
101 | 103 |
setFocusableInTouchMode(true); |
104 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
105 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
106 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
102 | 107 |
setRenderer(mRenderer); |
103 |
} |
|
104 | 108 |
|
105 |
mEffectDistort = new VertexEffectDistort( mDistort , mCenterVertex, mRegionVertex); |
|
106 |
mEffectSink = new VertexEffectSink(new Static1D(10), mCenterVertex, mRegionVertex); |
|
107 |
mEffectSwirl = new VertexEffectSwirl( new Static1D(30), mCenterVertex, mRegionVertex); |
|
108 |
mEffectAlpha = new FragmentEffectAlpha(new Static1D(0.5f), mRegionFragment, true); |
|
109 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mRegionFragment, true); |
|
109 |
mEffectDistort = new VertexEffectDistort( mDistort , mCenterVertex, mRegionVertex); |
|
110 |
mEffectSink = new VertexEffectSink(new Static1D(10), mCenterVertex, mRegionVertex); |
|
111 |
mEffectSwirl = new VertexEffectSwirl( new Static1D(30), mCenterVertex, mRegionVertex); |
|
112 |
mEffectAlpha = new FragmentEffectAlpha(new Static1D(0.5f), mRegionFragment, true); |
|
113 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mRegionFragment, true); |
|
114 |
} |
|
110 | 115 |
} |
111 | 116 |
|
112 | 117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java | ||
---|---|---|
109 | 109 |
mQuat1 = new Static4D(0,0,0,1); // unity |
110 | 110 |
mQuat2 = new Static4D(0,0,0,1); // quaternions |
111 | 111 |
|
112 |
mScreen = new DistortedScreen(mView);
|
|
112 |
mScreen = new DistortedScreen(); |
|
113 | 113 |
mScreen.setDebug(DistortedScreen.DEBUG_FPS); |
114 | 114 |
|
115 | 115 |
for(int i=0; i<NUM_OBJECTS; i++) |
src/main/java/org/distorted/examples/multiblur/MultiblurSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.multiblur; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
import android.view.MotionEvent; |
... | ... | |
46 | 48 |
if(!isInEditMode()) |
47 | 49 |
{ |
48 | 50 |
mRenderer = new MultiblurRenderer(this); |
51 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
52 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
53 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
49 | 54 |
setRenderer(mRenderer); |
50 | 55 |
Toast.makeText(context, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show(); |
51 | 56 |
} |
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
140 | 140 |
for(int j=0; j<NUM_LEAVES; j++) mCircleNode[i].attach(mLeaf, mEffects[j], mMesh); |
141 | 141 |
} |
142 | 142 |
|
143 |
mScreen = new DistortedScreen(mView);
|
|
143 |
mScreen = new DistortedScreen(); |
|
144 | 144 |
mScreen.attach(mRoot); |
145 | 145 |
} |
146 | 146 |
|
src/main/java/org/distorted/examples/olimpic/OlimpicSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.olimpic; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new OlimpicRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
---|---|---|
105 | 105 |
mEffects.apply(new MatrixEffectMove(mMove)); |
106 | 106 |
mEffects.apply(new MatrixEffectScale(mScale)); |
107 | 107 |
|
108 |
mScreen = new DistortedScreen(null);
|
|
108 |
mScreen = new DistortedScreen(); |
|
109 | 109 |
} |
110 | 110 |
|
111 | 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/projection/ProjectionRenderer.java | ||
---|---|---|
58 | 58 |
{ |
59 | 59 |
mView = view; |
60 | 60 |
mEffects= new DistortedEffects(); |
61 |
mScreen = new DistortedScreen(mView);
|
|
61 |
mScreen = new DistortedScreen(); |
|
62 | 62 |
|
63 | 63 |
mVector = new Static3D(0,0,0); |
64 | 64 |
mPoint1 = new Static3D(0,0,0); |
src/main/java/org/distorted/examples/projection/ProjectionSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.projection; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new ProjectionRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java | ||
---|---|---|
96 | 96 |
effects.apply(new MatrixEffectScale(mScale)); |
97 | 97 |
effects.apply( new MatrixEffectQuaternion(rot,mCenter) ); |
98 | 98 |
|
99 |
mScreen = new DistortedScreen(mView);
|
|
99 |
mScreen = new DistortedScreen(); |
|
100 | 100 |
mScreen.attach(mTexture,effects,mMesh); |
101 | 101 |
} |
102 | 102 |
|
src/main/java/org/distorted/examples/quaternion/QuaternionSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.quaternion; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
29 | 31 |
public QuaternionSurfaceView(Context context) |
30 | 32 |
{ |
31 | 33 |
super(context); |
34 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
35 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
36 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
32 | 37 |
setRenderer(new QuaternionRenderer(this)); |
33 | 38 |
} |
34 | 39 |
} |
src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
---|---|---|
101 | 101 |
mEffects.apply( new MatrixEffectScale(mScaleMain)); |
102 | 102 |
mEffects.apply( new MatrixEffectScale(mScaleFactor)); |
103 | 103 |
|
104 |
mScreen = new DistortedScreen(mView);
|
|
104 |
mScreen = new DistortedScreen(); |
|
105 | 105 |
} |
106 | 106 |
|
107 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/save/SaveSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.save; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new SaveRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
---|---|---|
75 | 75 |
mEffects.apply(new MatrixEffectMove(mMove)); |
76 | 76 |
mEffects.apply(new MatrixEffectScale(mScale)); |
77 | 77 |
|
78 |
mScreen = new DistortedScreen(mView);
|
|
78 |
mScreen = new DistortedScreen(); |
|
79 | 79 |
} |
80 | 80 |
|
81 | 81 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/sink/SinkSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.sink; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
29 | 31 |
public SinkSurfaceView(Context context) |
30 | 32 |
{ |
31 | 33 |
super(context); |
34 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
35 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
36 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
32 | 37 |
setRenderer(new SinkRenderer(this)); |
33 | 38 |
} |
34 | 39 |
} |
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
141 | 141 |
mStarEffects[i] = new DistortedEffects(mStarEffects[0], Distorted.CLONE_VERTEX); |
142 | 142 |
} |
143 | 143 |
|
144 |
mScreen = new DistortedScreen(mView);
|
|
144 |
mScreen = new DistortedScreen(); |
|
145 | 145 |
mScreen.setProjection(FOV_ANGLE, 0.02f); |
146 | 146 |
} |
147 | 147 |
|
src/main/java/org/distorted/examples/starwars/StarWarsSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.starwars; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
|
25 | 27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
32 | 34 |
{ |
33 | 35 |
super(context); |
34 | 36 |
mRenderer = new StarWarsRenderer(this); |
37 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
38 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
39 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
35 | 40 |
setRenderer(mRenderer); |
36 | 41 |
} |
37 | 42 |
|
src/main/java/org/distorted/examples/stencil/StencilRenderer.java | ||
---|---|---|
136 | 136 |
mCube2Node.glDepthMask(true); // Write to depth buffer |
137 | 137 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
138 | 138 |
|
139 |
mScreen = new DistortedScreen(mView);
|
|
139 |
mScreen = new DistortedScreen(); |
|
140 | 140 |
mScreen.glClearColor(1.0f,1.0f,1.0f,1.0f); |
141 | 141 |
mView.setEGLConfigChooser(5,6,5,0,16,8); // Screen: 16 bit depth, 8 bit STENCIL |
142 | 142 |
|
src/main/java/org/distorted/examples/stencil/StencilSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.stencil; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new StencilRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
src/main/java/org/distorted/examples/wind/WindRenderer.java | ||
---|---|---|
47 | 47 |
class WindRenderer implements GLSurfaceView.Renderer |
48 | 48 |
{ |
49 | 49 |
private GLSurfaceView mView; |
50 |
private DistortedEffects mEffects; |
|
51 | 50 |
private DistortedTexture mTexture; |
52 | 51 |
private DistortedScreen mScreen; |
53 | 52 |
private WindEffectsManager mManager; |
... | ... | |
61 | 60 |
{ |
62 | 61 |
mView = view; |
63 | 62 |
|
64 |
mEffects = new DistortedEffects(); |
|
65 | 63 |
mTexture = new DistortedTexture(50,30); |
66 | 64 |
mManager = new WindEffectsManager(mTexture); |
67 |
mScreen = new DistortedScreen(mView);
|
|
65 |
mScreen = new DistortedScreen(); |
|
68 | 66 |
|
69 |
mScreen.attach(mTexture,mEffects,new MeshCubes(50,30,1)); |
|
67 |
DistortedEffects effects = new DistortedEffects(); |
|
68 |
|
|
69 |
mScreen.attach(mTexture,effects,new MeshCubes(50,30,1)); |
|
70 | 70 |
|
71 | 71 |
mObjWidth = mTexture.getWidth(); |
72 | 72 |
mObjHeight= mTexture.getHeight(); |
73 | 73 |
|
74 | 74 |
mMove = new Static3D(0,0,0); |
75 | 75 |
mScale= new Static3D(1,1,1); |
76 |
mEffects.apply( new MatrixEffectMove(mMove));
|
|
77 |
mEffects.apply( new MatrixEffectScale(mScale));
|
|
76 |
effects.apply( new MatrixEffectMove(mMove));
|
|
77 |
effects.apply( new MatrixEffectScale(mScale));
|
|
78 | 78 |
|
79 | 79 |
Static1D angle = new Static1D(-45); |
80 | 80 |
Static3D axis = new Static3D(0,0,1); |
81 | 81 |
Static3D center= new Static3D(0,mObjHeight/2,0); |
82 | 82 |
|
83 |
mEffects.apply( new MatrixEffectRotate(angle, axis, center) );
|
|
84 |
mManager.apply(mEffects,mWind);
|
|
83 |
effects.apply( new MatrixEffectRotate(angle, axis, center) );
|
|
84 |
mManager.apply(effects,mWind);
|
|
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/wind/WindSurfaceView.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.examples.wind; |
21 | 21 |
|
22 |
import android.app.ActivityManager; |
|
22 | 23 |
import android.content.Context; |
24 |
import android.content.pm.ConfigurationInfo; |
|
23 | 25 |
import android.opengl.GLSurfaceView; |
24 | 26 |
import android.util.AttributeSet; |
25 | 27 |
|
... | ... | |
38 | 40 |
if(!isInEditMode()) |
39 | 41 |
{ |
40 | 42 |
mRenderer = new WindRenderer(this); |
43 |
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
|
44 |
final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); |
|
45 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
|
41 | 46 |
setRenderer(mRenderer); |
42 | 47 |
} |
43 | 48 |
} |
Also available in: Unified diff
Change of API: move setting the EGL context back to the APP.