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/quaternion/QuaternionRenderer.java
28 28

  
29 29
import org.distorted.examples.R;
30 30

  
31
import org.distorted.library.DistortedFramebuffer;
31 32
import org.distorted.library.EffectTypes;
32 33
import org.distorted.library.type.Dynamic;
33 34
import org.distorted.library.type.DynamicQuat;
......
51 52

  
52 53
  private GLSurfaceView mView;
53 54
  private DistortedTexture mTexture;
54
  private DistortedEffectQueues mQueues;
55
  private DistortedEffectQueues mEffects;
56
  private DistortedFramebuffer mScreen;
55 57
  private GridCubes mGrid;
56 58
  private DynamicQuat mRot;
57 59
    
......
62 64
    mView    = v;
63 65
    mGrid    = new GridCubes(1,1,false);
64 66
    mTexture = new DistortedTexture(1,1);
65
    mQueues  = new DistortedEffectQueues();
67
    mEffects = new DistortedEffectQueues();
66 68
    mRot     = new DynamicQuat();
67 69

  
68 70
    Random rnd = new Random(System.currentTimeMillis());
......
83 85
    mRot.setCount(0);
84 86
    mRot.setDuration(8000);
85 87
    mRot.setMode(Dynamic.MODE_LOOP);
88

  
89
    mScreen = new DistortedFramebuffer(0);
86 90
    }
87 91

  
88 92
///////////////////////////////////////////////////////////////////////////////////////////////////
......
90 94
  public void onDrawFrame(GL10 glUnused) 
91 95
    {
92 96
    GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
93
    mQueues.draw(System.currentTimeMillis(), mTexture,mGrid);
97
    mEffects.draw(System.currentTimeMillis(), mTexture,mGrid,mScreen);
94 98
    }
95 99

  
96 100
///////////////////////////////////////////////////////////////////////////////////////////////////
......
99 103
    {
100 104
    float scaleFactor = width>height ? height/3:width/3;
101 105

  
102
    mQueues.abortEffects(EffectTypes.MATRIX);
103
    mQueues.move( new Static3D( (width-scaleFactor)/2 , (height-scaleFactor)/2 , 0) );
104
    mQueues.scale(scaleFactor);
105
    mQueues.quaternion( mRot, new Static3D(0.5f,0.5f,0) );
106
    mEffects.abortEffects(EffectTypes.MATRIX);
107
    mEffects.move( new Static3D( (width-scaleFactor)/2 , (height-scaleFactor)/2 , 0) );
108
    mEffects.scale(scaleFactor);
109
    mEffects.quaternion( mRot, new Static3D(0.5f,0.5f,0) );
106 110
       
107
    Distorted.onSurfaceChanged(width, height); 
111
    mScreen.resize(width, height);
108 112
    }
109 113

  
110 114
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff