Search code examples
c#openglshadersharpgl

SharpGL and Geometry Shader


Have anyone used geometry shaders in SharpGL? I cannot figure out how to accomplish it in my code. As I see method Create which is provided with ShaderProgram from SharpGL.Shaders take only Vertex Shader and Fragment Shader as parameters.

public void Create(
  OpenGL gl,
  string vertexShaderSource,
  string fragmentShaderSource,
  Dictionary<uint, string> attributeLocations
);

How can I link my geometry shader with OpenGL via SharpGL? Or I need to use another approach to get Geometry Shader worked?


Solution

  • I've found the solution to my own question. Quite a straightforward OpenGL approach can be applied for this issue. All that's needed is to create a geometry shader, compile it and than attach to program.

    uint program = gl.CreateProgram();
    uint geom = gl.CreateShader(OpenGL.GL_GEOMETRY_SHADER);
    gl.ShaderSource(shader, geometryShaderSourceString);
    gl.CompileShader(shader);
    gl.AttachShader(program, geom);