<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.2//EN" "DTD/docbook/docbookx.dtd">
<!--
License Applicability. Except to the extent portions of this file are
made subject to an alternative license as permitted in the SGI Free
Software License B, Version 1.1 (the "License"), the contents of this
file are subject only to the provisions of the License. You may not use
this file except in compliance with the License. You may obtain a copy
of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
http://oss.sgi.com/projects/FreeB
Note that, as provided in the License, the Software is distributed on an
"AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
Original Code. The Original Code is: OpenGL ES Reference Manual,
Version 1.0, released September 2003, developed by Silicon Graphics,
Inc. The Original Code is Copyright (c) 2003 Silicon Graphics, Inc.
Copyright in any portions created by third parties is as indicated
elsewhere herein. All Rights Reserved.
-->
<refentry id="glLogicOp">
<refmeta>
<refentrytitle>glLogicOp</refentrytitle>
<manvolnum>3G</manvolnum>
</refmeta>
<refnamediv>
<refname>glLogicOp</refname>
<refpurpose>specify a logical pixel operation</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>C Specification</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>glLogicOp</function></funcdef>
<paramdef>GLenum <parameter>opcode</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term>
<parameter>opcode</parameter>
</term>
<listitem>
<para>Specifies a symbolic constant that selects a
logical operation. The following symbols are accepted:
<constant>GL_CLEAR</constant>,
<constant>GL_SET</constant>,
<constant>GL_COPY</constant>,
<constant>GL_COPY_INVERTED</constant>,
<constant>GL_NOOP</constant>,
<constant>GL_INVERT</constant>,
<constant>GL_AND</constant>,
<constant>GL_NAND</constant>,
<constant>GL_OR</constant>,
<constant>GL_NOR</constant>,
<constant>GL_XOR</constant>,
<constant>GL_EQUIV</constant>,
<constant>GL_AND_REVERSE</constant>,
<constant>GL_AND_INVERTED</constant>,
<constant>GL_OR_REVERSE</constant>, and
<constant>GL_OR_INVERTED</constant>. The initial value is
<constant>GL_COPY</constant>.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para><function>glLogicOp</function>
specifies a logical operation that, when enabled, is applied
between the incoming color and the color at the corresponding
location in the frame buffer.
To enable or disable the logical operation, call
<citerefentry><refentrytitle>glEnable</refentrytitle></citerefentry> and
<citerefentry><refentrytitle>glDisable</refentrytitle></citerefentry>
with argument <constant>GL_COLOR_LOGIC_OP</constant>.
Logical operation is initially disabled.
</para>
<informaltable frame="none">
<tgroup cols="2" align="center">
<colspec align="left"/>
<colspec align="center"/>
<thead>
<row>
<entry align="left">Opcode</entry>
<entry>Resulting Operation</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>GL_CLEAR</constant></entry>
<entry>0</entry>
</row>
<row>
<entry><constant>GL_SET</constant></entry>
<entry>1</entry>
</row>
<row>
<entry><constant>GL_COPY</constant></entry>
<entry><replaceable>s</replaceable></entry>
</row>
<row>
<entry><constant>GL_COPY_INVERTED</constant></entry>
<entry>
<inlineequation><math>
<mo>~</mo><mi>s</mi>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_NOOP</constant></entry>
<entry><replaceable>d</replaceable></entry>
</row>
<row>
<entry><constant>GL_INVERT</constant></entry>
<entry>
<inlineequation><math>
<mo>~</mo><mi>d</mi>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_AND</constant></entry>
<entry>
<inlineequation><math>
<mi>s</mi><mo>&</mo><mi>d</mi>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_NAND</constant></entry>
<entry>
<inlineequation><math>
<mo>~</mo><mfenced><mrow><mi>s</mi><mo>&</mo><mi>d</mi></mrow></mfenced>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_OR</constant></entry>
<entry>
<inlineequation><math>
<mi>s</mi><mo>|</mo><mi>d</mi>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_NOR</constant></entry>
<entry>
<inlineequation><math>
<mo>~</mo><mfenced><mrow><mi>s</mi><mo>|</mo><mi>d</mi></mrow></mfenced>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_XOR</constant></entry>
<entry>
<inlineequation><math>
<mi>s</mi><mo>^</mo><mi>d</mi>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_EQUIV</constant></entry>
<entry>
<inlineequation><math>
<mo>~</mo><mfenced><mrow><mi>s</mi><mo>^</mo><mi>d</mi></mrow></mfenced>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_AND_REVERSE</constant></entry>
<entry>
<inlineequation><math>
<mi>s</mi><mo>&</mo><mo>~</mo><mi>d</mi>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_AND_INVERTED</constant></entry>
<entry>
<inlineequation><math>
<mo>~</mo><mi>s</mi><mo>&</mo><mi>d</mi>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_OR_REVERSE</constant></entry>
<entry>
<inlineequation><math>
<mi>s</mi><mo>|</mo><mo>~</mo><mi>d</mi>
</math></inlineequation>
</entry>
</row>
<row>
<entry><constant>GL_OR_INVERTED</constant></entry>
<entry>
<inlineequation><math>
<mo>~</mo><mi>s</mi><mo>|</mo><mi>d</mi>
</math></inlineequation>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
<parameter>opcode</parameter>
is a symbolic constant chosen from the list above. In the
explanation of the logical operations, <parameter>s</parameter>
represents the incoming color and <parameter>d</parameter>
represents the color in the frame buffer. Standard C-language
operators are used. As these bitwise operators suggest, the
logical operation is applied independently to each bit pair of
the source and destination indices or colors.</para>
</refsect1>
<refsect1>
<title>Errors</title>
<para><constant>GL_INVALID_ENUM</constant> is generated if
<parameter>opcode</parameter> is not an accepted value.</para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>glAlphaFunc</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glBlendFunc</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glEnable</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glStencilOp</refentrytitle></citerefentry>
</para>
</refsect1>
</refentry>