Sign in to follow this  

Can anyone help with glBlendFunc?

Recommended Posts

Can I use the glBlendFunc to perform XOR operation? How can I do? Can I use multi-glBlendFunc for one fragment? Pls help, THX

Share this post

Link to post
Share on other sites
Red Book Ch 10

Does this thing still exist in openGL?
Logical Operations

The final operation on a fragment is the logical operation, such as an OR, XOR, or INVERT, which is applied to the incoming fragment values (source) and/or those currently in the color buffer (destination). Such fragment operations are especially useful on bit-blt-type machines, on which the primary graphics operation is copying a rectangle of data from one place in the window to another, from the window to processor memory, or from memory to the window. Typically, the copy doesn't write the data directly into memory but instead allows you to perform an arbitrary logical operation on the incoming data and the data already present; then it replaces the existing data with the results of the operation.

Since this process can be implemented fairly cheaply in hardware, many such machines are available. As an example of using a logical operation, XOR can be used to draw on an image in an undoable way; simply XOR the same drawing again, and the original image is restored. As another example, when using color-index mode, the color indices can be interpreted as bit patterns. Then you can compose an image as combinations of drawings on different layers, use writemasks to limit drawing to different sets of bitplanes, and perform logical operations to modify different layers.

You enable and disable logical operations by passing GL_INDEX_LOGIC_OP or GL_COLOR_LOGIC_OP to glEnable() and glDisable() for color-index mode or RGBA mode, respectively. You also must choose among the sixteen logical operations with glLogicOp(), or you'll just get the effect of the default value, GL_COPY. (For backward compatibility with OpenGL Version 1.0, glEnable(GL_LOGIC_OP) also enables logical operation in color-index mode.)

void glLogicOp(GLenum opcode);
Selects the logical operation to be performed, given an incoming (source) fragment and the pixel currently stored in the color buffer (destination). Table 10-4 shows the possible values for opcode and their meaning (s represents source and d destination). The default value is GL_COPY.

Table 10-4 : Sixteen Logical Operations...
with GL_XOR

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this