Revision e78a30fd
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/DistortedEffects.java | ||
---|---|---|
38 | 38 |
import org.distorted.library.type.Static3D; |
39 | 39 |
|
40 | 40 |
import java.io.InputStream; |
41 |
import java.nio.Buffer; |
|
41 | 42 |
import java.nio.ByteBuffer; |
42 | 43 |
import java.nio.ByteOrder; |
43 | 44 |
import java.nio.FloatBuffer; |
... | ... | |
140 | 141 |
//android.util.Log.e("Effects", "vertHeader= "+mainVertHeader); |
141 | 142 |
//android.util.Log.e("Effects", "fragHeader= "+mainFragHeader); |
142 | 143 |
|
143 |
mMainProgram = new DistortedProgram(mainVertStream,mainFragStream, mainVertHeader, mainFragHeader, Distorted.GLSL); |
|
144 |
String[] feedback = { "v_Position" }; |
|
145 |
|
|
146 |
mMainProgram = new DistortedProgram(mainVertStream,mainFragStream, mainVertHeader, mainFragHeader, Distorted.GLSL, feedback); |
|
144 | 147 |
|
145 | 148 |
int mainProgramH = mMainProgram.getProgramHandle(); |
146 | 149 |
EffectQueueFragment.getUniforms(mainProgramH); |
... | ... | |
306 | 309 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NORMAL_DATA_SIZE , GLES30.GL_FLOAT, false, 0, 0); |
307 | 310 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]); |
308 | 311 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE , GLES30.GL_FLOAT, false, 0, 0); |
312 |
|
|
313 |
//GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]); |
|
314 |
|
|
315 |
// GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES); |
|
309 | 316 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength); |
317 |
// GLES30.glEndTransformFeedback(); |
|
318 |
// GLES30.glFlush(); |
|
319 |
|
|
310 | 320 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 ); |
321 |
/* |
|
322 |
int len = mesh.dataLength*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE; |
|
323 |
|
|
324 |
Buffer mappedBuffer = GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, len, GLES30.GL_MAP_READ_BIT); |
|
325 |
FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer(); |
|
326 |
FloatBuffer bb = mesh.mMeshPositions; |
|
327 |
|
|
328 |
String msgB = "BEFORE: ", msgA = "AFTER : "; |
|
329 |
for(int d=0; d<mesh.dataLength; d++) |
|
330 |
{ |
|
331 |
msgB+="("+(2*halfW*bb.get(3*d+0))+","+(2*halfH*bb.get(3*d+1))+","+(2*halfZ*bb.get(3*d+2))+")"; |
|
332 |
msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")"; |
|
333 |
} |
|
334 |
android.util.Log.d( "Feedback", msgB); |
|
335 |
android.util.Log.d( "Feedback", msgA); |
|
311 | 336 |
|
312 | 337 |
/// DEBUG ONLY ////// |
313 |
// displayBoundingRect(halfInputW, halfInputH, halfZ, df, mM.getMVP(), mesh.getBoundingVertices() );
|
|
338 |
// displayBoundingRect(halfW, halfH, halfZ, surface, mM.getMVP(), fb, currTime );
|
|
314 | 339 |
/// END DEBUG /////// |
340 |
|
|
341 |
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER); |
|
342 |
*/ |
|
315 | 343 |
} |
316 | 344 |
|
317 | 345 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/EffectQueueMatrix.java | ||
---|---|---|
250 | 250 |
mUniforms[NUM_UNIFORMS*index+6] = mUniforms[NUM_UNIFORMS*(index+1)+6]; |
251 | 251 |
} |
252 | 252 |
|
253 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
254 |
|
|
255 |
float[] getMVP() |
|
256 |
{ |
|
257 |
return mMVPMatrix; |
|
258 |
} |
|
259 |
|
|
253 | 260 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
254 | 261 |
|
255 | 262 |
synchronized void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ) |
src/main/java/org/distorted/library/MeshObject.java | ||
---|---|---|
44 | 44 |
int[] mNorVBO = new int[1]; |
45 | 45 |
int[] mTexVBO = new int[1]; |
46 | 46 |
|
47 |
int[] mPosTBO = new int[1]; // Transform Feedback |
|
48 |
|
|
47 | 49 |
final float zFactor; // strange workaround for the fact that we need to somehow store the 'depth' |
48 | 50 |
// of the Mesh. Used in DistortedEffects. See DistortedTexture.getDepth(). |
49 | 51 |
|
... | ... | |
84 | 86 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength* TEX_DATA_SIZE*BYTES_PER_FLOAT, mMeshTexture , GLES30.GL_STATIC_READ); |
85 | 87 |
} |
86 | 88 |
|
89 |
if( mPosTBO[0]<0 ) |
|
90 |
{ |
|
91 |
GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mPosTBO[0]); |
|
92 |
GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ); |
|
93 |
GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0); |
|
94 |
} |
|
95 |
|
|
87 | 96 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0); |
88 | 97 |
} |
89 | 98 |
|
... | ... | |
107 | 116 |
GLES30.glDeleteBuffers(1, mTexVBO, 0); |
108 | 117 |
mTexVBO[0] = -1; |
109 | 118 |
} |
119 |
if( mPosTBO[0]>=0 ) |
|
120 |
{ |
|
121 |
GLES30.glDeleteBuffers(1, mPosTBO, 0); |
|
122 |
mPosTBO[0] = -1; |
|
123 |
} |
|
110 | 124 |
} |
111 | 125 |
|
112 | 126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
116 | 130 |
mPosVBO[0] = -1; |
117 | 131 |
mNorVBO[0] = -1; |
118 | 132 |
mTexVBO[0] = -1; |
133 |
mPosTBO[0] = -1; |
|
119 | 134 |
} |
120 | 135 |
|
121 | 136 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Progress with Transform Feedback.