Project

General

Profile

« Previous | Next » 

Revision f94110ca

Added by Leszek Koltunski over 4 years ago

Convert Mirror to stretchless API.

View differences:

src/main/java/org/distorted/examples/mirror/MirrorRenderer.java
27 27
import org.distorted.library.effect.FragmentEffectBrightness;
28 28
import org.distorted.library.effect.MatrixEffectMove;
29 29
import org.distorted.library.effect.MatrixEffectScale;
30
import org.distorted.library.effect.VertexEffectScale;
30 31
import org.distorted.library.main.DistortedLibrary;
31 32
import org.distorted.library.main.DistortedEffects;
32 33
import org.distorted.library.main.DistortedFramebuffer;
......
62 63
   private DistortedScreen mScreen;
63 64
   private MeshQuad mQuad1, mQuad2, mQuadMirror, mQuadHead;
64 65
   private Static3D mHeadPosition, mScaleMirror, mMoveOffscreen2, mScaleHead;
66
   private Static3D mScaleOffscreen1, mScaleOffscreen2;
65 67

  
66 68
   private int mX;
67 69
   private int mMirrorW, mMirrorH, mHeadW, mHeadH;
......
91 93
      mScaleMirror     = new Static3D(1,1,1);
92 94
      mMoveOffscreen2  = new Static3D(0,0,0);
93 95
      mScaleHead       = new Static3D(1,1,1);
96
      mScaleOffscreen1 = new Static3D(1,1,1);
97
      mScaleOffscreen2 = new Static3D(1,1,1);
94 98

  
95
      mEffectsMirror.apply( new MatrixEffectScale(mScaleMirror));
99
      mEffectsMirror.apply( new VertexEffectScale(mScaleMirror));
100
      mEffectsScreen.apply( new VertexEffectScale(mScaleOffscreen1) );
101
      mEffectsOffscreen1.apply( new VertexEffectScale(mScaleOffscreen1) );
96 102
      mEffectsOffscreen1.apply( new MatrixEffectScale( new Static3D(MIRROR_SCALE,MIRROR_SCALE,MIRROR_SCALE)));
103
      mEffectsOffscreen2.apply( new VertexEffectScale(mScaleOffscreen2) );
97 104
      mEffectsOffscreen2.apply( new MatrixEffectMove(mMoveOffscreen2) );
98
      mEffectsHead.apply( new MatrixEffectScale(mScaleHead) );
105
      mEffectsHead.apply( new VertexEffectScale(mScaleHead) );
99 106
      mEffectsHead.apply( new MatrixEffectMove(mHeadPosition) );
100 107
      mEffectsOffscreen1.apply(new FragmentEffectBrightness(new Static1D(MIRROR_BRIGHTNESS)));
101 108
      }
......
149 156
        int offscreen2W = (int)(MIRROR_SCALE*mScreenW);
150 157
        int offscreen2H = (int)(MIRROR_SCALE*mScreenH);
151 158

  
152
        mQuad1.setStretch(offscreen1W, offscreen1H, 0);
153
        mQuad2.setStretch(offscreen2W, offscreen2H, 0);
159
        mScaleOffscreen1.set(offscreen1W, offscreen1H, 0);
160
        mScaleOffscreen2.set(offscreen2W, offscreen2H, 0);
154 161

  
155 162
        mOffScreen1 = new DistortedFramebuffer( offscreen1W, offscreen1H, 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL );
156 163
        mOffScreen2 = new DistortedFramebuffer( offscreen2W, offscreen2H, 1, DistortedFramebuffer.NO_DEPTH_NO_STENCIL );
157 164

  
158
        float headScale = HEAD_SCALE *mScreenH/ mHeadH;
159
        mScaleHead.set(headScale,headScale,headScale);
160

  
161
        float scaleW = (float)mScreenW/mMirrorW;
162
        float scaleH = (float)mScreenH/mMirrorH;
163

  
164
        mScaleMirror.set( scaleW, scaleH, 1.0f);
165
        float headScale = HEAD_SCALE *mScreenH;
166
        mScaleHead.set(headScale*mHeadW/mHeadH,headScale,0);
167
        mScaleMirror.set( mScreenW, mScreenH, 0);
165 168

  
166 169
        mMoveOffscreen2.set( (MIRROR_MOVE_H-0.5f+0.5f*MIRROR_SCALE)*mScreenW, (MIRROR_MOVE_V-0.5f+0.5f*MIRROR_SCALE)*mScreenH*mMirrorW/mMirrorH, 0);
167 170
        mHeadPosition.set1( (0.5f*HEAD_SCALE - 0.5f + MIRROR_MARGIN*mMirrorW/mMirrorH)*mScreenH );
......
207 210
      mHeadW   = bitmapH.getWidth();
208 211
      mHeadH   = bitmapH.getHeight();
209 212

  
210
      mQuadMirror.setStretch(mMirrorW,mMirrorH,0);
211
      mQuadHead.setStretch(mHeadW, mHeadH,0);
212

  
213 213
      if( mTextureMirror==null ) mTextureMirror = new DistortedTexture();
214 214
      if( mTextureHead  ==null ) mTextureHead   = new DistortedTexture();
215 215

  
216 216
      mTextureMirror.setTexture(bitmapM);
217 217
      mTextureHead.setTexture(bitmapH);
218 218

  
219
      VertexEffectScale.enable();
219 220
      FragmentEffectBrightness.enable();
220 221

  
221 222
      try

Also available in: Unified diff