Questions tagged [glblendfunc]

The glBlendFunc function specifies pixel arithmetic for OpenGL rendering. Used to define how blend works.

glBlendFunc — specify pixel arithmetic

C Specification

void glBlendFunc( GLenum sfactor, GLenum dfactor); void glBlendFunci( GLuint buf, GLenum sfactor, GLenum dfactor); Parameters

buf For glBlendFunci, specifies the index of the draw buffer for which to set the blend function.

sfactor Specifies how the red, green, blue, and alpha source blending factors are computed. The initial value is GL_ONE.

dfactor Specifies how the red, green, blue, and alpha destination blending factors are computed. The following symbolic constants are accepted: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA. GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA. The initial value is GL_ZERO.

Description

Pixels can be drawn using a function that blends the incoming (source) RGBA values with the RGBA values that are already in the frame buffer (the destination values). Blending is initially disabled. Use glEnable and glDisable with argument GL_BLEND to enable and disable blending.

glBlendFunc defines the operation of blending for all draw buffers when it is enabled. glBlendFunci defines the operation of blending for a single draw buffer specified by buf when enabled for that draw buffer. sfactor specifies which method is used to scale the source color components. dfactor specifies which method is used to scale the destination color components. Both parameters must be one of the following symbolic constants: GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, GL_SRC_ALPHA_SATURATE, GL_SRC1_COLOR, GL_ONE_MINUS_SRC1_COLOR, GL_SRC1_ALPHA, and GL_ONE_MINUS_SRC1_ALPHA. The possible methods are described in the following table. Each method defines four scale factors, one each for red, green, blue, and alpha. In the table and in subsequent equations, first source, second source and destination color components are referred to as Rs0Gs0Bs0As0, Rs1Gs1Bs1As1 and RdGdBdAd, respectively.

53 questions
0
votes
1 answer

Custom blend mode

I'm not really getting the glBlendFunc() function and how it works. Is there a blend mode that lets destination black be black while overriding any other dst colour? I have a black and white canvas containing colouring edges and shapes. I'd like to…
George
  • 479
  • 3
  • 19
0
votes
0 answers

glBlendFunc and framebuffer object

Alpha blending is not working as expected when I draw to a framebuffer object. Specifically, calling glBlendFunc has no effect on what pixels are in the framebuffer. I check what is in the framebuffer before and after drawing using glReadPixels. The…
Little Endian
  • 784
  • 8
  • 19
0
votes
0 answers

Real life Paint GLBlenFunc

What GLBlendFunc would solve this problem? I am currently using: glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); I want the paint app to act like real paint would, but it seems that when using a lower opacity color, it won't paint over a solid…
The Way
  • 594
  • 5
  • 15
0
votes
1 answer

glPoint Alpha Blending issue

I am having issues alpha blending glPoints. The alpha blending works correctly when the glPoint is over the background but when a glPoint overlaps another glPoint the background color is visible rather then the underlying glPoint. // create…
user346443
  • 4,672
  • 15
  • 57
  • 80
0
votes
1 answer

OpenGL - glBlendFunc

I've been trying to find some concrete maths behind the innerworkings of glBlendFunc. Just to clarify, I know that the blending equation is: srcChannels * srcFactor + dstChannels * dstFactor = channelsRendered. my question is, are srcChannels,…
Matt Peck
  • 31
  • 1
0
votes
1 answer

GL Func Subtract Cocos2d

Does anyone know how to change the blending mode for a specific sprite in Cocos2d 2.x to GL_FUNC_SUBTRACT? Ive tried a few things, but basically I'm trying to create a layer mask using a white (or black) circle and hiding the alpha.
Kyle Goslan
  • 10,748
  • 7
  • 26
  • 41
0
votes
1 answer

How to do the opposite of scratch off image effect

I copied the code found here: http://www.cocos2d-iphone.org/forum/topic/12557 To create a successful "scratch off" effect, i.e. when my burnsprite visits the top layer image it makes it transparent in the spot the burnsprite is in, revealing the…
user2012741
  • 89
  • 1
  • 8
-1
votes
2 answers

OpenGL : Blending & feedback effect

I'm struggling on a simple project, as an example/sandbox, I'm rendering a small oscillating rectangle on my output. I'm not using glclearcolor() but instead, on every frame I draw a black rectangle before anything else, blending with…
ebkgne
  • 39
  • 6
1 2 3
4