Graphics Programs Reference
In-Depth Information
Figure 5-1 . Using color masks
You can set color masks using the ES 2.0 function glColorMask . This function
takes four Boolean arguments, where each argument corresponds to the “writable”
state of a component in the color buffer. To use this function correctly, color mask(s)
should be set before each call to any glDraw* function.
To understand this function, consider the following example. Suppose you render
two rectangles—rectangleOne (cyan colored) and rectangleTwo (white
colored)—and you want to render only the green component of rectangleOne and the
red component of rectangleTwo.
To make this work, before you render each of these rectangles (by calling any of
glDraw* ES 2.0 functions) using their separate programs, you must set the color
masks in the following manner:
▪ For rectangleOne, set the color mask by calling
GLES20.glColorMask(false, true, false,
true) . Since the green and alpha components are enabled, only
the green color will be visible.
▪ For rectangleTwo, set the color mask by calling
GLES20.glColorMask(true, false, false,
true) . Since the red and alpha components are enabled, only the
red color will be visible.
 
Search WWH ::




Custom Search