0
votes

I started with a working OpenGL program (with vertex and fragment shaders) that draws a single GL_POINT. Then I attached a simple geometry shader that outputs two points given a single point as input:

#version 400

layout(points) in;
layout(points, max_vertices = 2) out;

void main() {

    gl_Position = gl_in[0].gl_Position;
    EmitVertex();

    gl_Position = gl_in[0].gl_Position + vec4(0.1, 0, 0, 1);
    EmitVertex();


    EndPrimitive();
}

When I run my program I get the following compilation errors from GL:

Error Compiling Shader: ERROR: 0:4: Invalid use of layout 'points'
ERROR: 0:5: Invalid use of layout 'points'
ERROR: 0:9: Use of undeclared identifier 'gl_Position'
ERROR: 0:9: Use of undeclared identifier 'gl_in'
ERROR: 0:10: Call to undeclared function 'EmitVertex'
ERROR: 0:12: Use of undeclared identifier 'gl_Position'
ERROR: 0:12: Use of undeclared identifier 'gl_in'
ERROR: 0:13: Call to undeclared function 'EmitVertex'
ERROR: 0:16: Call to undeclared function 'EndPrimitive'

My System Specs:

Mac OSX 10.9, Nvidia Geforce 750M, OpenGL 4.1 driver

I also tried defining the following in my geometry shader:

#extension GL_EXT_geometry_shader4: enable

But my driver does not support the extension. This shouldn't be needed though since geometry shaders are apart of core since 3.2 (source: https://www.opengl.org/wiki/Geometry_shader#See_also)

Any thoughts?

1
Are you really trying to compile this as geomerty shader? Can you show your shader compilation code?derhass

1 Answers

1
votes

First, do not use #extension GL_EXT_geometry_shader4: enable.

Geometry Shaders are core in GLSL 4.00. The EXT extension actually has some different behavior such as gl_VerticesIn rather than gl_in.length () to determine the size of the input and the use of program parameters to set the input/output primitive types rather than a layout qualifier. Core profile implementations from Apple do not even support that extension.

Second, all of the errors you have listed point to one thing...

You are trying to create a fragment shader. Make sure you use GL_GEOMETRY_SHADER when you call glCreateShader (...).