Game Development Reference
In-Depth Information
Alpha Compositing and Blending
Before we can start designing our graphics module interfaces, we have to tackle one more thing:
image compositing. For the sake of this discussion, assume that we have a framebuffer to which
we can render, as well as a bunch of images loaded into RAM that we'll throw at the framebuffer.
Figure 3-25 shows a simple background image, as well as Bob, a zombie-slaying ladies' man.
Figure 3-25. A simple background and Bob, master of the universe
To draw Bob's world, we'd first draw the background image to the framebuffer, followed by
Bob over the background image in the framebuffer. This process is called compositing , as we
compose different images into a final image. The order in which we draw images is relevant, as
any new drawing operation will overwrite the current contents in the framebuffer. So, what would
be the final output of our compositing? Figure 3-26 shows it to you.
Figure 3-26. Compositing the background and Bob into the framebuffer (not what we wanted)
Ouch, that's not what we wanted. In Figure 3-26 , notice that Bob is surrounded by white pixels.
When we draw Bob on top of the background to the framebuffer, those white pixels also get
drawn, effectively overwriting the background. How can we draw Bob's image so that only Bob's
pixels are drawn and the white background pixels are ignored?
 
Search WWH ::




Custom Search