Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8165419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:31:57+00:00 2026-06-06T19:31:57+00:00

I fallowed @Stefan Monov tutorial in this question . And everything works, but I

  • 0

I fallowed @Stefan Monov tutorial in this question. And everything works, but I need to make it working with my brush. I need to do so:

// Next, we want a blendfunc that doesn't change the color of any pixels,
// but rather replaces the framebuffer alpha values with values based
// on the whiteness of the mask. In other words, if a pixel is white in the mask,
// then the corresponding framebuffer pixel's alpha will be set to 1.
glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO);
// Now "draw" the mask (again, this doesn't produce a visible result, it just
// changes the alpha values in the framebuffer)
drawQuad(maskTexture);

would be not a static texture, but dynamic shape. I mean, i’m trying to implement brush witch is doing such a thing that is written by @Stefan Monov. So I need that this place could be implemented in other – (void) function, so that it could be called, when coordinates changes (when user draws). I tried a variety of ways to change the sequence of your code, but it does not work correctly then. Now my bursh code is:

glEnable(GL_BLEND);
glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO);
glPointSize(100);
glBegin(GL_POINTS);
glColorMask(1.0,1.0,1.0, 1.0);
glVertex2f(loc.x, loc.y);
glEnd();
glDisable(GL_BLEND);

It is called when mouse is dragged. “loc” is dragged mouse coordinates. Afcourse its not working now at all, because of blendFunc and code’s sequence. When I leave sequence as @Stefan Monov described, it works, but it draws one point and drags it when mouse is dragged. Becouse after drawing point, other textures is being redrawed too. Any, at least similar, solution for it?


To make it more clear i’ll show how I want my APP to work.

Here is the original code:

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
drawQuad(backgroundTexture);

glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO);
drawQuad(maskTexture);

glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
drawQuad(foregroundTexture);

Now its working like this:

  1. Draws background
  2. Draws mask
  3. Draws foreground

I need it to work like this:

  1. Draws bacground
  2. Draws foreground
  3. Draws mask

But if i change the order of drawings it stops working. Ignores mask.

Expected result foto:
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:31:58+00:00Added an answer on June 6, 2026 at 7:31 pm

    Your attempt to draw the mask last makes no sense really.

    Drawing the mask only modifies what’s in the alpha channel, and the alpha channel itself is not visible in any way in the final image.

    The only use of the mask is to modify what’s drawn after it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Followed this question about delayed_job and monit Its working on my development machine. But
I followed this tutorial but still I go to the webpage refresh, then go
I fallowed recommendation in this SO question: What's the best solution for OpenID with
I followed the tutorial from this site: http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone/ to make my first iPhone application,
I followed this tutorial . But whenever I try to log in with my
I followed this link to gzip my php driven website It's working fine but
I followed this tutorial to implement facebook into my application. All I want is
I followed along this tutorial for django's RSS and ATOM feeds and I got
I followed this tutorial: https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf However, I can't seem to set the path right.
I followed this simple tutorial and created a nested repeater. This tutorial is simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.