Revision d8b42d02
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/save/SaveRenderer.java | ||
---|---|---|
154 | 154 |
|
155 | 155 |
public void onDrawFrame(GL10 glUnused) |
156 | 156 |
{ |
157 |
long time = System.currentTimeMillis(); |
|
158 |
|
|
159 | 157 |
if( isSaving ) // render to an offscreen buffer and read pixels |
160 | 158 |
{ |
161 | 159 |
mMove.set(0,0,0); |
162 | 160 |
mScaleMain.set(1,1,1); |
163 |
mOffscreen.render(time);
|
|
161 |
mOffscreen.render(System.currentTimeMillis());
|
|
164 | 162 |
applyMatrixEffects(scrWidth,scrHeight); |
165 | 163 |
|
166 | 164 |
int fW =(int)(mScale*bmpWidth); |
... | ... | |
180 | 178 |
{ |
181 | 179 |
android.util.Log.e("Save", "Error trying to read from offscreen FBO, textureID="+textureID); |
182 | 180 |
} |
183 |
|
|
184 | 181 |
isSaving = false; |
185 | 182 |
} |
186 | 183 |
|
187 |
mScreen.render(time); |
|
184 |
// Quite subtle issue here. Since we share the DistortedEffects object between the mOffscreen |
|
185 |
// and mScreen surfaces, we cannot render both of them in one go using the same time. That |
|
186 |
// would make the second render, in this case mScreen's render, re-use the values of the |
|
187 |
// Dynamics calculated the first time around and we don't want that (mOffscreen's scale and move |
|
188 |
// are different! What would happen is the mScreen would be - one render when we are 'saving' - |
|
189 |
// get drawn with different dimensions and on-screen position, i.e. we would see a flash. |
|
190 |
|
|
191 |
mScreen.render(System.currentTimeMillis()); |
|
188 | 192 |
} |
189 | 193 |
|
190 | 194 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Change of API: move setting the EGL context back to the APP.