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
2
votes
2 answers

OpenGL ES blend func so color always shows against background

I am using OpenGL ES 1.1 to draw lines in my iPad app. I want to make sure that the drawn lines are always visible on the screen regardless of the background colors, and without allowing the user to choose a color. Is there a blend function that…
Nate_Hirsch
  • 671
  • 1
  • 6
  • 12
1
vote
1 answer

OpenGL: glTexEnvi, glBlendFunc and On Screen Text Messages

I'm developing a movie player and I'm using OpenGL to draw frames and On Screen Messages. To draw the frame I use: glBegin(GL_QUADS); // Draw the quads glTexCoord2f(0.0f, 0.0f); glVertex2f (_movieRect.origin.x,_movieRect.origin.y +…
Andrea3000
  • 1,018
  • 1
  • 11
  • 26
1
vote
2 answers

How to animate gtlf models in Augmented reality in Three.js

Helle, I'm new to Three.js and I'm trying to show an animated gltf/glb model in my AR project. There are a lot of examples on how to animate gltf models in a 3d environment but i can't get it to work in my AR project. I can import the 3d model and…
1
vote
1 answer

how can i use glblendfuc to blend two image?

I want to blend two texture in my shader,so my code in shader like this: out vec4 fragColor1; out vec4 fragColor2; void main(){ fragColor1=vec4(1.0,0.0,0.0,1.0); fragColor2=vec4(0.0,1.0,0.0,1.0); } when i use…
isaiah.li
  • 35
  • 5
1
vote
3 answers

Mixing Audio Using OpenGL

I want to mix two (or more) 16bit audio streams using OpenGL and I need a bit of help Basically what I want to do is to put the audio data into texture which I draw to a frame buffer object and then read back. This is not a problem, however drawing…
ronag
  • 49,529
  • 25
  • 126
  • 221
1
vote
1 answer

GL_TRIANGLE_STRIP and transparency problems

I want to draw transparent polygon(a pyramid for example). Some faces appear transparent where as some faces appear opaque. Im drawing using GL_TRIANGLE_STRIP. I have enabled blend mode, but no luck. Please see the attached image,
vaishak
  • 63
  • 7
1
vote
1 answer

iPhone glBlendFunc error

I'm trying to use the glBlendFunc, but it's failing on the first call, with the error "unacceptable value specified for an enumerated argument". I've looked at the header, it appears that GL_DST_COLOR is 0x0306 (774) and that is causing the error,…
Andrew
  • 1,497
  • 1
  • 14
  • 22
1
vote
1 answer

Additive blending of positive and negative color fragments in a single render pass

I'm working on a WebGL project that resembles a particle system. For aesthetic purposes, my single rendering pass is configured to blend additively, and I've disabled depth testing. I'm also clearing my viewport buffer to 50% gray, for the sake of…
Rezmason
  • 115
  • 1
  • 1
  • 10
1
vote
1 answer

OpenGL ES 2.0 blending

I set glBlendFunc to glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); and for testing purposes I set the color in my fragment shader like this gl_FragColor = vec4(1.0,0.0,0.0,0.0); Shouldn't the object be fully transparent? What…
cboe
  • 469
  • 1
  • 9
  • 25
1
vote
1 answer

Using multiple blendfunc OpenGL

I want to use glBlendFunc(GL_ONE, GL_ONE) and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) at the same time. Is this possible?
1
vote
1 answer

Cocos2dx CCRendertexture and framebuffer object problems. My new texture doesn't look the same. Alpha values are incorrect

I'm having a bit of a problem trying to use the CCRenderTexture class from Cocos2Dx for the iPhone (which, as I understand it, is just a FBO class). I have a class that derives from CCSprite. Within it, I'm trying to draw a texture to a…
1
vote
1 answer

Deferred Rendering Pipeline Not Working On Laptop Graphics Cards, and Odd "Model Ghosting" Problems (glBlendFunc)

EDIT: Changing the fragment shader so only one light per-run was possible solved my first problem. My second problem still stands. thanks in advance for any help you can offer. I have been working on a deferred shading pipeline for my LWJGL…
Spaceman1701
  • 413
  • 5
  • 13
1
vote
1 answer

WebGL blendFunc bug or misunderstanding?

I'm trying to draw a semi-transparent black triangle on a black background. Here's my sample: http://codewithoutborders.com/posted/blend.html The blendFunc is set and enabled (line 151): gl.blendFunc(gl.SRC_ALPHA,…
Spongman
  • 9,665
  • 8
  • 39
  • 58
1
vote
0 answers

Alpha Blending for a Drawing App in cocos2d

Im using cocos2d to create a simple drawing app, I create a 32 bit texture in code in the shape of the brush i need (circle) with a simple hardness gradient (alpha = 1 in middle and alpha = 0 close to edge) The texture is obviously square so alpha…
bobjamin
  • 265
  • 1
  • 2
  • 11
0
votes
1 answer

Cannot render glb file in frontend, instead it showing a black image

I am trying to call the glb file from the backend server just like I did with the 2d image, how to modify the code if it is glb file and I can interact with the glb rendered image, redult coming is black image {!!images?.length && …
Roy
  • 29
  • 4