Revision e6519ac8
Added by Leszek Koltunski about 6 years ago
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.main; |
21 | 21 |
|
22 |
import android.opengl.GLES30;
|
|
22 |
import android.opengl.GLES31;
|
|
23 | 23 |
import android.opengl.Matrix; |
24 | 24 |
|
25 | 25 |
import org.distorted.library.effect.EffectQuality; |
... | ... | |
128 | 128 |
|
129 | 129 |
mClearDepth = 1.0f; |
130 | 130 |
mClearStencil = 0; |
131 |
mClear = GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT;
|
|
131 |
mClear = GLES31.GL_DEPTH_BUFFER_BIT | GLES31.GL_COLOR_BUFFER_BIT;
|
|
132 | 132 |
|
133 | 133 |
mBuffer = new DistortedOutputSurface[1+EffectQuality.LENGTH]; |
134 | 134 |
|
... | ... | |
194 | 194 |
|
195 | 195 |
DistortedObject.toDo(); // create the FBOs immediately. This is safe as we must be holding the OpenGL context now. |
196 | 196 |
|
197 |
GLES30.glStencilMask(0xff);
|
|
198 |
GLES30.glDepthMask(true);
|
|
199 |
GLES30.glColorMask(true,true,true,true);
|
|
200 |
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
201 |
GLES30.glClearDepthf(1.0f);
|
|
202 |
GLES30.glClearStencil(0);
|
|
197 |
GLES31.glStencilMask(0xff);
|
|
198 |
GLES31.glDepthMask(true);
|
|
199 |
GLES31.glColorMask(true,true,true,true);
|
|
200 |
GLES31.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
201 |
GLES31.glClearDepthf(1.0f);
|
|
202 |
GLES31.glClearStencil(0);
|
|
203 | 203 |
|
204 | 204 |
for(int j=0; j<EffectQuality.LENGTH; j++) |
205 | 205 |
{ |
206 | 206 |
mBuffer[j].setAsOutput(); |
207 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, mBuffer[j].mColorH[1], 0);
|
|
208 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT|GLES30.GL_DEPTH_BUFFER_BIT|GLES30.GL_STENCIL_BUFFER_BIT);
|
|
209 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, mBuffer[j].mColorH[0], 0);
|
|
210 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);
|
|
207 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mBuffer[j].mColorH[1], 0);
|
|
208 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT|GLES31.GL_DEPTH_BUFFER_BIT|GLES31.GL_STENCIL_BUFFER_BIT);
|
|
209 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mBuffer[j].mColorH[0], 0);
|
|
210 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
|
|
211 | 211 |
} |
212 | 212 |
} |
213 | 213 |
|
... | ... | |
215 | 215 |
|
216 | 216 |
private int blitWithDepth(long currTime, DistortedOutputSurface buffer) |
217 | 217 |
{ |
218 |
GLES30.glViewport(0, 0, mWidth, mHeight);
|
|
218 |
GLES31.glViewport(0, 0, mWidth, mHeight);
|
|
219 | 219 |
setAsOutput(currTime); |
220 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
|
221 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, buffer.mColorH[0]);
|
|
222 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE1);
|
|
223 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, buffer.mDepthStencilH[0]);
|
|
220 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
|
|
221 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, buffer.mColorH[0]);
|
|
222 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1);
|
|
223 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, buffer.mDepthStencilH[0]);
|
|
224 | 224 |
|
225 |
GLES30.glDisable(GLES30.GL_STENCIL_TEST);
|
|
226 |
GLES30.glStencilMask(0x00);
|
|
225 |
GLES31.glDisable(GLES31.GL_STENCIL_TEST);
|
|
226 |
GLES31.glStencilMask(0x00);
|
|
227 | 227 |
|
228 | 228 |
DistortedEffects.blitDepthPriv(this); |
229 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
|
|
230 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
|
|
231 |
GLES30.glActiveTexture(GLES30.GL_TEXTURE1);
|
|
232 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
|
|
229 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE0);
|
|
230 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
|
|
231 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1);
|
|
232 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0);
|
|
233 | 233 |
|
234 | 234 |
// clear buffers |
235 |
GLES30.glStencilMask(0xff);
|
|
236 |
GLES30.glDepthMask(true);
|
|
237 |
GLES30.glColorMask(true,true,true,true);
|
|
238 |
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
239 |
GLES30.glClearDepthf(1.0f);
|
|
240 |
GLES30.glClearStencil(0);
|
|
235 |
GLES31.glStencilMask(0xff);
|
|
236 |
GLES31.glDepthMask(true);
|
|
237 |
GLES31.glColorMask(true,true,true,true);
|
|
238 |
GLES31.glClearColor(0.0f,0.0f,0.0f,0.0f);
|
|
239 |
GLES31.glClearDepthf(1.0f);
|
|
240 |
GLES31.glClearStencil(0);
|
|
241 | 241 |
|
242 | 242 |
buffer.setAsOutput(); |
243 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, buffer.mColorH[1], 0);
|
|
244 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT|GLES30.GL_DEPTH_BUFFER_BIT|GLES30.GL_STENCIL_BUFFER_BIT);
|
|
245 |
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, buffer.mColorH[0], 0);
|
|
246 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT);
|
|
243 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, buffer.mColorH[1], 0);
|
|
244 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT|GLES31.GL_DEPTH_BUFFER_BIT|GLES31.GL_STENCIL_BUFFER_BIT);
|
|
245 |
GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, buffer.mColorH[0], 0);
|
|
246 |
GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
|
|
247 | 247 |
|
248 | 248 |
return 1; |
249 | 249 |
} |
... | ... | |
410 | 410 |
*/ |
411 | 411 |
public void setAsOutput(long time) |
412 | 412 |
{ |
413 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
|
|
413 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);
|
|
414 | 414 |
|
415 | 415 |
if( mTime!=time ) |
416 | 416 |
{ |
417 | 417 |
mTime = time; |
418 | 418 |
DistortedRenderState.colorDepthStencilOn(); |
419 |
GLES30.glClearColor(mClearR, mClearG, mClearB, mClearA);
|
|
420 |
GLES30.glClearDepthf(mClearDepth);
|
|
421 |
GLES30.glClearStencil(mClearStencil);
|
|
422 |
GLES30.glClear(mClear);
|
|
419 |
GLES31.glClearColor(mClearR, mClearG, mClearB, mClearA);
|
|
420 |
GLES31.glClearDepthf(mClearDepth);
|
|
421 |
GLES31.glClearStencil(mClearStencil);
|
|
422 |
GLES31.glClear(mClear);
|
|
423 | 423 |
DistortedRenderState.colorDepthStencilRestore(); |
424 | 424 |
} |
425 | 425 |
} |
... | ... | |
433 | 433 |
|
434 | 434 |
public void setAsOutput() |
435 | 435 |
{ |
436 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
|
|
436 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[0]);
|
|
437 | 437 |
} |
438 | 438 |
|
439 | 439 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
473 | 473 |
|
474 | 474 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
475 | 475 |
/** |
476 |
* Set the (R,G,B,A) values of GLES30.glClearColor() to set up color with which to clear
|
|
476 |
* Set the (R,G,B,A) values of GLES31.glClearColor() to set up color with which to clear
|
|
477 | 477 |
* this Surface at the beginning of each frame. |
478 | 478 |
* |
479 | 479 |
* @param r the Red component. Default: 0.0f |
Also available in: Unified diff
Up library requirements to OpenGL ES 3.1 (needed for the upcoming GL_SHADER_STORAGE_BUFFER)