1
votes

Is it possible for a OpenGL geometry shader to access the current settings for glFrontFace and glCullFace, and whether face culling is enabled? I have a geometry shader that renders normals for vertexes of triangles, and would like to render them only for triangles that will not be culled. What I would like to have is global variables, similar to built-in uniform variables, that tell whether glFrontFace was given GL_CCW or CL_CW, and whether glCullFace is set to GL_FRONT, GL_BACK, or GL_FRONT_AND_BACK, and whether face culling is enabled.

A workaround is for my C++ program to set the values as uniform variables in the shader program, but it would be more general, and make the shader program more easily usable, if it could query the status of culling, glFrontFace and glCullFace settings from OpenGL.

Please note, I do not want the gl_FrontFacing variable that is available to the fragment shader. Instead, the geometry shader needs to be able to access the values to know whether to generate a line representing a normal at the vertices of the triangle.

2
"Is it possible for a OpenGL geometry shader to access the current settings for glFrontFace and glCullFace [...]" `- No. You have to use an uniform.Rabbid76
Thank you for the answers. It confirms what I was expecting.Sam Buss

2 Answers

2
votes

No, these are all the inputs you have in geometry shaders: https://www.khronos.org/opengl/wiki/Geometry_Shader#Inputs

You will have to use use a uniform.

0
votes

Think of functions that change OpenGL server's states as interfaces to their internal implementation's uniforms used by fixed pipeline shaders. As you implement your own pipeline, you have to implement your own uniforms. One of ways to switch from fixed pipeline to flexible one within preexisting code is to implement your own emulation of OpenGl functions, although it would not be very effective one.