As I understood, from GLES30 there is no more gl_FragColor buffer (I saw it HERE)
Since I can’t read a "Special Variables ", how can I read an “out” buffer?
This is my GL code:
private static final String VERTEX_SHADER =
"#version 300 es
"+
"uniform mat4 uMVPMatrix;
" +
"uniform mat4 uSTMatrix;
" +
"in vec4 aPosition;
" +
"in vec4 aTextureCoord;
" +
"out vec2 vTextureCoord;
" +
"void main() {
" +
" gl_Position = uMVPMatrix * aPosition;
" +
" vTextureCoord = (uSTMatrix * aTextureCoord).xy;
" +
"}
";
private static final String FRAGMENT_SHADER =
"#version 300 es
"+
"#extension GL_OES_EGL_image_external_essl3 : require
" +
"precision mediump float;
" + // highp here doesn’t seem to matter
"in vec2 vTextureCoord;
" +
"uniform sampler2D sTexture;
" +
"layout(location = 0) out vec4 fragColor ;
" +
"void main() {
" +
" vec4 tc = texture(sTexture, vTextureCoord);
" +
" fragColor.r = tc.r * 0.3 + tc.g * 0.59 + tc.b * 0.11;
" +
" fragColor.g = tc.r * 0.3 + tc.g * 0.59 + tc.b * 0.11;
" +
" fragColor.b = tc.r * 0.3 + tc.g * 0.59 + tc.b * 0.11;
" +
"}
";
Here I tried to read the data:
ByteBuffer mPixelBuf = ByteBuffer.allocateDirect(mWidth * mHeight * 4);
mPixelBuf.order(ByteOrder.LITTLE_ENDIAN);
GLES30.glReadPixels(startX, startY, frameWidth, frameHeight, GLES30.GL_RGBA, GLES30.GL_UNSIGNED_BYTE, mPixelBuf);
There are no gl errors in the code.
The output mPixelBuf only zeroes.
How can I make sure that fragColor is reading?
Thanks