I am just starting with OpenGL using c++ on Ubuntu 18.04. The problem I have is that when I try to link Geometry Shader in my main program, the following function call is failingunable to create an object (and hence returns 0)
when ShaderType = GL_GEOMETRY_SHADER. The error log thrown is: "Error creating shader type 36313". Here, 36313 is the enum value for GL_GEOMETRY_SHADER.
NOTE: My program runs successfully (with a differing functionality) when I remove the geometry shader, while keeping the fragment & vertex shaders intact.
The following is the source code for my geometry shader:
#version 130
layout (triangles) in;
layout (triangle_strip, max_vertices = 4) out;
void main() {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
EmitVertex();
gl_Position = gl_in[2].gl_Position;
EmitVertex();
EndPrimitive();
}
The flow of the main code is as follows:
During CompileShaders(), the code calls AddShader(ShaderProgram, gs.c_str(), GL_GEOMETRY_SHADER). The following are the first few lines in this function.
static void AddShader(GLuint ShaderProgram, const char* pShaderText, GLenum ShaderType) {
GLuint ShaderObj = glCreateShader(ShaderType);
if (ShaderObj == 0) {
fprintf(stderr, "Error creating shader type %d\n", ShaderType);
exit(0);
}
...
}
Here glCreateShader() returns 0 which is why in the following if condition an error is thrown as mentioned previously.
The following are the version details of my setup.
The following is my hardware information.
I think this might be some version error. But I am not sure. I would be really, really grateful if someone could help me out with this.
Edit: The source files are:
main.cpp (AddShader() for Geometry shader is called at line 146. The error then occurs at line 95 where glCreateShader() isn't able to generate an object).