So I need to draw transparent brush strokes to OpenGL texture, to use it as mask later on. I have brush image (black square with transparent circle). And I need to draw brush stroke of that transparent part of brush texture to other opengl texture. I know how to do it directly drawing and blending, but now firstly I need to draw to texture. I was using code like this for that what I want to achieve. And it was working. But how can I firstly draw mask to texture (i know how to draw something to texture using FBO, but how to draw nice transparent brush strokes to it and make texture for example fully black, with only brushstrokes transparent?), and only then use this texture as mask. So if now I am acting like that:
Code :glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ZERO); //draw background glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO); //Draw vertexarray for brush strokes. glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA); //draw foreground
I want to act like that:
Code :glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, someFramebufferForBrushStroke); //draw vertexarray for brush strokes to texture glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ZERO); //draw background glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO); //Draw mask quad texture (texture witch is binded as GL_COLOR_ATTACHMENT to my frame buffer glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA); //draw foreground
Now I drag mouse, and OpenGL draws textured(my brush texture) quad at every mouse event location.
I want to: when I drag mouse openGL draws whole vertex array to texture (all these textured quads at mouse location, witch in my current method draws directly to screen), and then uses that texture as mask (draws full size quad).
Its OK with drawing to texture, but just what blending or something I should use to tell opengl to make transparent parts of texture where in my brush texture is transparent circle and to ignore black square around transparent circle?