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/differenteffects/DifferentEffectsRenderer.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;
......
50 51
   private static final int NUM = 3;
51 52
   
52 53
   private GLSurfaceView mView;
53
   private DistortedEffectQueues[] mQueue;
54
   private DistortedEffectQueues[] mEffects;
54 55
   private DistortedTexture mTexture;
55 56
   private GridFlat mGrid;
57
   private DistortedFramebuffer mScreen;
56 58
   private int bmpHeight, bmpWidth;
57 59
    
58 60
///////////////////////////////////////////////////////////////////////////////////////////////////
......
61 63
      {     
62 64
      mView = v;
63 65
      
64
      // mQueue[0] effects
66
      // mEffects[0] effects
65 67
      Static3D pLeft = new Static3D(214, 206, 0);
66 68
      Static3D pRight= new Static3D(390, 212, 0);
67 69
      Static4D RegionEye = new Static4D(0,0,60,60);
68 70
      
69
      // mQueue[1] effects
71
      // mEffects[1] effects
70 72
      Dynamic3D dyn = new Dynamic3D(1000,0.0f);
71 73
      dyn.add(new Static3D( 50,0,0));
72 74
      dyn.add(new Static3D(-50,0,0));
73 75
      Static3D pNose1 = new Static3D(305, 340, 0);
74 76
      
75
      // we don't need to prepare anything for mQueue[2] effects
77
      // we don't need to prepare anything for mEffects[2] effects
76 78

  
77
      mQueue= new DistortedEffectQueues[NUM];
79
      mEffects = new DistortedEffectQueues[NUM];
78 80

  
79
      for(int i=0; i<NUM; i++) mQueue[i] = new DistortedEffectQueues();
81
      for(int i=0; i<NUM; i++) mEffects[i] = new DistortedEffectQueues();
80 82

  
81 83
      Dynamic1D sink = new Dynamic1D(2000,0.0f);
82 84
      sink.add(new Static1D( 1));
83 85
      sink.add(new Static1D(10));
84 86

  
85
      mQueue[0].sink(sink, pLeft, RegionEye);
86
      mQueue[0].sink(sink, pRight,RegionEye);
87
      mQueue[1].distort(dyn, pNose1);
87
      mEffects[0].sink(sink, pLeft, RegionEye);
88
      mEffects[0].sink(sink, pRight,RegionEye);
89
      mEffects[1].distort(dyn, pNose1);
88 90

  
89 91
      Dynamic1D chromaDyn = new Dynamic1D(3000,0.0f);
90 92
      chromaDyn.add(new Static1D(0));
91 93
      chromaDyn.add(new Static1D(1));
92 94

  
93
      mQueue[2].chroma(chromaDyn, new Static3D(0,1,0) );
95
      mEffects[2].chroma(chromaDyn, new Static3D(0,1,0) );
96

  
97
      mScreen = new DistortedFramebuffer(0);
94 98
      }
95 99

  
96 100
///////////////////////////////////////////////////////////////////////////////////////////////////
......
101 105
      
102 106
     long time = System.currentTimeMillis();
103 107
   
104
     for(int i=NUM-1; i>=0; i--) mQueue[i].draw(time, mTexture, mGrid);
108
     for(int i=NUM-1; i>=0; i--) mEffects[i].draw(time, mTexture, mGrid, mScreen);
105 109
     }
106 110

  
107 111
///////////////////////////////////////////////////////////////////////////////////////////////////
......
110 114
     {
111 115
     for(int i=NUM-1; i>=0; i--)
112 116
       {
113
       mQueue[i].abortEffects(EffectTypes.MATRIX);
117
       mEffects[i].abortEffects(EffectTypes.MATRIX);
114 118
       }
115 119
      
116 120
     if( (float)bmpHeight/(NUM*bmpWidth) > (float)height/width )
......
120 124

  
121 125
       for(int i=NUM-1; i>=0; i--)
122 126
         {
123
         mQueue[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
124
         mQueue[i].scale(factor);
127
         mEffects[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) );
128
         mEffects[i].scale(factor);
125 129
         }
126 130
       }
127 131
     else
......
132 136

  
133 137
       for(int i=NUM-1; i>=0; i--)
134 138
         {
135
         mQueue[i].move( new Static3D(i*w, (height-h)/2, 0) );
136
         mQueue[i].scale(factor);
139
         mEffects[i].move( new Static3D(i*w, (height-h)/2, 0) );
140
         mEffects[i].scale(factor);
137 141
         }
138 142
       }
139 143
       
140
     Distorted.onSurfaceChanged(width, height);
144
     mScreen.resize(width, height);
141 145
     }
142 146

  
143 147
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff