Project

General

Profile

« Previous | Next » 

Revision 5c604561

Added by Leszek Koltunski over 7 years ago

Beginnings of support for DistortedEffects.drawPrivFeedback()

View differences:

src/main/java/org/distorted/examples/feedback/FeedbackRenderer.java
42 42
    private final int BYTESFLOAT = 4;
43 43
    private final int POSITION   = 3;
44 44

  
45
    private final boolean USEPOINTS=true;
45
    private final boolean USEPOINTS=false;
46 46

  
47 47
    private GLSurfaceView mView;
48 48
    private DistortedProgram mFeedbackProgram;
......
68 68

  
69 69
      GLES30.glEnable(GLES30.GL_RASTERIZER_DISCARD);
70 70
      GLES30.glBeginTransformFeedback( USEPOINTS ? GLES30.GL_POINTS : GLES30.GL_TRIANGLES);
71
      GLES30.glDrawArrays( USEPOINTS ? GLES30.GL_POINTS : GLES30.GL_TRIANGLE_STRIP, 0, mVertices);
71
      GLES30.glDrawArrays( USEPOINTS ? GLES30.GL_POINTS : GLES30.GL_TRIANGLES, 0, mVertices);
72 72

  
73 73
      int error = GLES30.glGetError();
74 74

  
......
81 81
      GLES30.glDisable(GLES30.GL_RASTERIZER_DISCARD);
82 82
      GLES30.glFlush();
83 83

  
84
      int numVertices = 3*(mVertices);
85

  
86
      Buffer mappedBuffer =  GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, numVertices*POSITION*BYTESFLOAT, GLES30.GL_MAP_READ_BIT);
84
      Buffer mappedBuffer =  GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mVertices*POSITION*BYTESFLOAT, GLES30.GL_MAP_READ_BIT);
87 85
      FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer();
88 86
      String msg = "";
89 87

  
90
      for(int i=0; i<numVertices*POSITION; i++) msg += (" "+fb.get(i));
88
      for(int i=0; i<mVertices*POSITION; i++) msg += (" "+fb.get(i));
91 89

  
92 90
      android.util.Log.d( "Feedback", msg);
93 91

  
......
132 130
        android.util.Log.e("Feedback", "exception creating feedback program: "+ex.getMessage());
133 131
        }
134 132

  
135
      float[] floatData = { 1.0f,4.0f,9.0f, 16.0f,25.0f,36.0f, 49.0f,64.0f,81.0f,  100.0f,121.0f,144.0f};
133
      float[] floatData = {   1.0f,  4.0f,  9.0f,
134
                             16.0f, 25.0f, 36.0f,
135
                             49.0f, 64.0f, 81.0f,
136
                            100.0f,121.0f,144.0f,
137
                              1.0f,  4.0f,  9.0f,
138
                             16.0f, 25.0f, 36.0f
139
                          };
140

  
136 141
      mVertices = floatData.length/POSITION;
137 142
      FloatBuffer data = ByteBuffer.allocateDirect(mVertices*POSITION*BYTESFLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
138 143
      data.put(floatData).position(0);
......
146 151
      mTBO = new int[1];
147 152
      GLES30.glGenBuffers(1, mTBO, 0);
148 153
      GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mTBO[0]);
149
      GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 3*(mVertices)*POSITION*BYTESFLOAT, null, GLES30.GL_STATIC_READ);
154
      GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mVertices*POSITION*BYTESFLOAT, null, GLES30.GL_STATIC_READ);
150 155
      GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0);
151 156
      }
152 157
}
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java
137 137
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
138 138

  
139 139
      // likewise the Mesh
140
      if( mMesh==null ) mMesh = new MeshFlat(2,2);//(9,9*bmpHeight/bmpWidth);
140
      if( mMesh==null ) mMesh = new MeshFlat(9,9*bmpHeight/bmpWidth);
141 141

  
142 142
      // even if mTexture wasn't null, we still need to call setTexture() on it
143 143
      // because every time activity goes to background, its OpenGL resources

Also available in: Unified diff