Results 1 to 5 of 5

Thread: Geometry Shader crashing

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2017
    Posts
    15

    Geometry Shader crashing

    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

    Code :
    #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.

    Code :
    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 ) and and glfw 3.2

    EDIT: Here is the steps I'm using to load up my shader.

    Creating a shader instance:

    Code :
    shader = new StaticShader("VertexShader.shader", "TesselationControl.shader", 
    "TessilationEvaluation.shader", "Geometry.shader", "FragmentShader.shader");
    StaticShader Constructor

    Code :
    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:

    Code :
    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;
    }

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2016
    Posts
    477
    im using also glfw 3, and my graphics card supportd also OpenGL 4.5, and i dont get those errors, it compiles successfully

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,101
    Quote Originally Posted by ED_RockStarGuy View Post
    Code :
    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
    Check that you are actually compiling this as a geometry shader, i.e. the shader was created with glCreateShader(GL_GEOMETRY_SHADER) and that shader is the one you're actually using (i.e. you didn't accidentally overwrite the name with that for a different shader, or pass the wrong name to glShaderSource(), or whatever).

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2017
    Posts
    15
    Quote Originally Posted by GClements View Post
    Check that you are actually compiling this as a geometry shader, i.e. the shader was created with glCreateShader(GL_GEOMETRY_SHADER) and that shader is the one you're actually using (i.e. you didn't accidentally overwrite the name with that for a different shader, or pass the wrong name to glShaderSource(), or whatever).
    I have checked and I am compiling as a Geometry shader and the source file is correct.

  5. #5
    Newbie Newbie
    Join Date
    Mar 2015
    Posts
    16

    Geometry Shader ERROR

    Quote Originally Posted by ED_RockStarGuy View Post
    I have checked and I am compiling as a Geometry shader and the source file is correct.
    Have you had any luck fixing this? I am also getting the same error in a Geometry shader. I have also checked I am compiling a Geometry shader but agree that the error codes seem to say that it is not. I am using OpenGL 4.5 on NVIDIA hardware (latest drivers).

Similar Threads

  1. Fragment Shader Not Compiling & glattachShader Crashing
    By superuser9001 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-14-2016, 12:41 AM
  2. Dot product crashing shader
    By BBeck1 in forum OpenGL: GLSL
    Replies: 4
    Last Post: 08-05-2016, 02:41 AM
  3. shader storage buffer objects within geometry shader
    By minidrive in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-14-2014, 08:43 AM
  4. Replies: 5
    Last Post: 06-23-2013, 01:13 AM
  5. Replies: 4
    Last Post: 11-16-2012, 04:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean