Revision 96fba026
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/feedback/FeedbackRenderer.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
class FeedbackRenderer implements GLSurfaceView.Renderer |
42 | 42 |
{ |
43 |
private final int BYTESFLOAT = 4; |
|
44 |
|
|
43 | 45 |
private GLSurfaceView mView; |
44 | 46 |
private DistortedProgram mFeedbackProgram; |
45 | 47 |
private int mBufferLength; |
... | ... | |
69 | 71 |
GLES30.glDisable(GLES30.GL_RASTERIZER_DISCARD); |
70 | 72 |
GLES30.glFlush(); |
71 | 73 |
|
72 |
Buffer mappedBuffer = GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mBufferLength, GLES30.GL_MAP_READ_BIT); |
|
74 |
Buffer mappedBuffer = GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mBufferLength*BYTESFLOAT, GLES30.GL_MAP_READ_BIT);
|
|
73 | 75 |
|
74 | 76 |
if (mappedBuffer!=null) |
75 | 77 |
{ |
... | ... | |
119 | 121 |
} |
120 | 122 |
|
121 | 123 |
float[] floatData = { 1.0f, 4.0f, 9.0f, 16.0f, 25.0f, 100.0f }; |
122 |
mBufferLength = floatData.length * 4;
|
|
123 |
FloatBuffer data = ByteBuffer.allocateDirect(mBufferLength).order(ByteOrder.nativeOrder()).asFloatBuffer(); |
|
124 |
mBufferLength = floatData.length; |
|
125 |
FloatBuffer data = ByteBuffer.allocateDirect(mBufferLength*BYTESFLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
|
124 | 126 |
data.put(floatData).position(0); |
125 | 127 |
|
126 | 128 |
mVBO = new int[1]; |
127 | 129 |
GLES30.glGenBuffers(1, mVBO, 0); |
128 | 130 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mVBO[0]); |
129 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, mBufferLength, data, GLES30.GL_STATIC_READ); |
|
131 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, mBufferLength*BYTESFLOAT, data, GLES30.GL_STATIC_READ);
|
|
130 | 132 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0); |
131 | 133 |
|
132 | 134 |
mTBO = new int[1]; |
133 | 135 |
GLES30.glGenBuffers(1, mTBO, 0); |
134 | 136 |
GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mTBO[0]); |
135 |
GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mBufferLength, null, GLES30.GL_STATIC_READ); |
|
137 |
GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mBufferLength*BYTESFLOAT, null, GLES30.GL_STATIC_READ);
|
|
136 | 138 |
GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0); |
137 | 139 |
} |
138 | 140 |
} |
Also available in: Unified diff
Bugfix (the thing was drawing too many GL_POINTS, this worked on Nexus 5X but not on Nexus 4)