# Thread: Not increasing alpha value in frame buffer

1. ## Not increasing alpha value in frame buffer

Now it works like that:

• Draw vertices array to framebuffer (framebuffer contents is black color, drawable quads (from vertices array) has white textures with various alpha values)
• If in same place is drawed two quads who's texture's alpha is 0.5, that place has white quad with 1.0 alpha

How to do so that if the place where I draw a textured quad with 0.5 alpha already has half-opaque white quad, don't add its alpha value to it (leave it white with 0.5 alpha)? And if I draw textured quad with 0.7 alpha on it, change that place's alpha to 0.7. And if I draw textured quad with for example 0.3 alpha on it, ignore it?

So it should look like this:
(number is white color's alpha value)
(where 0.0 it is black and where number is not 0.0, it means that there is drawn white quad with alpha equal to number represented in brackets)

in the beginning my image looks like this:
(0.0)(0.0)(0.0)(0.0)

after drawing this image:
(0.0)(0.0)(0.5)(0.0)

on it I should get:
(0.0)(0.0)(0.5)(0.0)

after drawing this image:
(0.0)(0.0)(0.3)(0.0)

on top of it, it's alpha is ignored because it is smaller than one that already is there and I get:
(0.0)(0.0)(0.5)(0.0)

after drawing this image:
(0.0)(0.0)(0.7)(0.0)

on top of it, I get:
(0.0)(0.0)(0.7)(0.0)

2. If in same place is drawed two quads who's texture's alpha is 0.5, that place has white quad with 1.0 alpha
http://www.opengl.org/sdk/docs/man/x...ndEquation.xml

It is important to fully understand how successive draw functions with an alpha value effect a pixel

3. Thank you. That helped me allot.

4. So now I use

Code :
`glBlendEquationSeparate(GL_FUNC_ADD, GL_MIN);`

and it works fine with the circumstances I described above. But the continue of question would sound like that:

My vertex-array depends on user mouse events. And if user drags a mouse, vertices are being recorded to vertex array and drawn to screen. And how now to do so that, when mouse is up, save the state, and if user drags mouse again over the place where vertices have been already drawn earlier, increase the alpha value, and if he drags mouse over the place where vertices have been already drawn in this mouse-drag period (after first mouse-up but before second), don't increase alpha value?

5. I am not sure what outcome you want. If the alpha value change is only effecting the vertex just change that alpha value in the vertex structure and redraw the screen.

6. I will explain outcome that I want.

So, user presses and drags mouse (draws). It acts like that:

mouseDown and mouseDragged events is being executed. Their coordinates are written to vertex-array (from every event I create 4 coordinates so that I could get quad), and then vertex array is drawn to framebuffer, and framebuffer is drawn to screen.

If drawable object opacity is set to 0.5, no matter how many times I draw it it still stays at 0.5. And I want so that:

For example I set drawable object opacity to 0.5, I draw one stroke (one mouseDown and much mouseDragged events). It should work like it works now, no matter how many times quad overlaps itself it's opacity stays 0.5. Then mouse is up (mouseUp event executed). And I press mouse and draw next stroke with same opacity setted. If current stroke overlaps stroke that has ben drawn earlier, that place should have 1.0 opacity, and if it overlaps itself opacity should stay 0.5.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•