Revision 67c3a83b
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.graphics.Bitmap; |
23 | 23 |
import android.graphics.BitmapFactory; |
24 |
import android.opengl.GLES30; |
|
24 | 25 |
import android.opengl.GLSurfaceView; |
25 | 26 |
|
26 | 27 |
import org.distorted.examples.R; |
... | ... | |
48 | 49 |
private DistortedTexture mTexture; |
49 | 50 |
private DistortedScreen mScreen; |
50 | 51 |
private AroundTheWorldEffectsManager mManager; |
51 |
private int bmpWidth, bmpHeight;
|
|
52 |
private int mObjWidth, mObjHeight;
|
|
52 | 53 |
|
53 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
54 | 55 |
|
... | ... | |
83 | 84 |
|
84 | 85 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
85 | 86 |
{ |
86 |
float qx = (float)width /bmpWidth; |
|
87 |
float qy = (float)height/bmpHeight; |
|
88 |
|
|
89 | 87 |
mEffects.abortEffects(EffectTypes.MATRIX); |
90 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
88 |
|
|
89 |
if( (float)mObjHeight/mObjWidth > (float)height/width ) |
|
90 |
{ |
|
91 |
int w = (height*mObjWidth)/mObjHeight; |
|
92 |
float factor = (float)height/mObjHeight; |
|
93 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
94 |
mEffects.scale(factor); |
|
95 |
} |
|
96 |
else |
|
97 |
{ |
|
98 |
int h = (width*mObjHeight)/mObjWidth; |
|
99 |
float factor = (float)width/mObjWidth; |
|
100 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
101 |
mEffects.scale(factor); |
|
102 |
} |
|
91 | 103 |
|
92 | 104 |
mScreen.resize(width,height); |
93 | 105 |
} |
... | ... | |
112 | 124 |
catch(IOException e) { } |
113 | 125 |
} |
114 | 126 |
|
115 |
bmpWidth = bitmap.getWidth();
|
|
116 |
bmpHeight= bitmap.getHeight();
|
|
127 |
mObjWidth = bitmap.getWidth();
|
|
128 |
mObjHeight= bitmap.getHeight();
|
|
117 | 129 |
|
118 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
130 |
if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
|
|
119 | 131 |
mTexture.setTexture(bitmap); |
120 | 132 |
|
121 | 133 |
mScreen.detachAll(); |
122 |
mScreen.attach(mTexture, mEffects, new MeshFlat(30,30*bmpHeight/bmpWidth));
|
|
134 |
mScreen.attach(mTexture, mEffects, new MeshFlat(30,30*mObjHeight/mObjWidth));
|
|
123 | 135 |
|
124 | 136 |
DistortedEffects.enableEffect(EffectNames.DISTORT); |
125 | 137 |
DistortedEffects.enableEffect(EffectNames.SINK); |
src/main/java/org/distorted/examples/blur/BlurRenderer.java | ||
---|---|---|
91 | 91 |
|
92 | 92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
93 | 93 |
|
94 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
95 |
{ |
|
96 |
float qx = (float)width /bmpWidth; |
|
97 |
float qy = (float)height/bmpHeight; |
|
98 |
|
|
99 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
100 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
94 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
95 |
{ |
|
96 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
101 | 97 |
|
102 |
mScreen.resize(width, height); |
|
103 |
} |
|
98 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
99 |
{ |
|
100 |
int w = (height*bmpWidth)/bmpHeight; |
|
101 |
float factor = (float)height/bmpHeight; |
|
102 |
|
|
103 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
104 |
mEffects.scale(factor); |
|
105 |
} |
|
106 |
else |
|
107 |
{ |
|
108 |
int h = (width*bmpHeight)/bmpWidth; |
|
109 |
float factor = (float)width/bmpWidth; |
|
110 |
|
|
111 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
112 |
mEffects.scale(factor); |
|
113 |
} |
|
114 |
|
|
115 |
mScreen.resize(width, height); |
|
116 |
} |
|
104 | 117 |
|
105 | 118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
106 | 119 |
|
107 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
108 |
{ |
|
109 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.dog); |
|
110 |
Bitmap bitmap; |
|
120 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
121 |
{
|
|
122 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.dog);
|
|
123 |
Bitmap bitmap;
|
|
111 | 124 |
|
112 |
try
|
|
113 |
{ |
|
114 |
bitmap = BitmapFactory.decodeStream(is); |
|
115 |
}
|
|
116 |
finally
|
|
117 |
{ |
|
118 |
try
|
|
119 |
{ |
|
120 |
is.close(); |
|
121 |
}
|
|
122 |
catch(IOException e) { } |
|
123 |
}
|
|
125 |
try
|
|
126 |
{
|
|
127 |
bitmap = BitmapFactory.decodeStream(is);
|
|
128 |
}
|
|
129 |
finally
|
|
130 |
{
|
|
131 |
try
|
|
132 |
{
|
|
133 |
is.close();
|
|
134 |
}
|
|
135 |
catch(IOException e) { }
|
|
136 |
}
|
|
124 | 137 |
|
125 |
bmpHeight = bitmap.getHeight(); |
|
126 |
bmpWidth = bitmap.getWidth(); |
|
127 |
|
|
128 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight); |
|
129 |
mTexture.setTexture(bitmap); |
|
130 |
|
|
131 |
mScreen.detachAll(); |
|
132 |
DistortedNode node = new DistortedNode(mTexture,mEffects,mMesh); |
|
133 |
node.setPostprocessEffects(mPostEffects); |
|
134 |
mScreen.attach(node); |
|
135 |
|
|
136 |
DistortedEffects.enableEffect(EffectNames.BLUR); |
|
137 |
|
|
138 |
try |
|
139 |
{ |
|
140 |
Distorted.onCreate(mView.getContext()); |
|
141 |
} |
|
142 |
catch(Exception ex) |
|
143 |
{ |
|
144 |
android.util.Log.e("Blur", ex.getMessage() ); |
|
145 |
} |
|
146 |
} |
|
138 |
bmpHeight = bitmap.getHeight();
|
|
139 |
bmpWidth = bitmap.getWidth();
|
|
140 |
|
|
141 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
142 |
mTexture.setTexture(bitmap);
|
|
143 |
|
|
144 |
mScreen.detachAll();
|
|
145 |
DistortedNode node = new DistortedNode(mTexture,mEffects,mMesh);
|
|
146 |
node.setPostprocessEffects(mPostEffects);
|
|
147 |
mScreen.attach(node);
|
|
148 |
|
|
149 |
DistortedEffects.enableEffect(EffectNames.BLUR);
|
|
150 |
|
|
151 |
try
|
|
152 |
{
|
|
153 |
Distorted.onCreate(mView.getContext());
|
|
154 |
}
|
|
155 |
catch(Exception ex)
|
|
156 |
{
|
|
157 |
android.util.Log.e("Blur", ex.getMessage() );
|
|
158 |
}
|
|
159 |
}
|
|
147 | 160 |
} |
src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import android.graphics.Bitmap; |
23 | 23 |
import android.graphics.BitmapFactory; |
24 |
import android.opengl.GLES30; |
|
24 | 25 |
import android.opengl.GLSurfaceView; |
25 | 26 |
|
26 | 27 |
import org.distorted.examples.R; |
src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
---|---|---|
157 | 157 |
|
158 | 158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
159 | 159 |
|
160 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
161 |
{
|
|
162 |
float qx = (float)width /bmpWidth; |
|
163 |
float qy = (float)height/bmpHeight; |
|
160 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
161 |
{
|
|
162 |
float qx = (float)width /bmpWidth;
|
|
163 |
float qy = (float)height/bmpHeight;
|
|
164 | 164 |
|
165 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
166 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
165 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
166 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) );
|
|
167 | 167 |
|
168 |
mScreen.resize(width, height); |
|
169 |
} |
|
168 |
mScreen.resize(width, height);
|
|
169 |
}
|
|
170 | 170 |
|
171 | 171 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
172 | 172 |
|
173 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
174 |
{ |
|
175 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.girl); |
|
176 |
Bitmap bitmap; |
|
173 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
174 |
{
|
|
175 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.girl);
|
|
176 |
Bitmap bitmap;
|
|
177 | 177 |
|
178 |
try
|
|
179 |
{ |
|
180 |
bitmap = BitmapFactory.decodeStream(is); |
|
181 |
}
|
|
182 |
finally
|
|
183 |
{ |
|
184 |
try
|
|
185 |
{ |
|
186 |
is.close(); |
|
187 |
}
|
|
188 |
catch(IOException e) { } |
|
189 |
}
|
|
178 |
try
|
|
179 |
{
|
|
180 |
bitmap = BitmapFactory.decodeStream(is);
|
|
181 |
}
|
|
182 |
finally
|
|
183 |
{
|
|
184 |
try
|
|
185 |
{
|
|
186 |
is.close();
|
|
187 |
}
|
|
188 |
catch(IOException e) { }
|
|
189 |
}
|
|
190 | 190 |
|
191 |
bmpHeight = bitmap.getHeight(); |
|
192 |
bmpWidth = bitmap.getWidth(); |
|
193 |
|
|
194 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight); |
|
195 |
mTexture.setTexture(bitmap); |
|
196 |
|
|
197 |
mScreen.detachAll(); |
|
198 |
mScreen.attach(mTexture,mEffects,new MeshFlat(30,30*bmpHeight/bmpWidth)); |
|
199 |
|
|
200 |
DistortedEffects.enableEffect(EffectNames.DISTORT); |
|
201 |
DistortedEffects.enableEffect(EffectNames.SINK); |
|
202 |
DistortedEffects.enableEffect(EffectNames.SWIRL); |
|
203 |
|
|
204 |
try |
|
205 |
{ |
|
206 |
Distorted.onCreate(mView.getContext()); |
|
207 |
} |
|
208 |
catch(Exception ex) |
|
209 |
{ |
|
210 |
android.util.Log.e("Renderer", ex.getMessage() ); |
|
211 |
} |
|
212 |
} |
|
191 |
bmpHeight = bitmap.getHeight();
|
|
192 |
bmpWidth = bitmap.getWidth();
|
|
193 |
|
|
194 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
195 |
mTexture.setTexture(bitmap);
|
|
196 |
|
|
197 |
mScreen.detachAll();
|
|
198 |
mScreen.attach(mTexture,mEffects,new MeshFlat(30,30*bmpHeight/bmpWidth));
|
|
199 |
|
|
200 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
201 |
DistortedEffects.enableEffect(EffectNames.SINK);
|
|
202 |
DistortedEffects.enableEffect(EffectNames.SWIRL);
|
|
203 |
|
|
204 |
try
|
|
205 |
{
|
|
206 |
Distorted.onCreate(mView.getContext());
|
|
207 |
}
|
|
208 |
catch(Exception ex)
|
|
209 |
{
|
|
210 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
211 |
}
|
|
212 |
}
|
|
213 | 213 |
} |
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
56 | 56 |
private DistortedTexture mLeaf; |
57 | 57 |
private DistortedScreen mScreen; |
58 | 58 |
private MeshFlat mMesh; |
59 |
private int mRootW, mRootH;
|
|
59 |
private int mScreenW, mScreenH;
|
|
60 | 60 |
private int mPrevRendered, mCurrRendered; |
61 | 61 |
|
62 | 62 |
private DistortedNode[] mCircleNode = new DistortedNode[NUM_CIRCLES]; |
... | ... | |
95 | 95 |
mMesh = new MeshFlat(1,1); |
96 | 96 |
DistortedEffects effects = new DistortedEffects(); |
97 | 97 |
|
98 |
mRootW = 9*LEAF_SIZE;
|
|
99 |
mRootH = 9*LEAF_SIZE;
|
|
100 |
mRoot = new DistortedNode(new DistortedTexture(mRootW,mRootH), effects, mMesh);
|
|
98 |
mScreenW = 9*LEAF_SIZE;
|
|
99 |
mScreenH = 9*LEAF_SIZE;
|
|
100 |
mRoot = new DistortedNode(new DistortedTexture(mScreenW,mScreenH), effects, mMesh);
|
|
101 | 101 |
|
102 | 102 |
Dynamic1D rot = new Dynamic1D(5000,0.0f); |
103 | 103 |
rot.setMode(Dynamic1D.MODE_JUMP); |
104 | 104 |
rot.add(new Static1D( 0)); |
105 | 105 |
rot.add(new Static1D(360)); |
106 | 106 |
|
107 |
int[] colors = new int[] {0,0,1, 0,0,0, 1,0,0, 1,1,0, 0,1,0}; // blue, black, red, yellow, green |
|
108 |
float[] positions = new float[] { -0.333f, -0.12f, 0.0f,-0.12f, +0.333f,-0.12f, |
|
109 |
-0.166f,+0.166f, +0.166f,+0.166f }; |
|
107 |
int[] colors = new int[] {0,0,1, 0,0,0, 1,0,0, 1,1,0, 0,1,0}; // blue, black, red, yellow, green |
|
108 |
int[] positions = new int[] {0,2*LEAF_SIZE, 3*LEAF_SIZE,2*LEAF_SIZE, 6*LEAF_SIZE,2*LEAF_SIZE, 3*LEAF_SIZE/2,9*LEAF_SIZE/2, 9*LEAF_SIZE/2,9*LEAF_SIZE/2}; |
|
110 | 109 |
|
111 |
Static3D center = new Static3D(0,0,0);
|
|
110 |
Static3D center = new Static3D(3*LEAF_SIZE/2, 3*LEAF_SIZE/2, 0);
|
|
112 | 111 |
Static3D axis = new Static3D(0,0,1); |
113 |
Static3D move = new Static3D(-0.33f,0.0f,0.0f); |
|
114 |
Static3D scale = new Static3D(0.333f,0.333f,0.333f); |
|
112 |
Static3D moveVector = new Static3D(0,LEAF_SIZE,0); |
|
115 | 113 |
|
116 | 114 |
for(int j=0; j<NUM_LEAVES; j++) |
117 | 115 |
{ |
118 | 116 |
mEffects[j] = new DistortedEffects(); |
119 |
mEffects[j].rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center); |
|
120 |
mEffects[j].move(move); |
|
121 |
mEffects[j].scale(scale); |
|
117 |
mEffects[j].rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center ); |
|
118 |
mEffects[j].move(moveVector); |
|
122 | 119 |
} |
123 | 120 |
|
124 | 121 |
for(int i=0; i<NUM_CIRCLES; i++) |
... | ... | |
126 | 123 |
effects = new DistortedEffects(); |
127 | 124 |
effects.move( new Static3D(positions[2*i], positions[2*i+1], 0) ); |
128 | 125 |
effects.rotate( rot, axis, center ); |
129 |
effects.scale( scale ); |
|
130 | 126 |
effects.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) ); |
131 | 127 |
|
132 | 128 |
mCircleNode[i] = new DistortedNode( surface, effects, mMesh); |
... | ... | |
141 | 137 |
|
142 | 138 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
143 | 139 |
|
144 |
public void onDrawFrame(GL10 glUnused)
|
|
145 |
{ |
|
146 |
mCurrRendered = mScreen.render(System.currentTimeMillis()); |
|
140 |
public void onDrawFrame(GL10 glUnused)
|
|
141 |
{
|
|
142 |
mCurrRendered = mScreen.render(System.currentTimeMillis());
|
|
147 | 143 |
|
148 |
if( mCurrRendered!=mPrevRendered ) |
|
149 |
{ |
|
150 |
mPrevRendered = mCurrRendered; |
|
144 |
if( mCurrRendered!=mPrevRendered )
|
|
145 |
{
|
|
146 |
mPrevRendered = mCurrRendered;
|
|
151 | 147 |
|
152 |
final OlimpicActivity act = (OlimpicActivity)mView.getContext(); |
|
148 |
final OlimpicActivity act = (OlimpicActivity)mView.getContext();
|
|
153 | 149 |
|
154 |
act.runOnUiThread(new Runnable() |
|
150 |
act.runOnUiThread(new Runnable()
|
|
155 | 151 |
{ |
156 | 152 |
public void run() |
157 | 153 |
{ |
158 |
act.setText("rendered: "+mCurrRendered+" objects"); |
|
159 |
} |
|
154 |
act.setText("rendered: "+mCurrRendered+" objects");
|
|
155 |
}
|
|
160 | 156 |
}); |
161 |
} |
|
162 |
} |
|
157 |
}
|
|
158 |
}
|
|
163 | 159 |
|
164 | 160 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
165 | 161 |
|
166 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
167 |
{ |
|
168 |
DistortedEffects effects = mRoot.getEffects(); |
|
162 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
163 |
{
|
|
164 |
DistortedEffects effects = mRoot.getEffects();
|
|
169 | 165 |
|
170 |
float qx = (float)width /mRootW; |
|
171 |
float qy = (float)height/mRootH; |
|
166 |
effects.abortEffects(EffectTypes.MATRIX); |
|
167 |
|
|
168 |
if( (float)mScreenH/mScreenW > (float)height/width ) |
|
169 |
{ |
|
170 |
int w = (height*mScreenW)/mScreenH; |
|
171 |
float factor = (float)height/mScreenH; |
|
172 | 172 |
|
173 |
effects.abortEffects(EffectTypes.MATRIX); |
|
174 |
effects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
173 |
effects.move( new Static3D((width-w)/2 ,0, 0) ); |
|
174 |
effects.scale( factor ); |
|
175 |
} |
|
176 |
else |
|
177 |
{ |
|
178 |
int h = (width*mScreenH)/mScreenW; |
|
179 |
float factor = (float)width/mScreenW; |
|
175 | 180 |
|
176 |
mScreen.resize(width, height); |
|
177 |
} |
|
181 |
effects.move( new Static3D(0,(height-h)/2,0) ); |
|
182 |
effects.scale( factor ); |
|
183 |
} |
|
184 |
|
|
185 |
mScreen.resize(width, height); |
|
186 |
} |
|
178 | 187 |
|
179 | 188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
180 | 189 |
|
181 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
182 |
{ |
|
183 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.leaf); |
|
184 |
Bitmap leaf; |
|
190 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
191 |
{
|
|
192 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.leaf);
|
|
193 |
Bitmap leaf;
|
|
185 | 194 |
|
186 |
try
|
|
187 |
{ |
|
188 |
leaf = BitmapFactory.decodeStream(is); |
|
189 |
}
|
|
190 |
finally
|
|
191 |
{ |
|
192 |
try
|
|
193 |
{ |
|
194 |
is.close(); |
|
195 |
}
|
|
196 |
catch(IOException e) { } |
|
197 |
}
|
|
195 |
try
|
|
196 |
{
|
|
197 |
leaf = BitmapFactory.decodeStream(is);
|
|
198 |
}
|
|
199 |
finally
|
|
200 |
{
|
|
201 |
try
|
|
202 |
{
|
|
203 |
is.close();
|
|
204 |
}
|
|
205 |
catch(IOException e) { }
|
|
206 |
}
|
|
198 | 207 |
|
199 |
mLeaf.setTexture(leaf); |
|
208 |
mLeaf.setTexture(leaf);
|
|
200 | 209 |
|
201 |
DistortedEffects.enableEffect(EffectNames.CHROMA); |
|
210 |
DistortedEffects.enableEffect(EffectNames.CHROMA);
|
|
202 | 211 |
|
203 |
try |
|
204 |
{ |
|
205 |
Distorted.onCreate(mView.getContext()); |
|
206 |
} |
|
207 |
catch(Exception ex) |
|
208 |
{ |
|
209 |
android.util.Log.e("Olympic", ex.getMessage() ); |
|
210 |
} |
|
211 |
} |
|
212 |
try |
|
213 |
{ |
|
214 |
Distorted.onCreate(mView.getContext()); |
|
215 |
} |
|
216 |
catch(Exception ex) |
|
217 |
{ |
|
218 |
android.util.Log.e("Olympic", ex.getMessage() ); |
|
219 |
} |
|
220 |
} |
|
221 |
|
|
222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
223 |
|
|
212 | 224 |
} |
src/main/java/org/distorted/examples/plainmonalisa/RenderThread.java | ||
---|---|---|
209 | 209 |
{ |
210 | 210 |
Log.d(TAG, "surfaceChanged " + width + "x" + height); |
211 | 211 |
|
212 |
float qx = (float)width /bmpWidth; |
|
213 |
float qy = (float)height/bmpHeight; |
|
214 |
|
|
215 | 212 |
mEffects.abortEffects(EffectTypes.MATRIX); |
216 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
213 |
|
|
214 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
215 |
{ |
|
216 |
int w = (height*bmpWidth)/bmpHeight; |
|
217 |
float factor = (float)height/bmpHeight; |
|
218 |
|
|
219 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
220 |
mEffects.scale( factor ); |
|
221 |
} |
|
222 |
else |
|
223 |
{ |
|
224 |
int h = (width*bmpHeight)/bmpWidth; |
|
225 |
float factor = (float)width/bmpWidth; |
|
226 |
|
|
227 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
228 |
mEffects.scale( factor ); |
|
229 |
} |
|
217 | 230 |
|
218 | 231 |
mScreen.resize(width, height); |
219 | 232 |
} |
src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
---|---|---|
187 | 187 |
|
188 | 188 |
private void applyMatrixEffects(int width, int height) |
189 | 189 |
{ |
190 |
float qx = (float)width /bmpWidth; |
|
191 |
float qy = (float)height/bmpHeight; |
|
192 |
|
|
193 | 190 |
mEffects.abortEffects(EffectTypes.MATRIX); |
194 |
mEffects.scale( qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) ); |
|
191 |
|
|
192 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
193 |
{ |
|
194 |
int w = (height*bmpWidth)/bmpHeight; |
|
195 |
float factor = (float)height/bmpHeight; |
|
196 |
|
|
197 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
198 |
mEffects.scale(factor); |
|
199 |
} |
|
200 |
else |
|
201 |
{ |
|
202 |
int h = (width*bmpHeight)/bmpWidth; |
|
203 |
float factor = (float)width/bmpWidth; |
|
204 |
|
|
205 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
206 |
mEffects.scale(factor); |
|
207 |
} |
|
195 | 208 |
|
196 | 209 |
mEffects.scale(mScaleDyn); |
197 | 210 |
} |
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
404 | 404 |
int crawlH = mCrawlTexture.getHeight(); |
405 | 405 |
int screenW= mScreen.getWidth(); |
406 | 406 |
int screenH= mScreen.getHeight(); |
407 |
int backW = mCrawlBackgroundTexture.getWidth(); |
|
408 | 407 |
int backH = mCrawlBackgroundTexture.getHeight(); |
409 |
float scale= ((float)backW/backH)*((float)crawlH/crawlW);
|
|
408 |
float scale= (float)screenW/crawlW;
|
|
410 | 409 |
|
411 |
mCrawlBackgroundEffects.move( new Static3D(0, -((float)backH/screenH-1.0f)/2 ,0) );
|
|
410 |
//mCrawlBackgroundEffects.move( new Static3D(0,screenH-backH,0) );
|
|
412 | 411 |
mCrawlBackgroundEffects.rotate( new Static1D(CRAWL_ANGLE), new Static3D(1,0,0), new Static3D(0.5f,1.0f,0.0f) ); |
413 | 412 |
mCrawlBackgroundEffects.scale( new Static3D(1.0f, (float)backH/screenH,1.0f) ); |
414 | 413 |
|
415 | 414 |
final int transpDist = 5; |
416 | 415 |
Static4D region = new Static4D(screenW/2,(1-transpDist)*backH,transpDist*backH,transpDist*backH); |
417 |
mCrawlBackgroundEffects.alpha(new Static1D(1-transpDist*0.6f), region, true); |
|
416 |
//mCrawlBackgroundEffects.alpha(new Static1D(1-transpDist*0.6f), region, true);
|
|
418 | 417 |
|
419 | 418 |
Dynamic3D di = new Dynamic3D(70000,0.5f); |
420 |
di.add(new Static3D(0, 0,0)); |
|
421 |
di.add(new Static3D(0,-(1+scale),0)); |
|
422 |
|
|
423 |
mCrawlEffects.move(di); |
|
424 |
mCrawlEffects.move ( new Static3D(0, (1+scale)/2,0) ); |
|
425 |
mCrawlEffects.scale( new Static3D(1, scale ,1) ); |
|
419 |
di.add(new Static3D(screenW/2,+backH , 0)); |
|
420 |
di.add(new Static3D(screenW/2,-scale*crawlH, 0)); |
|
426 | 421 |
|
422 |
//mCrawlEffects.move(di); |
|
423 |
//mCrawlEffects.scale( new Static3D(scale,scale,scale) ); |
|
424 |
//mCrawlEffects.move( new Static3D(-crawlW/2,0,0) ); |
|
425 |
|
|
427 | 426 |
mBackground = mScreen.attach(mCrawlBackgroundTexture, mCrawlBackgroundEffects,mQuad); |
428 | 427 |
mBackground.attach(mCrawlTexture, mCrawlEffects,mQuad); |
429 | 428 |
mBackground.glDisable(GLES30.GL_DEPTH_TEST); |
Also available in: Unified diff
Revert "Convert a few more APPs to the new resolution-independent Matrix Effects."
This reverts commit 51554e4700774b72e18e97c7cc72ef887dfbf551.