Thanks, based on your answer, I improved the code.
vertex_shader
#version 300 es
layout(location = 0) in vec4 position;
layout(location =1) in vec4 in_tex0;
out vec4 texcoord0;
void main() {
texcoord0 = in_tex0;
gl_position = position; }
In fragment_shader, i want to output YUV buffer
#version 300 es
#extension GL_OES_EGL_image_external_essl3 : enable
#extension GL_EXT_YUV_target : require
precision mediump float;
in vec4 texcoord0;
layout(yuv) out vec4 outColor;
uniform __samplerExternal2DY2YEXT diffuse;
void main() {
outColor = texture(diffuse, texcoord0.xy); }
I wrote a new code now that I learned more how opengl works.
But i noticed that glDrwuElements fails.
The glGetError was 1282. Do you know what’s heppening?
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAX_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, EGLImage);
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_EXTERNAL_OES, tex, 0)
glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE, 3*sizeof(GLfloat), vertices);
glVertexAttribPointer(1,2,GL_FLOAT,GL_FALSE, 2*sizeof(GLfloat), texcoords);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
glUniformli(glGetUniformLocation(program, "diffuse"), 0);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
// glGetError() == 1282