Okay, I did not know that this is your first OpenGL project.

Then it may be shooting a bit too far.

But just one thing with your "visible" variable and how geometry shaders work:

A geometry shader is invoked for a set of all the three vertices that make up a triangle.

There, you have access to all vertices of that triangle, which is the reason why the geometry shader can compute the distances to the edges of that triangle.

Your "visible" variable is also per vertex, so you need to specify a different vertex attribute layout in your geometry shader, since it works both on the vertex "position" as well as on the "visible" flag.

Regarding the interpretation of that "visible" flag: Since that flag should be per edge but is in fact per vertex, we can use the "first" vertex of a triangle to mean the edge which would lead to the second vertex (in winding order). I admit that this is advanced. Sorry for proposing it.

So, your vertex attribute layout in the geometry shader would be:

`in myVertex { // <- this comes from the vertex shader`

vec4 gl_Position;

bool visible;

} vertices[];

Your vertex shader (situated before the geometry shader) would then declare the following interface:

`in int visible; // <- this comes from vertex stream`

in vec3 position; // <- this also comes from your vertex stream

out myVertex { // <- this goes to the geometry shader

vec4 gl_Position;

bool visible;

} vertex;

Logically, the 'in int visible' should have type 'bool', but that is not supported as an vertex attribute. So we just use 0 for false and 1 for true. You can also use float with 0.0 and 1.0.

First i think about a boolean or a byte type, but this is probably not possible in one

VBO object with float vertices.

You can pack any information in a VBO in an interleaved way, or use different VBOs for different vertex attributes.

You can in theory use the following interleaved format:

`XYZV|XYZV|XYZV|XYZV|...`where XYZ is the vertex position as three floats and V is a single 32-bit integer being either 0 or 1.

You just have to declare the vertex attributes correctly with

`glVertexAttribPointer`.