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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

elect
This post was updated on .
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?
Reply | Threaded
Open this post in threaded view
|

Re: Sharing the same ubo among different shaders of the same program

elect
Found the error, I was declaring the std140 in one glsl to be included, it turned out only one of the shaders was actually including this file so basically the glsl compiler was looking at two differnt ubos because they had different layouts..