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/girl/GirlRenderer.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;
......
49 50
{
50 51
    private GLSurfaceView mView;
51 52
    private DistortedTexture mTexture;
52
    private DistortedEffectQueues mQueues;
53
    private DistortedEffectQueues mEffects;
54
    private DistortedFramebuffer mScreen;
53 55
    private GridFlat mGrid;
54 56
    private Static3D v0,v1,v2,v3;
55 57
    private Static1D dBegin, dMiddle, dEnd, s0;
......
109 111
      diHips.add(dMiddle);
110 112
      diHips.add(dBegin);
111 113

  
112
      mQueues = new DistortedEffectQueues();
114
      mEffects = new DistortedEffectQueues();
113 115

  
114
      mQueues.sink( diSink, pLeft, sinkRegion );
115
      mQueues.sink( diSink, pRight,sinkRegion );
116
      mEffects.sink( diSink, pLeft, sinkRegion );
117
      mEffects.sink( diSink, pRight,sinkRegion );
116 118

  
117
      mQueues.distort(diL, pLeft , Region);
118
      mQueues.distort(diR, pRight, Region);
119
      mEffects.distort(diL, pLeft , Region);
120
      mEffects.distort(diR, pRight, Region);
119 121

  
120
      mQueues.swirl(diHips, pHips, HipsRegion );
122
      mEffects.swirl(diHips, pHips, HipsRegion );
123

  
124
      mScreen = new DistortedFramebuffer(0);
121 125
      }
122 126

  
123 127
///////////////////////////////////////////////////////////////////////////////////////////////////
......
150 154
   public void onDrawFrame(GL10 glUnused) 
151 155
      {
152 156
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
153
      mQueues.draw(System.currentTimeMillis(),mTexture,mGrid);
157
      mEffects.draw(System.currentTimeMillis(),mTexture,mGrid,mScreen);
154 158
      }
155 159

  
156 160
///////////////////////////////////////////////////////////////////////////////////////////////////
157 161
    
158 162
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
159 163
      { 
160
      mQueues.abortEffects(EffectTypes.MATRIX);
164
      mEffects.abortEffects(EffectTypes.MATRIX);
161 165
      
162 166
      if( (float)bmpHeight/bmpWidth > (float)height/width )
163 167
        {
164 168
        int w = (height*bmpWidth)/bmpHeight;
165 169
        float factor = (float)height/bmpHeight;
166 170

  
167
        mQueues.move( new Static3D((width-w)/2,0,0) );
168
        mQueues.scale(factor);
171
        mEffects.move( new Static3D((width-w)/2,0,0) );
172
        mEffects.scale(factor);
169 173
        }
170 174
      else
171 175
        {
172 176
        int h = (width*bmpHeight)/bmpWidth;
173 177
        float factor = (float)width/bmpWidth;
174 178

  
175
        mQueues.move( new Static3D(0,(height-h)/2,0) );
176
        mQueues.scale(factor);
179
        mEffects.move( new Static3D(0,(height-h)/2,0) );
180
        mEffects.scale(factor);
177 181
        }
178 182
      
179
      Distorted.onSurfaceChanged(width, height); 
183
      mScreen.resize(width, height);
180 184
      }
181 185

  
182 186
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff