Project

General

Profile

« Previous | Next » 

Revision 8ff32d4d

Added by Leszek Koltunski almost 8 years ago

Finally fix the 'when rendering though an FBO, the other side of triangles is visible'

View differences:

src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
45 45
{
46 46
    private GLSurfaceView mView;
47 47
    private DistortedBitmap monaLisa;
48
    private Static2D pLeft, pRight;
49
    private Static4D rLeft, rRight;
50
    private Dynamic3D dLeft, dRight;
51

  
52
    private int bmpHeight, bmpWidth;
48 53

  
49 54
///////////////////////////////////////////////////////////////////////////////////////////////////
50 55

  
51 56
    public MonaLisaRenderer(GLSurfaceView v) 
52 57
      {
53 58
      mView = v;
59

  
60
      pLeft = new Static2D( 90, 258);
61
      pRight= new Static2D(176, 255);
62

  
63
      rLeft = new Static4D(-10,-10,25,25);
64
      rRight= new Static4D( 10, -5,25,25);
65
      dLeft = new Dynamic3D(1000,0.0f);
66
      dRight= new Dynamic3D(1000,0.0f);
67
      dLeft.add ( new Static3D(  0,  0,0) );
68
      dLeft.add ( new Static3D(-20,-20,0) );
69
      dRight.add( new Static3D(  0,  0,0) );
70
      dRight.add( new Static3D( 20,-10,0) );
54 71
      }
55 72

  
56 73
///////////////////////////////////////////////////////////////////////////////////////////////////
......
59 76
      {
60 77
      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
61 78
      GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
62
      
79

  
63 80
      monaLisa.draw(System.currentTimeMillis());
64 81
      }
65 82

  
......
68 85
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
69 86
      { 
70 87
      monaLisa.abortEffects(EffectTypes.MATRIX);
71
      monaLisa.move( new Static3D((width-200)/2, 10, 0) );
88

  
89
      if( bmpHeight/bmpWidth > height/width )
90
        {
91
        int w = (height*bmpWidth)/bmpHeight;
92
        float factor = (float)height/bmpHeight;
93
        monaLisa.move( new Static3D((width-w)/2,0,0) );
94
        monaLisa.scale(factor);
95
        }
96
      else
97
        {
98
        int h = (width*bmpHeight)/bmpWidth;
99
        float factor = (float)width/bmpWidth;
100
        monaLisa.move( new Static3D(0,(height-h)/2,0) );
101
        monaLisa.scale(factor);
102
        }
72 103

  
73 104
      Distorted.onSurfaceChanged(width, height); 
74 105
      }
......
93 124
        catch(IOException e) { }
94 125
        }  
95 126

  
96
      monaLisa = new DistortedBitmap(200,200,1);
97
      monaLisa.setBitmap(bitmap);
127
      bmpHeight = bitmap.getHeight();
128
      bmpWidth  = bitmap.getWidth();
129

  
130
      monaLisa = new DistortedBitmap(bitmap, 9);
131
      monaLisa.distort( dLeft, pLeft , rLeft );
132
      monaLisa.distort(dRight, pRight, rRight);
98 133

  
99 134
      try
100 135
        {

Also available in: Unified diff