Skip to main content

Using TextureAttributes to change image color

No replies
shembelcut
Offline
Joined: 2012-10-03
Points: 0

I need to load an image in my app and based on BlinkingColor, it should combine the source color( image ) and blinking color( RED,WHITE ) so that It looks like this :

Expected Output
Expected Output

By using the attached code it is able to combine the colors correctly but It won't blink, while the function is getting called every second and passing the right color.( red, white, red,white ....)

Current Output:
Current Output

here's the function code:

@Override
    public void setColor(Color3f BlinkingColor) {
        TextureAttributes ta = appearance.getTextureAttributes();
        if (ta == null) {
            ta = new TextureAttributes();
            ta.setCapability(TextureAttributes.ALLOW_COMBINE_WRITE);
            ta.setCapability(TextureAttributes.ALLOW_COMBINE_READ);
            ta.setTextureMode(TextureAttributes.COMBINE);
            ta.setCombineRgbSource(0,TextureAttributes.COMBINE_TEXTURE_COLOR);
            ta.setCombineRgbFunction(0,TextureAttributes.COMBINE_SRC_COLOR);
            appearance.setTextureAttributes(ta);
        }
        if (BlinkingColor == null) {
            this.color = null;
        } else if (this.color == null) {
            this.color = new Color3f(BlinkingColor);
        } else {
            this.color.set(BlinkingColor);
        }
}