User is deleted
User is deleted

Reputation: 155

Blend that adding color instead of just replacing?

Is there a way to add color's value on pixel (Instead of settings) when drawing?

My pesudo code for example:

//DrawPixel( int x, int y, Color color ); - Puts pixel to color buffer with specific place.
DrawPixel( 0, 0, Red );
DrawPixel( 0, 0, Green );

And after I execute this code, the 0,0 pixel's color is the result of Red+Green. (Yellow) I don't talk only about drawing pixels or blend. Is there a way in OpenGL to make it done?

Upvotes: 0

Views: 247

Answers (2)

Bovinedragon
Bovinedragon

Reputation: 307

In addition to Aki Suihkonen's answer, you may also need to call glEnable(GL_BLEND) to turn blending on. You said it is currently just replacing the color which sounds like you have blending turned off.

Assuming you have initialized glew properly, when an OpenGL call throws an exception saying you are trying to call 0x00000000 it means that that API is not available in your version of OpenGL, so make sure you are using the correct function for your version of OpenGL.

Upvotes: 1

Aki Suihkonen
Aki Suihkonen

Reputation: 20017

Yes there is. It's called GL_FUNC_ADD. In addition to transparency there are a handful of other useful blending functions​.

In earlier opengl versions Gl.BlendFunc(Gl.SRC_COLOR,Gl.DST_COLOR) might just do the trick.

Upvotes: 1

Related Questions