I keep getting some strange errors in my Geometry shader and when I search for the cause of the errors, it returns nothing substantial. Here is the code.
Shader
#version 450 core
layout(triangles) in;
layout(points, max_vertices = 3)out;
void main(void) {
int i;
for (i = 0; i < gl_in.length(); i++) {
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
}
Log.
0(4) : error C3008: unknown layout specifier 'max_vertices = 3'
0(4) : error C3008: unknown layout specifier 'points'
0(10) : error C3004: function "void EmitVertex();" not supported in this profile
I’m using OpenGL 4.5 (My pc supports it before anyone asks :p) and and glfw 3.2
EDIT: Here is the steps I’m using to load up my shader.
Creating a shader instance:
shader = new StaticShader("VertexShader.shader", "TesselationControl.shader",
"TessilationEvaluation.shader", "Geometry.shader", "FragmentShader.shader");
StaticShader Constructor
ShaderProgram::ShaderProgram(const char * vertex_file_path, const char * tesselation_controll_shader_path,
const char * tesselation_evaluation_shader_path, const char * geometry_shader_path, const char * fragment_file_path) {
vertexShaderID = loadShader(vertex_file_path, GL_VERTEX_SHADER);
tessControllShaderID = loadShader(tesselation_controll_shader_path, GL_TESS_CONTROL_SHADER);
tessEvaluationShaderID = loadShader(tesselation_evaluation_shader_path, GL_TESS_EVALUATION_SHADER);
geometryShaderID = loadShader(geometry_shader_path, GL_GEOMETRY_SHADER);
fragmentShaderID = loadShader(fragment_file_path, GL_FRAGMENT_SHADER);
Status("ShaderProgram", "Initilizing shader program");
programID = glCreateProgram();
glAttachShader(programID, vertexShaderID);
glAttachShader(programID, tessControllShaderID);
glAttachShader(programID, tessEvaluationShaderID);
glAttachShader(programID, geometryShaderID);
glAttachShader(programID, fragmentShaderID);
bindAttributes();
glLinkProgram(programID);
GLint isLinked = 0;
glGetProgramiv(programID, GL_LINK_STATUS, (int *)&isLinked);
if (isLinked == GL_FALSE) {
GLint maxLength = 0;
glGetProgramiv(programID, GL_INFO_LOG_LENGTH, &maxLength);
if (maxLength > 1) {
GLchar* infoLog = (GLchar*)malloc(maxLength);
glGetProgramInfoLog(programID, maxLength, &maxLength, &infoLog[0]);
std::cout << infoLog;
}
StatusError();
exit(0);
}
StatusOkay();
//Clean Up
glDetachShader(programID, vertexShaderID);
glDetachShader(programID, tessControllShaderID);
glDetachShader(programID, tessEvaluationShaderID);
glDetachShader(programID, geometryShaderID);
glDetachShader(programID, fragmentShaderID);
glDeleteShader(vertexShaderID);
glDeleteShader(tessControllShaderID);
glDeleteShader(tessEvaluationShaderID);
glDeleteShader(geometryShaderID);
glDeleteShader(fragmentShaderID);
}
Load shader function:
GLuint ShaderProgram::loadShader(const char * file_path, int type) {
GLuint shaderID = glCreateShader(type);
std::string shaderCode = FileManager::readFile(file_path);
char const * sourcePointer = shaderCode.c_str();
Status("ShaderObject", "Compiling Shader " + std::string(file_path));
glShaderSource(shaderID, 1, &sourcePointer, NULL);
glCompileShader(shaderID);
GLint isCompiled = 0;
glGetShaderiv(shaderID, GL_COMPILE_STATUS, &isCompiled);
if (isCompiled == GL_FALSE){
GLint maxLength = 0;
glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &maxLength);
if (maxLength > 1) {
GLchar* infoLog = (GLchar*)malloc(maxLength);
glGetShaderInfoLog(shaderID, maxLength, &maxLength, &infoLog[0]);
std::cout << infoLog;
}
StatusError();
exit(0);
}
StatusOkay();
return shaderID;
}