Revision cdd5e827
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/DistortedFramebuffer.java | ||
---|---|---|
53 | 53 |
private int[] fboIds = new int[1]; |
54 | 54 |
|
55 | 55 |
private boolean mMarked; |
56 |
private boolean mDepthWanted;
|
|
56 |
private boolean mDepthEnabled;
|
|
57 | 57 |
|
58 | 58 |
private int mTexWidth, mTexHeight; |
59 | 59 |
|
... | ... | |
84 | 84 |
|
85 | 85 |
checkStatus("color"); |
86 | 86 |
} |
87 |
if( mDepthWanted && depthIds[0]==NOT_CREATED_YET ) // we need to create a new DEPTH attachment
|
|
87 |
if( mDepthEnabled && depthIds[0]==NOT_CREATED_YET ) // we need to create a new DEPTH attachment
|
|
88 | 88 |
{ |
89 | 89 |
GLES30.glGenTextures(1, depthIds, 0); |
90 | 90 |
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, depthIds[0]); |
... | ... | |
99 | 99 |
|
100 | 100 |
checkStatus("depth"); |
101 | 101 |
} |
102 |
if( !mDepthWanted && depthIds[0]!=NOT_CREATED_YET ) // we need to detach and destroy the DEPTH attachment.
|
|
102 |
if( !mDepthEnabled && depthIds[0]!=NOT_CREATED_YET ) // we need to detach and destroy the DEPTH attachment.
|
|
103 | 103 |
{ |
104 | 104 |
GLES30.glDeleteTextures(1, depthIds, 0); |
105 | 105 |
depthIds[0]=NOT_CREATED_YET; |
... | ... | |
221 | 221 |
for( DistortedFramebuffer fbo : mList) |
222 | 222 |
{ |
223 | 223 |
if( fbo.colorIds[0]!=DONT_CREATE ) fbo.colorIds[0] = NOT_CREATED_YET; |
224 |
if( fbo.mDepthWanted ) fbo.depthIds[0] = NOT_CREATED_YET;
|
|
224 |
if( fbo.mDepthEnabled) fbo.depthIds[0] = NOT_CREATED_YET;
|
|
225 | 225 |
} |
226 | 226 |
} |
227 | 227 |
|
... | ... | |
279 | 279 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
280 | 280 |
// PUBLIC API |
281 | 281 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
282 |
/** |
|
283 |
* Create a new offscreen Framebuffer. |
|
284 |
* |
|
285 |
* @param width Width of the COLOR attachment. |
|
286 |
* @param height Height of the COLOR attachment. |
|
287 |
* @param depthEnabled Add DEPTH attachment? |
|
288 |
*/ |
|
289 |
@SuppressWarnings("unused") |
|
290 |
public DistortedFramebuffer(int width, int height, boolean depthEnabled) |
|
291 |
{ |
|
292 |
mProjectionMatrix = new float[16]; |
|
293 |
|
|
294 |
mHeight = height; |
|
295 |
mWidth = width; |
|
296 |
mTexHeight = height; |
|
297 |
mTexWidth = width; |
|
298 |
mFOV = 60.0f; |
|
299 |
mX = 0.0f; |
|
300 |
mY = 0.0f; |
|
301 |
mMarked = false; |
|
302 |
mDepthEnabled= depthEnabled; |
|
303 |
|
|
304 |
fboIds[0] =-1; |
|
305 |
colorIds[0]= NOT_CREATED_YET; |
|
306 |
depthIds[0]= NOT_CREATED_YET; |
|
307 |
|
|
308 |
createProjection(); |
|
309 |
|
|
310 |
mList.add(this); |
|
311 |
} |
|
312 |
|
|
282 | 313 |
/** |
283 | 314 |
* Create a new offscreen Framebuffer. |
284 | 315 |
* |
... | ... | |
290 | 321 |
{ |
291 | 322 |
mProjectionMatrix = new float[16]; |
292 | 323 |
|
293 |
mHeight = height; |
|
294 |
mWidth = width; |
|
295 |
mTexHeight = height; |
|
296 |
mTexWidth = width; |
|
297 |
mFOV = 60.0f; |
|
298 |
mX = 0.0f; |
|
299 |
mY = 0.0f; |
|
300 |
mMarked = false; |
|
301 |
mDepthWanted= false;
|
|
324 |
mHeight = height;
|
|
325 |
mWidth = width;
|
|
326 |
mTexHeight = height;
|
|
327 |
mTexWidth = width;
|
|
328 |
mFOV = 60.0f;
|
|
329 |
mX = 0.0f;
|
|
330 |
mY = 0.0f;
|
|
331 |
mMarked = false;
|
|
332 |
mDepthEnabled= false;
|
|
302 | 333 |
|
303 | 334 |
fboIds[0] =-1; |
304 | 335 |
colorIds[0]= NOT_CREATED_YET; |
... | ... | |
321 | 352 |
{ |
322 | 353 |
mProjectionMatrix = new float[16]; |
323 | 354 |
|
324 |
mFOV = 60.0f; |
|
325 |
mX = 0.0f; |
|
326 |
mY = 0.0f; |
|
327 |
mMarked = false; |
|
328 |
mDepthWanted= true;
|
|
355 |
mFOV = 60.0f;
|
|
356 |
mX = 0.0f;
|
|
357 |
mY = 0.0f;
|
|
358 |
mMarked = false;
|
|
359 |
mDepthEnabled= true;
|
|
329 | 360 |
|
330 | 361 |
fboIds[0] = fbo; |
331 | 362 |
colorIds[0]= DONT_CREATE; |
... | ... | |
336 | 367 |
/** |
337 | 368 |
* Create a new DEPTH buffer and attach it or (param=false) detach an existing DEPTh attachment and destroy it. |
338 | 369 |
* |
339 |
* @param hasDepthAttachment <bold>true</bold> if we want to attach a new DEPTH buffer to the FBO.<br>
|
|
340 |
* <bold>false</bold> if we want to detach the DEPTH attachment.
|
|
370 |
* @param enable <bold>true</bold> if we want to attach a new DEPTH buffer to the FBO.<br>
|
|
371 |
* <bold>false</bold> if we want to detach the DEPTH attachment. |
|
341 | 372 |
*/ |
342 |
public void setDepthAttachment(boolean hasDepthAttachment)
|
|
373 |
public void enableDepthAttachment(boolean enable)
|
|
343 | 374 |
{ |
344 |
mDepthWanted = hasDepthAttachment;
|
|
375 |
mDepthEnabled = enable;
|
|
345 | 376 |
} |
346 | 377 |
|
347 | 378 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
492 | 523 |
*/ |
493 | 524 |
public boolean hasDepth() |
494 | 525 |
{ |
495 |
return mDepthWanted;
|
|
526 |
return mDepthEnabled;
|
|
496 | 527 |
} |
497 | 528 |
} |
Also available in: Unified diff
Some fixes for issues discovered by the Multiblur app.