Revision e4330c89
Added by Leszek Koltunski almost 7 years ago
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 |
} |
Also available in: Unified diff
Change of API: move setting the EGL context back to the APP.