1

I am making a game in OpenGL and C++ and I want to add a little red tint to everything. I decided to do this by clearing the screen red after rendering everything but making the alpha channel a low number Here is what I tried :

// inside main function (called once)
glEnable(GL_BLEND); 
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

// render loop (called every frame)
// drawing code here ...

glClearColor(8.0f, 0.0f, 0.0f, 0.3f);
glClear(GL_COLOR_BUFFER_BIT);

I expected this to put a red tint over everything, but this just turned the entire screen red. Is there any way to make the alpha value in glClearColor() work?

1
  • There's no way to do alpha blending with glClear Commented Jul 27, 2021 at 2:55

1 Answer 1

1

When you clear the framebuffer, you clear the framebuffer. You aren't doing a rendering process (which is the only time that blending matters). You're setting the value of every pixel in the framebuffer to a specific value. Just like when you set a block of memory to a value, you're setting that memory to that value.

If you want to do some kind of full-screen tint operation, then you're going to have to render a full-screen quad with blending or something of that nature.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.