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/fbo/FBORenderer.java
27 27

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

  
30
import org.distorted.library.DistortedFramebuffer;
30 31
import org.distorted.library.DistortedObjectTree;
31 32
import org.distorted.library.Distorted;
32 33
import org.distorted.library.GridCubes;
......
49 50
class FBORenderer implements GLSurfaceView.Renderer 
50 51
{
51 52
   private GLSurfaceView mView;
52
   private DistortedEffectQueues mQueues;
53
   private int lisaHeight, lisaWidth;
54
    
53
   private DistortedEffectQueues mEffects;
54
   private DistortedFramebuffer mScreen;
55 55
   private DistortedObjectTree mRoot;
56
    
56
   private int lisaHeight, lisaWidth;
57

  
57 58
///////////////////////////////////////////////////////////////////////////////////////////////////
58 59

  
59 60
   FBORenderer(GLSurfaceView v)
60 61
      {
61
      mView = v;
62
      mQueues = new DistortedEffectQueues();
62
      mView   = v;
63
      mEffects= new DistortedEffectQueues();
64
      mScreen = new DistortedFramebuffer(0);
63 65
      }
64 66

  
65 67
///////////////////////////////////////////////////////////////////////////////////////////////////
......
67 69
    public void onDrawFrame(GL10 glUnused) 
68 70
      {
69 71
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
70
      mRoot.draw(System.currentTimeMillis());
72
      mRoot.draw(System.currentTimeMillis(),mScreen);
71 73
      }
72 74

  
73 75
///////////////////////////////////////////////////////////////////////////////////////////////////
74 76
    
75 77
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
76 78
      { 
77
      mQueues.abortEffects(EffectTypes.MATRIX);
79
      mEffects.abortEffects(EffectTypes.MATRIX);
78 80
         
79 81
      if( (float)lisaHeight/lisaWidth > (float)height/width )
80 82
        {
81 83
        int w = (height*lisaWidth)/lisaHeight;
82 84
        float factor = (float)height/lisaHeight;
83 85

  
84
        mQueues.move( new Static3D((width-w)/2,0,0) );
85
        mQueues.scale(factor);
86
        mEffects.move( new Static3D((width-w)/2,0,0) );
87
        mEffects.scale(factor);
86 88
        }
87 89
      else
88 90
        {
89 91
        int h = (width*lisaHeight)/lisaWidth;
90 92
        float factor = (float)width/lisaWidth;
91 93

  
92
        mQueues.move( new Static3D(0,(height-h)/2,0) );
93
        mQueues.scale(factor);
94
        mEffects.move( new Static3D(0,(height-h)/2,0) );
95
        mEffects.scale(factor);
94 96
        }
95 97
      
96
      Distorted.onSurfaceChanged(width, height); 
98
      mScreen.resize(width, height);
97 99
      }
98 100

  
99 101
///////////////////////////////////////////////////////////////////////////////////////////////////
......
133 135
      text.setTexture(bitmap2);
134 136
      DistortedEffectQueues textQueues = new DistortedEffectQueues();
135 137

  
136
      mQueues.abortAllEffects();
138
      mEffects.abortAllEffects();
137 139

  
138
      mRoot = new DistortedObjectTree(lisa,mQueues,new GridFlat(1,1));
140
      mRoot = new DistortedObjectTree(lisa, mEffects,new GridFlat(1,1));
139 141
      mRoot.attach(text,textQueues,new GridCubes(20,5,false));
140 142

  
141 143
      float factor = lisaWidth/(2.0f*textWidth);
......
160 162
      chromaDyn.add(new Static1D(0.0f));
161 163
      chromaDyn.add(new Static1D(1.0f));
162 164

  
163
      mQueues.chroma(chromaDyn, new Static3D(0,0,1) );
165
      mEffects.chroma(chromaDyn, new Static3D(0,0,1) );
164 166
      
165 167
      try
166 168
        {

Also available in: Unified diff