Login  Register

[Solved] Sharing the same ubo among different shaders of the same program

Posted by elect on Apr 13, 2016; 8:37am
URL: https://forum.jogamp.org/Solved-Sharing-the-same-ubo-among-different-shaders-of-the-same-program-tp4036597.html

I got some problems as titled.

I load my shaders as:

            ShaderCode vertShader = ShaderCode.create(gl3, GL_VERTEX_SHADER, 2, this.getClass(), SHADERS_ROOT,
                    new String[]{SHADERS_SRC[Program.INIT], "shade"}, "vs", null, null, null, false);
            ShaderCode fragShader = ShaderCode.create(gl3, GL_FRAGMENT_SHADER, 2, this.getClass(), SHADERS_ROOT,
                    new String[]{SHADERS_SRC[Program.INIT], "shade"}, "fs", null, null, null, false);

            ShaderProgram shaderProgram = new ShaderProgram();
            shaderProgram.add(vertShader);
            shaderProgram.add(fragShader);

            shaderProgram.link(gl3, System.out);

            programName[Program.INIT] = shaderProgram.program();


both SHADERS_SRC[Program.INIT] and "shade" shall access the same ubo

If I define it in both place, I get:

0(21) : error C1038: declaration of "params" conflicts with previous declaration at 0(55)
0(21) : error C1038: declaration of "Parameters" conflicts with previous declaration at 0(55)

If I define only in one place, the other complains:

Shader status invalid: 0(72) : error C1008: undefined variable "params"

How shall I do?