| 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd"> |
| 3 | <!-- saved from url=(0013)about:internet --> |
| 4 | <?xml-stylesheet type="text/xsl" href="mathml.xsl"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:pref="http://www.w3.org/2002/Math/preference" pref:renderer="mathplayer-dl"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="stylesheet" type="text/css" href="opengl-man.css" /><title>glTexSubImage2D - OpenGL 3.3 Reference Pages</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="glTexSubImage2D"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>glTexSubImage2D — specify a two-dimensional texture subimage</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">void <b class="fsfunc">glTexSubImage2D</b>(</code></td><td>GLenum </td><td><var class="pdparam">target</var>, </td></tr><tr><td> </td><td>GLint </td><td><var class="pdparam">level</var>, </td></tr><tr><td> </td><td>GLint </td><td><var class="pdparam">xoffset</var>, </td></tr><tr><td> </td><td>GLint </td><td><var class="pdparam">yoffset</var>, </td></tr><tr><td> </td><td>GLsizei </td><td><var class="pdparam">width</var>, </td></tr><tr><td> </td><td>GLsizei </td><td><var class="pdparam">height</var>, </td></tr><tr><td> </td><td>GLenum </td><td><var class="pdparam">format</var>, </td></tr><tr><td> </td><td>GLenum </td><td><var class="pdparam">type</var>, </td></tr><tr><td> </td><td>const GLvoid * </td><td><var class="pdparam">data</var><code>)</code>;</td></tr></table></div></div><p> |
| 5 | </p><div class="refsect1" lang="en" xml:lang="en"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>target</code></em></span></dt><dd><p> |
| 6 | Specifies the target texture. |
| 7 | Must be <code class="constant">GL_TEXTURE_2D</code>, |
| 8 | <code class="constant">GL_TEXTURE_CUBE_MAP_POSITIVE_X</code>, |
| 9 | <code class="constant">GL_TEXTURE_CUBE_MAP_NEGATIVE_X</code>, |
| 10 | <code class="constant">GL_TEXTURE_CUBE_MAP_POSITIVE_Y</code>, |
| 11 | <code class="constant">GL_TEXTURE_CUBE_MAP_NEGATIVE_Y</code>, |
| 12 | <code class="constant">GL_TEXTURE_CUBE_MAP_POSITIVE_Z</code>, |
| 13 | <code class="constant">GL_TEXTURE_CUBE_MAP_NEGATIVE_Z</code>, |
| 14 | or <code class="constant">GL_TEXTURE_1D_ARRAY</code>. |
| 15 | </p></dd><dt><span class="term"><em class="parameter"><code>level</code></em></span></dt><dd><p> |
| 16 | Specifies the level-of-detail number. |
| 17 | Level 0 is the base image level. |
| 18 | Level <span class="emphasis"><em>n</em></span> is the <span class="emphasis"><em>n</em></span>th mipmap reduction image. |
| 19 | </p></dd><dt><span class="term"><em class="parameter"><code>xoffset</code></em></span></dt><dd><p> |
| 20 | Specifies a texel offset in the x direction within the texture array. |
| 21 | </p></dd><dt><span class="term"><em class="parameter"><code>yoffset</code></em></span></dt><dd><p> |
| 22 | Specifies a texel offset in the y direction within the texture array. |
| 23 | </p></dd><dt><span class="term"><em class="parameter"><code>width</code></em></span></dt><dd><p> |
| 24 | Specifies the width of the texture subimage. |
| 25 | </p></dd><dt><span class="term"><em class="parameter"><code>height</code></em></span></dt><dd><p> |
| 26 | Specifies the height of the texture subimage. |
| 27 | </p></dd><dt><span class="term"><em class="parameter"><code>format</code></em></span></dt><dd><p> |
| 28 | Specifies the format of the pixel data. |
| 29 | The following symbolic values are accepted: |
| 30 | <code class="constant">GL_RED</code>, |
| 31 | <code class="constant">GL_RG</code>, |
| 32 | <code class="constant">GL_RGB</code>, |
| 33 | <code class="constant">GL_BGR</code>, |
| 34 | <code class="constant">GL_RGBA</code>, and |
| 35 | <code class="constant">GL_BGRA</code>. |
| 36 | </p></dd><dt><span class="term"><em class="parameter"><code>type</code></em></span></dt><dd><p> |
| 37 | Specifies the data type of the pixel data. |
| 38 | The following symbolic values are accepted: |
| 39 | <code class="constant">GL_UNSIGNED_BYTE</code>, |
| 40 | <code class="constant">GL_BYTE</code>, |
| 41 | <code class="constant">GL_UNSIGNED_SHORT</code>, |
| 42 | <code class="constant">GL_SHORT</code>, |
| 43 | <code class="constant">GL_UNSIGNED_INT</code>, |
| 44 | <code class="constant">GL_INT</code>, |
| 45 | <code class="constant">GL_FLOAT</code>, |
| 46 | <code class="constant">GL_UNSIGNED_BYTE_3_3_2</code>, |
| 47 | <code class="constant">GL_UNSIGNED_BYTE_2_3_3_REV</code>, |
| 48 | <code class="constant">GL_UNSIGNED_SHORT_5_6_5</code>, |
| 49 | <code class="constant">GL_UNSIGNED_SHORT_5_6_5_REV</code>, |
| 50 | <code class="constant">GL_UNSIGNED_SHORT_4_4_4_4</code>, |
| 51 | <code class="constant">GL_UNSIGNED_SHORT_4_4_4_4_REV</code>, |
| 52 | <code class="constant">GL_UNSIGNED_SHORT_5_5_5_1</code>, |
| 53 | <code class="constant">GL_UNSIGNED_SHORT_1_5_5_5_REV</code>, |
| 54 | <code class="constant">GL_UNSIGNED_INT_8_8_8_8</code>, |
| 55 | <code class="constant">GL_UNSIGNED_INT_8_8_8_8_REV</code>, |
| 56 | <code class="constant">GL_UNSIGNED_INT_10_10_10_2</code>, and |
| 57 | <code class="constant">GL_UNSIGNED_INT_2_10_10_10_REV</code>. |
| 58 | </p></dd><dt><span class="term"><em class="parameter"><code>data</code></em></span></dt><dd><p> |
| 59 | Specifies a pointer to the image data in memory. |
| 60 | </p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p> |
| 61 | Texturing maps a portion of a specified texture image |
| 62 | onto each graphical primitive for which texturing is enabled. |
| 63 | </p><p> |
| 64 | <code class="function">glTexSubImage2D</code> redefines a contiguous subregion of an existing two-dimensional |
| 65 | or one-dimensional array texture image. |
| 66 | The texels referenced by <em class="parameter"><code>data</code></em> replace the portion of the |
| 67 | existing texture array with x indices <em class="parameter"><code>xoffset</code></em> and |
| 68 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> |
| 69 | |
| 70 | <mml:mrow> |
| 71 | <mml:mi mathvariant="italic">xoffset</mml:mi> |
| 72 | <mml:mo>+</mml:mo> |
| 73 | <mml:mi mathvariant="italic">width</mml:mi> |
| 74 | <mml:mo>-</mml:mo> |
| 75 | <mml:mn>1</mml:mn> |
| 76 | </mml:mrow> |
| 77 | </mml:math>, |
| 78 | inclusive, |
| 79 | and y indices <em class="parameter"><code>yoffset</code></em> and |
| 80 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> |
| 81 | |
| 82 | <mml:mrow> |
| 83 | <mml:mi mathvariant="italic">yoffset</mml:mi> |
| 84 | <mml:mo>+</mml:mo> |
| 85 | <mml:mi mathvariant="italic">height</mml:mi> |
| 86 | <mml:mo>-</mml:mo> |
| 87 | <mml:mn>1</mml:mn> |
| 88 | </mml:mrow> |
| 89 | </mml:math>, |
| 90 | inclusive. |
| 91 | This region may not include any texels outside the range of the |
| 92 | texture array as it was originally specified. |
| 93 | It is not an error to specify a subtexture with zero width or height, but |
| 94 | such a specification has no effect. |
| 95 | </p><p> |
| 96 | If a non-zero named buffer object is bound to the <code class="constant">GL_PIXEL_UNPACK_BUFFER</code> target |
| 97 | (see <a href="glBindBuffer.xml"><span class="citerefentry"><span class="refentrytitle">glBindBuffer</span></span></a>) while a texture image is |
| 98 | specified, <em class="parameter"><code>data</code></em> is treated as a byte offset into the buffer object's data store. |
| 99 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="notes"></a><h2>Notes</h2><p> |
| 100 | <a href="glPixelStore.xml"><span class="citerefentry"><span class="refentrytitle">glPixelStore</span></span></a> modes affect texture images. |
| 101 | </p><p> |
| 102 | <code class="function">glTexSubImage2D</code> specifies a two-dimensional subtexture for the current texture unit, |
| 103 | specified with <a href="glActiveTexture.xml"><span class="citerefentry"><span class="refentrytitle">glActiveTexture</span></span></a>. |
| 104 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="errors"></a><h2>Errors</h2><p> |
| 105 | <code class="constant">GL_INVALID_ENUM</code> is generated if <em class="parameter"><code>target</code></em> is not <code class="constant">GL_TEXTURE_2D</code>, |
| 106 | <code class="constant">GL_TEXTURE_CUBE_MAP_POSITIVE_X</code>, |
| 107 | <code class="constant">GL_TEXTURE_CUBE_MAP_NEGATIVE_X</code>, |
| 108 | <code class="constant">GL_TEXTURE_CUBE_MAP_POSITIVE_Y</code>, |
| 109 | <code class="constant">GL_TEXTURE_CUBE_MAP_NEGATIVE_Y</code>, |
| 110 | <code class="constant">GL_TEXTURE_CUBE_MAP_POSITIVE_Z</code>, or |
| 111 | <code class="constant">GL_TEXTURE_CUBE_MAP_NEGATIVE_Z</code>. |
| 112 | </p><p> |
| 113 | <code class="constant">GL_INVALID_ENUM</code> is generated if <em class="parameter"><code>format</code></em> is not an accepted |
| 114 | format constant. |
| 115 | </p><p> |
| 116 | <code class="constant">GL_INVALID_ENUM</code> is generated if <em class="parameter"><code>type</code></em> is not a type constant. |
| 117 | </p><p> |
| 118 | <code class="constant">GL_INVALID_VALUE</code> is generated if <em class="parameter"><code>level</code></em> is less than 0. |
| 119 | </p><p> |
| 120 | <code class="constant">GL_INVALID_VALUE</code> may be generated if <em class="parameter"><code>level</code></em> is greater |
| 121 | than |
| 122 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> |
| 123 | |
| 124 | <mml:msub><mml:mi mathvariant="italic">log</mml:mi> |
| 125 | <mml:mn>2</mml:mn> |
| 126 | </mml:msub> |
| 127 | </mml:math> |
| 128 | <span class="emphasis"><em>max</em></span>, |
| 129 | where <span class="emphasis"><em>max</em></span> is the returned value of <code class="constant">GL_MAX_TEXTURE_SIZE</code>. |
| 130 | </p><p> |
| 131 | <code class="constant">GL_INVALID_VALUE</code> is generated if |
| 132 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> |
| 133 | |
| 134 | <mml:mrow> |
| 135 | <mml:mi mathvariant="italic">xoffset</mml:mi> |
| 136 | <mml:mo><</mml:mo> |
| 137 | <mml:mrow> |
| 138 | <mml:mo>-</mml:mo> |
| 139 | <mml:mi mathvariant="italic">b</mml:mi> |
| 140 | </mml:mrow> |
| 141 | </mml:mrow> |
| 142 | </mml:math>, |
| 143 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> |
| 144 | |
| 145 | <mml:mrow> |
| 146 | <mml:mfenced open="(" close=")"> |
| 147 | <mml:mrow> |
| 148 | <mml:mi mathvariant="italic">xoffset</mml:mi> |
| 149 | <mml:mo>+</mml:mo> |
| 150 | <mml:mi mathvariant="italic">width</mml:mi> |
| 151 | </mml:mrow> |
| 152 | </mml:mfenced> |
| 153 | <mml:mo>></mml:mo> |
| 154 | <mml:mfenced open="(" close=")"> |
| 155 | <mml:mrow> |
| 156 | <mml:mi mathvariant="italic">w</mml:mi> |
| 157 | <mml:mo>-</mml:mo> |
| 158 | <mml:mi mathvariant="italic">b</mml:mi> |
| 159 | </mml:mrow> |
| 160 | </mml:mfenced> |
| 161 | </mml:mrow> |
| 162 | </mml:math>, |
| 163 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> |
| 164 | |
| 165 | <mml:mrow> |
| 166 | <mml:mi mathvariant="italic">yoffset</mml:mi> |
| 167 | <mml:mo><</mml:mo> |
| 168 | <mml:mrow> |
| 169 | <mml:mo>-</mml:mo> |
| 170 | <mml:mi mathvariant="italic">b</mml:mi> |
| 171 | </mml:mrow> |
| 172 | </mml:mrow> |
| 173 | </mml:math>, |
| 174 | or |
| 175 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> |
| 176 | |
| 177 | <mml:mrow> |
| 178 | <mml:mfenced open="(" close=")"> |
| 179 | <mml:mrow> |
| 180 | <mml:mi mathvariant="italic">yoffset</mml:mi> |
| 181 | <mml:mo>+</mml:mo> |
| 182 | <mml:mi mathvariant="italic">height</mml:mi> |
| 183 | </mml:mrow> |
| 184 | </mml:mfenced> |
| 185 | <mml:mo>></mml:mo> |
| 186 | <mml:mfenced open="(" close=")"> |
| 187 | <mml:mrow> |
| 188 | <mml:mi mathvariant="italic">h</mml:mi> |
| 189 | <mml:mo>-</mml:mo> |
| 190 | <mml:mi mathvariant="italic">b</mml:mi> |
| 191 | </mml:mrow> |
| 192 | </mml:mfenced> |
| 193 | </mml:mrow> |
| 194 | </mml:math>, |
| 195 | where |
| 196 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">w</mml:mi></mml:math> |
| 197 | is the <code class="constant">GL_TEXTURE_WIDTH</code>, |
| 198 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">h</mml:mi></mml:math> |
| 199 | is the <code class="constant">GL_TEXTURE_HEIGHT</code>, and |
| 200 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">b</mml:mi></mml:math> |
| 201 | is the border width |
| 202 | of the texture image being modified. |
| 203 | Note that |
| 204 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">w</mml:mi></mml:math> |
| 205 | and |
| 206 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">h</mml:mi></mml:math> |
| 207 | include twice the border width. |
| 208 | </p><p> |
| 209 | <code class="constant">GL_INVALID_VALUE</code> is generated if <em class="parameter"><code>width</code></em> or <em class="parameter"><code>height</code></em> is less than 0. |
| 210 | </p><p> |
| 211 | <code class="constant">GL_INVALID_OPERATION</code> is generated if the texture array has not |
| 212 | been defined by a previous <a href="glTexImage2D.xml"><span class="citerefentry"><span class="refentrytitle">glTexImage2D</span></span></a> operation. |
| 213 | </p><p> |
| 214 | <code class="constant">GL_INVALID_OPERATION</code> is generated if <em class="parameter"><code>type</code></em> is one of |
| 215 | <code class="constant">GL_UNSIGNED_BYTE_3_3_2</code>, |
| 216 | <code class="constant">GL_UNSIGNED_BYTE_2_3_3_REV</code>, |
| 217 | <code class="constant">GL_UNSIGNED_SHORT_5_6_5</code>, or |
| 218 | <code class="constant">GL_UNSIGNED_SHORT_5_6_5_REV</code> |
| 219 | and <em class="parameter"><code>format</code></em> is not <code class="constant">GL_RGB</code>. |
| 220 | </p><p> |
| 221 | <code class="constant">GL_INVALID_OPERATION</code> is generated if <em class="parameter"><code>type</code></em> is one of |
| 222 | <code class="constant">GL_UNSIGNED_SHORT_4_4_4_4</code>, |
| 223 | <code class="constant">GL_UNSIGNED_SHORT_4_4_4_4_REV</code>, |
| 224 | <code class="constant">GL_UNSIGNED_SHORT_5_5_5_1</code>, |
| 225 | <code class="constant">GL_UNSIGNED_SHORT_1_5_5_5_REV</code>, |
| 226 | <code class="constant">GL_UNSIGNED_INT_8_8_8_8</code>, |
| 227 | <code class="constant">GL_UNSIGNED_INT_8_8_8_8_REV</code>, |
| 228 | <code class="constant">GL_UNSIGNED_INT_10_10_10_2</code>, or |
| 229 | <code class="constant">GL_UNSIGNED_INT_2_10_10_10_REV</code> |
| 230 | and <em class="parameter"><code>format</code></em> is neither <code class="constant">GL_RGBA</code> nor <code class="constant">GL_BGRA</code>. |
| 231 | </p><p> |
| 232 | <code class="constant">GL_INVALID_OPERATION</code> is generated if a non-zero buffer object name is bound to the |
| 233 | <code class="constant">GL_PIXEL_UNPACK_BUFFER</code> target and the buffer object's data store is currently mapped. |
| 234 | </p><p> |
| 235 | <code class="constant">GL_INVALID_OPERATION</code> is generated if a non-zero buffer object name is bound to the |
| 236 | <code class="constant">GL_PIXEL_UNPACK_BUFFER</code> target and the data would be unpacked from the buffer |
| 237 | object such that the memory reads required would exceed the data store size. |
| 238 | </p><p> |
| 239 | <code class="constant">GL_INVALID_OPERATION</code> is generated if a non-zero buffer object name is bound to the |
| 240 | <code class="constant">GL_PIXEL_UNPACK_BUFFER</code> target and <em class="parameter"><code>data</code></em> is not evenly divisible |
| 241 | into the number of bytes needed to store in memory a datum indicated by <em class="parameter"><code>type</code></em>. |
| 242 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="associatedgets"></a><h2>Associated Gets</h2><p> |
| 243 | <a href="glGetTexImage.xml"><span class="citerefentry"><span class="refentrytitle">glGetTexImage</span></span></a> |
| 244 | </p><p> |
| 245 | <a href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a> with argument <code class="constant">GL_PIXEL_UNPACK_BUFFER_BINDING</code> |
| 246 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p> |
| 247 | <a href="glActiveTexture.xml"><span class="citerefentry"><span class="refentrytitle">glActiveTexture</span></span></a>, |
| 248 | <a href="glCopyTexImage1D.xml"><span class="citerefentry"><span class="refentrytitle">glCopyTexImage1D</span></span></a>, |
| 249 | <a href="glCopyTexImage2D.xml"><span class="citerefentry"><span class="refentrytitle">glCopyTexImage2D</span></span></a>, |
| 250 | <a href="glCopyTexSubImage1D.xml"><span class="citerefentry"><span class="refentrytitle">glCopyTexSubImage1D</span></span></a>, |
| 251 | <a href="glCopyTexSubImage2D.xml"><span class="citerefentry"><span class="refentrytitle">glCopyTexSubImage2D</span></span></a>, |
| 252 | <a href="glCopyTexSubImage3D.xml"><span class="citerefentry"><span class="refentrytitle">glCopyTexSubImage3D</span></span></a>, |
| 253 | <a href="glPixelStore.xml"><span class="citerefentry"><span class="refentrytitle">glPixelStore</span></span></a>, |
| 254 | <a href="glTexImage1D.xml"><span class="citerefentry"><span class="refentrytitle">glTexImage1D</span></span></a>, |
| 255 | <a href="glTexImage2D.xml"><span class="citerefentry"><span class="refentrytitle">glTexImage2D</span></span></a>, |
| 256 | <a href="glTexImage3D.xml"><span class="citerefentry"><span class="refentrytitle">glTexImage3D</span></span></a>, |
| 257 | <a href="glTexSubImage1D.xml"><span class="citerefentry"><span class="refentrytitle">glTexSubImage1D</span></span></a>, |
| 258 | <a href="glTexSubImage3D.xml"><span class="citerefentry"><span class="refentrytitle">glTexSubImage3D</span></span></a>, |
| 259 | <a href="glTexParameter.xml"><span class="citerefentry"><span class="refentrytitle">glTexParameter</span></span></a> |
| 260 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="Copyright"></a><h2>Copyright</h2><p> |
| 261 | Copyright <span class="trademark"></span>© 1991-2006 |
| 262 | Silicon Graphics, Inc. This document is licensed under the SGI |
| 263 | Free Software B License. For details, see |
| 264 | <a href="http://oss.sgi.com/projects/FreeB/" target="_top">http://oss.sgi.com/projects/FreeB/</a>. |
| 265 | </p></div></div></body></html> |