I've been not into OpenGL for a long time, and never used OpenGLES at all.
For my project I must use OpenGLES, the version printed by glGetString(GL_VERSION)
is 3.0, but since I'm doing a collage of tutorials is perfectly possible that I'm mixing code which can't work on this version (that is why the #version
tag is commented on the shaders code, but it did not fix the problem anyway).
This is the code of the vertex shader:
const GLchar * vertex_shader_source =
// "#version 100\n "
// " "
" attribute vec2 a_TexCoordinate; /* Per-vertex texture coordinate */ "
" /* information we will pass in. */ "
" attribute vec2 coord2d; "
" "
" "
" varying vec2 v_TexCoordinate; // This will be passed into the fragment "
" "
" void main(){ "
" "
" gl_Position = vec4(coord2d, 0.0, 1.0); "
" "
" // Pass through the texture coordinate. "
" v_TexCoordinate = a_TexCoordinate; "
" } ";
glShaderSource(vertex_shader_index, 1, &vertex_shader_source, nullptr);
glCompileShader(vertex_shader_index);
glGetShaderiv(vertex_shader_index, GL_COMPILE_STATUS, &compile_ok);
And this is the code of the fragment shader:
const GLchar * fragment_shader_source =
// "#version 100\n "
// " "
"uniform sampler2D u_Texture; // The input texture. "
" "
"varying vec2 v_TexCoordinate; /* Interpolated texture */ "
" /* coordinate per fragment */ "
" "
" void main(){ "
" "
" // Output color = color of the texture at the specified UV "
" gl_FragColor = texture2D(u_Texture, v_TexCoordinate); "
" } ";
glShaderSource(fragment_shader_index, 1, &fragment_shader_source, nullptr);
glCompileShader(fragment_shader_index);
glGetShaderiv(fragment_shader_index, GL_COMPILE_STATUS, &compile_ok);
This is the code of the program:
m_program = glCreateProgram( );
glAttachShader(m_program, vertex_shader_index);
glAttachShader(m_program, fragment_shader_index);
glLinkProgram(m_program);
glGetProgramiv(m_program, GL_LINK_STATUS, &link_ok);
The variable link_ok
is false, while the variables compile_ok
are both true. The extended error from the linking of the program says:
(0) Vertex info: C3001 no program defined (0) Fragment info: C3001 no program defined