| Brian Paul | b51b0a8 | 2001-03-07 05:06:11 +0000 | [diff] [blame] | 1 | /* $Id: teximage.c,v 1.83 2001/03/07 05:06:12 brianp Exp $ */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * Mesa 3-D graphics library |
| Brian Paul | 01e5475 | 2000-09-05 15:40:34 +0000 | [diff] [blame] | 5 | * Version: 3.5 |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 6 | * |
| Brian Paul | 663049a | 2000-01-31 23:10:16 +0000 | [diff] [blame] | 7 | * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 8 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 9 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 10 | * copy of this software and associated documentation files (the "Software"), |
| 11 | * to deal in the Software without restriction, including without limitation |
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 13 | * and/or sell copies of the Software, and to permit persons to whom the |
| 14 | * Software is furnished to do so, subject to the following conditions: |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 15 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 16 | * The above copyright notice and this permission notice shall be included |
| 17 | * in all copies or substantial portions of the Software. |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 18 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | |
| 28 | #ifdef PC_HEADER |
| 29 | #include "all.h" |
| 30 | #else |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 31 | #include "glheader.h" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 32 | #include "context.h" |
| Brian Paul | f93b3dd | 2000-08-30 18:22:28 +0000 | [diff] [blame] | 33 | #include "convolve.h" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 34 | #include "image.h" |
| Brian Paul | ebb248a | 2000-10-29 18:23:16 +0000 | [diff] [blame] | 35 | #include "macros.h" |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 36 | #include "mem.h" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 37 | #include "mmath.h" |
| Brian Paul | fa4525e | 2000-08-21 14:22:24 +0000 | [diff] [blame] | 38 | #include "state.h" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 39 | #include "teximage.h" |
| 40 | #include "texstate.h" |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 41 | #include "mtypes.h" |
| Brian Paul | 7298e71 | 2000-11-07 16:40:37 +0000 | [diff] [blame] | 42 | #include "swrast/s_span.h" /* XXX SWRAST hack */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 43 | #endif |
| 44 | |
| 45 | |
| 46 | /* |
| 47 | * NOTES: |
| 48 | * |
| Brian Paul | 699bc7b | 2000-10-29 18:12:14 +0000 | [diff] [blame] | 49 | * Mesa's native texture datatype is GLchan. Native formats are |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 50 | * GL_ALPHA, GL_LUMINANCE, GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, GL_RGBA, |
| 51 | * and GL_COLOR_INDEX. |
| 52 | * Device drivers are free to implement any internal format they want. |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 53 | */ |
| 54 | |
| 55 | |
| Brian Paul | 4827179 | 2000-03-29 18:13:59 +0000 | [diff] [blame] | 56 | #ifdef DEBUG |
| Brian Paul | e5d68a2 | 2000-03-30 18:37:51 +0000 | [diff] [blame] | 57 | static void PrintTexture(const struct gl_texture_image *img) |
| Brian Paul | 4827179 | 2000-03-29 18:13:59 +0000 | [diff] [blame] | 58 | { |
| Brian Paul | b51b0a8 | 2001-03-07 05:06:11 +0000 | [diff] [blame] | 59 | GLuint i, j, c; |
| 60 | const GLchan *data = (const GLchan *) img->Data; |
| Brian Paul | e5d68a2 | 2000-03-30 18:37:51 +0000 | [diff] [blame] | 61 | |
| Brian Paul | b51b0a8 | 2001-03-07 05:06:11 +0000 | [diff] [blame] | 62 | if (!data) { |
| 63 | printf("No texture data\n"); |
| 64 | return; |
| 65 | } |
| Brian Paul | e5d68a2 | 2000-03-30 18:37:51 +0000 | [diff] [blame] | 66 | |
| Brian Paul | b51b0a8 | 2001-03-07 05:06:11 +0000 | [diff] [blame] | 67 | switch (img->Format) { |
| 68 | case GL_ALPHA: |
| 69 | case GL_LUMINANCE: |
| 70 | case GL_INTENSITY: |
| 71 | case GL_COLOR_INDEX: |
| 72 | c = 1; |
| 73 | break; |
| 74 | case GL_LUMINANCE_ALPHA: |
| 75 | c = 2; |
| 76 | break; |
| 77 | case GL_RGB: |
| 78 | c = 3; |
| 79 | break; |
| 80 | case GL_RGBA: |
| 81 | c = 4; |
| 82 | break; |
| 83 | default: |
| 84 | _mesa_problem(NULL, "error in PrintTexture\n"); |
| 85 | return; |
| 86 | } |
| Brian Paul | e5d68a2 | 2000-03-30 18:37:51 +0000 | [diff] [blame] | 87 | |
| Brian Paul | b51b0a8 | 2001-03-07 05:06:11 +0000 | [diff] [blame] | 88 | for (i = 0; i < img->Height; i++) { |
| 89 | for (j = 0; j < img->Width; j++) { |
| 90 | if (c==1) |
| 91 | printf("%02x ", data[0]); |
| 92 | else if (c==2) |
| 93 | printf("%02x%02x ", data[0], data[1]); |
| 94 | else if (c==3) |
| 95 | printf("%02x%02x%02x ", data[0], data[1], data[2]); |
| 96 | else if (c==4) |
| 97 | printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]); |
| 98 | data += c; |
| 99 | } |
| 100 | printf("\n"); |
| 101 | } |
| Brian Paul | 4827179 | 2000-03-29 18:13:59 +0000 | [diff] [blame] | 102 | } |
| 103 | #endif |
| 104 | |
| 105 | |
| 106 | |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 107 | /* |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 108 | * Compute log base 2 of n. |
| 109 | * If n isn't an exact power of two return -1. |
| 110 | * If n<0 return -1. |
| 111 | */ |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 112 | static int |
| 113 | logbase2( int n ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 114 | { |
| 115 | GLint i = 1; |
| 116 | GLint log2 = 0; |
| 117 | |
| 118 | if (n<0) { |
| 119 | return -1; |
| 120 | } |
| 121 | |
| 122 | while ( n > i ) { |
| 123 | i *= 2; |
| 124 | log2++; |
| 125 | } |
| 126 | if (i != n) { |
| 127 | return -1; |
| 128 | } |
| 129 | else { |
| 130 | return log2; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | |
| 135 | |
| 136 | /* |
| 137 | * Given an internal texture format enum or 1, 2, 3, 4 return the |
| 138 | * corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE, |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 139 | * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. |
| 140 | * Return -1 if invalid enum. |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 141 | */ |
| Brian Paul | b132e8d | 2000-03-23 16:23:14 +0000 | [diff] [blame] | 142 | GLint |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 143 | _mesa_base_tex_format( GLcontext *ctx, GLint format ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 144 | { |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 145 | /* |
| 146 | * Ask the driver for the base format, if it doesn't |
| 147 | * know, it will return -1; |
| 148 | */ |
| 149 | if (ctx->Driver.BaseCompressedTexFormat) { |
| 150 | GLint ifmt = (*ctx->Driver.BaseCompressedTexFormat)(ctx, format); |
| 151 | if (ifmt >= 0) { |
| 152 | return ifmt; |
| 153 | } |
| 154 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 155 | switch (format) { |
| 156 | case GL_ALPHA: |
| 157 | case GL_ALPHA4: |
| 158 | case GL_ALPHA8: |
| 159 | case GL_ALPHA12: |
| 160 | case GL_ALPHA16: |
| 161 | return GL_ALPHA; |
| 162 | case 1: |
| 163 | case GL_LUMINANCE: |
| 164 | case GL_LUMINANCE4: |
| 165 | case GL_LUMINANCE8: |
| 166 | case GL_LUMINANCE12: |
| 167 | case GL_LUMINANCE16: |
| 168 | return GL_LUMINANCE; |
| 169 | case 2: |
| 170 | case GL_LUMINANCE_ALPHA: |
| 171 | case GL_LUMINANCE4_ALPHA4: |
| 172 | case GL_LUMINANCE6_ALPHA2: |
| 173 | case GL_LUMINANCE8_ALPHA8: |
| 174 | case GL_LUMINANCE12_ALPHA4: |
| 175 | case GL_LUMINANCE12_ALPHA12: |
| 176 | case GL_LUMINANCE16_ALPHA16: |
| 177 | return GL_LUMINANCE_ALPHA; |
| 178 | case GL_INTENSITY: |
| 179 | case GL_INTENSITY4: |
| 180 | case GL_INTENSITY8: |
| 181 | case GL_INTENSITY12: |
| 182 | case GL_INTENSITY16: |
| 183 | return GL_INTENSITY; |
| 184 | case 3: |
| 185 | case GL_RGB: |
| 186 | case GL_R3_G3_B2: |
| 187 | case GL_RGB4: |
| 188 | case GL_RGB5: |
| 189 | case GL_RGB8: |
| 190 | case GL_RGB10: |
| 191 | case GL_RGB12: |
| 192 | case GL_RGB16: |
| 193 | return GL_RGB; |
| 194 | case 4: |
| 195 | case GL_RGBA: |
| 196 | case GL_RGBA2: |
| 197 | case GL_RGBA4: |
| 198 | case GL_RGB5_A1: |
| 199 | case GL_RGBA8: |
| 200 | case GL_RGB10_A2: |
| 201 | case GL_RGBA12: |
| 202 | case GL_RGBA16: |
| 203 | return GL_RGBA; |
| 204 | case GL_COLOR_INDEX: |
| 205 | case GL_COLOR_INDEX1_EXT: |
| 206 | case GL_COLOR_INDEX2_EXT: |
| 207 | case GL_COLOR_INDEX4_EXT: |
| 208 | case GL_COLOR_INDEX8_EXT: |
| 209 | case GL_COLOR_INDEX12_EXT: |
| 210 | case GL_COLOR_INDEX16_EXT: |
| 211 | return GL_COLOR_INDEX; |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 212 | case GL_DEPTH_COMPONENT: |
| 213 | case GL_DEPTH_COMPONENT16_SGIX: |
| 214 | case GL_DEPTH_COMPONENT24_SGIX: |
| 215 | case GL_DEPTH_COMPONENT32_SGIX: |
| 216 | if (ctx->Extensions.SGIX_depth_texture) |
| 217 | return GL_DEPTH_COMPONENT; |
| 218 | else |
| 219 | return -1; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 220 | default: |
| 221 | return -1; /* error */ |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 226 | /* |
| 227 | * Test if the given image format is a color/rgba format. That is, |
| 228 | * not color index, depth, stencil, etc. |
| 229 | */ |
| 230 | static GLboolean |
| 231 | is_color_format(GLenum format) |
| 232 | { |
| 233 | switch (format) { |
| 234 | case GL_ALPHA: |
| 235 | case GL_ALPHA4: |
| 236 | case GL_ALPHA8: |
| 237 | case GL_ALPHA12: |
| 238 | case GL_ALPHA16: |
| 239 | case 1: |
| 240 | case GL_LUMINANCE: |
| 241 | case GL_LUMINANCE4: |
| 242 | case GL_LUMINANCE8: |
| 243 | case GL_LUMINANCE12: |
| 244 | case GL_LUMINANCE16: |
| 245 | case 2: |
| 246 | case GL_LUMINANCE_ALPHA: |
| 247 | case GL_LUMINANCE4_ALPHA4: |
| 248 | case GL_LUMINANCE6_ALPHA2: |
| 249 | case GL_LUMINANCE8_ALPHA8: |
| 250 | case GL_LUMINANCE12_ALPHA4: |
| 251 | case GL_LUMINANCE12_ALPHA12: |
| 252 | case GL_LUMINANCE16_ALPHA16: |
| 253 | case GL_INTENSITY: |
| 254 | case GL_INTENSITY4: |
| 255 | case GL_INTENSITY8: |
| 256 | case GL_INTENSITY12: |
| 257 | case GL_INTENSITY16: |
| 258 | case 3: |
| 259 | case GL_RGB: |
| 260 | case GL_R3_G3_B2: |
| 261 | case GL_RGB4: |
| 262 | case GL_RGB5: |
| 263 | case GL_RGB8: |
| 264 | case GL_RGB10: |
| 265 | case GL_RGB12: |
| 266 | case GL_RGB16: |
| 267 | case 4: |
| 268 | case GL_RGBA: |
| 269 | case GL_RGBA2: |
| 270 | case GL_RGBA4: |
| 271 | case GL_RGB5_A1: |
| 272 | case GL_RGBA8: |
| 273 | case GL_RGB10_A2: |
| 274 | case GL_RGBA12: |
| 275 | case GL_RGBA16: |
| 276 | return GL_TRUE; |
| 277 | default: |
| 278 | return GL_FALSE; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | |
| 283 | static GLboolean |
| 284 | is_index_format(GLenum format) |
| 285 | { |
| 286 | switch (format) { |
| 287 | case GL_COLOR_INDEX: |
| 288 | case GL_COLOR_INDEX1_EXT: |
| 289 | case GL_COLOR_INDEX2_EXT: |
| 290 | case GL_COLOR_INDEX4_EXT: |
| 291 | case GL_COLOR_INDEX8_EXT: |
| 292 | case GL_COLOR_INDEX12_EXT: |
| 293 | case GL_COLOR_INDEX16_EXT: |
| 294 | return GL_TRUE; |
| 295 | default: |
| 296 | return GL_FALSE; |
| 297 | } |
| 298 | } |
| 299 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 300 | |
| 301 | /* |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 302 | * Return GL_TRUE if internalFormat is a compressed format, return GL_FALSE |
| 303 | * otherwise. |
| 304 | */ |
| 305 | static GLboolean |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 306 | is_compressed_format(GLcontext *ctx, GLenum internalFormat) |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 307 | { |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 308 | if (ctx->Driver.IsCompressedFormat) { |
| 309 | return (*ctx->Driver.IsCompressedFormat)(ctx, internalFormat); |
| 310 | } |
| 311 | return GL_FALSE; |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 315 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 316 | /* |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 317 | * Store a gl_texture_image pointer in a gl_texture_object structure |
| 318 | * according to the target and level parameters. |
| 319 | * This was basically prompted by the introduction of cube maps. |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 320 | */ |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 321 | static void |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 322 | set_tex_image(struct gl_texture_object *tObj, |
| 323 | GLenum target, GLint level, |
| 324 | struct gl_texture_image *texImage) |
| 325 | { |
| 326 | ASSERT(tObj); |
| 327 | ASSERT(texImage); |
| 328 | switch (target) { |
| 329 | case GL_TEXTURE_2D: |
| 330 | tObj->Image[level] = texImage; |
| 331 | return; |
| 332 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: |
| Brian Paul | 413d6a2 | 2000-05-26 14:44:59 +0000 | [diff] [blame] | 333 | tObj->Image[level] = texImage; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 334 | return; |
| 335 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: |
| 336 | tObj->NegX[level] = texImage; |
| 337 | return; |
| 338 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: |
| 339 | tObj->PosY[level] = texImage; |
| 340 | return; |
| 341 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: |
| 342 | tObj->NegY[level] = texImage; |
| 343 | return; |
| 344 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: |
| 345 | tObj->PosZ[level] = texImage; |
| 346 | return; |
| 347 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: |
| 348 | tObj->NegZ[level] = texImage; |
| 349 | return; |
| 350 | default: |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 351 | _mesa_problem(NULL, "bad target in set_tex_image()"); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 352 | return; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 357 | |
| Brian Paul | 77ce6da | 2000-03-20 23:40:12 +0000 | [diff] [blame] | 358 | /* |
| 359 | * Return new gl_texture_image struct with all fields initialized to zero. |
| 360 | */ |
| 361 | struct gl_texture_image * |
| Brian Paul | 021a525 | 2000-03-27 17:54:17 +0000 | [diff] [blame] | 362 | _mesa_alloc_texture_image( void ) |
| Brian Paul | 77ce6da | 2000-03-20 23:40:12 +0000 | [diff] [blame] | 363 | { |
| 364 | return CALLOC_STRUCT(gl_texture_image); |
| 365 | } |
| 366 | |
| 367 | |
| 368 | |
| Brian Paul | 77ce6da | 2000-03-20 23:40:12 +0000 | [diff] [blame] | 369 | void |
| Brian Paul | 021a525 | 2000-03-27 17:54:17 +0000 | [diff] [blame] | 370 | _mesa_free_texture_image( struct gl_texture_image *teximage ) |
| Brian Paul | 77ce6da | 2000-03-20 23:40:12 +0000 | [diff] [blame] | 371 | { |
| 372 | if (teximage->Data) { |
| 373 | FREE( teximage->Data ); |
| 374 | teximage->Data = NULL; |
| 375 | } |
| 376 | FREE( teximage ); |
| 377 | } |
| 378 | |
| 379 | |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 380 | /* |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 381 | * Return GL_TRUE if the target is a proxy target. |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 382 | */ |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 383 | static GLboolean |
| 384 | is_proxy_target(GLenum target) |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 385 | { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 386 | return (target == GL_PROXY_TEXTURE_1D || |
| 387 | target == GL_PROXY_TEXTURE_2D || |
| 388 | target == GL_PROXY_TEXTURE_3D || |
| 389 | target == GL_PROXY_TEXTURE_CUBE_MAP_ARB); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 393 | /* |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 394 | * Given a texture unit and a texture target, return the corresponding |
| 395 | * texture object. |
| 396 | */ |
| 397 | struct gl_texture_object * |
| Brian Paul | 01e5475 | 2000-09-05 15:40:34 +0000 | [diff] [blame] | 398 | _mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit, |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 399 | GLenum target) |
| 400 | { |
| 401 | switch (target) { |
| 402 | case GL_TEXTURE_1D: |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 403 | return texUnit->Current1D; |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 404 | case GL_PROXY_TEXTURE_1D: |
| 405 | return ctx->Texture.Proxy1D; |
| 406 | case GL_TEXTURE_2D: |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 407 | return texUnit->Current2D; |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 408 | case GL_PROXY_TEXTURE_2D: |
| 409 | return ctx->Texture.Proxy2D; |
| 410 | case GL_TEXTURE_3D: |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 411 | return texUnit->Current3D; |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 412 | case GL_PROXY_TEXTURE_3D: |
| 413 | return ctx->Texture.Proxy3D; |
| 414 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: |
| 415 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: |
| 416 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: |
| 417 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: |
| 418 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: |
| 419 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 420 | return ctx->Extensions.ARB_texture_cube_map |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 421 | ? texUnit->CurrentCubeMap : NULL; |
| 422 | case GL_PROXY_TEXTURE_CUBE_MAP_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 423 | return ctx->Extensions.ARB_texture_cube_map |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 424 | ? ctx->Texture.ProxyCubeMap : NULL; |
| 425 | default: |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 426 | _mesa_problem(NULL, "bad target in _mesa_select_tex_object()"); |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 427 | return NULL; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | |
| 432 | /* |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 433 | * Return the texture image struct which corresponds to target and level |
| 434 | * for the given texture unit. |
| 435 | */ |
| 436 | struct gl_texture_image * |
| 437 | _mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit, |
| 438 | GLenum target, GLint level) |
| 439 | { |
| 440 | ASSERT(texUnit); |
| 441 | switch (target) { |
| 442 | case GL_TEXTURE_1D: |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 443 | return texUnit->Current1D->Image[level]; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 444 | case GL_PROXY_TEXTURE_1D: |
| 445 | return ctx->Texture.Proxy1D->Image[level]; |
| 446 | case GL_TEXTURE_2D: |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 447 | return texUnit->Current2D->Image[level]; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 448 | case GL_PROXY_TEXTURE_2D: |
| 449 | return ctx->Texture.Proxy2D->Image[level]; |
| 450 | case GL_TEXTURE_3D: |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 451 | return texUnit->Current3D->Image[level]; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 452 | case GL_PROXY_TEXTURE_3D: |
| 453 | return ctx->Texture.Proxy3D->Image[level]; |
| 454 | case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 455 | if (ctx->Extensions.ARB_texture_cube_map) |
| Brian Paul | 413d6a2 | 2000-05-26 14:44:59 +0000 | [diff] [blame] | 456 | return texUnit->CurrentCubeMap->Image[level]; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 457 | else |
| 458 | return NULL; |
| 459 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 460 | if (ctx->Extensions.ARB_texture_cube_map) |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 461 | return texUnit->CurrentCubeMap->NegX[level]; |
| 462 | else |
| 463 | return NULL; |
| 464 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 465 | if (ctx->Extensions.ARB_texture_cube_map) |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 466 | return texUnit->CurrentCubeMap->PosY[level]; |
| 467 | else |
| 468 | return NULL; |
| 469 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 470 | if (ctx->Extensions.ARB_texture_cube_map) |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 471 | return texUnit->CurrentCubeMap->NegY[level]; |
| 472 | else |
| 473 | return NULL; |
| 474 | case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 475 | if (ctx->Extensions.ARB_texture_cube_map) |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 476 | return texUnit->CurrentCubeMap->PosZ[level]; |
| 477 | else |
| 478 | return NULL; |
| 479 | case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 480 | if (ctx->Extensions.ARB_texture_cube_map) |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 481 | return texUnit->CurrentCubeMap->NegZ[level]; |
| 482 | else |
| 483 | return NULL; |
| 484 | case GL_PROXY_TEXTURE_CUBE_MAP_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 485 | if (ctx->Extensions.ARB_texture_cube_map) |
| Brian Paul | 413d6a2 | 2000-05-26 14:44:59 +0000 | [diff] [blame] | 486 | return ctx->Texture.ProxyCubeMap->Image[level]; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 487 | else |
| 488 | return NULL; |
| 489 | default: |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 490 | _mesa_problem(ctx, "bad target in _mesa_select_tex_image()"); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 491 | return NULL; |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | |
| 496 | |
| Brian Paul | f93b3dd | 2000-08-30 18:22:28 +0000 | [diff] [blame] | 497 | /* |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 498 | * glTexImage[123]D can accept a NULL image pointer. In this case we |
| 499 | * create a texture image with unspecified image contents per the OpenGL |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 500 | * spec. |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 501 | */ |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 502 | static GLubyte * |
| 503 | make_null_texture(GLint width, GLint height, GLint depth, GLenum format) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 504 | { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 505 | const GLint components = _mesa_components_in_format(format); |
| 506 | const GLint numPixels = width * height * depth; |
| 507 | GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte)); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 508 | |
| 509 | /* |
| 510 | * Let's see if anyone finds this. If glTexImage2D() is called with |
| 511 | * a NULL image pointer then load the texture image with something |
| 512 | * interesting instead of leaving it indeterminate. |
| 513 | */ |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 514 | if (data) { |
| Brian Paul | 65d5460 | 2000-03-01 23:28:20 +0000 | [diff] [blame] | 515 | static const char message[8][32] = { |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 516 | " X X XXXXX XXX X ", |
| 517 | " XX XX X X X X X ", |
| 518 | " X X X X X X X ", |
| 519 | " X X XXXX XXX XXXXX ", |
| 520 | " X X X X X X ", |
| 521 | " X X X X X X X ", |
| 522 | " X X XXXXX XXX X X ", |
| 523 | " " |
| 524 | }; |
| 525 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 526 | GLubyte *imgPtr = data; |
| 527 | GLint h, i, j, k; |
| 528 | for (h = 0; h < depth; h++) { |
| 529 | for (i = 0; i < height; i++) { |
| 530 | GLint srcRow = 7 - (i % 8); |
| 531 | for (j = 0; j < width; j++) { |
| 532 | GLint srcCol = j % 32; |
| 533 | GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70; |
| 534 | for (k = 0; k < components; k++) { |
| 535 | *imgPtr++ = texel; |
| 536 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 537 | } |
| 538 | } |
| 539 | } |
| 540 | } |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 541 | |
| 542 | return data; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | |
| 546 | |
| 547 | /* |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 548 | * Reset the fields of a gl_texture_image struct to zero. |
| Brian Paul | 9c27278 | 2000-09-05 22:04:30 +0000 | [diff] [blame] | 549 | * This is called when a proxy texture test fails, we set all the |
| 550 | * image members (except DriverData) to zero. |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 551 | * It's also used in glTexImage[123]D as a safeguard to be sure all |
| 552 | * required fields get initialized properly by the Driver.TexImage[123]D |
| 553 | * functions. |
| Brian Paul | 9c27278 | 2000-09-05 22:04:30 +0000 | [diff] [blame] | 554 | */ |
| 555 | static void |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 556 | clear_teximage_fields(struct gl_texture_image *img) |
| Brian Paul | 9c27278 | 2000-09-05 22:04:30 +0000 | [diff] [blame] | 557 | { |
| 558 | ASSERT(img); |
| 559 | img->Format = 0; |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 560 | img->Type = 0; |
| Brian Paul | 9c27278 | 2000-09-05 22:04:30 +0000 | [diff] [blame] | 561 | img->IntFormat = 0; |
| 562 | img->RedBits = 0; |
| 563 | img->GreenBits = 0; |
| 564 | img->BlueBits = 0; |
| 565 | img->AlphaBits = 0; |
| 566 | img->IntensityBits = 0; |
| 567 | img->LuminanceBits = 0; |
| 568 | img->IndexBits = 0; |
| 569 | img->Border = 0; |
| 570 | img->Width = 0; |
| 571 | img->Height = 0; |
| 572 | img->Depth = 0; |
| 573 | img->Width2 = 0; |
| 574 | img->Height2 = 0; |
| 575 | img->Depth2 = 0; |
| 576 | img->WidthLog2 = 0; |
| 577 | img->HeightLog2 = 0; |
| 578 | img->DepthLog2 = 0; |
| 579 | img->Data = NULL; |
| 580 | img->IsCompressed = 0; |
| 581 | img->CompressedSize = 0; |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 582 | img->FetchTexel = NULL; |
| Brian Paul | 9c27278 | 2000-09-05 22:04:30 +0000 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | |
| Brian Paul | 6628bc9 | 2001-02-07 03:27:41 +0000 | [diff] [blame] | 586 | /* |
| 587 | * Initialize basic fields of the gl_texture_image struct. |
| 588 | */ |
| 589 | static void |
| 590 | init_teximage_fields(GLcontext *ctx, |
| 591 | struct gl_texture_image *img, |
| 592 | GLsizei width, GLsizei height, GLsizei depth, |
| 593 | GLint border, GLenum internalFormat) |
| 594 | { |
| 595 | ASSERT(img); |
| 596 | |
| 597 | img->IntFormat = internalFormat; |
| 598 | img->Border = border; |
| 599 | img->Width = width; |
| 600 | img->Height = height; |
| 601 | img->Depth = depth; |
| 602 | img->WidthLog2 = logbase2(width - 2 * border); |
| 603 | if (height == 1) /* 1-D texture */ |
| 604 | img->HeightLog2 = 0; |
| 605 | else |
| 606 | img->HeightLog2 = logbase2(height - 2 * border); |
| 607 | if (depth == 1) /* 2-D texture */ |
| 608 | img->DepthLog2 = 0; |
| 609 | else |
| 610 | img->DepthLog2 = logbase2(depth - 2 * border); |
| 611 | img->Width2 = 1 << img->WidthLog2; |
| 612 | img->Height2 = 1 << img->HeightLog2; |
| 613 | img->Depth2 = 1 << img->DepthLog2; |
| 614 | img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); |
| 615 | img->IsCompressed = is_compressed_format(ctx, internalFormat); |
| 616 | } |
| 617 | |
| 618 | |
| Brian Paul | 9c27278 | 2000-09-05 22:04:30 +0000 | [diff] [blame] | 619 | |
| 620 | /* |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 621 | * Test glTexImage[123]D() parameters for errors. |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 622 | * Input: |
| 623 | * dimensions - must be 1 or 2 or 3 |
| 624 | * Return: GL_TRUE = an error was detected, GL_FALSE = no errors |
| 625 | */ |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 626 | static GLboolean |
| 627 | texture_error_check( GLcontext *ctx, GLenum target, |
| 628 | GLint level, GLint internalFormat, |
| 629 | GLenum format, GLenum type, |
| Brian Paul | 5b37c32 | 1999-11-05 06:43:10 +0000 | [diff] [blame] | 630 | GLuint dimensions, |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 631 | GLint width, GLint height, |
| 632 | GLint depth, GLint border ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 633 | { |
| 634 | GLboolean isProxy; |
| 635 | GLint iformat; |
| 636 | |
| 637 | if (dimensions == 1) { |
| Brian Paul | 5b37c32 | 1999-11-05 06:43:10 +0000 | [diff] [blame] | 638 | isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_1D); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 639 | if (target != GL_TEXTURE_1D && !isProxy) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 640 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 641 | return GL_TRUE; |
| 642 | } |
| 643 | } |
| 644 | else if (dimensions == 2) { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 645 | isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_2D || |
| 646 | target == GL_PROXY_TEXTURE_CUBE_MAP_ARB); |
| Brian Paul | 413d6a2 | 2000-05-26 14:44:59 +0000 | [diff] [blame] | 647 | if (target != GL_TEXTURE_2D && !isProxy && |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 648 | !(ctx->Extensions.ARB_texture_cube_map && |
| Brian Paul | 413d6a2 | 2000-05-26 14:44:59 +0000 | [diff] [blame] | 649 | target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && |
| 650 | target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 651 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 652 | return GL_TRUE; |
| 653 | } |
| 654 | } |
| 655 | else if (dimensions == 3) { |
| Brian Paul | 5b37c32 | 1999-11-05 06:43:10 +0000 | [diff] [blame] | 656 | isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_3D); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 657 | if (target != GL_TEXTURE_3D && !isProxy) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 658 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 659 | return GL_TRUE; |
| 660 | } |
| 661 | } |
| 662 | else { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 663 | _mesa_problem( ctx, "bad dims in texture_error_check" ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 664 | return GL_TRUE; |
| 665 | } |
| 666 | |
| 667 | /* Border */ |
| Brian Paul | 9fd2b0a | 2000-03-24 23:59:06 +0000 | [diff] [blame] | 668 | if (border != 0 && border != 1) { |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 669 | if (!isProxy) { |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 670 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 671 | sprintf(message, "glTexImage%dD(border=%d)", dimensions, border); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 672 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 673 | } |
| 674 | return GL_TRUE; |
| 675 | } |
| 676 | |
| 677 | /* Width */ |
| 678 | if (width < 2 * border || width > 2 + ctx->Const.MaxTextureSize |
| 679 | || logbase2( width - 2 * border ) < 0) { |
| 680 | if (!isProxy) { |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 681 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 682 | sprintf(message, "glTexImage%dD(width=%d)", dimensions, width); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 683 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 684 | } |
| 685 | return GL_TRUE; |
| 686 | } |
| 687 | |
| 688 | /* Height */ |
| 689 | if (dimensions >= 2) { |
| 690 | if (height < 2 * border || height > 2 + ctx->Const.MaxTextureSize |
| 691 | || logbase2( height - 2 * border ) < 0) { |
| 692 | if (!isProxy) { |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 693 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 694 | sprintf(message, "glTexImage%dD(height=%d)", dimensions, height); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 695 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 696 | } |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 697 | return GL_TRUE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 698 | } |
| 699 | } |
| 700 | |
| Brian Paul | ad81770 | 2000-05-30 00:27:24 +0000 | [diff] [blame] | 701 | /* For cube map, width must equal height */ |
| 702 | if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && |
| 703 | target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { |
| 704 | if (width != height) { |
| 705 | if (!isProxy) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 706 | _mesa_error(ctx, GL_INVALID_VALUE, "glTexImage2D(width != height)"); |
| Brian Paul | ad81770 | 2000-05-30 00:27:24 +0000 | [diff] [blame] | 707 | } |
| 708 | return GL_TRUE; |
| 709 | } |
| 710 | } |
| 711 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 712 | /* Depth */ |
| 713 | if (dimensions >= 3) { |
| 714 | if (depth < 2 * border || depth > 2 + ctx->Const.MaxTextureSize |
| 715 | || logbase2( depth - 2 * border ) < 0) { |
| 716 | if (!isProxy) { |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 717 | char message[100]; |
| 718 | sprintf(message, "glTexImage3D(depth=%d)", depth ); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 719 | _mesa_error( ctx, GL_INVALID_VALUE, message ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 720 | } |
| 721 | return GL_TRUE; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | /* Level */ |
| Brian Paul | 9fd2b0a | 2000-03-24 23:59:06 +0000 | [diff] [blame] | 726 | if (level < 0 || level >= ctx->Const.MaxTextureLevels) { |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 727 | if (!isProxy) { |
| 728 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 729 | sprintf(message, "glTexImage%dD(level=%d)", dimensions, level); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 730 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 731 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 732 | return GL_TRUE; |
| 733 | } |
| 734 | |
| Brian Paul | 1f57563 | 2001-02-26 18:24:55 +0000 | [diff] [blame] | 735 | /* For cube map, width must equal height */ |
| 736 | if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && |
| 737 | target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { |
| 738 | if (width != height) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 739 | _mesa_error(ctx, GL_INVALID_VALUE, "glTexImage2D(width != height)"); |
| Brian Paul | 1f57563 | 2001-02-26 18:24:55 +0000 | [diff] [blame] | 740 | return GL_TRUE; |
| 741 | } |
| 742 | } |
| 743 | |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 744 | iformat = _mesa_base_tex_format( ctx, internalFormat ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 745 | if (iformat < 0) { |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 746 | if (!isProxy) { |
| 747 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 748 | sprintf(message, "glTexImage%dD(internalFormat=0x%x)", dimensions, |
| 749 | internalFormat); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 750 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 751 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 752 | return GL_TRUE; |
| 753 | } |
| 754 | |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 755 | if (!is_compressed_format(ctx, internalFormat)) { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 756 | if (!_mesa_is_legal_format_and_type( format, type )) { |
| 757 | /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there |
| 758 | * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4. |
| 759 | */ |
| 760 | if (!isProxy) { |
| 761 | char message[100]; |
| 762 | sprintf(message, "glTexImage%dD(format or type)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 763 | _mesa_error(ctx, GL_INVALID_OPERATION, message); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 764 | } |
| 765 | return GL_TRUE; |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 766 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | /* if we get here, the parameters are OK */ |
| 770 | return GL_FALSE; |
| 771 | } |
| 772 | |
| 773 | |
| 774 | |
| 775 | /* |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 776 | * Test glTexSubImage[123]D() parameters for errors. |
| 777 | * Input: |
| 778 | * dimensions - must be 1 or 2 or 3 |
| 779 | * Return: GL_TRUE = an error was detected, GL_FALSE = no errors |
| 780 | */ |
| 781 | static GLboolean |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 782 | subtexture_error_check( GLcontext *ctx, GLuint dimensions, |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 783 | GLenum target, GLint level, |
| 784 | GLint xoffset, GLint yoffset, GLint zoffset, |
| 785 | GLint width, GLint height, GLint depth, |
| 786 | GLenum format, GLenum type ) |
| 787 | { |
| 788 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 789 | struct gl_texture_image *destTex; |
| 790 | |
| 791 | if (dimensions == 1) { |
| 792 | if (target != GL_TEXTURE_1D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 793 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(target)" ); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 794 | return GL_TRUE; |
| 795 | } |
| 796 | } |
| 797 | else if (dimensions == 2) { |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 798 | if (ctx->Extensions.ARB_texture_cube_map) { |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 799 | if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || |
| 800 | target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) && |
| 801 | target != GL_TEXTURE_2D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 802 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 803 | return GL_TRUE; |
| 804 | } |
| 805 | } |
| 806 | else if (target != GL_TEXTURE_2D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 807 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 808 | return GL_TRUE; |
| 809 | } |
| 810 | } |
| 811 | else if (dimensions == 3) { |
| 812 | if (target != GL_TEXTURE_3D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 813 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage3D(target)" ); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 814 | return GL_TRUE; |
| 815 | } |
| 816 | } |
| 817 | else { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 818 | _mesa_problem( ctx, "bad dims in texture_error_check" ); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 819 | return GL_TRUE; |
| 820 | } |
| 821 | |
| 822 | if (level < 0 || level >= ctx->Const.MaxTextureLevels) { |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 823 | char message[100]; |
| 824 | sprintf(message, "glTexSubImage2D(level=%d)", level); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 825 | _mesa_error(ctx, GL_INVALID_ENUM, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 826 | return GL_TRUE; |
| 827 | } |
| 828 | |
| 829 | if (width < 0) { |
| 830 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 831 | sprintf(message, "glTexSubImage%dD(width=%d)", dimensions, width); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 832 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 833 | return GL_TRUE; |
| 834 | } |
| 835 | if (height < 0 && dimensions > 1) { |
| 836 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 837 | sprintf(message, "glTexSubImage%dD(height=%d)", dimensions, height); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 838 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 839 | return GL_TRUE; |
| 840 | } |
| 841 | if (depth < 0 && dimensions > 2) { |
| 842 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 843 | sprintf(message, "glTexSubImage%dD(depth=%d)", dimensions, depth); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 844 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 845 | return GL_TRUE; |
| 846 | } |
| 847 | |
| Brian Paul | f2718b0 | 2001-01-23 23:35:23 +0000 | [diff] [blame] | 848 | destTex = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 849 | |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 850 | if (!destTex) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 851 | _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage2D"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 852 | return GL_TRUE; |
| 853 | } |
| 854 | |
| 855 | if (xoffset < -((GLint)destTex->Border)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 856 | _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage1/2/3D(xoffset)"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 857 | return GL_TRUE; |
| 858 | } |
| 859 | if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 860 | _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage1/2/3D(xoffset+width)"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 861 | return GL_TRUE; |
| 862 | } |
| 863 | if (dimensions > 1) { |
| 864 | if (yoffset < -((GLint)destTex->Border)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 865 | _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage2/3D(yoffset)"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 866 | return GL_TRUE; |
| 867 | } |
| 868 | if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 869 | _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage2/3D(yoffset+height)"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 870 | return GL_TRUE; |
| 871 | } |
| 872 | } |
| 873 | if (dimensions > 2) { |
| 874 | if (zoffset < -((GLint)destTex->Border)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 875 | _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 876 | return GL_TRUE; |
| 877 | } |
| 878 | if (zoffset + depth > (GLint) (destTex->Depth+destTex->Border)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 879 | _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 880 | return GL_TRUE; |
| 881 | } |
| 882 | } |
| 883 | |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 884 | if (!is_compressed_format(ctx, destTex->IntFormat)) { |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 885 | if (!_mesa_is_legal_format_and_type(format, type)) { |
| 886 | char message[100]; |
| 887 | sprintf(message, "glTexSubImage%dD(format or type)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 888 | _mesa_error(ctx, GL_INVALID_ENUM, message); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 889 | return GL_TRUE; |
| 890 | } |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | return GL_FALSE; |
| 894 | } |
| 895 | |
| 896 | |
| 897 | /* |
| 898 | * Test glCopyTexImage[12]D() parameters for errors. |
| 899 | * Input: dimensions - must be 1 or 2 or 3 |
| 900 | * Return: GL_TRUE = an error was detected, GL_FALSE = no errors |
| 901 | */ |
| 902 | static GLboolean |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 903 | copytexture_error_check( GLcontext *ctx, GLuint dimensions, |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 904 | GLenum target, GLint level, GLint internalFormat, |
| 905 | GLint width, GLint height, GLint border ) |
| 906 | { |
| 907 | GLint iformat; |
| 908 | |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 909 | if (dimensions == 1) { |
| 910 | if (target != GL_TEXTURE_1D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 911 | _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" ); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 912 | return GL_TRUE; |
| 913 | } |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 914 | } |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 915 | else if (dimensions == 2) { |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 916 | if (ctx->Extensions.ARB_texture_cube_map) { |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 917 | if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || |
| 918 | target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) && |
| 919 | target != GL_TEXTURE_2D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 920 | _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 921 | return GL_TRUE; |
| 922 | } |
| 923 | } |
| 924 | else if (target != GL_TEXTURE_2D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 925 | _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 926 | return GL_TRUE; |
| 927 | } |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | /* Border */ |
| 931 | if (border!=0 && border!=1) { |
| 932 | char message[100]; |
| 933 | sprintf(message, "glCopyTexImage%dD(border)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 934 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 935 | return GL_TRUE; |
| 936 | } |
| 937 | |
| 938 | /* Width */ |
| 939 | if (width < 2 * border || width > 2 + ctx->Const.MaxTextureSize |
| 940 | || logbase2( width - 2 * border ) < 0) { |
| 941 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 942 | sprintf(message, "glCopyTexImage%dD(width=%d)", dimensions, width); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 943 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 944 | return GL_TRUE; |
| 945 | } |
| 946 | |
| 947 | /* Height */ |
| 948 | if (dimensions >= 2) { |
| 949 | if (height < 2 * border || height > 2 + ctx->Const.MaxTextureSize |
| 950 | || logbase2( height - 2 * border ) < 0) { |
| 951 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 952 | sprintf(message, "glCopyTexImage%dD(height=%d)", dimensions, height); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 953 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 954 | return GL_TRUE; |
| 955 | } |
| 956 | } |
| 957 | |
| Brian Paul | ad81770 | 2000-05-30 00:27:24 +0000 | [diff] [blame] | 958 | /* For cube map, width must equal height */ |
| 959 | if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && |
| 960 | target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { |
| 961 | if (width != height) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 962 | _mesa_error(ctx, GL_INVALID_VALUE, "glCopyTexImage2D(width != height)"); |
| Brian Paul | ad81770 | 2000-05-30 00:27:24 +0000 | [diff] [blame] | 963 | return GL_TRUE; |
| 964 | } |
| 965 | } |
| 966 | |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 967 | /* Level */ |
| 968 | if (level<0 || level>=ctx->Const.MaxTextureLevels) { |
| 969 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 970 | sprintf(message, "glCopyTexImage%dD(level=%d)", dimensions, level); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 971 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 972 | return GL_TRUE; |
| 973 | } |
| 974 | |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 975 | iformat = _mesa_base_tex_format( ctx, internalFormat ); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 976 | if (iformat < 0) { |
| 977 | char message[100]; |
| 978 | sprintf(message, "glCopyTexImage%dD(internalFormat)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 979 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 980 | return GL_TRUE; |
| 981 | } |
| 982 | |
| 983 | /* if we get here, the parameters are OK */ |
| 984 | return GL_FALSE; |
| 985 | } |
| 986 | |
| 987 | |
| 988 | static GLboolean |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 989 | copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions, |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 990 | GLenum target, GLint level, |
| 991 | GLint xoffset, GLint yoffset, GLint zoffset, |
| Brian Paul | 5b37c32 | 1999-11-05 06:43:10 +0000 | [diff] [blame] | 992 | GLsizei width, GLsizei height ) |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 993 | { |
| 994 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 995 | struct gl_texture_image *teximage; |
| 996 | |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 997 | if (dimensions == 1) { |
| 998 | if (target != GL_TEXTURE_1D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 999 | _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" ); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 1000 | return GL_TRUE; |
| 1001 | } |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1002 | } |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 1003 | else if (dimensions == 2) { |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 1004 | if (ctx->Extensions.ARB_texture_cube_map) { |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 1005 | if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || |
| 1006 | target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) && |
| 1007 | target != GL_TEXTURE_2D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1008 | _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 1009 | return GL_TRUE; |
| 1010 | } |
| 1011 | } |
| 1012 | else if (target != GL_TEXTURE_2D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1013 | _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 1014 | return GL_TRUE; |
| 1015 | } |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1016 | } |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 1017 | else if (dimensions == 3) { |
| 1018 | if (target != GL_TEXTURE_3D) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1019 | _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" ); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 1020 | return GL_TRUE; |
| 1021 | } |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
| 1024 | if (level < 0 || level >= ctx->Const.MaxTextureLevels) { |
| 1025 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 1026 | sprintf(message, "glCopyTexSubImage%dD(level=%d)", dimensions, level); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1027 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1028 | return GL_TRUE; |
| 1029 | } |
| 1030 | |
| 1031 | if (width < 0) { |
| 1032 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 1033 | sprintf(message, "glCopyTexSubImage%dD(width=%d)", dimensions, width); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1034 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1035 | return GL_TRUE; |
| 1036 | } |
| 1037 | if (dimensions > 1 && height < 0) { |
| 1038 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 1039 | sprintf(message, "glCopyTexSubImage%dD(height=%d)", dimensions, height); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1040 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1041 | return GL_TRUE; |
| 1042 | } |
| 1043 | |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 1044 | teximage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1045 | if (!teximage) { |
| 1046 | char message[100]; |
| 1047 | sprintf(message, "glCopyTexSubImage%dD(undefined texture)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1048 | _mesa_error(ctx, GL_INVALID_OPERATION, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1049 | return GL_TRUE; |
| 1050 | } |
| 1051 | |
| 1052 | if (xoffset < -((GLint)teximage->Border)) { |
| 1053 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 1054 | sprintf(message, "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1055 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1056 | return GL_TRUE; |
| 1057 | } |
| 1058 | if (xoffset+width > (GLint) (teximage->Width+teximage->Border)) { |
| 1059 | char message[100]; |
| 1060 | sprintf(message, "glCopyTexSubImage%dD(xoffset+width)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1061 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1062 | return GL_TRUE; |
| 1063 | } |
| 1064 | if (dimensions > 1) { |
| 1065 | if (yoffset < -((GLint)teximage->Border)) { |
| 1066 | char message[100]; |
| Brian Paul | ec15398 | 2000-12-08 18:09:33 +0000 | [diff] [blame] | 1067 | sprintf(message, "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1068 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1069 | return GL_TRUE; |
| 1070 | } |
| 1071 | /* NOTE: we're adding the border here, not subtracting! */ |
| 1072 | if (yoffset+height > (GLint) (teximage->Height+teximage->Border)) { |
| 1073 | char message[100]; |
| 1074 | sprintf(message, "glCopyTexSubImage%dD(yoffset+height)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1075 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1076 | return GL_TRUE; |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | if (dimensions > 2) { |
| 1081 | if (zoffset < -((GLint)teximage->Border)) { |
| 1082 | char message[100]; |
| 1083 | sprintf(message, "glCopyTexSubImage%dD(zoffset)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1084 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1085 | return GL_TRUE; |
| 1086 | } |
| 1087 | if (zoffset > (GLint) (teximage->Depth+teximage->Border)) { |
| 1088 | char message[100]; |
| 1089 | sprintf(message, "glCopyTexSubImage%dD(zoffset+depth)", dimensions); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1090 | _mesa_error(ctx, GL_INVALID_VALUE, message); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1091 | return GL_TRUE; |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | /* if we get here, the parameters are OK */ |
| 1096 | return GL_FALSE; |
| 1097 | } |
| 1098 | |
| 1099 | |
| 1100 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1101 | void |
| 1102 | _mesa_GetTexImage( GLenum target, GLint level, GLenum format, |
| 1103 | GLenum type, GLvoid *pixels ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1104 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1105 | GET_CURRENT_CONTEXT(ctx); |
| Brian Paul | 01e5475 | 2000-09-05 15:40:34 +0000 | [diff] [blame] | 1106 | const struct gl_texture_unit *texUnit; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1107 | const struct gl_texture_object *texObj; |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1108 | struct gl_texture_image *texImage; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1109 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1110 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1111 | |
| 1112 | if (level < 0 || level >= ctx->Const.MaxTextureLevels) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1113 | _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1114 | return; |
| 1115 | } |
| 1116 | |
| Brian Paul | b7d076f | 2000-03-21 01:03:40 +0000 | [diff] [blame] | 1117 | if (_mesa_sizeof_type(type) <= 0) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1118 | _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1119 | return; |
| 1120 | } |
| 1121 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1122 | if (_mesa_components_in_format(format) <= 0 || |
| 1123 | format == GL_STENCIL_INDEX) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1124 | _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1125 | return; |
| 1126 | } |
| 1127 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1128 | if (!ctx->Extensions.EXT_paletted_texture && is_index_format(format)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1129 | _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | if (!ctx->Extensions.SGIX_depth_texture && format == GL_DEPTH_COMPONENT) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1133 | _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | /* XXX what if format/type doesn't match texture format/type? */ |
| 1137 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1138 | if (!pixels) |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1139 | return; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1140 | |
| Brian Paul | 01e5475 | 2000-09-05 15:40:34 +0000 | [diff] [blame] | 1141 | texUnit = &(ctx->Texture.Unit[ctx->Texture.CurrentUnit]); |
| 1142 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1143 | if (!texObj || is_proxy_target(target)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1144 | _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)"); |
| Brian Paul | 01e5475 | 2000-09-05 15:40:34 +0000 | [diff] [blame] | 1145 | return; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1146 | } |
| 1147 | |
| Brian Paul | 8e3366f | 2000-11-10 15:32:07 +0000 | [diff] [blame] | 1148 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1149 | if (!texImage) { |
| Brian Paul | 7298e71 | 2000-11-07 16:40:37 +0000 | [diff] [blame] | 1150 | /* invalid mipmap level, not an error */ |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1151 | return; |
| 1152 | } |
| 1153 | |
| 1154 | if (!texImage->Data) { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1155 | /* no image data, not an error */ |
| 1156 | return; |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1157 | } |
| 1158 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1159 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1160 | _mesa_update_state(ctx); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1161 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1162 | if (is_color_format(format) && |
| 1163 | ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1164 | /* convert texture image to GL_RGBA, GL_FLOAT */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1165 | GLint width = texImage->Width; |
| 1166 | GLint height = texImage->Height; |
| Brian Paul | f96ce6a | 2000-09-06 15:15:43 +0000 | [diff] [blame] | 1167 | GLint depth = texImage->Depth; |
| 1168 | GLint img, row; |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1169 | GLfloat *tmpImage, *convImage; |
| 1170 | tmpImage = (GLfloat *) MALLOC(width * height * 4 * sizeof(GLfloat)); |
| 1171 | if (!tmpImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1172 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1173 | return; |
| 1174 | } |
| 1175 | convImage = (GLfloat *) MALLOC(width * height * 4 * sizeof(GLfloat)); |
| 1176 | if (!convImage) { |
| 1177 | FREE(tmpImage); |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1178 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage"); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1179 | return; |
| 1180 | } |
| 1181 | |
| 1182 | for (img = 0; img < depth; img++) { |
| 1183 | GLint convWidth, convHeight; |
| 1184 | |
| 1185 | /* convert texture data to GLfloat/GL_RGBA */ |
| 1186 | for (row = 0; row < height; row++) { |
| 1187 | GLchan texels[1 << MAX_TEXTURE_LEVELS][4]; |
| 1188 | GLint col; |
| 1189 | GLfloat *dst = tmpImage + row * width * 4; |
| 1190 | for (col = 0; col < width; col++) { |
| Brian Paul | e75d242 | 2001-02-17 18:41:01 +0000 | [diff] [blame] | 1191 | (*texImage->FetchTexel)(texImage, col, row, img, |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1192 | texels[col]); |
| 1193 | } |
| 1194 | _mesa_unpack_float_color_span(ctx, width, GL_RGBA, dst, |
| 1195 | GL_RGBA, CHAN_TYPE, texels, |
| 1196 | &_mesa_native_packing, |
| 1197 | ctx->_ImageTransferState & IMAGE_PRE_CONVOLUTION_BITS, |
| 1198 | GL_FALSE); |
| 1199 | } |
| 1200 | |
| 1201 | convWidth = width; |
| 1202 | convHeight = height; |
| 1203 | |
| 1204 | /* convolve */ |
| 1205 | if (target == GL_TEXTURE_1D) { |
| 1206 | if (ctx->Pixel.Convolution1DEnabled) { |
| 1207 | _mesa_convolve_1d_image(ctx, &convWidth, tmpImage, convImage); |
| 1208 | } |
| 1209 | } |
| 1210 | else { |
| 1211 | if (ctx->Pixel.Convolution2DEnabled) { |
| 1212 | _mesa_convolve_2d_image(ctx, &convWidth, &convHeight, |
| 1213 | tmpImage, convImage); |
| 1214 | } |
| 1215 | else if (ctx->Pixel.Separable2DEnabled) { |
| 1216 | _mesa_convolve_sep_image(ctx, &convWidth, &convHeight, |
| 1217 | tmpImage, convImage); |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | /* pack convolved image */ |
| 1222 | for (row = 0; row < convHeight; row++) { |
| 1223 | const GLfloat *src = convImage + row * convWidth * 4; |
| 1224 | GLvoid *dest = _mesa_image_address(&ctx->Pack, pixels, |
| 1225 | convWidth, convHeight, |
| 1226 | format, type, img, row, 0); |
| 1227 | _mesa_pack_float_rgba_span(ctx, convWidth, |
| 1228 | (const GLfloat(*)[4]) src, |
| 1229 | format, type, dest, &ctx->Pack, |
| 1230 | ctx->_ImageTransferState & IMAGE_POST_CONVOLUTION_BITS); |
| 1231 | } |
| 1232 | } |
| 1233 | |
| 1234 | FREE(tmpImage); |
| 1235 | FREE(convImage); |
| 1236 | } |
| 1237 | else { |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1238 | /* no convolution, or non-rgba image */ |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1239 | GLint width = texImage->Width; |
| 1240 | GLint height = texImage->Height; |
| 1241 | GLint depth = texImage->Depth; |
| 1242 | GLint img, row; |
| 1243 | for (img = 0; img < depth; img++) { |
| 1244 | for (row = 0; row < height; row++) { |
| 1245 | /* compute destination address in client memory */ |
| 1246 | GLvoid *dest = _mesa_image_address( &ctx->Unpack, pixels, |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1247 | width, height, format, type, |
| 1248 | img, row, 0); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1249 | assert(dest); |
| 1250 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1251 | if (format == GL_COLOR_INDEX) { |
| 1252 | GLuint indexRow[MAX_WIDTH]; |
| 1253 | GLint col; |
| 1254 | for (col = 0; col < width; col++) { |
| Brian Paul | e75d242 | 2001-02-17 18:41:01 +0000 | [diff] [blame] | 1255 | (*texImage->FetchTexel)(texImage, col, row, img, |
| 1256 | (GLvoid *) &indexRow[col]); |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1257 | } |
| 1258 | _mesa_pack_index_span(ctx, width, type, dest, |
| 1259 | indexRow, &ctx->Pack, |
| 1260 | ctx->_ImageTransferState); |
| 1261 | } |
| 1262 | else if (format == GL_DEPTH_COMPONENT) { |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1263 | GLfloat depthRow[MAX_WIDTH]; |
| 1264 | GLint col; |
| 1265 | for (col = 0; col < width; col++) { |
| Brian Paul | e75d242 | 2001-02-17 18:41:01 +0000 | [diff] [blame] | 1266 | (*texImage->FetchTexel)(texImage, col, row, img, |
| 1267 | (GLvoid *) &depthRow[col]); |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1268 | } |
| 1269 | _mesa_pack_depth_span(ctx, width, dest, type, |
| 1270 | depthRow, &ctx->Pack); |
| 1271 | } |
| 1272 | else { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1273 | /* general case: convert row to RGBA format */ |
| 1274 | GLchan rgba[MAX_WIDTH][4]; |
| 1275 | GLint col; |
| 1276 | for (col = 0; col < width; col++) { |
| Brian Paul | e75d242 | 2001-02-17 18:41:01 +0000 | [diff] [blame] | 1277 | (*texImage->FetchTexel)(texImage, col, row, img, |
| 1278 | (GLvoid *) rgba[col]); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1279 | } |
| Brian Paul | e75d242 | 2001-02-17 18:41:01 +0000 | [diff] [blame] | 1280 | _mesa_pack_rgba_span(ctx, width, (const GLchan (*)[4])rgba, |
| 1281 | format, type, dest, &ctx->Pack, |
| 1282 | ctx->_ImageTransferState); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1283 | } /* format */ |
| 1284 | } /* row */ |
| 1285 | } /* img */ |
| 1286 | } /* convolution */ |
| 1287 | } |
| 1288 | |
| 1289 | |
| 1290 | |
| 1291 | /* |
| 1292 | * Called from the API. Note that width includes the border. |
| 1293 | */ |
| 1294 | void |
| 1295 | _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, |
| 1296 | GLsizei width, GLint border, GLenum format, |
| 1297 | GLenum type, const GLvoid *pixels ) |
| 1298 | { |
| 1299 | GLsizei postConvWidth = width; |
| 1300 | GET_CURRENT_CONTEXT(ctx); |
| 1301 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1302 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1303 | if (is_color_format(internalFormat)) { |
| 1304 | _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); |
| 1305 | } |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1306 | |
| 1307 | if (target == GL_TEXTURE_1D) { |
| 1308 | struct gl_texture_unit *texUnit; |
| 1309 | struct gl_texture_object *texObj; |
| 1310 | struct gl_texture_image *texImage; |
| 1311 | |
| 1312 | if (texture_error_check(ctx, target, level, internalFormat, |
| 1313 | format, type, 1, postConvWidth, 1, 1, border)) { |
| 1314 | return; /* error was recorded */ |
| 1315 | } |
| 1316 | |
| 1317 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1318 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 1319 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 1320 | |
| 1321 | if (!texImage) { |
| 1322 | texImage = _mesa_alloc_texture_image(); |
| 1323 | texObj->Image[level] = texImage; |
| 1324 | if (!texImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1325 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1326 | return; |
| 1327 | } |
| 1328 | } |
| 1329 | else if (texImage->Data) { |
| 1330 | /* free the old texture data */ |
| 1331 | FREE(texImage->Data); |
| 1332 | texImage->Data = NULL; |
| 1333 | } |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1334 | clear_teximage_fields(texImage); /* not really needed, but helpful */ |
| Brian Paul | 6628bc9 | 2001-02-07 03:27:41 +0000 | [diff] [blame] | 1335 | init_teximage_fields(ctx, texImage, postConvWidth, 1, 1, |
| 1336 | border, internalFormat); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1337 | |
| Brian Paul | 9499e01 | 2000-10-30 16:32:42 +0000 | [diff] [blame] | 1338 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1339 | _mesa_update_state(ctx); |
| Brian Paul | fa4525e | 2000-08-21 14:22:24 +0000 | [diff] [blame] | 1340 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1341 | ASSERT(ctx->Driver.TexImage1D); |
| 1342 | if (pixels) { |
| 1343 | (*ctx->Driver.TexImage1D)(ctx, target, level, internalFormat, |
| 1344 | width, border, format, type, pixels, |
| 1345 | &ctx->Unpack, texObj, texImage); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1346 | } |
| Brian Paul | f96ce6a | 2000-09-06 15:15:43 +0000 | [diff] [blame] | 1347 | else { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1348 | GLubyte *dummy = make_null_texture(width, 1, 1, format); |
| 1349 | if (dummy) { |
| 1350 | (*ctx->Driver.TexImage1D)(ctx, target, level, internalFormat, |
| 1351 | width, border, |
| 1352 | format, GL_UNSIGNED_BYTE, dummy, |
| 1353 | &_mesa_native_packing, texObj, texImage); |
| 1354 | FREE(dummy); |
| 1355 | } |
| 1356 | } |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1357 | |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1358 | /* one of these has to be non-zero! */ |
| 1359 | ASSERT(texImage->RedBits || texImage->IndexBits || texImage->AlphaBits || |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1360 | texImage->LuminanceBits || texImage->IntensityBits || |
| 1361 | texImage->DepthBits); |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1362 | ASSERT(texImage->FetchTexel); |
| 1363 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1364 | /* state update */ |
| 1365 | texObj->Complete = GL_FALSE; |
| 1366 | ctx->NewState |= _NEW_TEXTURE; |
| 1367 | } |
| 1368 | else if (target == GL_PROXY_TEXTURE_1D) { |
| 1369 | /* Proxy texture: check for errors and update proxy state */ |
| 1370 | GLenum error = texture_error_check(ctx, target, level, internalFormat, |
| 1371 | format, type, 1, |
| 1372 | postConvWidth, 1, 1, border); |
| 1373 | if (!error) { |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 1374 | struct gl_texture_unit *texUnit; |
| 1375 | struct gl_texture_image *texImage; |
| 1376 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1377 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 1378 | init_teximage_fields(ctx, texImage, postConvWidth, 1, 1, |
| 1379 | border, internalFormat); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1380 | ASSERT(ctx->Driver.TestProxyTexImage); |
| 1381 | error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, |
| 1382 | internalFormat, format, type, |
| 1383 | postConvWidth, 1, 1, border); |
| 1384 | } |
| 1385 | if (error) { |
| 1386 | /* if error, clear all proxy texture image parameters */ |
| 1387 | if (level >= 0 && level < ctx->Const.MaxTextureLevels) { |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1388 | clear_teximage_fields(ctx->Texture.Proxy1D->Image[level]); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1389 | } |
| 1390 | } |
| 1391 | } |
| 1392 | else { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1393 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" ); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1394 | return; |
| 1395 | } |
| 1396 | } |
| 1397 | |
| 1398 | |
| 1399 | void |
| 1400 | _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, |
| 1401 | GLsizei width, GLsizei height, GLint border, |
| 1402 | GLenum format, GLenum type, |
| 1403 | const GLvoid *pixels ) |
| 1404 | { |
| 1405 | GLsizei postConvWidth = width, postConvHeight = height; |
| 1406 | GET_CURRENT_CONTEXT(ctx); |
| 1407 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1408 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1409 | if (is_color_format(internalFormat)) { |
| 1410 | _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, |
| 1411 | &postConvHeight); |
| 1412 | } |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1413 | |
| 1414 | if (target == GL_TEXTURE_2D || |
| 1415 | (ctx->Extensions.ARB_texture_cube_map && |
| 1416 | target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && |
| 1417 | target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { |
| 1418 | /* non-proxy target */ |
| 1419 | struct gl_texture_unit *texUnit; |
| 1420 | struct gl_texture_object *texObj; |
| 1421 | struct gl_texture_image *texImage; |
| 1422 | |
| 1423 | if (texture_error_check(ctx, target, level, internalFormat, |
| 1424 | format, type, 2, postConvWidth, postConvHeight, |
| 1425 | 1, border)) { |
| 1426 | return; /* error was recorded */ |
| 1427 | } |
| 1428 | |
| 1429 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1430 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 1431 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 1432 | |
| 1433 | if (!texImage) { |
| 1434 | texImage = _mesa_alloc_texture_image(); |
| 1435 | set_tex_image(texObj, target, level, texImage); |
| 1436 | if (!texImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1437 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1438 | return; |
| 1439 | } |
| 1440 | } |
| 1441 | else if (texImage->Data) { |
| 1442 | /* free the old texture data */ |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1443 | FREE(texImage->Data); |
| 1444 | texImage->Data = NULL; |
| 1445 | } |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1446 | clear_teximage_fields(texImage); /* not really needed, but helpful */ |
| Brian Paul | 6628bc9 | 2001-02-07 03:27:41 +0000 | [diff] [blame] | 1447 | init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight, 1, |
| 1448 | border, internalFormat); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1449 | |
| 1450 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1451 | _mesa_update_state(ctx); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1452 | |
| 1453 | ASSERT(ctx->Driver.TexImage2D); |
| 1454 | if (pixels) { |
| 1455 | (*ctx->Driver.TexImage2D)(ctx, target, level, internalFormat, |
| 1456 | width, height, border, format, type, pixels, |
| 1457 | &ctx->Unpack, texObj, texImage); |
| 1458 | } |
| 1459 | else { |
| 1460 | GLubyte *dummy = make_null_texture(width, height, 1, format); |
| 1461 | if (dummy) { |
| 1462 | (*ctx->Driver.TexImage2D)(ctx, target, level, internalFormat, |
| 1463 | width, height, border, |
| 1464 | format, GL_UNSIGNED_BYTE, dummy, |
| 1465 | &_mesa_native_packing, texObj, texImage); |
| 1466 | FREE(dummy); |
| 1467 | } |
| 1468 | } |
| 1469 | |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1470 | /* one of these has to be non-zero! */ |
| 1471 | ASSERT(texImage->RedBits || texImage->IndexBits || texImage->AlphaBits || |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1472 | texImage->LuminanceBits || texImage->IntensityBits || |
| 1473 | texImage->DepthBits); |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1474 | ASSERT(texImage->FetchTexel); |
| 1475 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1476 | /* state update */ |
| 1477 | texObj->Complete = GL_FALSE; |
| 1478 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1479 | } |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1480 | else if (target == GL_PROXY_TEXTURE_2D) { |
| 1481 | /* Proxy texture: check for errors and update proxy state */ |
| 1482 | GLenum error = texture_error_check(ctx, target, level, internalFormat, |
| 1483 | format, type, 2, |
| 1484 | postConvWidth, postConvHeight, 1, border); |
| 1485 | if (!error) { |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 1486 | struct gl_texture_unit *texUnit; |
| 1487 | struct gl_texture_image *texImage; |
| 1488 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1489 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 1490 | init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight, 1, |
| 1491 | border, internalFormat); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1492 | ASSERT(ctx->Driver.TestProxyTexImage); |
| 1493 | error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, |
| 1494 | internalFormat, format, type, |
| 1495 | postConvWidth, postConvHeight, 1, border); |
| 1496 | } |
| 1497 | if (error) { |
| 1498 | /* if error, clear all proxy texture image parameters */ |
| 1499 | if (level >= 0 && level < ctx->Const.MaxTextureLevels) { |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1500 | clear_teximage_fields(ctx->Texture.Proxy2D->Image[level]); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1501 | } |
| 1502 | } |
| 1503 | } |
| 1504 | else { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1505 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" ); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1506 | return; |
| 1507 | } |
| 1508 | } |
| 1509 | |
| 1510 | |
| 1511 | /* |
| 1512 | * Called by the API or display list executor. |
| 1513 | * Note that width and height include the border. |
| 1514 | */ |
| 1515 | void |
| 1516 | _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, |
| 1517 | GLsizei width, GLsizei height, GLsizei depth, |
| 1518 | GLint border, GLenum format, GLenum type, |
| 1519 | const GLvoid *pixels ) |
| 1520 | { |
| 1521 | GET_CURRENT_CONTEXT(ctx); |
| 1522 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1523 | |
| 1524 | if (target == GL_TEXTURE_3D) { |
| 1525 | struct gl_texture_unit *texUnit; |
| 1526 | struct gl_texture_object *texObj; |
| 1527 | struct gl_texture_image *texImage; |
| 1528 | |
| 1529 | if (texture_error_check(ctx, target, level, internalFormat, |
| 1530 | format, type, 3, width, height, depth, border)) { |
| 1531 | return; /* error was recorded */ |
| 1532 | } |
| 1533 | |
| 1534 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1535 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 1536 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 1537 | |
| 1538 | if (!texImage) { |
| 1539 | texImage = _mesa_alloc_texture_image(); |
| 1540 | texObj->Image[level] = texImage; |
| 1541 | if (!texImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1542 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1543 | return; |
| 1544 | } |
| 1545 | } |
| 1546 | else if (texImage->Data) { |
| 1547 | FREE(texImage->Data); |
| 1548 | texImage->Data = NULL; |
| 1549 | } |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1550 | clear_teximage_fields(texImage); /* not really needed, but helpful */ |
| Brian Paul | 6628bc9 | 2001-02-07 03:27:41 +0000 | [diff] [blame] | 1551 | init_teximage_fields(ctx, texImage, width, height, depth, border, |
| 1552 | internalFormat); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1553 | |
| 1554 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1555 | _mesa_update_state(ctx); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1556 | |
| 1557 | ASSERT(ctx->Driver.TexImage3D); |
| 1558 | if (pixels) { |
| 1559 | (*ctx->Driver.TexImage3D)(ctx, target, level, internalFormat, |
| 1560 | width, height, depth, border, |
| 1561 | format, type, pixels, |
| 1562 | &ctx->Unpack, texObj, texImage); |
| 1563 | } |
| 1564 | else { |
| 1565 | GLubyte *dummy = make_null_texture(width, height, depth, format); |
| 1566 | if (dummy) { |
| 1567 | (*ctx->Driver.TexImage3D)(ctx, target, level, internalFormat, |
| 1568 | width, height, depth, border, |
| 1569 | format, GL_UNSIGNED_BYTE, dummy, |
| 1570 | &_mesa_native_packing, texObj, texImage); |
| 1571 | FREE(dummy); |
| 1572 | } |
| 1573 | } |
| 1574 | |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1575 | /* one of these has to be non-zero! */ |
| 1576 | ASSERT(texImage->RedBits || texImage->IndexBits || texImage->AlphaBits || |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1577 | texImage->LuminanceBits || texImage->IntensityBits || |
| 1578 | texImage->DepthBits); |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1579 | ASSERT(texImage->FetchTexel); |
| 1580 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1581 | /* state update */ |
| 1582 | texObj->Complete = GL_FALSE; |
| 1583 | ctx->NewState |= _NEW_TEXTURE; |
| 1584 | } |
| 1585 | else if (target == GL_PROXY_TEXTURE_3D) { |
| 1586 | /* Proxy texture: check for errors and update proxy state */ |
| 1587 | GLenum error = texture_error_check(ctx, target, level, internalFormat, |
| 1588 | format, type, 3, width, height, depth, border); |
| 1589 | if (!error) { |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 1590 | struct gl_texture_unit *texUnit; |
| 1591 | struct gl_texture_image *texImage; |
| 1592 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1593 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 1594 | init_teximage_fields(ctx, texImage, width, height, 1, |
| 1595 | border, internalFormat); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1596 | ASSERT(ctx->Driver.TestProxyTexImage); |
| 1597 | error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, |
| 1598 | internalFormat, format, type, |
| 1599 | width, height, depth, border); |
| 1600 | } |
| 1601 | if (error) { |
| 1602 | /* if error, clear all proxy texture image parameters */ |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 1603 | if (level >= 0 && level < ctx->Const.MaxTextureLevels) { |
| 1604 | clear_teximage_fields(ctx->Texture.Proxy3D->Image[level]); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1605 | } |
| 1606 | } |
| 1607 | } |
| 1608 | else { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1609 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" ); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1610 | return; |
| 1611 | } |
| 1612 | } |
| 1613 | |
| 1614 | |
| 1615 | void |
| 1616 | _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, |
| 1617 | GLsizei width, GLsizei height, GLsizei depth, |
| 1618 | GLint border, GLenum format, GLenum type, |
| 1619 | const GLvoid *pixels ) |
| 1620 | { |
| 1621 | _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height, |
| 1622 | depth, border, format, type, pixels); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1623 | } |
| 1624 | |
| 1625 | |
| 1626 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1627 | void |
| 1628 | _mesa_TexSubImage1D( GLenum target, GLint level, |
| 1629 | GLint xoffset, GLsizei width, |
| 1630 | GLenum format, GLenum type, |
| 1631 | const GLvoid *pixels ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1632 | { |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1633 | GLsizei postConvWidth = width; |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1634 | GET_CURRENT_CONTEXT(ctx); |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1635 | struct gl_texture_unit *texUnit; |
| 1636 | struct gl_texture_object *texObj; |
| 1637 | struct gl_texture_image *texImage; |
| Brian Paul | a805bb9 | 2000-09-02 17:52:21 +0000 | [diff] [blame] | 1638 | |
| Brian Paul | 75280a2 | 2001-03-05 22:18:23 +0000 | [diff] [blame] | 1639 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1640 | |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1641 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1642 | _mesa_update_state(ctx); |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1643 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1644 | /* XXX should test internal format */ |
| 1645 | if (is_color_format(format)) { |
| 1646 | _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); |
| 1647 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1648 | |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1649 | if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0, |
| Brian Paul | a805bb9 | 2000-09-02 17:52:21 +0000 | [diff] [blame] | 1650 | postConvWidth, 1, 1, format, type)) { |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1651 | return; /* error was detected */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1652 | } |
| 1653 | |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1654 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1655 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 1656 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1657 | assert(texImage); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1658 | |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1659 | if (width == 0 || !pixels) |
| 1660 | return; /* no-op, not an error */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1661 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1662 | ASSERT(ctx->Driver.TexSubImage1D); |
| 1663 | (*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width, |
| 1664 | format, type, pixels, &ctx->Unpack, |
| 1665 | texObj, texImage); |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 1666 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1667 | } |
| 1668 | |
| 1669 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1670 | void |
| 1671 | _mesa_TexSubImage2D( GLenum target, GLint level, |
| 1672 | GLint xoffset, GLint yoffset, |
| 1673 | GLsizei width, GLsizei height, |
| 1674 | GLenum format, GLenum type, |
| 1675 | const GLvoid *pixels ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1676 | { |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1677 | GLsizei postConvWidth = width, postConvHeight = height; |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1678 | GET_CURRENT_CONTEXT(ctx); |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1679 | struct gl_texture_unit *texUnit; |
| 1680 | struct gl_texture_object *texObj; |
| 1681 | struct gl_texture_image *texImage; |
| Brian Paul | a805bb9 | 2000-09-02 17:52:21 +0000 | [diff] [blame] | 1682 | |
| Brian Paul | 75280a2 | 2001-03-05 22:18:23 +0000 | [diff] [blame] | 1683 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1684 | |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1685 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1686 | _mesa_update_state(ctx); |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1687 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1688 | /* XXX should test internal format */ |
| 1689 | if (is_color_format(format)) { |
| 1690 | _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, |
| 1691 | &postConvHeight); |
| 1692 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1693 | |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1694 | if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, |
| Brian Paul | a805bb9 | 2000-09-02 17:52:21 +0000 | [diff] [blame] | 1695 | postConvWidth, postConvHeight, 1, format, type)) { |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1696 | return; /* error was detected */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1697 | } |
| 1698 | |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1699 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| Brian Paul | 35d5301 | 2000-05-23 17:14:49 +0000 | [diff] [blame] | 1700 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1701 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1702 | assert(texImage); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1703 | |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1704 | if (width == 0 || height == 0 || !pixels) |
| 1705 | return; /* no-op, not an error */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1706 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1707 | ASSERT(ctx->Driver.TexSubImage2D); |
| 1708 | (*ctx->Driver.TexSubImage2D)(ctx, target, level, xoffset, yoffset, |
| 1709 | width, height, format, type, pixels, |
| 1710 | &ctx->Unpack, texObj, texImage); |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 1711 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1712 | } |
| 1713 | |
| 1714 | |
| 1715 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1716 | void |
| 1717 | _mesa_TexSubImage3D( GLenum target, GLint level, |
| 1718 | GLint xoffset, GLint yoffset, GLint zoffset, |
| 1719 | GLsizei width, GLsizei height, GLsizei depth, |
| 1720 | GLenum format, GLenum type, |
| 1721 | const GLvoid *pixels ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1722 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1723 | GET_CURRENT_CONTEXT(ctx); |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1724 | struct gl_texture_unit *texUnit; |
| 1725 | struct gl_texture_object *texObj; |
| 1726 | struct gl_texture_image *texImage; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1727 | |
| Brian Paul | 75280a2 | 2001-03-05 22:18:23 +0000 | [diff] [blame] | 1728 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1729 | |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1730 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1731 | _mesa_update_state(ctx); |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1732 | |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1733 | if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset, |
| 1734 | width, height, depth, format, type)) { |
| Brian Paul | f7b5707 | 2000-03-20 14:37:52 +0000 | [diff] [blame] | 1735 | return; /* error was detected */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1736 | } |
| 1737 | |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1738 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1739 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 1740 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | 0293878 | 2000-03-22 17:38:11 +0000 | [diff] [blame] | 1741 | assert(texImage); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1742 | |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1743 | if (width == 0 || height == 0 || height == 0 || !pixels) |
| 1744 | return; /* no-op, not an error */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1745 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1746 | ASSERT(ctx->Driver.TexSubImage3D); |
| 1747 | (*ctx->Driver.TexSubImage3D)(ctx, target, level, |
| 1748 | xoffset, yoffset, zoffset, |
| 1749 | width, height, depth, |
| 1750 | format, type, pixels, |
| 1751 | &ctx->Unpack, texObj, texImage ); |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 1752 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1753 | } |
| 1754 | |
| 1755 | |
| 1756 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1757 | void |
| 1758 | _mesa_CopyTexImage1D( GLenum target, GLint level, |
| 1759 | GLenum internalFormat, |
| 1760 | GLint x, GLint y, |
| 1761 | GLsizei width, GLint border ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1762 | { |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1763 | struct gl_texture_unit *texUnit; |
| 1764 | struct gl_texture_object *texObj; |
| 1765 | struct gl_texture_image *texImage; |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1766 | GLsizei postConvWidth = width; |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1767 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1768 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1769 | |
| Brian Paul | 9499e01 | 2000-10-30 16:32:42 +0000 | [diff] [blame] | 1770 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1771 | _mesa_update_state(ctx); |
| Brian Paul | fa4525e | 2000-08-21 14:22:24 +0000 | [diff] [blame] | 1772 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1773 | if (is_color_format(internalFormat)) { |
| 1774 | _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); |
| 1775 | } |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1776 | |
| 1777 | if (copytexture_error_check(ctx, 1, target, level, internalFormat, |
| 1778 | postConvWidth, 1, border)) |
| 1779 | return; |
| 1780 | |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1781 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1782 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 1783 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 1784 | if (!texImage) { |
| 1785 | texImage = _mesa_alloc_texture_image(); |
| 1786 | set_tex_image(texObj, target, level, texImage); |
| 1787 | if (!texImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1788 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1789 | return; |
| 1790 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1791 | } |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1792 | else if (texImage->Data) { |
| 1793 | /* free the old texture data */ |
| 1794 | FREE(texImage->Data); |
| 1795 | texImage->Data = NULL; |
| 1796 | } |
| 1797 | |
| 1798 | clear_teximage_fields(texImage); /* not really needed, but helpful */ |
| 1799 | init_teximage_fields(ctx, texImage, postConvWidth, 1, 1, |
| 1800 | border, internalFormat); |
| 1801 | |
| 1802 | |
| 1803 | ASSERT(ctx->Driver.CopyTexImage1D); |
| 1804 | (*ctx->Driver.CopyTexImage1D)(ctx, target, level, internalFormat, |
| 1805 | x, y, width, border); |
| 1806 | |
| 1807 | /* state update */ |
| 1808 | texObj->Complete = GL_FALSE; |
| 1809 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1810 | } |
| 1811 | |
| 1812 | |
| 1813 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1814 | void |
| 1815 | _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, |
| 1816 | GLint x, GLint y, GLsizei width, GLsizei height, |
| 1817 | GLint border ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1818 | { |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1819 | struct gl_texture_unit *texUnit; |
| 1820 | struct gl_texture_object *texObj; |
| 1821 | struct gl_texture_image *texImage; |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1822 | GLsizei postConvWidth = width, postConvHeight = height; |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1823 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1824 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1825 | |
| Brian Paul | 9499e01 | 2000-10-30 16:32:42 +0000 | [diff] [blame] | 1826 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1827 | _mesa_update_state(ctx); |
| Brian Paul | fa4525e | 2000-08-21 14:22:24 +0000 | [diff] [blame] | 1828 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1829 | if (is_color_format(internalFormat)) { |
| 1830 | _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, |
| 1831 | &postConvHeight); |
| 1832 | } |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1833 | |
| 1834 | if (copytexture_error_check(ctx, 2, target, level, internalFormat, |
| 1835 | postConvWidth, postConvHeight, border)) |
| 1836 | return; |
| 1837 | |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1838 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 1839 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 1840 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 1841 | if (!texImage) { |
| 1842 | texImage = _mesa_alloc_texture_image(); |
| 1843 | set_tex_image(texObj, target, level, texImage); |
| 1844 | if (!texImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1845 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D"); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1846 | return; |
| 1847 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1848 | } |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1849 | else if (texImage->Data) { |
| 1850 | /* free the old texture data */ |
| 1851 | FREE(texImage->Data); |
| 1852 | texImage->Data = NULL; |
| 1853 | } |
| 1854 | |
| 1855 | clear_teximage_fields(texImage); /* not really needed, but helpful */ |
| 1856 | init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight, 1, |
| 1857 | border, internalFormat); |
| 1858 | |
| 1859 | ASSERT(ctx->Driver.CopyTexImage2D); |
| 1860 | (*ctx->Driver.CopyTexImage2D)(ctx, target, level, internalFormat, |
| 1861 | x, y, width, height, border); |
| 1862 | |
| 1863 | /* state update */ |
| 1864 | texObj->Complete = GL_FALSE; |
| 1865 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | |
| 1869 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1870 | void |
| 1871 | _mesa_CopyTexSubImage1D( GLenum target, GLint level, |
| 1872 | GLint xoffset, GLint x, GLint y, GLsizei width ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1873 | { |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1874 | GLsizei postConvWidth = width; |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1875 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1876 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1877 | |
| Brian Paul | 9499e01 | 2000-10-30 16:32:42 +0000 | [diff] [blame] | 1878 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1879 | _mesa_update_state(ctx); |
| Brian Paul | fa4525e | 2000-08-21 14:22:24 +0000 | [diff] [blame] | 1880 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1881 | /* XXX should test internal format */ |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1882 | _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL); |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1883 | |
| 1884 | if (copytexsubimage_error_check(ctx, 1, target, level, |
| 1885 | xoffset, 0, 0, postConvWidth, 1)) |
| 1886 | return; |
| 1887 | |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1888 | ASSERT(ctx->Driver.CopyTexSubImage1D); |
| 1889 | (*ctx->Driver.CopyTexSubImage1D)(ctx, target, level, xoffset, x, y, width); |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 1890 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1891 | } |
| 1892 | |
| 1893 | |
| 1894 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1895 | void |
| 1896 | _mesa_CopyTexSubImage2D( GLenum target, GLint level, |
| 1897 | GLint xoffset, GLint yoffset, |
| 1898 | GLint x, GLint y, GLsizei width, GLsizei height ) |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1899 | { |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1900 | GLsizei postConvWidth = width, postConvHeight = height; |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1901 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1902 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1903 | |
| Brian Paul | 9499e01 | 2000-10-30 16:32:42 +0000 | [diff] [blame] | 1904 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1905 | _mesa_update_state(ctx); |
| Brian Paul | fa4525e | 2000-08-21 14:22:24 +0000 | [diff] [blame] | 1906 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1907 | /* XXX should test internal format */ |
| 1908 | _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight); |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1909 | |
| 1910 | if (copytexsubimage_error_check(ctx, 2, target, level, xoffset, yoffset, 0, |
| 1911 | postConvWidth, postConvHeight)) |
| 1912 | return; |
| 1913 | |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1914 | ASSERT(ctx->Driver.CopyTexSubImage2D); |
| 1915 | (*ctx->Driver.CopyTexSubImage2D)(ctx, target, level, |
| 1916 | xoffset, yoffset, x, y, width, height); |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 1917 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1918 | } |
| 1919 | |
| 1920 | |
| 1921 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1922 | void |
| 1923 | _mesa_CopyTexSubImage3D( GLenum target, GLint level, |
| 1924 | GLint xoffset, GLint yoffset, GLint zoffset, |
| 1925 | GLint x, GLint y, GLsizei width, GLsizei height ) |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1926 | { |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1927 | GLsizei postConvWidth = width, postConvHeight = height; |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 1928 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1929 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| Brian Paul | c3f0a51 | 1999-11-03 17:27:05 +0000 | [diff] [blame] | 1930 | |
| Brian Paul | 9499e01 | 2000-10-30 16:32:42 +0000 | [diff] [blame] | 1931 | if (ctx->NewState & _NEW_PIXEL) |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1932 | _mesa_update_state(ctx); |
| Brian Paul | fa4525e | 2000-08-21 14:22:24 +0000 | [diff] [blame] | 1933 | |
| Brian Paul | f7e1dfe | 2001-02-17 00:15:39 +0000 | [diff] [blame] | 1934 | /* XXX should test internal format */ |
| 1935 | _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight); |
| Brian Paul | ab6e78f | 2000-12-09 21:30:43 +0000 | [diff] [blame] | 1936 | |
| 1937 | if (copytexsubimage_error_check(ctx, 3, target, level, xoffset, yoffset, |
| 1938 | zoffset, postConvWidth, postConvHeight)) |
| 1939 | return; |
| 1940 | |
| Brian Paul | 2aadbf4 | 2001-02-19 20:01:41 +0000 | [diff] [blame] | 1941 | ASSERT(ctx->Driver.CopyTexSubImage3D); |
| 1942 | (*ctx->Driver.CopyTexSubImage3D)(ctx, target, level, |
| 1943 | xoffset, yoffset, zoffset, |
| 1944 | x, y, width, height); |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 1945 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1946 | } |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 1947 | |
| 1948 | |
| 1949 | |
| 1950 | void |
| 1951 | _mesa_CompressedTexImage1DARB(GLenum target, GLint level, |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 1952 | GLenum internalFormat, GLsizei width, |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 1953 | GLint border, GLsizei imageSize, |
| 1954 | const GLvoid *data) |
| 1955 | { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 1956 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 1957 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 1958 | |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 1959 | switch (internalFormat) { |
| 1960 | case GL_COMPRESSED_ALPHA_ARB: |
| 1961 | case GL_COMPRESSED_LUMINANCE_ARB: |
| 1962 | case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: |
| 1963 | case GL_COMPRESSED_INTENSITY_ARB: |
| 1964 | case GL_COMPRESSED_RGB_ARB: |
| 1965 | case GL_COMPRESSED_RGBA_ARB: |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1966 | _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB"); |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 1967 | return; |
| 1968 | default: |
| 1969 | /* silence compiler warning */ |
| 1970 | ; |
| 1971 | } |
| 1972 | |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 1973 | if (target == GL_TEXTURE_1D) { |
| 1974 | struct gl_texture_unit *texUnit; |
| 1975 | struct gl_texture_object *texObj; |
| 1976 | struct gl_texture_image *texImage; |
| 1977 | |
| 1978 | if (texture_error_check(ctx, target, level, internalFormat, |
| 1979 | GL_NONE, GL_NONE, 1, width, 1, 1, border)) { |
| 1980 | return; /* error in texture image was detected */ |
| 1981 | } |
| 1982 | |
| 1983 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 1984 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 1985 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 1986 | |
| 1987 | if (!texImage) { |
| 1988 | texImage = _mesa_alloc_texture_image(); |
| 1989 | texObj->Image[level] = texImage; |
| 1990 | if (!texImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 1991 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 1992 | return; |
| 1993 | } |
| 1994 | } |
| 1995 | else if (texImage->Data) { |
| 1996 | FREE(texImage->Data); |
| 1997 | texImage->Data = NULL; |
| 1998 | } |
| 1999 | |
| Brian Paul | 6628bc9 | 2001-02-07 03:27:41 +0000 | [diff] [blame] | 2000 | init_teximage_fields(ctx, texImage, width, 1, 1, border, internalFormat); |
| 2001 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2002 | if (ctx->Extensions.ARB_texture_compression) { |
| 2003 | ASSERT(ctx->Driver.CompressedTexImage1D); |
| 2004 | (*ctx->Driver.CompressedTexImage1D)(ctx, target, level, |
| 2005 | internalFormat, width, border, |
| 2006 | imageSize, data, |
| 2007 | texObj, texImage); |
| 2008 | ASSERT(texImage->CompressedSize > 0); /* sanity */ |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2009 | } |
| 2010 | |
| 2011 | /* state update */ |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 2012 | texObj->Complete = GL_FALSE; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 2013 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2014 | } |
| 2015 | else if (target == GL_PROXY_TEXTURE_1D) { |
| 2016 | /* Proxy texture: check for errors and update proxy state */ |
| Brian Paul | 38d3f3d | 2000-09-07 15:38:49 +0000 | [diff] [blame] | 2017 | GLenum error = texture_error_check(ctx, target, level, internalFormat, |
| 2018 | GL_NONE, GL_NONE, 1, width, 1, 1, border); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2019 | if (!error) { |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 2020 | struct gl_texture_unit *texUnit; |
| 2021 | struct gl_texture_image *texImage; |
| 2022 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 2023 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 2024 | init_teximage_fields(ctx, texImage, width, 1, 1, |
| 2025 | border, internalFormat); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2026 | ASSERT(ctx->Driver.TestProxyTexImage); |
| Brian Paul | 38d3f3d | 2000-09-07 15:38:49 +0000 | [diff] [blame] | 2027 | error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, |
| 2028 | internalFormat, GL_NONE, GL_NONE, |
| 2029 | width, 1, 1, border); |
| 2030 | } |
| 2031 | if (error) { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2032 | /* if error, clear all proxy texture image parameters */ |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 2033 | if (level >= 0 && level < ctx->Const.MaxTextureLevels) { |
| 2034 | clear_teximage_fields(ctx->Texture.Proxy1D->Image[level]); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2035 | } |
| 2036 | } |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2037 | } |
| 2038 | else { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2039 | _mesa_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB(target)" ); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2040 | return; |
| 2041 | } |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2042 | } |
| 2043 | |
| 2044 | |
| 2045 | void |
| 2046 | _mesa_CompressedTexImage2DARB(GLenum target, GLint level, |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2047 | GLenum internalFormat, GLsizei width, |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2048 | GLsizei height, GLint border, GLsizei imageSize, |
| 2049 | const GLvoid *data) |
| 2050 | { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2051 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 2052 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2053 | |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 2054 | switch (internalFormat) { |
| 2055 | case GL_COMPRESSED_ALPHA_ARB: |
| 2056 | case GL_COMPRESSED_LUMINANCE_ARB: |
| 2057 | case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: |
| 2058 | case GL_COMPRESSED_INTENSITY_ARB: |
| 2059 | case GL_COMPRESSED_RGB_ARB: |
| 2060 | case GL_COMPRESSED_RGBA_ARB: |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2061 | _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB"); |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 2062 | return; |
| 2063 | default: |
| 2064 | /* silence compiler warning */ |
| 2065 | ; |
| 2066 | } |
| 2067 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2068 | if (target == GL_TEXTURE_2D || |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 2069 | (ctx->Extensions.ARB_texture_cube_map && |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2070 | target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && |
| 2071 | target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2072 | struct gl_texture_unit *texUnit; |
| 2073 | struct gl_texture_object *texObj; |
| 2074 | struct gl_texture_image *texImage; |
| 2075 | |
| 2076 | if (texture_error_check(ctx, target, level, internalFormat, |
| 2077 | GL_NONE, GL_NONE, 1, width, height, 1, border)) { |
| 2078 | return; /* error in texture image was detected */ |
| 2079 | } |
| 2080 | |
| 2081 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2082 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 2083 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2084 | |
| 2085 | if (!texImage) { |
| 2086 | texImage = _mesa_alloc_texture_image(); |
| 2087 | texObj->Image[level] = texImage; |
| 2088 | if (!texImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2089 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2090 | return; |
| 2091 | } |
| 2092 | } |
| 2093 | else if (texImage->Data) { |
| 2094 | FREE(texImage->Data); |
| 2095 | texImage->Data = NULL; |
| 2096 | } |
| 2097 | |
| Brian Paul | 6628bc9 | 2001-02-07 03:27:41 +0000 | [diff] [blame] | 2098 | init_teximage_fields(ctx, texImage, width, height, 1, border, |
| 2099 | internalFormat); |
| 2100 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2101 | if (ctx->Extensions.ARB_texture_compression) { |
| 2102 | ASSERT(ctx->Driver.CompressedTexImage2D); |
| 2103 | (*ctx->Driver.CompressedTexImage2D)(ctx, target, level, |
| 2104 | internalFormat, width, height, |
| 2105 | border, imageSize, data, |
| 2106 | texObj, texImage); |
| 2107 | ASSERT(texImage->CompressedSize > 0); /* sanity */ |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2108 | } |
| 2109 | |
| 2110 | /* state update */ |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 2111 | texObj->Complete = GL_FALSE; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 2112 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2113 | } |
| 2114 | else if (target == GL_PROXY_TEXTURE_2D) { |
| 2115 | /* Proxy texture: check for errors and update proxy state */ |
| Brian Paul | 38d3f3d | 2000-09-07 15:38:49 +0000 | [diff] [blame] | 2116 | GLenum error = texture_error_check(ctx, target, level, internalFormat, |
| 2117 | GL_NONE, GL_NONE, 2, width, height, 1, border); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2118 | if (!error) { |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 2119 | struct gl_texture_unit *texUnit; |
| 2120 | struct gl_texture_image *texImage; |
| 2121 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 2122 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 2123 | init_teximage_fields(ctx, texImage, width, height, 1, |
| 2124 | border, internalFormat); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2125 | ASSERT(ctx->Driver.TestProxyTexImage); |
| Brian Paul | 38d3f3d | 2000-09-07 15:38:49 +0000 | [diff] [blame] | 2126 | error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, |
| 2127 | internalFormat, GL_NONE, GL_NONE, |
| 2128 | width, height, 1, border); |
| 2129 | } |
| 2130 | if (error) { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2131 | /* if error, clear all proxy texture image parameters */ |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 2132 | if (level >= 0 && level < ctx->Const.MaxTextureLevels) { |
| 2133 | clear_teximage_fields(ctx->Texture.Proxy2D->Image[level]); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2134 | } |
| 2135 | } |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2136 | } |
| 2137 | else { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2138 | _mesa_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB(target)" ); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2139 | return; |
| 2140 | } |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2141 | } |
| 2142 | |
| 2143 | |
| 2144 | void |
| 2145 | _mesa_CompressedTexImage3DARB(GLenum target, GLint level, |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2146 | GLenum internalFormat, GLsizei width, |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2147 | GLsizei height, GLsizei depth, GLint border, |
| 2148 | GLsizei imageSize, const GLvoid *data) |
| 2149 | { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2150 | GET_CURRENT_CONTEXT(ctx); |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 2151 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2152 | |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 2153 | switch (internalFormat) { |
| 2154 | case GL_COMPRESSED_ALPHA_ARB: |
| 2155 | case GL_COMPRESSED_LUMINANCE_ARB: |
| 2156 | case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: |
| 2157 | case GL_COMPRESSED_INTENSITY_ARB: |
| 2158 | case GL_COMPRESSED_RGB_ARB: |
| 2159 | case GL_COMPRESSED_RGBA_ARB: |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2160 | _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB"); |
| Brian Paul | 289d47e | 2000-08-29 23:31:23 +0000 | [diff] [blame] | 2161 | return; |
| 2162 | default: |
| 2163 | /* silence compiler warning */ |
| 2164 | ; |
| 2165 | } |
| 2166 | |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2167 | if (target == GL_TEXTURE_3D) { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2168 | struct gl_texture_unit *texUnit; |
| 2169 | struct gl_texture_object *texObj; |
| 2170 | struct gl_texture_image *texImage; |
| 2171 | |
| 2172 | if (texture_error_check(ctx, target, level, internalFormat, |
| 2173 | GL_NONE, GL_NONE, 1, width, height, depth, border)) { |
| 2174 | return; /* error in texture image was detected */ |
| 2175 | } |
| 2176 | |
| 2177 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2178 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 2179 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2180 | |
| 2181 | if (!texImage) { |
| 2182 | texImage = _mesa_alloc_texture_image(); |
| 2183 | texObj->Image[level] = texImage; |
| 2184 | if (!texImage) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2185 | _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2186 | return; |
| 2187 | } |
| 2188 | } |
| 2189 | else if (texImage->Data) { |
| 2190 | FREE(texImage->Data); |
| 2191 | texImage->Data = NULL; |
| 2192 | } |
| 2193 | |
| Brian Paul | 6628bc9 | 2001-02-07 03:27:41 +0000 | [diff] [blame] | 2194 | init_teximage_fields(ctx, texImage, width, height, depth, border, |
| 2195 | internalFormat); |
| 2196 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2197 | if (ctx->Extensions.ARB_texture_compression) { |
| 2198 | ASSERT(ctx->Driver.CompressedTexImage3D); |
| 2199 | (*ctx->Driver.CompressedTexImage3D)(ctx, target, level, |
| 2200 | internalFormat, |
| 2201 | width, height, depth, |
| 2202 | border, imageSize, data, |
| 2203 | texObj, texImage); |
| 2204 | ASSERT(texImage->CompressedSize > 0); /* sanity */ |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2205 | } |
| 2206 | |
| 2207 | /* state update */ |
| Brian Paul | a852378 | 2000-11-19 23:10:25 +0000 | [diff] [blame] | 2208 | texObj->Complete = GL_FALSE; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 2209 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2210 | } |
| 2211 | else if (target == GL_PROXY_TEXTURE_3D) { |
| 2212 | /* Proxy texture: check for errors and update proxy state */ |
| Brian Paul | 38d3f3d | 2000-09-07 15:38:49 +0000 | [diff] [blame] | 2213 | GLenum error = texture_error_check(ctx, target, level, internalFormat, |
| 2214 | GL_NONE, GL_NONE, 1, width, height, depth, border); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2215 | if (!error) { |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 2216 | struct gl_texture_unit *texUnit; |
| 2217 | struct gl_texture_image *texImage; |
| 2218 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 2219 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 2220 | init_teximage_fields(ctx, texImage, width, height, depth, |
| 2221 | border, internalFormat); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2222 | ASSERT(ctx->Driver.TestProxyTexImage); |
| Brian Paul | 38d3f3d | 2000-09-07 15:38:49 +0000 | [diff] [blame] | 2223 | error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level, |
| 2224 | internalFormat, GL_NONE, GL_NONE, |
| 2225 | width, height, depth, border); |
| 2226 | } |
| 2227 | if (error) { |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2228 | /* if error, clear all proxy texture image parameters */ |
| Brian Paul | f378ab8 | 2001-02-06 23:35:26 +0000 | [diff] [blame] | 2229 | if (level >= 0 && level < ctx->Const.MaxTextureLevels) { |
| 2230 | clear_teximage_fields(ctx->Texture.Proxy3D->Image[level]); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2231 | } |
| 2232 | } |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2233 | } |
| 2234 | else { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2235 | _mesa_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB(target)" ); |
| Brian Paul | aea66b1 | 2000-05-24 14:04:06 +0000 | [diff] [blame] | 2236 | return; |
| 2237 | } |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2238 | } |
| 2239 | |
| 2240 | |
| 2241 | void |
| 2242 | _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, |
| 2243 | GLsizei width, GLenum format, |
| 2244 | GLsizei imageSize, const GLvoid *data) |
| 2245 | { |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2246 | struct gl_texture_unit *texUnit; |
| 2247 | struct gl_texture_object *texObj; |
| 2248 | struct gl_texture_image *texImage; |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 2249 | GET_CURRENT_CONTEXT(ctx); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2250 | |
| Brian Paul | 75280a2 | 2001-03-05 22:18:23 +0000 | [diff] [blame] | 2251 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 2252 | |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2253 | if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0, |
| 2254 | width, 1, 1, format, GL_NONE)) { |
| 2255 | return; /* error was detected */ |
| 2256 | } |
| 2257 | |
| 2258 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 2259 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2260 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2261 | assert(texImage); |
| 2262 | |
| 2263 | if (width == 0 || !data) |
| 2264 | return; /* no-op, not an error */ |
| 2265 | |
| 2266 | if (ctx->Driver.CompressedTexSubImage1D) { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2267 | (*ctx->Driver.CompressedTexSubImage1D)(ctx, target, level, |
| 2268 | xoffset, width, |
| 2269 | format, imageSize, data, |
| 2270 | texObj, texImage); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2271 | } |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 2272 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | |
| 2276 | void |
| 2277 | _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, |
| 2278 | GLint yoffset, GLsizei width, GLsizei height, |
| 2279 | GLenum format, GLsizei imageSize, |
| 2280 | const GLvoid *data) |
| 2281 | { |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2282 | struct gl_texture_unit *texUnit; |
| 2283 | struct gl_texture_object *texObj; |
| 2284 | struct gl_texture_image *texImage; |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 2285 | GET_CURRENT_CONTEXT(ctx); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2286 | |
| Brian Paul | 75280a2 | 2001-03-05 22:18:23 +0000 | [diff] [blame] | 2287 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 2288 | |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2289 | if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, |
| 2290 | width, height, 1, format, GL_NONE)) { |
| 2291 | return; /* error was detected */ |
| 2292 | } |
| 2293 | |
| 2294 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 2295 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2296 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2297 | assert(texImage); |
| 2298 | |
| 2299 | if (width == 0 || height == 0 || !data) |
| 2300 | return; /* no-op, not an error */ |
| 2301 | |
| 2302 | if (ctx->Driver.CompressedTexSubImage2D) { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2303 | (*ctx->Driver.CompressedTexSubImage2D)(ctx, target, level, |
| 2304 | xoffset, yoffset, width, height, |
| 2305 | format, imageSize, data, |
| 2306 | texObj, texImage); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2307 | } |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 2308 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2309 | } |
| 2310 | |
| 2311 | |
| 2312 | void |
| 2313 | _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, |
| 2314 | GLint yoffset, GLint zoffset, GLsizei width, |
| 2315 | GLsizei height, GLsizei depth, GLenum format, |
| 2316 | GLsizei imageSize, const GLvoid *data) |
| 2317 | { |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2318 | struct gl_texture_unit *texUnit; |
| 2319 | struct gl_texture_object *texObj; |
| 2320 | struct gl_texture_image *texImage; |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 2321 | GET_CURRENT_CONTEXT(ctx); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2322 | |
| Brian Paul | 75280a2 | 2001-03-05 22:18:23 +0000 | [diff] [blame] | 2323 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 2324 | |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2325 | if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset, |
| 2326 | width, height, depth, format, GL_NONE)) { |
| 2327 | return; /* error was detected */ |
| 2328 | } |
| 2329 | |
| 2330 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 2331 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2332 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2333 | assert(texImage); |
| 2334 | |
| 2335 | if (width == 0 || height == 0 || depth == 0 || !data) |
| 2336 | return; /* no-op, not an error */ |
| 2337 | |
| 2338 | if (ctx->Driver.CompressedTexSubImage3D) { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2339 | (*ctx->Driver.CompressedTexSubImage3D)(ctx, target, level, |
| 2340 | xoffset, yoffset, zoffset, |
| 2341 | width, height, depth, |
| 2342 | format, imageSize, data, |
| 2343 | texObj, texImage); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2344 | } |
| Brian Paul | bf8b5f9 | 2001-02-27 22:16:27 +0000 | [diff] [blame] | 2345 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2346 | } |
| 2347 | |
| 2348 | |
| 2349 | void |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2350 | _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2351 | { |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2352 | const struct gl_texture_unit *texUnit; |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2353 | const struct gl_texture_object *texObj; |
| 2354 | struct gl_texture_image *texImage; |
| Brian Paul | a1f1586 | 2001-02-07 16:27:41 +0000 | [diff] [blame] | 2355 | GET_CURRENT_CONTEXT(ctx); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2356 | |
| Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 2357 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2358 | |
| 2359 | if (level < 0 || level >= ctx->Const.MaxTextureLevels) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2360 | _mesa_error( ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)" ); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2361 | return; |
| 2362 | } |
| 2363 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2364 | if (is_proxy_target(target)) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2365 | _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)"); |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2366 | return; |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2367 | } |
| 2368 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2369 | texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 2370 | texObj = _mesa_select_tex_object(ctx, texUnit, target); |
| 2371 | texImage = _mesa_select_tex_image(ctx, texUnit, target, level); |
| 2372 | |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2373 | if (!texImage) { |
| 2374 | /* invalid mipmap level */ |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2375 | _mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)"); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2376 | return; |
| 2377 | } |
| 2378 | |
| 2379 | if (!texImage->IsCompressed) { |
| Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 2380 | _mesa_error(ctx, GL_INVALID_OPERATION, "glGetCompressedTexImageARB"); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2381 | return; |
| 2382 | } |
| 2383 | |
| 2384 | if (!img) |
| 2385 | return; |
| 2386 | |
| Brian Paul | 8e39ad2 | 2001-02-06 21:42:48 +0000 | [diff] [blame] | 2387 | if (ctx->Extensions.ARB_texture_compression) { |
| 2388 | ASSERT(ctx->Driver.GetCompressedTexImage); |
| Brian Paul | 9540a1d | 2000-06-06 17:03:38 +0000 | [diff] [blame] | 2389 | (*ctx->Driver.GetCompressedTexImage)(ctx, target, level, img, texObj, |
| 2390 | texImage); |
| 2391 | } |
| Brian Paul | 1207bf0 | 2000-05-23 20:10:49 +0000 | [diff] [blame] | 2392 | } |