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/monalisa/MonaLisaRenderer.java
27 27

  
28 28
import org.distorted.examples.R;
29 29
import org.distorted.library.Distorted;
30
import org.distorted.library.DistortedFramebuffer;
30 31
import org.distorted.library.DistortedTexture;
31 32
import org.distorted.library.DistortedEffectQueues;
32 33
import org.distorted.library.GridFlat;
......
46 47
{
47 48
    private GLSurfaceView mView;
48 49
    private DistortedTexture mTexture;
49
    private DistortedEffectQueues mQueues;
50
    private DistortedEffectQueues mEffects;
51
    private DistortedFramebuffer mScreen;
50 52
    private GridFlat mGrid;
51 53
    private int bmpHeight, bmpWidth;
52 54

  
......
68 70
      dRight.add( new Static3D(  0,  0,0) );
69 71
      dRight.add( new Static3D( 20,-10,0) );
70 72

  
71
      mQueues = new DistortedEffectQueues();
72
      mQueues.distort( dLeft, pLeft , rLeft );
73
      mQueues.distort(dRight, pRight, rRight);
73
      mEffects = new DistortedEffectQueues();
74
      mEffects.distort( dLeft, pLeft , rLeft );
75
      mEffects.distort(dRight, pRight, rRight);
76

  
77
      mScreen = new DistortedFramebuffer(0);
74 78
      }
75 79

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

  
84 88
///////////////////////////////////////////////////////////////////////////////////////////////////
85 89
    
86 90
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
87 91
      { 
88
      mQueues.abortEffects(EffectTypes.MATRIX);
92
      mEffects.abortEffects(EffectTypes.MATRIX);
89 93

  
90 94
      if( (float)bmpHeight/bmpWidth > (float)height/width )
91 95
        {
92 96
        int w = (height*bmpWidth)/bmpHeight;
93 97
        float factor = (float)height/bmpHeight;
94
        mQueues.move( new Static3D((width-w)/2,0,0) );
95
        mQueues.scale(factor);
98
        mEffects.move( new Static3D((width-w)/2,0,0) );
99
        mEffects.scale(factor);
96 100
        }
97 101
      else
98 102
        {
99 103
        int h = (width*bmpHeight)/bmpWidth;
100 104
        float factor = (float)width/bmpWidth;
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