Hi,
I’m trying to use OpenGLGraphicsContextCustomShader to draw a complex background in a component. My whole app is attached to an OpenGLContext. The background should only be redrawn when the component was resized. It is first drawn into “bgImage” then I call:
if(auto *context = OpenGLContext::getContextAttachedTo(*this))
context->executeOnGLThread([&] (OpenGLContext& callerContext) {
texture.loadImage(bgImage);
}, true);
In my paint method I then run the following. “shader” is my OpenGLGraphicsContextCustomShader object.
texture.bind();
shader.fillRect(g.getInternalContext(), getLocalBounds());
texture.unbind();
And I created this callback for the shader:
shader.onShaderActivated = [&] (OpenGLShaderProgram &program) {
program.setUniform("texture", (GLint) texture.getTextureID());
};
My fragmentshader looks like this:
uniform sampler2D texture;
void main() {
gl_FragColor = texture2D(texture, gl_FragCoord.xy);
}
The endresult is a black component. I am actually not to sure about any step along the way. I tested setting a uniform from the shader call. That worked. Texture won’t. Help!