2

I would like to attach a geometry shader to my existing (and working) vertex and fragment shaders. The snippet responsible for building the program:

    int geometryShader = GLES31.glCreateShader(GLES31Ext.GL_GEOMETRY_SHADER_EXT);
    glShaderSource(geometryShader, geometryShaderSource);
    glCompileShader(geometryShader);

    // Error checking:
    glGetShaderiv(geometryShader, GL_COMPILE_STATUS, success, 0);
    if(success[0] == 0)
        Log.v(Debug.shaderHelper, "Geometry Shader Compile Failed: " + glGetShaderInfoLog(geometryShader));


    int program = glCreateProgram();
    glAttachShader(program, vertexShader);
    glAttachShader(program, geometryShader);
    glAttachShader(program, fragmentShader);

    glLinkProgram(program);

And here is the geometry shader:

#version 310 es
layout (triangles) in;
layout (triangle_strip) out;
layout (max_vertices = 3) out;

void main(void){
    int i

    for (i = 0; i < gl_in.length(); i++){
        //gl_Position = gl_in[i].gl_Position;

        gl_Position = vec4(0.0);

        //EmitVertex();
    }

//EndPrimitive();
}

This shader should be just a pass-through shader (just for testing for now). The problem is that the geometry shader code has no effect on the final processing of the vertices. Even though I commented out important parts of the code, it still works. (Not to mention the missing semicolon.)

There are no errors logged, even though I check them.

So my questions are:

  • How can I compile a geometry shader on android?

  • Why are there no errors?

  • Can I just attach the geometry shader to the program just like the vertex and fragment shader?

andras
  • 3,305
  • 5
  • 30
  • 45
  • `glGetShaderiv` only takes 3 parameters. (https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetShaderiv.xml), but you're calling it with 4. Are you sure you're checking the error correctly? – MuertoExcobito Feb 21 '16 at 03:10
  • @MuertoExcobito : I am sorry that I did not mention it, but this is android java code, not C++. [link](http://developer.android.com/reference/android/opengl/GLES20.html#glGetShaderiv(int, int, int[], int)) – andras Feb 21 '16 at 09:20

1 Answers1

1

The code I posted is fine, this is how you add a geometry shader. My device does not support this extension, that is the reason why it did not give any error logs. It turns out that android os version has nothing to do with the opengl versions and extensions (5.0 os and 3.0 opengl version).

andras
  • 3,305
  • 5
  • 30
  • 45