Project

General

Profile

« Previous | Next » 

Revision 392e16fd

Added by Leszek Koltunski over 7 years ago

Change in the API: we always have to create a DistortedFramebuffer to render to.

View differences:

src/main/java/org/distorted/examples/sink/SinkRenderer.java
28 28
import org.distorted.examples.R;
29 29

  
30 30
import org.distorted.library.Distorted;
31
import org.distorted.library.DistortedFramebuffer;
31 32
import org.distorted.library.GridFlat;
32 33
import org.distorted.library.DistortedTexture;
33 34
import org.distorted.library.DistortedEffectQueues;
......
48 49
  {
49 50
  private GLSurfaceView mView;
50 51
  private DistortedTexture mTexture;
51
  private DistortedEffectQueues mQueues;
52
  private DistortedEffectQueues mEffects;
53
  private DistortedFramebuffer mScreen;
52 54
  private GridFlat mGrid;
53 55
  private int bmpHeight, bmpWidth;
54 56
    
......
66 68
    dSink.add(new Static1D( 1));
67 69
    dSink.add(new Static1D(10));
68 70

  
69
    mQueues = new DistortedEffectQueues();
70
    mQueues.sink( dSink, pLeft, Region);
71
    mQueues.sink( dSink, pRight,Region);
71
    mEffects = new DistortedEffectQueues();
72
    mEffects.sink( dSink, pLeft, Region);
73
    mEffects.sink( dSink, pRight,Region);
74

  
75
    mScreen = new DistortedFramebuffer(0);
72 76
    }
73 77

  
74 78
///////////////////////////////////////////////////////////////////////////////////////////////////
......
76 80
  public void onDrawFrame(GL10 glUnused) 
77 81
    {
78 82
    GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
79
    mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
83
    mEffects.draw(System.currentTimeMillis(), mTexture,mGrid,mScreen);
80 84
    }
81 85

  
82 86
///////////////////////////////////////////////////////////////////////////////////////////////////
83 87
    
84 88
  public void onSurfaceChanged(GL10 glUnused, int width, int height) 
85 89
    { 
86
    mQueues.abortEffects(EffectTypes.MATRIX);
90
    mEffects.abortEffects(EffectTypes.MATRIX);
87 91
         
88 92
    if( (float)bmpHeight/bmpWidth > (float)height/width )
89 93
      {
90 94
      int w = (height*bmpWidth)/bmpHeight;
91 95
      float factor = (float)height/bmpHeight;
92 96

  
93
      mQueues.move( new Static3D((width-w)/2,0,0) );
94
      mQueues.scale( factor );
97
      mEffects.move( new Static3D((width-w)/2,0,0) );
98
      mEffects.scale( factor );
95 99
      }
96 100
    else
97 101
      {
98 102
      int h = (width*bmpHeight)/bmpWidth;
99 103
      float factor = (float)width/bmpWidth;
100 104

  
101
      mQueues.move( new Static3D(0,(height-h)/2,0) );
102
      mQueues.scale( factor );
105
      mEffects.move( new Static3D(0,(height-h)/2,0) );
106
      mEffects.scale( factor );
103 107
      }
104 108
      
105
    Distorted.onSurfaceChanged(width, height); 
109
    mScreen.resize(width, height);
106 110
    }
107 111

  
108 112
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff