<?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="glCopyTexSubImage2D">
<refmeta>
<refentrytitle>glCopyTexSubImage2D</refentrytitle>
<manvolnum>3G</manvolnum>
</refmeta>
<refnamediv>
<refname>glCopyTexSubImage2D</refname>
<refpurpose>specify a two-dimensional texture subimage with pixels from the color buffer</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>C Specification</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>glCopyTexSubImage2D</function></funcdef>
<paramdef>GLenum <parameter>target</parameter></paramdef>
<paramdef>GLint <parameter>level</parameter></paramdef>
<paramdef>GLint <parameter>xoffset</parameter></paramdef>
<paramdef>GLint <parameter>yoffset</parameter></paramdef>
<paramdef>GLint <parameter>x</parameter></paramdef>
<paramdef>GLint <parameter>y</parameter></paramdef>
<paramdef>GLsizei <parameter>width</parameter></paramdef>
<paramdef>GLsizei <parameter>height</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Parameters</title>
<variablelist>
<varlistentry>
<term>
<parameter>target</parameter>
</term>
<listitem>
<para>Specifies the target texture. Must be
<constant>GL_TEXTURE_2D</constant>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>level</parameter>
</term>
<listitem>
<para>Specifies the level-of-detail number. Level 0 is
the base image level. Level <parameter>n</parameter>
is the <parameter>n</parameter>th mipmap reduction image.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>xoffset</parameter>
</term>
<listitem>
<para>Specifies a texel offset in the x direction within
the texture array.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>yoffset</parameter>
</term>
<listitem>
<para>Specifies a texel offset in the y direction within
the texture array.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>x</parameter>, <parameter>y</parameter>
</term>
<listitem>
<para>Specify the window coordinates of the lower left
corner of the rectangular region of pixels to be
copied.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>width</parameter>
</term>
<listitem>
<para>Specifies the width of the texture subimage.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<parameter>height</parameter>
</term>
<listitem>
<para>Specifies the height of the texture subimage.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para><function>glCopyTexSubImage2D</function>
replaces a rectangular portion of a two-dimensional texture
image with pixels from the color buffer.
</para>
<para>The screen-aligned pixel rectangle with lower left corner at (
<parameter>x</parameter>, <parameter>y</parameter>) and with width
<parameter>width</parameter> and height
<parameter>height</parameter>
replaces the portion of the texture array with x indices
<parameter>xoffset</parameter> through
<inlineequation><math>
<mi>xoffset</mi><mo>+</mo><mi>width</mi><mo>-</mo><mn>1</mn>
</math></inlineequation>,
inclusive, and y indices
<parameter>yoffset</parameter> through
<inlineequation><math>
<mi>yoffset</mi><mo>+</mo><mi>height</mi><mo>-</mo><mn>1</mn>
</math></inlineequation>,
inclusive, at the mipmap level specified by
<parameter>level</parameter>.</para>
<para>The pixels in the rectangle are processed the same way
as with
<citerefentry><refentrytitle>glCopyTexImage2D</refentrytitle></citerefentry>.
</para>
<para><function>glCopyTexSubImage2D</function> requires
that the internal format of the currently bound texture is such that
color buffer components can be dropped during conversion to the
internal format, but new components cannot be added. For example,
an <constant>RGB</constant> color buffer can be used to create
<constant>LUMINANCE</constant> or <constant>RGB</constant>
textures, but not <constant>ALPHA</constant>,
<constant>LUMINANCE_ALPHA</constant> or <constant>RGBA</constant>
textures.</para>
<para>The destination rectangle in the texture array may not
include any texels outside the texture array as it was
originally specified. It is not an error to specify a
subtexture with zero width or height, but such a specification
has no effect.</para>
<para>If any of the pixels within the specified rectangle of
the current color buffer are outside the read window associated
with the current rendering context, then the values obtained
for those pixels are undefined.</para>
<para>No change is made to the
<parameter>internalformat</parameter>,
<parameter>width</parameter>,
<parameter>height</parameter>, or
<parameter>border</parameter>
parameters of the specified texture array or to texel values
outside the specified subregion.</para>
</refsect1>
<refsect1>
<title>Errors</title>
<para><constant>GL_INVALID_ENUM</constant> is generated if
<parameter>target</parameter> is not
<constant>GL_TEXTURE_2D</constant>.</para>
<para><constant>GL_INVALID_OPERATION</constant> is generated if
the texture array has not been defined by a previous
<citerefentry><refentrytitle>glTexImage2D</refentrytitle></citerefentry>
or
<citerefentry><refentrytitle>glCopyTexImage2D</refentrytitle></citerefentry>
operation or if the internal format of the currently bound texture
is not compatible with the color buffer format.</para>
<para><constant>GL_INVALID_VALUE</constant> is generated if
<parameter>level</parameter> is less than 0.</para>
<para><constant>GL_INVALID_VALUE</constant> may be generated if
<parameter>level</parameter> is greater than
<inlineequation><math>
<msub><mo>log</mo><mn>2</mn></msub><mi>max</mi>
</math></inlineequation>, where
<replaceable>max</replaceable> is the returned value of
<constant>GL_MAX_TEXTURE_SIZE</constant>.</para>
<para><constant>GL_INVALID_VALUE</constant> is generated if
<inlineequation><math>
<mi>x</mi><mo><</mo><mo>-</mo><mi>b</mi>
</math></inlineequation>, or
<inlineequation><math>
<mi>y</mi><mo><</mo><mo>-</mo><mi>b</mi>
</math></inlineequation>, where
<replaceable>b</replaceable> is the border
of the texture being modified.</para>
<para><constant>GL_INVALID_VALUE</constant> is generated if
<inlineequation><math>
<mi>xoffset</mi><mo><</mo><mo>-</mo><mi>b</mi>
</math></inlineequation>,
<inlineequation><math>
<mi>xoffset</mi><mo>+</mo><mi>width</mi><mo>></mo>
<mfenced><mrow><mi>w</mi><mo>-</mo><mi>b</mi></mrow></mfenced>
</math></inlineequation>,
<inlineequation><math>
<mi>yoffset</mi><mo><</mo><mo>-</mo><mi>b</mi>
</math></inlineequation>, or
<inlineequation><math>
<mi>yoffset</mi><mo>+</mo><mi>height</mi><mo>></mo>
<mfenced><mrow><mi>h</mi><mo>-</mo><mi>b</mi></mrow></mfenced>
</math></inlineequation>, where
<replaceable>w</replaceable> is the texture width,
<replaceable>h</replaceable> is the texture height, and
<replaceable>b</replaceable> is the border of the texture
image being modified.
Note that <replaceable>w</replaceable> and <replaceable>h</replaceable>
include twice the border width.</para>
</refsect1>
<refsect1>
<title>Associated Gets</title>
<para>
<citerefentry><refentrytitle>glGetInteger</refentrytitle></citerefentry>
with argument <constant>GL_MAX_TEXTURE_SIZE</constant></para>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>glCompressedTexSubImage2D</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glCopyTexImage2D</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glGetInteger</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glTexEnv</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glTexImage2D</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glTexParameter</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glTexSubImage2D</refentrytitle></citerefentry>
</para>
</refsect1>
</refentry>