Project

General

Profile

« Previous | Next » 

Revision 227ac49a

Added by Leszek Koltunski almost 8 years ago

progress with DistortedRenderable

View differences:

src/main/java/org/distorted/library/DistortedFramebuffer.java
58 58

  
59 59
///////////////////////////////////////////////////////////////////////////////////////////////////
60 60
// Must be called from a thread holding OpenGL Context
61
// Watch out - this has the side-effect of binding a Texture and a Framebuffer!
61 62

  
62 63
  void create()
63 64
    {
......
125 126
///////////////////////////////////////////////////////////////////////////////////////////////////
126 127
// Must be called from a thread holding OpenGL Context
127 128

  
128
  private void delete()
129
  void delete()
129 130
    {
130 131
    if( mColorH[0]>=0 )
131 132
      {
......
368 369
 * <p>
369 370
 * Must be called from a thread holding OpenGL Context.
370 371
 *
371
 * @param tex input Texture to use.
372
 * @param ren input Renderable to use.
372 373
 * @param mesh Class descendant from MeshObject
373 374
 * @param effects The DistortedEffects to use when rendering
374 375
 * @param time Current time, in milliseconds.
375 376
 */
376
  public void renderTo(DistortedTexture tex, MeshObject mesh, DistortedEffects effects, long time)
377
  public void renderTo(DistortedRenderable ren, MeshObject mesh, DistortedEffects effects, long time)
377 378
    {
378
    tex.create();
379
    ren.create();  // Watch out  - this needs to be before
380
    create();      // the 'setAsInput' because this has side-effects!
379 381

  
380
    if( tex.setAsInput() )
382
    if( ren.setAsInput() )
381 383
      {
382 384
      DistortedFramebuffer.deleteAllMarked();
383 385
      DistortedTexture.deleteAllMarked();
384
      create();
385
      effects.drawPriv(tex.getWidth()/2.0f, tex.getHeight()/2.0f, mesh, this, time);
386
      }
387
    }
388

  
389
///////////////////////////////////////////////////////////////////////////////////////////////////
390
/**
391
 * Draw the (framebuffer,mesh,effects) object to the Framebuffer.
392
 * <p>
393
 * Must be called from a thread holding OpenGL Context.
394
 *
395
 * @param fbo The Framebuffer (previously created with the first constructor, drawing FROM the screen
396
 *            is unsupported!) whose COLOR attachment 0 will be used as input texture.
397
 *            Please note that rendering from an FBO to itself is unsupported by OpenGL!
398
 * @param mesh Class descendant from MeshObject
399
 * @param effects The DistortedEffects to use when rendering
400
 * @param time Current time, in milliseconds.
401
 */
402
  public void renderTo(DistortedFramebuffer fbo, MeshObject mesh, DistortedEffects effects, long time)
403
    {
404
    fbo.create();
405

  
406
    if( fbo.setAsInput() )
407
      {
408
      DistortedFramebuffer.deleteAllMarked();
409
      DistortedTexture.deleteAllMarked();
410
      create();
411
      effects.drawPriv(fbo.getWidth()/2.0f, fbo.getHeight()/2.0f, mesh, this, time);
386
      effects.drawPriv(ren.getWidth()/2.0f, ren.getHeight()/2.0f, mesh, this, time);
412 387
      }
413 388
    }
414 389

  
......
435 410
 */
436 411
  public void markForDeletion()
437 412
    {
438
    //android.util.Log.e("FBO", "marking for deletion ("+mWidth+","+mHeight+") "+mFBOH[0]);
439

  
440 413
    mListMarked = true;
441 414
    mMarked     = true;
442 415
    }
src/main/java/org/distorted/library/DistortedRenderable.java
32 32
  int[] mColorH = new int[1];
33 33
  int mSizeX, mSizeY;  // in screen space
34 34

  
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36

  
37
  abstract void create();
38
  abstract void delete();
39

  
35 40
///////////////////////////////////////////////////////////////////////////////////////////////////
36 41

  
37 42
  long getID()
src/main/java/org/distorted/library/DistortedTexture.java
97 97
///////////////////////////////////////////////////////////////////////////////////////////////////
98 98
// must be called from a thread holding OpenGL Context
99 99

  
100
  private void delete()
100
  void delete()
101 101
    {
102 102
    if( mColorH !=null && mColorH[0]>0 )
103 103
      {

Also available in: Unified diff