Revision a0f644b7
Added by Leszek Koltunski almost 9 years ago
| src/main/java/org/distorted/library/DistortedEffects.java | ||
|---|---|---|
| 165 | 165 |
initializeEffectLists(dc,flags); |
| 166 | 166 |
} |
| 167 | 167 |
|
| 168 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 169 |
/** |
|
| 170 |
* Draw the (texture,grid) object to the Framebuffer passed. |
|
| 171 |
* <p> |
|
| 172 |
* Must be called from a thread holding OpenGL Context |
|
| 173 |
* |
|
| 174 |
* @param currTime Current time, in milliseconds. |
|
| 175 |
* @param df Framebuffer to render this to. |
|
| 176 |
*/ |
|
| 177 |
public void draw(long currTime, DistortedTexture tex, GridObject grid, DistortedFramebuffer df) |
|
| 178 |
{
|
|
| 179 |
tex.createTexture(); |
|
| 180 |
df.createFBO(); |
|
| 181 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, df.fboIds[0]); |
|
| 182 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex.mTextureDataH[0]); |
|
| 183 |
drawPriv(currTime, tex, grid, df); |
|
| 184 |
DistortedFramebuffer.deleteAllMarked(); |
|
| 185 |
DistortedTexture.deleteAllMarked(); |
|
| 186 |
} |
|
| 187 |
|
|
| 188 | 168 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 189 | 169 |
/** |
| 190 | 170 |
* Releases all resources. After this call, the queue should not be used anymore. |
| src/main/java/org/distorted/library/DistortedFramebuffer.java | ||
|---|---|---|
| 245 | 245 |
mMarked = false; |
| 246 | 246 |
} |
| 247 | 247 |
|
| 248 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 249 |
/** |
|
| 250 |
* Draw the (texture,grid,effects) object to the Framebuffer. |
|
| 251 |
* <p> |
|
| 252 |
* Must be called from a thread holding OpenGL Context |
|
| 253 |
* |
|
| 254 |
* @param tex input Texture to use. |
|
| 255 |
* @param grid Class descendant from GridObject |
|
| 256 |
* @param effects The DistortedEffects to use when rendering |
|
| 257 |
* @param time Current time, in milliseconds. |
|
| 258 |
*/ |
|
| 259 |
public void renderTo(DistortedTexture tex, GridObject grid, DistortedEffects effects, long time) |
|
| 260 |
{
|
|
| 261 |
tex.createTexture(); |
|
| 262 |
createFBO(); |
|
| 263 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fboIds[0]); |
|
| 264 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex.mTextureDataH[0]); |
|
| 265 |
effects.drawPriv(time, tex, grid, this); |
|
| 266 |
DistortedFramebuffer.deleteAllMarked(); |
|
| 267 |
DistortedTexture.deleteAllMarked(); |
|
| 268 |
} |
|
| 269 |
|
|
| 270 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 271 |
/** |
|
| 272 |
* Draws the Tree, and all its children, to the Framebuffer. |
|
| 273 |
* <p> |
|
| 274 |
* Must be called from a thread holding OpenGL Context |
|
| 275 |
* |
|
| 276 |
* @param dt DistortedTree to render. |
|
| 277 |
* @param time Current time, in milliseconds. This will be passed to all the Effects stored in the Tree. |
|
| 278 |
*/ |
|
| 279 |
public void renderTo(DistortedTree dt, long time) |
|
| 280 |
{
|
|
| 281 |
createFBO(); |
|
| 282 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fboIds[0]); |
|
| 283 |
dt.drawRecursive(time,this); |
|
| 284 |
DistortedFramebuffer.deleteAllMarked(); |
|
| 285 |
DistortedTexture.deleteAllMarked(); |
|
| 286 |
} |
|
| 287 |
|
|
| 248 | 288 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 249 | 289 |
/** |
| 250 | 290 |
* Mark the underlying OpenGL object for deletion. Actual deletion will take place on the next render. |
| src/main/java/org/distorted/library/DistortedTree.java | ||
|---|---|---|
| 69 | 69 |
mMapNodeID.clear(); |
| 70 | 70 |
} |
| 71 | 71 |
|
| 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 73 |
|
|
| 74 |
private void drawRecursive(long currTime, DistortedFramebuffer df) |
|
| 75 |
{
|
|
| 76 |
mTexture.createTexture(); |
|
| 77 |
|
|
| 78 |
if( mNumChildren[0]<=0 ) |
|
| 79 |
{
|
|
| 80 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]); |
|
| 81 |
} |
|
| 82 |
else |
|
| 83 |
{
|
|
| 84 |
mData.mDF.createFBO(); |
|
| 85 |
|
|
| 86 |
if( mData.numRendered==0 ) |
|
| 87 |
{
|
|
| 88 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mData.mDF.fboIds[0]); |
|
| 89 |
|
|
| 90 |
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
|
| 91 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
|
| 92 |
|
|
| 93 |
if( mTexture.mBitmapSet[0] ) |
|
| 94 |
{
|
|
| 95 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]); |
|
| 96 |
mQueues.drawNoEffectsPriv(mTexture, mGrid, mData.mDF); |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
synchronized(this) |
|
| 100 |
{
|
|
| 101 |
for(int i=0; i<mNumChildren[0]; i++) |
|
| 102 |
{
|
|
| 103 |
mChildren.get(i).drawRecursive(currTime, mData.mDF); |
|
| 104 |
} |
|
| 105 |
} |
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
mData.numRendered++; |
|
| 109 |
mData.numRendered %= mData.numPointingNodes; |
|
| 110 |
|
|
| 111 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, df.fboIds[0]); |
|
| 112 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mData.mDF.texIds[0]); |
|
| 113 |
} |
|
| 114 |
|
|
| 115 |
mQueues.drawPriv(currTime, mTexture, mGrid, df); |
|
| 116 |
} |
|
| 117 |
|
|
| 118 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 119 | 73 |
// tree isomorphism |
| 120 | 74 |
|
| ... | ... | |
| 246 | 200 |
} |
| 247 | 201 |
} |
| 248 | 202 |
|
| 203 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 204 |
|
|
| 205 |
void drawRecursive(long currTime, DistortedFramebuffer df) |
|
| 206 |
{
|
|
| 207 |
mTexture.createTexture(); |
|
| 208 |
|
|
| 209 |
if( mNumChildren[0]<=0 ) |
|
| 210 |
{
|
|
| 211 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]); |
|
| 212 |
} |
|
| 213 |
else |
|
| 214 |
{
|
|
| 215 |
mData.mDF.createFBO(); |
|
| 216 |
|
|
| 217 |
if( mData.numRendered==0 ) |
|
| 218 |
{
|
|
| 219 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mData.mDF.fboIds[0]); |
|
| 220 |
|
|
| 221 |
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
|
| 222 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
|
| 223 |
|
|
| 224 |
if( mTexture.mBitmapSet[0] ) |
|
| 225 |
{
|
|
| 226 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]); |
|
| 227 |
mQueues.drawNoEffectsPriv(mTexture, mGrid, mData.mDF); |
|
| 228 |
} |
|
| 229 |
|
|
| 230 |
synchronized(this) |
|
| 231 |
{
|
|
| 232 |
for(int i=0; i<mNumChildren[0]; i++) |
|
| 233 |
{
|
|
| 234 |
mChildren.get(i).drawRecursive(currTime, mData.mDF); |
|
| 235 |
} |
|
| 236 |
} |
|
| 237 |
} |
|
| 238 |
|
|
| 239 |
mData.numRendered++; |
|
| 240 |
mData.numRendered %= mData.numPointingNodes; |
|
| 241 |
|
|
| 242 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, df.fboIds[0]); |
|
| 243 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mData.mDF.texIds[0]); |
|
| 244 |
} |
|
| 245 |
|
|
| 246 |
mQueues.drawPriv(currTime, mTexture, mGrid, df); |
|
| 247 |
} |
|
| 248 |
|
|
| 249 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 250 | 250 |
// PUBLIC API |
| 251 | 251 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 450 | 450 |
} |
| 451 | 451 |
} |
| 452 | 452 |
|
| 453 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 454 |
/** |
|
| 455 |
* Draws the Node, and all its children, to the Framebuffer passed. |
|
| 456 |
* <p> |
|
| 457 |
* Must be called from a thread holding OpenGL Context |
|
| 458 |
* |
|
| 459 |
* @param currTime Current time, in milliseconds. |
|
| 460 |
* @param df Framebuffer to render this to. |
|
| 461 |
*/ |
|
| 462 |
public void draw(long currTime, DistortedFramebuffer df) |
|
| 463 |
{
|
|
| 464 |
df.createFBO(); |
|
| 465 |
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, df.fboIds[0]); |
|
| 466 |
drawRecursive(currTime,df); |
|
| 467 |
DistortedFramebuffer.deleteAllMarked(); |
|
| 468 |
DistortedTexture.deleteAllMarked(); |
|
| 469 |
} |
|
| 470 |
|
|
| 471 | 453 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 472 | 454 |
/** |
| 473 | 455 |
* Returns the DistortedEffects object that's in the Node. |
Also available in: Unified diff
Again change of API. Now instead of the 'DistortedEffects.draw() and DistortedTree.draw()' we have 'DistortedFramebuffer.renderTo()'