Revision 698ad0a8
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
84 | 84 |
dRight.add( new Static3D( 0, 0, 0) ); |
85 | 85 |
dRight.add( new Static3D( 20, 10, 0) ); |
86 | 86 |
|
87 |
mEffects = new DistortedEffects(1);
|
|
87 |
mEffects = new DistortedEffects(); |
|
88 | 88 |
mEffects.apply( new VertexEffectDistort(dLeft , pLeft , rLeft ) ); |
89 | 89 |
mEffects.apply( new VertexEffectDistort(dRight, pRight, rRight) ); |
90 | 90 |
|
... | ... | |
150 | 150 |
bmpHeight = bitmap.getHeight(); |
151 | 151 |
bmpWidth = bitmap.getWidth(); |
152 | 152 |
|
153 |
// We could have gotten here after the activity went to the background |
|
154 |
// for a brief amount of time; in this case mTexture is already created. |
|
155 |
// Do not leak memory by creating it the second time around. |
|
156 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
157 |
|
|
158 |
// likewise the Mesh |
|
153 | 159 |
// This will make the Mesh stretched by bmpWidth x bmpHeight even before any effects |
154 | 160 |
// are applied to it (the Mesh - MeshRectangles - is flat, so the third parameter does not |
155 | 161 |
// not matter). bmpWight x bmpHeight is the size of the Bitmap, thus this means that we can |
... | ... | |
158 | 164 |
// around its center has to be centered at (bmpWidth/2, bmpHeight/2, 0). |
159 | 165 |
// Without this call, the default size of the Mesh is 1x1x0 ( or 1x1x1 in case of not-flat |
160 | 166 |
// Meshes) so we would need to be rotating around (0.5,0.5,0.0). |
161 |
mEffects.setStretch(bmpWidth,bmpHeight,0); |
|
162 |
|
|
163 |
// We could have gotten here after the activity went to the background |
|
164 |
// for a brief amount of time; in this case mTexture is already created. |
|
165 |
// Do not leak memory by creating it the second time around. |
|
166 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
|
167 |
|
|
168 |
// likewise the Mesh |
|
169 |
if( mMesh==null ) mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth); |
|
167 |
if( mMesh==null ) |
|
168 |
{ |
|
169 |
mMesh = new MeshRectangles(9,9*bmpHeight/bmpWidth); |
|
170 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
171 |
} |
|
170 | 172 |
|
171 | 173 |
// even if mTexture wasn't null, we still need to call setTexture() on it |
172 | 174 |
// because every time activity goes to background, its OpenGL resources |
Also available in: Unified diff
Move the Effects.setStretch to Meshbase.setStretch