I am modifying the OpenGLDemo2D code in hopes of figuring out how to get uniforms working with OpenGLGraphicsContextCustomShader
as follows:
in OpenGL2DShaderDemo::paint(Graphics& g)
//snip...
if (shader != nullptr)
{
statusLabel.setText (String(), dontSendNotification);
//@matkatmusic
auto* prg = shader->getProgram(g.getInternalContext());
if( prg->getUniformIDFromName("colour1") < 0 )
{
//jassertfalse;
}
else
{
DBG( shader->getFragmentShaderCode() );
prg->setUniform("colour1", 1.f, 0.f, 0.f, 1.f);
}
//end @matkatmusic
shader->fillRect (g.getInternalContext(), getLocalBounds());
}
and in static Array<ShaderPreset> OpenGL2DShaderDemo::getPresets()
:
//snip...
{
"Simple Gradient",
SHADER_DEMO_HEADER
"uniform vec4 colour1;\n" //@matkatmusic
"void main()\n"
"{\n"
" gl_FragColor = colour1;\n"
"}\n"
},
This should result in a solid color when the shader is executed, but it ends up looking like this:
is OpenGLGraphicsContextCustomShader broken, in that you can’t set uniforms on it?
calling shader->getProgram(g.getInternalContext())->setUniform("colour1", 1.f, 0.f, 0.f, 1.f);
should set the background to a solid red color but it doesn’t.