Revision 52358355
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/library/DistortedEffects.java | ||
---|---|---|
86 | 86 |
|
87 | 87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
88 | 88 |
|
89 |
void drawPriv(long currTime, DistortedTexture tex, GridObject grid, DistortedFramebuffer df)
|
|
89 |
void drawPriv(float halfInputW, float halfInputH, GridObject grid, DistortedFramebuffer df, long currTime)
|
|
90 | 90 |
{ |
91 | 91 |
GLES20.glViewport(0, 0, df.mWidth, df.mHeight); |
92 | 92 |
|
93 |
float halfZ = tex.mHalfX*grid.zFactor;
|
|
93 |
float halfZ = halfInputW*grid.zFactor;
|
|
94 | 94 |
|
95 | 95 |
mM.compute(currTime); |
96 |
mM.send(df,tex.mHalfX,tex.mHalfY,halfZ);
|
|
96 |
mM.send(df,halfInputW,halfInputH,halfZ);
|
|
97 | 97 |
|
98 | 98 |
mV.compute(currTime); |
99 |
mV.send(tex.mHalfX,tex.mHalfY,halfZ);
|
|
99 |
mV.send(halfInputW,halfInputH,halfZ);
|
|
100 | 100 |
|
101 | 101 |
mF.compute(currTime); |
102 |
mF.send(tex.mHalfX,tex.mHalfY);
|
|
102 |
mF.send(halfInputW,halfInputH);
|
|
103 | 103 |
|
104 | 104 |
grid.draw(); |
105 | 105 |
} |
106 | 106 |
|
107 | 107 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
108 | 108 |
|
109 |
void drawNoEffectsPriv(DistortedTexture tex, GridObject grid, DistortedFramebuffer df)
|
|
109 |
void drawNoEffectsPriv(float halfInputW, float halfInputH, GridObject grid, DistortedFramebuffer df)
|
|
110 | 110 |
{ |
111 | 111 |
GLES20.glViewport(0, 0, df.mWidth, df.mHeight); |
112 | 112 |
|
113 |
mM.sendZero(df,tex.mHalfX,tex.mHalfY,tex.mHalfX*grid.zFactor);
|
|
113 |
mM.sendZero(df,halfInputW,halfInputH,halfInputW*grid.zFactor);
|
|
114 | 114 |
mV.sendZero(); |
115 | 115 |
mF.sendZero(); |
116 | 116 |
|
src/main/java/org/distorted/library/DistortedFramebuffer.java | ||
---|---|---|
262 | 262 |
createFBO(); |
263 | 263 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fboIds[0]); |
264 | 264 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex.mTextureDataH[0]); |
265 |
effects.drawPriv(time, tex, grid, this);
|
|
265 |
effects.drawPriv(tex.mHalfX, tex.mHalfY, grid, this, time);
|
|
266 | 266 |
DistortedFramebuffer.deleteAllMarked(); |
267 | 267 |
DistortedTexture.deleteAllMarked(); |
268 | 268 |
} |
269 | 269 |
|
270 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
271 |
/** |
|
272 |
* Draw the (framebuffer,grid,effects) object to the Framebuffer. |
|
273 |
* <p> |
|
274 |
* Must be called from a thread holding OpenGL Context |
|
275 |
* |
|
276 |
* @param fbo The Framebuffer whose COLOR attachment 0 will be used as input texture. |
|
277 |
* @param grid Class descendant from GridObject |
|
278 |
* @param effects The DistortedEffects to use when rendering |
|
279 |
* @param time Current time, in milliseconds. |
|
280 |
*/ |
|
281 |
public void renderTo(DistortedFramebuffer fbo, GridObject grid, DistortedEffects effects, long time) |
|
282 |
{ |
|
283 |
fbo.createFBO(); |
|
284 |
|
|
285 |
if( fbo.texIds[0]>=0 ) // we cannot (yet?) render to FBO created with the second constructor. |
|
286 |
{ |
|
287 |
createFBO(); |
|
288 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fboIds[0]); |
|
289 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, fbo.texIds[0]); |
|
290 |
effects.drawPriv(fbo.mWidth/2, fbo.mHeight/2, grid, this, time); |
|
291 |
DistortedFramebuffer.deleteAllMarked(); |
|
292 |
DistortedTexture.deleteAllMarked(); |
|
293 |
} |
|
294 |
} |
|
295 |
|
|
270 | 296 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
271 | 297 |
/** |
272 | 298 |
* Draws the Tree, and all its children, to the Framebuffer. |
src/main/java/org/distorted/library/DistortedTree.java | ||
---|---|---|
224 | 224 |
if( mTexture.mBitmapSet[0] ) |
225 | 225 |
{ |
226 | 226 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]); |
227 |
mEffects.drawNoEffectsPriv(mTexture, mGrid, mData.mDF); |
|
227 |
mEffects.drawNoEffectsPriv(mTexture.mHalfX, mTexture.mHalfY, mGrid, mData.mDF);
|
|
228 | 228 |
} |
229 | 229 |
|
230 | 230 |
synchronized(this) |
... | ... | |
243 | 243 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mData.mDF.texIds[0]); |
244 | 244 |
} |
245 | 245 |
|
246 |
mEffects.drawPriv(currTime, mTexture, mGrid, df);
|
|
246 |
mEffects.drawPriv(mTexture.mHalfX, mTexture.mHalfY, mGrid, df, currTime);
|
|
247 | 247 |
} |
248 | 248 |
|
249 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Add API to render from a FBO to another FBO