GLPaint-based OpenGL ES Blending Issue

I am working on an application based on Apple GLPaint code sample. I changed the transparent color to transparent black and added a transparency slider, however, when I mix colors together with a low opacity setting, they don't mix as I expect. They seem to mix light mixes, not how the paints mix. Here is an example of what I mean:

enter image description here

The "desired result" was obtained using glReadPixels to render each color separately and merge with the previous rendered image (i.e., using Apple's default blending).

, " ", OpenGL ? , , , , - , !

+3
3

, , . , , . , GLKit.

, GLKit OpenGL ES.

:

  • GLKit , GLKView ( GLKit).
  • OpenGl , FBO.
  • , - ( , ).

OpenGl, Xcode. . : , . 2 , GLKit, - .

:

, OpenGL ES , OpenGL ES 2.0 . , 6 , - , , .

+3

" " - , OpenGL. , , , . OpenGL ES 1.1, OpenGL ES 2.0, . iOS, , , . OpenGL ES .

0

You need to write this code in a function called when the color changes. and every time you need to install BlendFunc.

CGFloat red , green, blue;
// set red, green ,blue with desire color combination
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(red* kBrushOpacity,
          green * kBrushOpacity,
          blue* kBrushOpacity,
                      kBrushOpacity);

To do more things using BlendFunc use this link.

Please indicate if it works or not. This works for me.

0
source

All Articles