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
14
votes
4 answers

Opengl Render To Texture With Partial Transparancy (Translucency) And Then Rendering That To The Screen

I've found a few places where this has been asked, but I've not yet found a good answer. The problem: I want to render to texture, and then I want to draw that rendered texture to the screen IDENTICALLY to how It would appear if I skipped the render…
M2tM
  • 4,415
  • 1
  • 34
  • 43
5
votes
1 answer

Why does OpenGL blending not work on HTC Desire?

Does anyone know how to enable blending in OpenGL (android) on a HTC Desire. I am trying to draw colored triangles and using the alpha value of the color buffer to blend them with the background (or another triangle). It works both on the emulator…
Sunkas
  • 9,542
  • 6
  • 62
  • 102
5
votes
1 answer

cocos2d. Correct blending?

I modified standard example "Hello World": CCSprite *sprite = [CCSprite spriteWithFile:@"Untitled-1.png"]; CGSize winSize = [CCDirector sharedDirector].winSize; sprite.position = ccp(winSize.width / 2, winSize.height / 2); …
user2083364
  • 744
  • 1
  • 7
  • 20
4
votes
1 answer

Opengl, Ruby, glBlendFunc: place transparent images on top of each others as if it was opaque

I'm not sure if glBlendFunc is the great function to resolve my problem, but I think that I'll need it! Here is my problem: You see the two pine trees' reflects on the right? I'd like to have something like that: Then, I need a method which is…
Nat
  • 119
  • 5
3
votes
1 answer

WebGL render buffers receiving skewed pixel values from shader

I'm rendering a scene of polygons to multiple render targets so that I can perform postprocessing effects. However, the values I'm setting in the fragment shader don't seem to be accurately reflected in the pixel shader. Right now the pipeline…
Ipsquiggle
  • 1,814
  • 1
  • 15
  • 25
3
votes
2 answers

How to do something like Photoshop's screen Blending with glBlendFunc (OpenGL ES 1.x)?

I have a simple one channel (8bit) bitmap with luminance data only, and I want to blend it with the existing framebufer like Screen blending mode does it in Photoshop. So the source's white pixels (255) should result white, source's 50% gray pixels…
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
3
votes
1 answer

libgdx - blendFunc for brush line drawing? (additive/non-additive mixture)

I am drawing sprites to the framebuffer at each pixel for every step in a line between two points, but I have an issue with the blending: I am currently using: (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); Then, in my shader I do: if( color.a == 0 ) …
JoeOfTex
  • 97
  • 1
  • 10
3
votes
1 answer

OpenGL's glBlendFunc

Is there a way in OpenGL's glBlendFunc to scale up the destination RGB? (ie (10,50,5) to (20,100,10) it seems the only thing you can do is add source rgb (multiplied by some factors that are <1)
Matt Peck
  • 31
  • 1
2
votes
2 answers

glBlendFunc Disables Shader

I have a very simple shader (just sets a background square to green) and this works perfectly. I recently added in some quads that have a texture applied to them. This texture has some alpha values so I use this to call it: glEnable (GL_BLEND); …
Andrew
  • 896
  • 2
  • 12
  • 31
2
votes
1 answer

Is it possible to accumulate fragment numbers on a uint32 format texture?

I want to count the number of fragments on each pixel (with depth test disabled). I have tried enabling blending and setting glBlendFunc(GL_ONE,GL_ONE) to accumulate them. This works just fine with a float32 format texture binding to a FBO, but I…
2
votes
1 answer

OpenGL Blending - fill intersections with a different color

I'm rendering a bunch of shapes on the screen (polygons), and I'm not using depth test. I simply want those shapes to use their own color when they're drawn over the empty space, and to to be red pixels whenever they're drawn over anything not…
Vlad Vyatkin
  • 544
  • 5
  • 16
2
votes
2 answers

OpenGL Multi Bit Alpha Textures

I'm having some troubles rendering a texture that has a 8 bit alpha channel - namely, its being flattened to 1 bit and glBlendFunc() doesn't seem to be doing anything. Here is the immediate mode…
Tomas
  • 1,379
  • 1
  • 13
  • 20
2
votes
0 answers

Why does a black source color with glBlendFunc(GL_SRC_ALPHA, GL_ONE); still cause a change in the destination color?

I am trying to develop a particle system in C++ using OpenGL, and I am confused about how blending works. I am trying to use additive blending, and from my understanding, calling the glBlendFunc function with the following…
Jeremy
  • 145
  • 2
  • 12
2
votes
1 answer

OpenGL: Overlay one texture over another and suppress white background

I am a starter of Iphone opengl ES programming. I have two textures, the first one is the background and occupies the full screen. I am printing the second picture on top of the first image but the white background of the second image covers part of…
user371260
  • 71
  • 2
  • 5
2
votes
1 answer

Preserving the GLBlendFunc

I need to preserve the current GlBlendFunc so can restore it after I do some work. It seems that this is not one of the attributes that can be saved with GLPushAttrib, is there some other similar method I can use to preserve the state?
Mike2012
  • 7,629
  • 15
  • 84
  • 135
1
2 3 4