Reputation: 127
Im studying open gl and I came across GL_BLEND. Its kinda confusing to understand the practical usage of it, so if somebody got experience in using it, can you explain it to me?
Upvotes: 3
Views: 5780
Reputation: 162317
You know how "Layers" work in Photoshop (or similar image editing programs) and what the "merge layers" function does? It's the same principle: There's a "bottom" layer (the destination) and a "top" layer (the source) that has the pixels of a single primitive (triangle, line, point). For every triangle, line or point drawn the "bottom" layer of what's currently in the framebuffer is merged with the newly incoming layer of that single triangle, line or point. The exact mode of composition is controlled through the blending function, set with glBlendFunc
. Each single primitive (triangle, line, point) drawn "adds" a new layer and immediately merges that with the bottom layer.
The practical application is everything you'd do with layers in Photoshop. For example you may have a stock photo of a window, where the glass is translucent. The same works in OpenGL where you can draw geometry where parts of it are rendered translucent and blend with what's been drawn before.
Upvotes: 8