machineboy
machineboy

Reputation: 321

In iOS openGL, how can one create a blend mode similar to kCGBlendModeDarken?

On a white background, drawing lines using kCGBlendModeDarken darkens the areas where different colors meet, like this:

darken blend mode

I am trying to recreate this using openGL in iOS, but I don't know how to set the glBlendFunc properties to achieve this. The openGL documentation is hard to grasp for a beginner.

What would be the proper way to achieve this in openGL ES 1_X on iOS?

Upvotes: 0

Views: 2350

Answers (3)

George
George

Reputation: 949

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);

Upvotes: 0

Chris Burt-Brown
Chris Burt-Brown

Reputation: 2727

I am using glBlendEquationOES(GL_MIN_EXT);.

Upvotes: 1

Robert Rouhani
Robert Rouhani

Reputation: 14678

Assuming that kCGBlendModeDarken is just a regular darkening blend mode, the same effect can be achieved in OpenGL using these two commands:

glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_MIN);

Depending on your version of OpenGL, GL_MIN might be GL_FUNC_MIN.

Upvotes: 1

Related Questions