[ Previous | Next | Contents | Glossary | Home | Search ]
GL3.2 for AIX: Graphics Library (GL) Technical Reference

logicop Subroutine

Purpose

Specifies the logical, arithmetic, or comparison operation for pixel updates.

Libraries

Graphics Library

C (libgl.a)

FORTRAN (libfgl.a)

C Syntax

void logicop(Int32 opcode)

FORTRAN Syntax

SUBROUTINE LOGICO(opcode)
INTEGER*4 opcode

Description

The logicop subroutine specifies the bitwise logical, arithmetic, or comparison operation for pixel updates. The operation is applied between the incoming (source) and existing (destination) values to generate the final pixel value. In color map mode, all writemask-enabled index bits (up to 12) are changed. In RGB mode, all enabled component bits (up to 32) are changed.

The logicop subroutine defaults to the value of LO_SRC, meaning that the incoming (source) value replaces the existing (destination) value.

The arithmetic and comparison operations treat each channel (R, G, and B) separately. That is, the result of an arithmetic or comparison operation in one channel does not affect the others; each channel is treated as a separate 8-bit entity, rather than a part of a 24-bit quantity. For example, if the opcode parameter is set to the LO_MAX value, if the current pixel has an RGB intensity of (119, 34, 230), and the incoming pixel has an intensity of (180, 180, 180), the final pixel value is (180, 180, 230).

The pixel color comparisons do not affect the way the z-buffer works. Z-buffer comparisons and color comparisons can be done simultaneously. The color of a pixel is updated only if the z-buffer comparison passed first; the color is then updated if the color comparison test passes. This function is more general than that provided by the zsource subroutine with a ZSRC_COLOR setting because it does not disable z-comparisons the way that the zsource subroutine does.

The arithmetic operations in each channel saturate, rather than wrap around. Because each color channel is 8 bits deep, color values saturate at 255 and 0. For example, if the opcode parameter is set to the LO_SUM value, if the current pixel has an RGB intensity of (119, 34, 230), and the incoming pixel has an intensity of (180, 180, 180), then the final pixel value is (255, 214, 255).

It is not possible to do logical and blending operations simultaneously. When the opcode parameter is set to any value other than LO_SRC, the blendfunction subroutine values sfactor and dfactor are forced to their default values, BF_ONE and BF_ZERO, respectively. Likewise, calling the blendfunction subroutine with arguments other than BF_ONE and BF_ZERO forces the logical opcode to a value of LO_SRC.

Unlike the blendfunction subroutine, the logicop subroutine is valid in all drawing modes (NORMALDRAW, UNDERDRAW, OVERDRAW, PUPDRAW, CURSORDRAW) and in both color map and RGB modes. Like the blendfunction subroutine, it affects all drawing operations, including points, lines, polygons, and pixel area transfers. The logicop subroutine does not affect pixel block transfers (blits) into the z-buffer.

The logicop subroutine functions in systems without alpha bitplanes.

Note: Use the logicop subroutine when drawing antialiased lines to improve the appearance of intersecting lines.

Parameter

opcode Token indicating which of the following operations should be in effect:
C FORTRAN Operation
LO_ZERO LOZERO 0
LO_AND LOAND src AND dst
LO_ANDR LOANDR src AND (NOT dst)
LO_SRC LOSRC src
LO_ANDI LOANDI (NOT src) AND dst
LO_DST LODST dst
LO_XOR LOXOR src XOR dst
LO_OR LOOR src OR dst
LO_NOR LONOR NOT (src OR dst)
LO_XNOR LOXNOR NOT (src XOR dst)
LO_NDST LONDST NOT dst
LO_ORR LOORR src OR (NOT dst)
LO_NSRC LONSRC NOT src
LO_ORI LOORI (NOT src) OR dst
LO_NAND LONAND NOT (src AND dst)
LO_ONE LOONE 1
LO_MAX LOMAX D=Maximum (S, D)
LO_MIN LOMIN D=Minimum (S, D)
LO_SUM LOSUM D= D + S (saturated)
LO_DMS LODMS D= D - S (saturated)
LO_SMD LOSMD D= S - D (saturated)
LO_AVG LOAVG D=(S + D) / 2

Implementation Specifics

This subroutine is part of GL in the AIXwindows Environment/6000 Version 1, Release 2 with AIXwindows/3D Feature.

The numeric assignment of the 22 operation names were chosen to be identical to those defined by the AIXwindows system.

The LO_MAX, LO_MIN, LO_SUM, LO_DMS, LO_SMD, and LO_AVG values are not supported on the 3-D Color Graphics Processor, the Supergraphics Processor Subsystem, or the POWER GXT1000 adapter.

Files

/usr/include/gl/gl.h Contains C language constant and variable type definitions for GL.
/usr/include/gl/fgl.h Contains FORTRAN constant and variable type definitions for GL.

Related Information

Specifying the alpha blending ratio with the blendfunction subroutine.

Specifying either depth or color as the source for z comparisons with the zsource subroutine.

Configuring the Frame Buffer.

Writemasks and Logical Operations and Working in Color Map and RGB Modes.


[ Previous | Next | Contents | Glossary | Home | Search ]