Revision 3a91bfe1
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/examples/listener/ListenerRenderer.java | ||
---|---|---|
109 | 109 |
|
110 | 110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
111 | 111 |
|
112 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
113 |
{
|
|
114 |
mEffects.abortEffects(EffectTypes.MATRIX);
|
|
112 |
public void onSurfaceChanged(GL10 glUnused, int width, int height)
|
|
113 |
{
|
|
114 |
mEffects.abortEffects(EffectTypes.MATRIX); |
|
115 | 115 |
|
116 |
if( (float)bmpHeight/bmpWidth > (float)height/width )
|
|
117 |
{
|
|
118 |
int w = (height*bmpWidth)/bmpHeight;
|
|
119 |
float factor = (float)height/bmpHeight;
|
|
120 |
|
|
121 |
mEffects.move( new Static3D((width-w)/2,0,0) );
|
|
122 |
mEffects.scale(factor);
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
int h = (width*bmpHeight)/bmpWidth;
|
|
127 |
float factor = (float)width/bmpWidth;
|
|
128 |
|
|
129 |
mEffects.move( new Static3D(0,(height-h)/2,0) );
|
|
130 |
mEffects.scale(factor);
|
|
131 |
}
|
|
116 |
if( (float)bmpHeight/bmpWidth > (float)height/width ) |
|
117 |
{ |
|
118 |
int w = (height*bmpWidth)/bmpHeight; |
|
119 |
float factor = (float)height/bmpHeight; |
|
120 |
|
|
121 |
mEffects.move( new Static3D((width-w)/2,0,0) ); |
|
122 |
mEffects.scale(factor); |
|
123 |
} |
|
124 |
else |
|
125 |
{ |
|
126 |
int h = (width*bmpHeight)/bmpWidth; |
|
127 |
float factor = (float)width/bmpWidth; |
|
128 |
|
|
129 |
mEffects.move( new Static3D(0,(height-h)/2,0) ); |
|
130 |
mEffects.scale(factor); |
|
131 |
} |
|
132 | 132 |
|
133 |
mScreen.resize(width, height);
|
|
134 |
}
|
|
133 |
mScreen.resize(width, height); |
|
134 |
} |
|
135 | 135 |
|
136 | 136 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
137 | 137 |
|
138 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
139 |
{
|
|
140 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.water);
|
|
141 |
Bitmap bitmap;
|
|
138 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
|
|
139 |
{ |
|
140 |
InputStream is = mView.getContext().getResources().openRawResource(R.raw.water); |
|
141 |
Bitmap bitmap; |
|
142 | 142 |
|
143 |
try
|
|
144 |
{
|
|
145 |
bitmap = BitmapFactory.decodeStream(is);
|
|
146 |
}
|
|
147 |
finally
|
|
148 |
{
|
|
149 |
try
|
|
150 |
{
|
|
151 |
is.close();
|
|
152 |
}
|
|
153 |
catch(IOException e) { }
|
|
154 |
}
|
|
155 |
|
|
156 |
bmpHeight = bitmap.getHeight();
|
|
157 |
bmpWidth = bitmap.getWidth();
|
|
158 |
|
|
159 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
|
|
160 |
mTexture.setTexture(bitmap);
|
|
161 |
|
|
162 |
if( mMesh==null ) mMesh = new MeshFlat(50,50*bmpHeight/bmpWidth);
|
|
163 |
|
|
164 |
mScreen.detachAll();
|
|
165 |
mScreen.attach(mTexture,mEffects,mMesh);
|
|
166 |
|
|
167 |
for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble();
|
|
168 |
|
|
169 |
DistortedEffects.enableEffect(EffectNames.DISTORT);
|
|
170 |
|
|
171 |
try
|
|
172 |
{
|
|
173 |
Distorted.onCreate(mView.getContext());
|
|
174 |
}
|
|
175 |
catch(Exception ex)
|
|
176 |
{
|
|
177 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
178 |
}
|
|
179 |
}
|
|
143 |
try
|
|
144 |
{ |
|
145 |
bitmap = BitmapFactory.decodeStream(is); |
|
146 |
}
|
|
147 |
finally
|
|
148 |
{ |
|
149 |
try
|
|
150 |
{ |
|
151 |
is.close(); |
|
152 |
}
|
|
153 |
catch(IOException e) { } |
|
154 |
}
|
|
155 |
|
|
156 |
bmpHeight = bitmap.getHeight(); |
|
157 |
bmpWidth = bitmap.getWidth(); |
|
158 |
|
|
159 |
if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight); |
|
160 |
mTexture.setTexture(bitmap); |
|
161 |
|
|
162 |
if( mMesh==null ) mMesh = new MeshFlat(50,50*bmpHeight/bmpWidth); |
|
163 |
|
|
164 |
mScreen.detachAll(); |
|
165 |
mScreen.attach(mTexture,mEffects,mMesh); |
|
166 |
|
|
167 |
for(int i=0; i<NUM_BUBBLES; i++) randomizeNewBubble(); |
|
168 |
|
|
169 |
DistortedEffects.enableEffect(EffectNames.DISTORT); |
|
170 |
|
|
171 |
try |
|
172 |
{ |
|
173 |
Distorted.onCreate(mView.getContext()); |
|
174 |
} |
|
175 |
catch(Exception ex) |
|
176 |
{ |
|
177 |
android.util.Log.e("Renderer", ex.getMessage() ); |
|
178 |
} |
|
179 |
} |
|
180 | 180 |
} |
Also available in: Unified diff
Progress with GLOW.
Serious bug sorting Surface's children into postprocessing Buckets detected.