ofxBox2D image texture somehow dark

Hello OFX forum,

I have adapted an example project of ofxBox2D to see if i could get an image texture on a circle shape, which i succeeded in, yay! However, somehow, the image is being darkened, and i have no idea where this is coming from. I have zipped the project, and posted some screenshots on my cloud space here:

original transparent PNG image:
http://cl.ly/image/0d2V3K383Z0D

How coin looks in adapted Box2D example project:
http://cl.ly/image/461N3U061Y0L

sorry, i have no rights to put images inside posts, apparently :stuck_out_tongue:

1 Like

If you call ofSetColor(255) before drawing the image, does bring the image color back to what you expect?

CB

2 Likes

Yes, that works perfectly. How does it work? Is color simply overlayed over images in OpenFrameworks, always? Or is it something ofxBox2D specific?

Thanks!

http://cl.ly/image/3n0p16300u1C

OpenGL/OF is (mostly) state-based which means the last color that was set will continue to be used until it is changed again. In the case of textures, you can think of the color as a “tint” similar to that option in Processing if you’ve used that before. Without setting the color yourself, your textures were being “tinted” by the last color that was set in the last call to ofSetColor().

2 Likes

Thanks, very clear answer!

1 Like

You can also use ofPushStyle() and ofPopStyle() to keep track of your state.

1 Like