Reputation: 13
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?
Upvotes: 1
Views: 792
Reputation: 474436
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.
Upvotes: 1