Changeset 31781 in vbox for trunk/src/VBox/GuestHost/OpenGL
- Timestamp:
- Aug 19, 2010 11:14:24 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64968
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c
r28860 r31781 22 22 void crStateTextureDestroy(CRContext *ctx) 23 23 { 24 25 26 27 24 crStateDeleteTextureObjectData(&ctx->texture.base1D); 25 crStateDeleteTextureObjectData(&ctx->texture.proxy1D); 26 crStateDeleteTextureObjectData(&ctx->texture.base2D); 27 crStateDeleteTextureObjectData(&ctx->texture.proxy2D); 28 28 #ifdef CR_OPENGL_VERSION_1_2 29 30 29 crStateDeleteTextureObjectData(&ctx->texture.base3D); 30 crStateDeleteTextureObjectData(&ctx->texture.proxy3D); 31 31 #endif 32 32 #ifdef CR_ARB_texture_cube_map 33 34 33 crStateDeleteTextureObjectData(&ctx->texture.baseCubeMap); 34 crStateDeleteTextureObjectData(&ctx->texture.proxyCubeMap); 35 35 #endif 36 36 #ifdef CR_NV_texture_rectangle 37 38 37 crStateDeleteTextureObjectData(&ctx->texture.baseRect); 38 crStateDeleteTextureObjectData(&ctx->texture.proxyRect); 39 39 #endif 40 40 } … … 43 43 void crStateTextureInit(CRContext *ctx) 44 44 { 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 45 CRLimitsState *limits = &ctx->limits; 46 CRTextureState *t = &ctx->texture; 47 CRStateBits *sb = GetCurrentBits(); 48 CRTextureBits *tb = &(sb->texture); 49 unsigned int i; 50 unsigned int a; 51 GLvectorf zero_vector = {0.0f, 0.0f, 0.0f, 0.0f}; 52 GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f}; 53 GLvectorf x_vector = {1.0f, 0.0f, 0.0f, 0.0f}; 54 GLvectorf y_vector = {0.0f, 1.0f, 0.0f, 0.0f}; 55 56 /* compute max levels from max sizes */ 57 for (i=0, a=limits->maxTextureSize; a; i++, a=a>>1); 58 t->maxLevel = i; 59 for (i=0, a=limits->max3DTextureSize; a; i++, a=a>>1); 60 t->max3DLevel = i; 61 61 #ifdef CR_ARB_texture_cube_map 62 63 62 for (i=0, a=limits->maxCubeMapTextureSize; a; i++, a=a>>1); 63 t->maxCubeMapLevel = i; 64 64 #endif 65 65 #ifdef CR_NV_texture_rectangle 66 67 68 #endif 69 70 71 66 for (i=0, a=limits->maxRectTextureSize; a; i++, a=a>>1); 67 t->maxRectLevel = i; 68 #endif 69 70 crStateTextureInitTextureObj(ctx, &(t->base1D), 0, GL_TEXTURE_1D); 71 crStateTextureInitTextureObj(ctx, &(t->base2D), 0, GL_TEXTURE_2D); 72 72 #ifdef CR_OPENGL_VERSION_1_2 73 73 crStateTextureInitTextureObj(ctx, &(t->base3D), 0, GL_TEXTURE_3D); 74 74 #endif 75 75 #ifdef CR_ARB_texture_cube_map 76 77 76 crStateTextureInitTextureObj(ctx, &(t->baseCubeMap), 0, 77 GL_TEXTURE_CUBE_MAP_ARB); 78 78 #endif 79 79 #ifdef CR_NV_texture_rectangle 80 81 82 #endif 83 84 85 80 crStateTextureInitTextureObj(ctx, &(t->baseRect), 0, 81 GL_TEXTURE_RECTANGLE_NV); 82 #endif 83 84 crStateTextureInitTextureObj(ctx, &(t->proxy1D), 0, GL_TEXTURE_1D); 85 crStateTextureInitTextureObj(ctx, &(t->proxy2D), 0, GL_TEXTURE_2D); 86 86 #ifdef CR_OPENGL_VERSION_1_2 87 87 crStateTextureInitTextureObj(ctx, &(t->proxy3D), 0, GL_TEXTURE_3D); 88 88 #endif 89 89 #ifdef CR_ARB_texture_cube_map 90 91 90 crStateTextureInitTextureObj(ctx, &(t->proxyCubeMap), 0, 91 GL_TEXTURE_CUBE_MAP_ARB); 92 92 #endif 93 93 #ifdef CR_NV_texture_rectangle 94 95 96 #endif 97 98 99 100 101 102 103 104 105 94 crStateTextureInitTextureObj(ctx, &(t->proxyRect), 0, 95 GL_TEXTURE_RECTANGLE_NV); 96 #endif 97 98 t->curTextureUnit = 0; 99 100 /* Per-unit initialization */ 101 for (i = 0; i < limits->maxTextureUnits; i++) 102 { 103 t->unit[i].currentTexture1D = &(t->base1D); 104 t->unit[i].currentTexture2D = &(t->base2D); 105 t->unit[i].currentTexture3D = &(t->base3D); 106 106 #ifdef CR_ARB_texture_cube_map 107 107 t->unit[i].currentTextureCubeMap = &(t->baseCubeMap); 108 108 #endif 109 109 #ifdef CR_NV_texture_rectangle 110 111 #endif 112 113 114 115 116 110 t->unit[i].currentTextureRect = &(t->baseRect); 111 #endif 112 113 t->unit[i].enabled1D = GL_FALSE; 114 t->unit[i].enabled2D = GL_FALSE; 115 t->unit[i].enabled3D = GL_FALSE; 116 t->unit[i].enabledCubeMap = GL_FALSE; 117 117 #ifdef CR_NV_texture_rectangle 118 119 #endif 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 118 t->unit[i].enabledRect = GL_FALSE; 119 #endif 120 t->unit[i].textureGen.s = GL_FALSE; 121 t->unit[i].textureGen.t = GL_FALSE; 122 t->unit[i].textureGen.r = GL_FALSE; 123 t->unit[i].textureGen.q = GL_FALSE; 124 125 t->unit[i].gen.s = GL_EYE_LINEAR; 126 t->unit[i].gen.t = GL_EYE_LINEAR; 127 t->unit[i].gen.r = GL_EYE_LINEAR; 128 t->unit[i].gen.q = GL_EYE_LINEAR; 129 130 t->unit[i].objSCoeff = x_vector; 131 t->unit[i].objTCoeff = y_vector; 132 t->unit[i].objRCoeff = zero_vector; 133 t->unit[i].objQCoeff = zero_vector; 134 135 t->unit[i].eyeSCoeff = x_vector; 136 t->unit[i].eyeTCoeff = y_vector; 137 t->unit[i].eyeRCoeff = zero_vector; 138 t->unit[i].eyeQCoeff = zero_vector; 139 t->unit[i].envMode = GL_MODULATE; 140 t->unit[i].envColor = zero_color; 141 142 t->unit[i].combineModeRGB = GL_MODULATE; 143 t->unit[i].combineModeA = GL_MODULATE; 144 t->unit[i].combineSourceRGB[0] = GL_TEXTURE; 145 t->unit[i].combineSourceRGB[1] = GL_PREVIOUS_EXT; 146 t->unit[i].combineSourceRGB[2] = GL_CONSTANT_EXT; 147 t->unit[i].combineSourceA[0] = GL_TEXTURE; 148 t->unit[i].combineSourceA[1] = GL_PREVIOUS_EXT; 149 t->unit[i].combineSourceA[2] = GL_CONSTANT_EXT; 150 t->unit[i].combineOperandRGB[0] = GL_SRC_COLOR; 151 t->unit[i].combineOperandRGB[1] = GL_SRC_COLOR; 152 t->unit[i].combineOperandRGB[2] = GL_SRC_ALPHA; 153 t->unit[i].combineOperandA[0] = GL_SRC_ALPHA; 154 t->unit[i].combineOperandA[1] = GL_SRC_ALPHA; 155 t->unit[i].combineOperandA[2] = GL_SRC_ALPHA; 156 t->unit[i].combineScaleRGB = 1.0F; 157 t->unit[i].combineScaleA = 1.0F; 158 158 #ifdef CR_EXT_texture_lod_bias 159 160 #endif 161 162 163 164 165 166 167 168 159 t->unit[i].lodBias = 0.0F; 160 #endif 161 RESET(tb->enable[i], ctx->bitid); 162 RESET(tb->current[i], ctx->bitid); 163 RESET(tb->objGen[i], ctx->bitid); 164 RESET(tb->eyeGen[i], ctx->bitid); 165 RESET(tb->genMode[i], ctx->bitid); 166 RESET(tb->envBit[i], ctx->bitid); 167 } 168 RESET(tb->dirty, ctx->bitid); 169 169 } 170 170 … … 172 172 void 173 173 crStateTextureInitTextureObj(CRContext *ctx, CRTextureObj *tobj, 174 175 { 176 177 178 179 180 181 182 183 184 185 186 174 GLuint name, GLenum target) 175 { 176 const CRTextureState *t = &(ctx->texture); 177 int i, face; 178 179 tobj->borderColor.r = 0.0f; 180 tobj->borderColor.g = 0.0f; 181 tobj->borderColor.b = 0.0f; 182 tobj->borderColor.a = 0.0f; 183 tobj->minFilter = GL_NEAREST_MIPMAP_LINEAR; 184 tobj->magFilter = GL_LINEAR; 185 tobj->wrapS = GL_REPEAT; 186 tobj->wrapT = GL_REPEAT; 187 187 #ifdef CR_OPENGL_VERSION_1_2 188 189 190 191 192 193 194 #endif 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 188 tobj->wrapR = GL_REPEAT; 189 tobj->priority = 1.0f; 190 tobj->minLod = -1000.0; 191 tobj->maxLod = 1000.0; 192 tobj->baseLevel = 0; 193 tobj->maxLevel = 1000; 194 #endif 195 tobj->target = target; 196 tobj->name = name; 197 198 CRASSERT(t->maxLevel); 199 200 /* XXX don't always need all six faces */ 201 for (face = 0; face < 6; face++) { 202 /* allocate array of mipmap levels */ 203 CRASSERT(t->maxLevel < CR_MAX_MIPMAP_LEVELS); 204 tobj->level[face] = (CRTextureLevel *) 205 crCalloc(sizeof(CRTextureLevel) * CR_MAX_MIPMAP_LEVELS); 206 207 if (!tobj->level[face]) 208 return; /* out of memory */ 209 210 /* init non-zero fields */ 211 for (i = 0; i <= t->maxLevel; i++) { 212 CRTextureLevel *tl = &(tobj->level[face][i]); 213 tl->internalFormat = GL_ONE; 214 tl->format = GL_RGBA; 215 tl->type = GL_UNSIGNED_BYTE; 216 crStateTextureInitTextureFormat( tl, tl->internalFormat ); 217 } 218 } 219 219 220 220 #ifdef CR_EXT_texture_filter_anisotropic 221 221 tobj->maxAnisotropy = 1.0f; 222 222 #endif 223 223 224 224 #ifdef CR_ARB_depth_texture 225 225 tobj->depthMode = GL_LUMINANCE; 226 226 #endif 227 227 228 228 #ifdef CR_ARB_shadow 229 230 229 tobj->compareMode = GL_NONE; 230 tobj->compareFunc = GL_LEQUAL; 231 231 #endif 232 232 233 233 #ifdef CR_ARB_shadow_ambient 234 235 #endif 236 237 238 239 240 241 242 234 tobj->compareFailValue = 0.0; 235 #endif 236 237 RESET(tobj->dirty, ctx->bitid); 238 RESET(tobj->imageBit, ctx->bitid); 239 for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) 240 { 241 RESET(tobj->paramsBit[i], ctx->bitid); 242 } 243 243 } 244 244 … … 249 249 250 250 const CRTextureFormat _texformat_rgba8888 = { 251 8, 252 8, 253 8, 254 8, 255 0, 256 0, 257 0, 251 8, /* RedBits */ 252 8, /* GreenBits */ 253 8, /* BlueBits */ 254 8, /* AlphaBits */ 255 0, /* LuminanceBits */ 256 0, /* IntensityBits */ 257 0, /* IndexBits */ 258 258 }; 259 259 260 260 const CRTextureFormat _texformat_argb8888 = { 261 8, 262 8, 263 8, 264 8, 265 0, 266 0, 267 0, 261 8, /* RedBits */ 262 8, /* GreenBits */ 263 8, /* BlueBits */ 264 8, /* AlphaBits */ 265 0, /* LuminanceBits */ 266 0, /* IntensityBits */ 267 0, /* IndexBits */ 268 268 }; 269 269 270 270 const CRTextureFormat _texformat_rgb888 = { 271 8, 272 8, 273 8, 274 0, 275 0, 276 0, 277 0, 271 8, /* RedBits */ 272 8, /* GreenBits */ 273 8, /* BlueBits */ 274 0, /* AlphaBits */ 275 0, /* LuminanceBits */ 276 0, /* IntensityBits */ 277 0, /* IndexBits */ 278 278 }; 279 279 280 280 const CRTextureFormat _texformat_rgb565 = { 281 5, 282 6, 283 5, 284 0, 285 0, 286 0, 287 0, 281 5, /* RedBits */ 282 6, /* GreenBits */ 283 5, /* BlueBits */ 284 0, /* AlphaBits */ 285 0, /* LuminanceBits */ 286 0, /* IntensityBits */ 287 0, /* IndexBits */ 288 288 }; 289 289 290 290 const CRTextureFormat _texformat_argb4444 = { 291 4, 292 4, 293 4, 294 4, 295 0, 296 0, 297 0, 291 4, /* RedBits */ 292 4, /* GreenBits */ 293 4, /* BlueBits */ 294 4, /* AlphaBits */ 295 0, /* LuminanceBits */ 296 0, /* IntensityBits */ 297 0, /* IndexBits */ 298 298 }; 299 299 300 300 const CRTextureFormat _texformat_argb1555 = { 301 5, 302 5, 303 5, 304 1, 305 0, 306 0, 307 0, 301 5, /* RedBits */ 302 5, /* GreenBits */ 303 5, /* BlueBits */ 304 1, /* AlphaBits */ 305 0, /* LuminanceBits */ 306 0, /* IntensityBits */ 307 0, /* IndexBits */ 308 308 }; 309 309 310 310 const CRTextureFormat _texformat_al88 = { 311 0, 312 0, 313 0, 314 8, 315 8, 316 0, 317 0, 311 0, /* RedBits */ 312 0, /* GreenBits */ 313 0, /* BlueBits */ 314 8, /* AlphaBits */ 315 8, /* LuminanceBits */ 316 0, /* IntensityBits */ 317 0, /* IndexBits */ 318 318 }; 319 319 320 320 const CRTextureFormat _texformat_rgb332 = { 321 3, 322 3, 323 2, 324 0, 325 0, 326 0, 327 0, 321 3, /* RedBits */ 322 3, /* GreenBits */ 323 2, /* BlueBits */ 324 0, /* AlphaBits */ 325 0, /* LuminanceBits */ 326 0, /* IntensityBits */ 327 0, /* IndexBits */ 328 328 }; 329 329 330 330 const CRTextureFormat _texformat_a8 = { 331 0, 332 0, 333 0, 334 8, 335 0, 336 0, 337 0, 331 0, /* RedBits */ 332 0, /* GreenBits */ 333 0, /* BlueBits */ 334 8, /* AlphaBits */ 335 0, /* LuminanceBits */ 336 0, /* IntensityBits */ 337 0, /* IndexBits */ 338 338 }; 339 339 340 340 const CRTextureFormat _texformat_l8 = { 341 0, 342 0, 343 0, 344 0, 345 8, 346 0, 347 0, 341 0, /* RedBits */ 342 0, /* GreenBits */ 343 0, /* BlueBits */ 344 0, /* AlphaBits */ 345 8, /* LuminanceBits */ 346 0, /* IntensityBits */ 347 0, /* IndexBits */ 348 348 }; 349 349 350 350 const CRTextureFormat _texformat_i8 = { 351 0, 352 0, 353 0, 354 0, 355 0, 356 8, 357 0, 351 0, /* RedBits */ 352 0, /* GreenBits */ 353 0, /* BlueBits */ 354 0, /* AlphaBits */ 355 0, /* LuminanceBits */ 356 8, /* IntensityBits */ 357 0, /* IndexBits */ 358 358 }; 359 359 360 360 const CRTextureFormat _texformat_ci8 = { 361 0, 362 0, 363 0, 364 0, 365 0, 366 0, 367 8, 361 0, /* RedBits */ 362 0, /* GreenBits */ 363 0, /* BlueBits */ 364 0, /* AlphaBits */ 365 0, /* LuminanceBits */ 366 0, /* IntensityBits */ 367 8, /* IndexBits */ 368 368 }; 369 369 … … 378 378 crStateTextureInitTextureFormat( CRTextureLevel *tl, GLenum internalFormat ) 379 379 { 380 381 382 383 380 switch (internalFormat) { 381 case 4: 382 case GL_RGBA: 383 case GL_COMPRESSED_RGBA_ARB: 384 384 #ifdef CR_EXT_texture_sRGB 385 385 case GL_SRGB_ALPHA_EXT: … … 387 387 case GL_COMPRESSED_SRGB_ALPHA_EXT: 388 388 #endif 389 390 391 392 393 394 389 tl->texFormat = &_texformat_rgba8888; 390 break; 391 392 case 3: 393 case GL_RGB: 394 case GL_COMPRESSED_RGB_ARB: 395 395 #ifdef CR_EXT_texture_sRGB 396 396 case GL_SRGB_EXT: … … 398 398 case GL_COMPRESSED_SRGB_EXT: 399 399 #endif 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 400 tl->texFormat = &_texformat_rgb888; 401 break; 402 403 case GL_RGBA2: 404 case GL_RGBA4: 405 case GL_RGB5_A1: 406 case GL_RGBA8: 407 case GL_RGB10_A2: 408 case GL_RGBA12: 409 case GL_RGBA16: 410 tl->texFormat = &_texformat_rgba8888; 411 break; 412 413 case GL_R3_G3_B2: 414 tl->texFormat = &_texformat_rgb332; 415 break; 416 case GL_RGB4: 417 case GL_RGB5: 418 case GL_RGB8: 419 case GL_RGB10: 420 case GL_RGB12: 421 case GL_RGB16: 422 tl->texFormat = &_texformat_rgb888; 423 break; 424 425 case GL_ALPHA: 426 case GL_ALPHA4: 427 case GL_ALPHA8: 428 case GL_ALPHA12: 429 case GL_ALPHA16: 430 case GL_COMPRESSED_ALPHA_ARB: 431 tl->texFormat = &_texformat_a8; 432 break; 433 434 case 1: 435 case GL_LUMINANCE: 436 case GL_LUMINANCE4: 437 case GL_LUMINANCE8: 438 case GL_LUMINANCE12: 439 case GL_LUMINANCE16: 440 case GL_COMPRESSED_LUMINANCE_ARB: 441 441 #ifdef CR_EXT_texture_sRGB 442 442 case GL_SLUMINANCE_EXT: … … 444 444 case GL_COMPRESSED_SLUMINANCE_EXT: 445 445 #endif 446 447 448 449 450 451 452 453 454 455 456 457 446 tl->texFormat = &_texformat_l8; 447 break; 448 449 case 2: 450 case GL_LUMINANCE_ALPHA: 451 case GL_LUMINANCE4_ALPHA4: 452 case GL_LUMINANCE6_ALPHA2: 453 case GL_LUMINANCE8_ALPHA8: 454 case GL_LUMINANCE12_ALPHA4: 455 case GL_LUMINANCE12_ALPHA12: 456 case GL_LUMINANCE16_ALPHA16: 457 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: 458 458 #ifdef CR_EXT_texture_sRGB 459 459 case GL_SLUMINANCE_ALPHA_EXT: … … 461 461 case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: 462 462 #endif 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 463 tl->texFormat = &_texformat_al88; 464 break; 465 466 case GL_INTENSITY: 467 case GL_INTENSITY4: 468 case GL_INTENSITY8: 469 case GL_INTENSITY12: 470 case GL_INTENSITY16: 471 case GL_COMPRESSED_INTENSITY_ARB: 472 tl->texFormat = &_texformat_i8; 473 break; 474 475 case GL_COLOR_INDEX: 476 case GL_COLOR_INDEX1_EXT: 477 case GL_COLOR_INDEX2_EXT: 478 case GL_COLOR_INDEX4_EXT: 479 case GL_COLOR_INDEX8_EXT: 480 case GL_COLOR_INDEX12_EXT: 481 case GL_COLOR_INDEX16_EXT: 482 tl->texFormat = &_texformat_ci8; 483 break; 484 485 default: 486 return; 487 } 488 488 } 489 489 … … 491 491 void crStateTextureInitTexture (GLuint name) 492 492 { 493 494 495 496 497 498 499 500 493 CRContext *g = GetCurrentContext(); 494 CRTextureState *t = &(g->texture); 495 CRTextureObj *tobj; 496 497 GET_TOBJ(tobj, name); 498 if (!tobj) return; 499 500 crStateTextureInitTextureObj(g, tobj, name, GL_NONE); 501 501 } 502 502 #endif … … 510 510 crStateTextureGet(GLenum target, GLuint name) 511 511 { 512 513 514 515 516 517 518 519 520 521 522 523 524 512 CRContext *g = GetCurrentContext(); 513 CRTextureState *t = &(g->texture); 514 CRTextureObj *tobj; 515 516 if (name == 0) 517 { 518 switch (target) { 519 case GL_TEXTURE_1D: 520 return &t->base1D; 521 case GL_TEXTURE_2D: 522 return &t->base2D; 523 case GL_TEXTURE_3D: 524 return &t->base3D; 525 525 #ifdef CR_ARB_texture_cube_map 526 527 526 case GL_TEXTURE_CUBE_MAP_ARB: 527 return &t->baseCubeMap; 528 528 #endif 529 529 #ifdef CR_NV_texture_rectangle 530 531 532 #endif 533 534 535 536 537 538 539 540 530 case GL_TEXTURE_RECTANGLE_NV: 531 return &t->baseRect; 532 #endif 533 default: 534 return NULL; 535 } 536 } 537 538 GET_TOBJ(tobj, g, name); 539 540 return tobj; 541 541 } 542 542 … … 549 549 crStateTextureAllocate_t(CRContext *ctx, GLuint name) 550 550 { 551 552 553 554 555 556 557 558 559 560 561 562 563 564 551 CRTextureObj *tobj; 552 553 if (!name) 554 return NULL; 555 556 tobj = crCalloc(sizeof(CRTextureObj)); 557 if (!tobj) 558 return NULL; 559 560 crHashtableAdd( ctx->shared->textureTable, name, (void *) tobj ); 561 562 crStateTextureInitTextureObj(ctx, tobj, name, GL_NONE); 563 564 return tobj; 565 565 } 566 566 … … 574 574 crStateDeleteTextureObjectData(CRTextureObj *tobj) 575 575 { 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 576 int k; 577 int face; 578 579 CRASSERT(tobj); 580 581 /* Free the texture images */ 582 for (face = 0; face < 6; face++) { 583 CRTextureLevel *levels = NULL; 584 levels = tobj->level[face]; 585 if (levels) { 586 /* free all mipmap levels for this face */ 587 for (k = 0; k < CR_MAX_MIPMAP_LEVELS; k++) { 588 CRTextureLevel *tl = levels + k; 589 if (tl->img) { 590 crFree(tl->img); 591 tl->img = NULL; 592 tl->bytes = 0; 593 } 594 } 595 crFree(levels); 596 } 597 tobj->level[face] = NULL; 598 } 599 599 } 600 600 … … 603 603 crStateDeleteTextureObject(CRTextureObj *tobj) 604 604 { 605 606 605 crStateDeleteTextureObjectData(tobj); 606 crFree(tobj); 607 607 } 608 608 609 609 void STATE_APIENTRY crStateGenTextures(GLsizei n, GLuint *textures) 610 610 { 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 611 CRContext *g = GetCurrentContext(); 612 GLint start; 613 614 FLUSH(); 615 616 if (g->current.inBeginEnd) 617 { 618 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 619 "glGenTextures called in Begin/End"); 620 return; 621 } 622 623 if (n < 0) 624 { 625 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 626 "Negative n passed to glGenTextures: %d", n); 627 return; 628 } 629 630 start = crHashtableAllocKeys(g->shared->textureTable, n); 631 if (start) 632 { 633 GLint i; 634 for (i = 0; i < n; i++) 635 textures[i] = (GLuint) (start + i); 636 } 637 else 638 { 639 crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenTextures"); 640 } 641 641 } 642 642 … … 676 676 void STATE_APIENTRY crStateDeleteTextures(GLsizei n, const GLuint *textures) 677 677 { 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 678 CRContext *g = GetCurrentContext(); 679 CRTextureState *t = &(g->texture); 680 CRStateBits *sb = GetCurrentBits(); 681 CRTextureBits *tb = &(sb->texture); 682 int i; 683 684 FLUSH(); 685 686 if (g->current.inBeginEnd) 687 { 688 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 689 "glDeleteTextures called in Begin/End"); 690 return; 691 } 692 693 if (n < 0) 694 { 695 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 696 "Negative n passed to glDeleteTextures: %d", n); 697 return; 698 } 699 700 for (i=0; i<n; i++) 701 { 702 GLuint name = textures[i]; 703 CRTextureObj *tObj; 704 GET_TOBJ(tObj, g, name); 705 if (name && tObj) 706 { 707 GLuint u; 708 /* remove from hashtable */ 709 crHashtableDelete(g->shared->textureTable, name, NULL); 710 711 /* if the currentTexture is deleted, 712 ** reset back to the base texture. 713 */ 714 for (u = 0; u < g->limits.maxTextureUnits; u++) 715 { 716 if (tObj == t->unit[u].currentTexture1D) 717 { 718 t->unit[u].currentTexture1D = &(t->base1D); 719 } 720 if (tObj == t->unit[u].currentTexture2D) 721 { 722 t->unit[u].currentTexture2D = &(t->base2D); 723 } 724 724 #ifdef CR_OPENGL_VERSION_1_2 725 726 727 728 725 if (tObj == t->unit[u].currentTexture3D) 726 { 727 t->unit[u].currentTexture3D = &(t->base3D); 728 } 729 729 #endif 730 730 #ifdef CR_ARB_texture_cube_map 731 732 733 734 731 if (tObj == t->unit[u].currentTextureCubeMap) 732 { 733 t->unit[u].currentTextureCubeMap = &(t->baseCubeMap); 734 } 735 735 #endif 736 736 #ifdef CR_NV_texture_rectangle 737 738 739 740 741 #endif 742 737 if (tObj == t->unit[u].currentTextureRect) 738 { 739 t->unit[u].currentTextureRect = &(t->baseRect); 740 } 741 #endif 742 } 743 743 744 744 #ifdef CR_EXT_framebuffer_object … … 746 746 crStateTextureCheckFBOAPs(GL_READ_FRAMEBUFFER, name); 747 747 #endif 748 749 750 751 752 753 748 crStateDeleteTextureObject(tObj); 749 } 750 } 751 752 DIRTY(tb->dirty, g->neg_bitid); 753 DIRTY(tb->current[t->curTextureUnit], g->neg_bitid); 754 754 } 755 755 … … 758 758 void STATE_APIENTRY crStateClientActiveTextureARB( GLenum texture ) 759 759 { 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 760 CRContext *g = GetCurrentContext(); 761 CRClientState *c = &(g->client); 762 763 FLUSH(); 764 765 if (!g->extensions.ARB_multitexture) { 766 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 767 "glClientActiveTextureARB not available"); 768 return; 769 } 770 771 if (g->current.inBeginEnd) 772 { 773 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 774 "glClientActiveTextureARB called in Begin/End"); 775 return; 776 } 777 778 if ( texture < GL_TEXTURE0_ARB || 779 texture >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits) 780 { 781 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 782 "crStateClientActiveTexture: unit = %d (max is %d)", 783 texture, g->limits.maxTextureUnits ); 784 return; 785 } 786 787 c->curClientTextureUnit = texture - GL_TEXTURE0_ARB; 788 788 } 789 789 790 790 void STATE_APIENTRY crStateActiveTextureARB( GLenum texture ) 791 791 { 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 792 CRContext *g = GetCurrentContext(); 793 CRTextureState *t = &(g->texture); 794 795 FLUSH(); 796 797 if (!g->extensions.ARB_multitexture) { 798 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 799 "glActiveTextureARB not available"); 800 return; 801 } 802 803 if (g->current.inBeginEnd) 804 { 805 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glActiveTextureARB called in Begin/End"); 806 return; 807 } 808 809 if ( texture < GL_TEXTURE0_ARB || texture >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits) 810 { 811 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Bad texture unit passed to crStateActiveTexture: %d (max is %d)", texture, g->limits.maxTextureUnits ); 812 return; 813 } 814 815 t->curTextureUnit = texture - GL_TEXTURE0_ARB; 816 817 /* update the current matrix pointer, etc. */ 818 if (g->transform.matrixMode == GL_TEXTURE) { 819 crStateMatrixMode(GL_TEXTURE); 820 } 821 821 } 822 822 823 823 void STATE_APIENTRY crStateBindTexture(GLenum target, GLuint texture) 824 824 { 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 825 CRContext *g = GetCurrentContext(); 826 CRTextureState *t = &(g->texture); 827 CRTextureObj *tobj; 828 CRStateBits *sb = GetCurrentBits(); 829 CRTextureBits *tb = &(sb->texture); 830 831 FLUSH(); 832 833 if (g->current.inBeginEnd) 834 { 835 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBindTexture called in Begin/End"); 836 return; 837 } 838 839 /* Special Case name = 0 */ 840 if (!texture) 841 { 842 switch (target) 843 { 844 case GL_TEXTURE_1D: 845 t->unit[t->curTextureUnit].currentTexture1D = &(t->base1D); 846 break; 847 case GL_TEXTURE_2D: 848 t->unit[t->curTextureUnit].currentTexture2D = &(t->base2D); 849 break; 850 850 #ifdef CR_OPENGL_VERSION_1_2 851 852 853 851 case GL_TEXTURE_3D: 852 t->unit[t->curTextureUnit].currentTexture3D = &(t->base3D); 853 break; 854 854 #endif 855 855 #ifdef CR_ARB_texture_cube_map 856 857 858 859 860 861 862 863 856 case GL_TEXTURE_CUBE_MAP_ARB: 857 if (!g->extensions.ARB_texture_cube_map) { 858 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 859 "Invalid target passed to glBindTexture: %d", target); 860 return; 861 } 862 t->unit[t->curTextureUnit].currentTextureCubeMap = &(t->baseCubeMap); 863 break; 864 864 #endif 865 865 #ifdef CR_NV_texture_rectangle 866 867 868 869 870 871 872 873 874 #endif 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 866 case GL_TEXTURE_RECTANGLE_NV: 867 if (!g->extensions.NV_texture_rectangle) { 868 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 869 "Invalid target passed to glBindTexture: %d", target); 870 return; 871 } 872 t->unit[t->curTextureUnit].currentTextureRect = &(t->baseRect); 873 break; 874 #endif 875 default: 876 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid target passed to glBindTexture: %d", target); 877 return; 878 } 879 880 DIRTY(tb->dirty, g->neg_bitid); 881 DIRTY(tb->current[t->curTextureUnit], g->neg_bitid); 882 return; 883 } 884 885 /* texture != 0 */ 886 /* Get the texture */ 887 GET_TOBJ(tobj, g, texture); 888 if (!tobj) 889 { 890 tobj = crStateTextureAllocate_t(g, texture); 891 } 892 893 /* Check the targets */ 894 if (tobj->target == GL_NONE) 895 { 896 /* Target isn't set so set it now.*/ 897 tobj->target = target; 898 } 899 else if (tobj->target != target) 900 { 901 crWarning( "You called glBindTexture with a target of 0x%x, but the texture you wanted was target 0x%x [1D: %x 2D: %x 3D: %x cube: %x]", (int) target, (int) tobj->target, GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP ); 902 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Attempt to bind a texture of diffent dimenions"); 903 return; 904 } 905 906 /* Set the current texture */ 907 switch (target) 908 { 909 case GL_TEXTURE_1D: 910 t->unit[t->curTextureUnit].currentTexture1D = tobj; 911 break; 912 case GL_TEXTURE_2D: 913 t->unit[t->curTextureUnit].currentTexture2D = tobj; 914 break; 915 915 #ifdef CR_OPENGL_VERSION_1_2 916 917 918 916 case GL_TEXTURE_3D: 917 t->unit[t->curTextureUnit].currentTexture3D = tobj; 918 break; 919 919 #endif 920 920 #ifdef CR_ARB_texture_cube_map 921 922 923 921 case GL_TEXTURE_CUBE_MAP_ARB: 922 t->unit[t->curTextureUnit].currentTextureCubeMap = tobj; 923 break; 924 924 #endif 925 925 #ifdef CR_NV_texture_rectangle 926 927 928 929 #endif 930 931 932 933 934 935 936 937 926 case GL_TEXTURE_RECTANGLE_NV: 927 t->unit[t->curTextureUnit].currentTextureRect = tobj; 928 break; 929 #endif 930 default: 931 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 932 "Invalid target passed to glBindTexture: %d", target); 933 return; 934 } 935 936 DIRTY(tb->dirty, g->neg_bitid); 937 DIRTY(tb->current[t->curTextureUnit], g->neg_bitid); 938 938 } 939 939 … … 942 942 crStateTexParameterfv(GLenum target, GLenum pname, const GLfloat *param) 943 943 { 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 944 CRContext *g = GetCurrentContext(); 945 CRTextureObj *tobj = NULL; 946 CRTextureLevel *tl = NULL; 947 GLenum e = (GLenum) *param; 948 CRStateBits *sb = GetCurrentBits(); 949 CRTextureBits *tb = &(sb->texture); 950 unsigned int i; 951 952 FLUSH(); 953 954 if (g->current.inBeginEnd) 955 { 956 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 957 "TexParameterfv called in Begin/End"); 958 return; 959 } 960 961 crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl); 962 if (!tobj) { 963 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 964 "TexParamterfv(invalid target=0x%x)", target); 965 return; 966 } 967 968 switch (pname) 969 { 970 case GL_TEXTURE_MIN_FILTER: 971 if (e != GL_NEAREST && 972 e != GL_LINEAR && 973 e != GL_NEAREST_MIPMAP_NEAREST && 974 e != GL_LINEAR_MIPMAP_NEAREST && 975 e != GL_NEAREST_MIPMAP_LINEAR && 976 e != GL_LINEAR_MIPMAP_LINEAR) 977 { 978 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 979 "TexParamterfv: GL_TEXTURE_MIN_FILTER invalid param: %d", e); 980 return; 981 } 982 tobj->minFilter = e; 983 break; 984 case GL_TEXTURE_MAG_FILTER: 985 if (e != GL_NEAREST && e != GL_LINEAR) 986 { 987 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 988 "TexParamterfv: GL_TEXTURE_MAG_FILTER invalid param: %d", e); 989 return; 990 } 991 tobj->magFilter = e; 992 break; 993 case GL_TEXTURE_WRAP_S: 994 if (e == GL_CLAMP || e == GL_REPEAT) { 995 tobj->wrapS = e; 996 } 997 997 #ifdef CR_OPENGL_VERSION_1_2 998 999 1000 998 else if (e == GL_CLAMP_TO_EDGE) { 999 tobj->wrapS = e; 1000 } 1001 1001 #endif 1002 1002 #ifdef GL_CLAMP_TO_EDGE_EXT 1003 1004 1005 1003 else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) { 1004 tobj->wrapS = e; 1005 } 1006 1006 #endif 1007 1007 #ifdef CR_ARB_texture_border_clamp 1008 1009 1010 1008 else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) { 1009 tobj->wrapS = e; 1010 } 1011 1011 #endif 1012 1012 #ifdef CR_ARB_texture_mirrored_repeat 1013 1014 1015 1016 #endif 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1013 else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) { 1014 tobj->wrapS = e; 1015 } 1016 #endif 1017 else { 1018 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1019 "TexParameterfv: GL_TEXTURE_WRAP_S invalid param: 0x%x", e); 1020 return; 1021 } 1022 break; 1023 case GL_TEXTURE_WRAP_T: 1024 if (e == GL_CLAMP || e == GL_REPEAT) { 1025 tobj->wrapT = e; 1026 } 1027 1027 #ifdef CR_OPENGL_VERSION_1_2 1028 1029 1030 1028 else if (e == GL_CLAMP_TO_EDGE) { 1029 tobj->wrapT = e; 1030 } 1031 1031 #endif 1032 1032 #ifdef GL_CLAMP_TO_EDGE_EXT 1033 1034 1035 1033 else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) { 1034 tobj->wrapT = e; 1035 } 1036 1036 #endif 1037 1037 #ifdef CR_ARB_texture_border_clamp 1038 1039 1040 1038 else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) { 1039 tobj->wrapT = e; 1040 } 1041 1041 #endif 1042 1042 #ifdef CR_ARB_texture_mirrored_repeat 1043 1044 1045 1046 #endif 1047 1048 1049 1050 1051 1052 1043 else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) { 1044 tobj->wrapT = e; 1045 } 1046 #endif 1047 else { 1048 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1049 "TexParameterfv: GL_TEXTURE_WRAP_T invalid param: 0x%x", e); 1050 return; 1051 } 1052 break; 1053 1053 #ifdef CR_OPENGL_VERSION_1_2 1054 1055 1056 1057 1058 1059 1060 1054 case GL_TEXTURE_WRAP_R: 1055 if (e == GL_CLAMP || e == GL_REPEAT) { 1056 tobj->wrapR = e; 1057 } 1058 else if (e == GL_CLAMP_TO_EDGE) { 1059 tobj->wrapR = e; 1060 } 1061 1061 #ifdef GL_CLAMP_TO_EDGE_EXT 1062 1063 1064 1062 else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) { 1063 tobj->wrapR = e; 1064 } 1065 1065 #endif 1066 1066 #ifdef CR_ARB_texture_border_clamp 1067 1068 1069 1067 else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) { 1068 tobj->wrapR = e; 1069 } 1070 1070 #endif 1071 1071 #ifdef CR_ARB_texture_mirrored_repeat 1072 1073 1074 1075 #endif 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 #endif 1110 1111 1112 1113 1114 1115 1072 else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) { 1073 tobj->wrapR = e; 1074 } 1075 #endif 1076 else { 1077 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1078 "TexParameterfv: GL_TEXTURE_WRAP_R invalid param: 0x%x", e); 1079 return; 1080 } 1081 break; 1082 case GL_TEXTURE_PRIORITY: 1083 tobj->priority = param[0]; 1084 break; 1085 case GL_TEXTURE_MIN_LOD: 1086 tobj->minLod = param[0]; 1087 break; 1088 case GL_TEXTURE_MAX_LOD: 1089 tobj->maxLod = param[0]; 1090 break; 1091 case GL_TEXTURE_BASE_LEVEL: 1092 if (e < 0.0f) 1093 { 1094 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1095 "TexParameterfv: GL_TEXTURE_BASE_LEVEL invalid param: 0x%x", e); 1096 return; 1097 } 1098 tobj->baseLevel = e; 1099 break; 1100 case GL_TEXTURE_MAX_LEVEL: 1101 if (e < 0.0f) 1102 { 1103 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1104 "TexParameterfv: GL_TEXTURE_MAX_LEVEL invalid param: 0x%x", e); 1105 return; 1106 } 1107 tobj->maxLevel = e; 1108 break; 1109 #endif 1110 case GL_TEXTURE_BORDER_COLOR: 1111 tobj->borderColor.r = param[0]; 1112 tobj->borderColor.g = param[1]; 1113 tobj->borderColor.b = param[2]; 1114 tobj->borderColor.a = param[3]; 1115 break; 1116 1116 #ifdef CR_EXT_texture_filter_anisotropic 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1117 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 1118 if (g->extensions.EXT_texture_filter_anisotropic) { 1119 if (param[0] < 1.0f) 1120 { 1121 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 1122 "TexParameterfv: GL_TEXTURE_MAX_ANISOTROPY_EXT called with parameter less than 1: %f", param[0]); 1123 return; 1124 } 1125 tobj->maxAnisotropy = param[0]; 1126 if (tobj->maxAnisotropy > g->limits.maxTextureAnisotropy) 1127 { 1128 tobj->maxAnisotropy = g->limits.maxTextureAnisotropy; 1129 } 1130 } 1131 break; 1132 1132 #endif 1133 1133 #ifdef CR_ARB_depth_texture 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1134 case GL_DEPTH_TEXTURE_MODE_ARB: 1135 if (g->extensions.ARB_depth_texture) { 1136 if (param[0] == GL_LUMINANCE || 1137 param[0] == GL_INTENSITY || 1138 param[0] == GL_ALPHA) { 1139 tobj->depthMode = (GLenum) param[0]; 1140 } 1141 else 1142 { 1143 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 1144 "TexParameterfv: GL_DEPTH_TEXTURE_MODE_ARB called with invalid parameter: 0x%x", param[0]); 1145 return; 1146 } 1147 } 1148 break; 1149 1149 #endif 1150 1150 #ifdef CR_ARB_shadow 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1151 case GL_TEXTURE_COMPARE_MODE_ARB: 1152 if (g->extensions.ARB_shadow) { 1153 if (param[0] == GL_NONE || 1154 param[0] == GL_COMPARE_R_TO_TEXTURE_ARB) { 1155 tobj->compareMode = (GLenum) param[0]; 1156 } 1157 else 1158 { 1159 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 1160 "TexParameterfv: GL_TEXTURE_COMPARE_MODE_ARB called with invalid parameter: 0x%x", param[0]); 1161 return; 1162 } 1163 } 1164 break; 1165 case GL_TEXTURE_COMPARE_FUNC_ARB: 1166 if (g->extensions.ARB_shadow) { 1167 if (param[0] == GL_LEQUAL || 1168 param[0] == GL_GEQUAL) { 1169 tobj->compareFunc = (GLenum) param[0]; 1170 } 1171 } 1172 1172 #ifdef CR_EXT_shadow_funcs 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 #endif 1184 1185 1186 1187 1188 1189 1173 else if (g->extensions.EXT_shadow_funcs) { 1174 if (param[0] == GL_LEQUAL || 1175 param[0] == GL_GEQUAL || 1176 param[0] == GL_LESS || 1177 param[0] == GL_GREATER || 1178 param[0] == GL_ALWAYS || 1179 param[0] == GL_NEVER ) { 1180 tobj->compareFunc = (GLenum) param[0]; 1181 } 1182 } 1183 #endif 1184 else { 1185 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 1186 "TexParameterfv: GL_TEXTURE_COMPARE_FUNC_ARB called with invalid parameter: 0x%x", param[0]); 1187 return; 1188 } 1189 break; 1190 1190 #endif 1191 1191 #ifdef CR_ARB_shadow_ambient 1192 1193 1194 1195 1196 1192 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: 1193 if (g->extensions.ARB_shadow_ambient) { 1194 tobj->compareFailValue = param[0]; 1195 } 1196 break; 1197 1197 #endif 1198 1198 #ifdef CR_SGIS_generate_mipmap 1199 1200 1201 1202 1203 1204 #endif 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1199 case GL_GENERATE_MIPMAP_SGIS: 1200 if (g->extensions.SGIS_generate_mipmap) { 1201 tobj->generateMipmap = param[0] ? GL_TRUE : GL_FALSE; 1202 } 1203 break; 1204 #endif 1205 default: 1206 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1207 "TexParamterfv: Invalid pname: %d", pname); 1208 return; 1209 } 1210 1211 DIRTY(tobj->dirty, g->neg_bitid); 1212 for (i = 0; i < g->limits.maxTextureUnits; i++) 1213 { 1214 DIRTY(tobj->paramsBit[i], g->neg_bitid); 1215 } 1216 DIRTY(tb->dirty, g->neg_bitid); 1217 1217 } 1218 1218 … … 1221 1221 crStateTexParameteriv(GLenum target, GLenum pname, const GLint *param) 1222 1222 { 1223 1224 1225 1226 1227 1228 1229 1230 1223 GLfloat f_param; 1224 GLcolor f_color; 1225 switch (pname) 1226 { 1227 case GL_TEXTURE_MIN_FILTER: 1228 case GL_TEXTURE_MAG_FILTER: 1229 case GL_TEXTURE_WRAP_S: 1230 case GL_TEXTURE_WRAP_T: 1231 1231 #ifdef CR_OPENGL_VERSION_1_2 1232 1233 1234 1235 1236 1237 1232 case GL_TEXTURE_WRAP_R: 1233 case GL_TEXTURE_PRIORITY: 1234 case GL_TEXTURE_MIN_LOD: 1235 case GL_TEXTURE_MAX_LOD: 1236 case GL_TEXTURE_BASE_LEVEL: 1237 case GL_TEXTURE_MAX_LEVEL: 1238 1238 #endif 1239 1239 #ifdef CR_EXT_texture_filter_anisotropic 1240 1240 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 1241 1241 #endif 1242 1242 #ifdef CR_ARB_depth_texture 1243 1243 case GL_DEPTH_TEXTURE_MODE_ARB: 1244 1244 #endif 1245 1245 #ifdef CR_ARB_shadow 1246 1247 1246 case GL_TEXTURE_COMPARE_MODE_ARB: 1247 case GL_TEXTURE_COMPARE_FUNC_ARB: 1248 1248 #endif 1249 1249 #ifdef CR_ARB_shadow_ambinet 1250 1250 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: 1251 1251 #endif 1252 1252 #ifdef CR_SGIS_generate_mipmap 1253 1254 #endif 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1253 case GL_GENERATE_MIPMAP_SGIS: 1254 #endif 1255 f_param = (GLfloat) (*param); 1256 crStateTexParameterfv( target, pname, &(f_param) ); 1257 break; 1258 case GL_TEXTURE_BORDER_COLOR: 1259 f_color.r = ((GLfloat) param[0])/CR_MAXINT; 1260 f_color.g = ((GLfloat) param[1])/CR_MAXINT; 1261 f_color.b = ((GLfloat) param[2])/CR_MAXINT; 1262 f_color.a = ((GLfloat) param[3])/CR_MAXINT; 1263 crStateTexParameterfv( target, pname, (const GLfloat *) &(f_color) ); 1264 break; 1265 default: 1266 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1267 "TexParamteriv: Invalid pname: %d", pname); 1268 return; 1269 } 1270 1270 } 1271 1271 … … 1274 1274 crStateTexParameterf(GLenum target, GLenum pname, GLfloat param) 1275 1275 { 1276 1276 crStateTexParameterfv( target, pname, ¶m ); 1277 1277 } 1278 1278 … … 1280 1280 void STATE_APIENTRY 1281 1281 crStateTexParameteri(GLenum target, GLenum pname, GLint param) { 1282 1283 1282 GLfloat f_param = (GLfloat) param; 1283 crStateTexParameterfv( target, pname, &f_param ); 1284 1284 } 1285 1285 … … 1288 1288 crStateTexEnvfv(GLenum target, GLenum pname, const GLfloat *param) 1289 1289 { 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1290 CRContext *g = GetCurrentContext(); 1291 CRTextureState *t = &(g->texture); 1292 CRStateBits *sb = GetCurrentBits(); 1293 CRTextureBits *tb = &(sb->texture); 1294 GLenum e; 1295 GLcolorf c; 1296 GLuint stage = 0; 1297 1298 (void) stage; 1299 1300 FLUSH(); 1301 1302 if (g->current.inBeginEnd) 1303 { 1304 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 1305 "glTexEnvfv called in begin/end"); 1306 return; 1307 } 1308 1308 1309 1309 #if CR_EXT_texture_lod_bias 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1310 if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { 1311 if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) { 1312 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnv"); 1313 } 1314 else { 1315 t->unit[t->curTextureUnit].lodBias = *param; 1316 DIRTY(tb->envBit[t->curTextureUnit], g->neg_bitid); 1317 DIRTY(tb->dirty, g->neg_bitid); 1318 } 1319 return; 1320 } 1321 else 1322 1322 #endif 1323 1323 #if CR_ARB_point_sprite 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 #endif 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1324 if (target == GL_POINT_SPRITE_ARB) { 1325 if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) { 1326 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnv"); 1327 } 1328 else { 1329 CRPointBits *pb = &(sb->point); 1330 g->point.coordReplacement[t->curTextureUnit] = *param ? GL_TRUE : GL_FALSE; 1331 DIRTY(pb->coordReplacement[t->curTextureUnit], g->neg_bitid); 1332 DIRTY(pb->dirty, g->neg_bitid); 1333 } 1334 return; 1335 } 1336 else 1337 #endif 1338 if (target != GL_TEXTURE_ENV) 1339 { 1340 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1341 "glTexEnvfv: target != GL_TEXTURE_ENV: %d", target); 1342 return; 1343 } 1344 1345 switch (pname) 1346 { 1347 case GL_TEXTURE_ENV_MODE: 1348 e = (GLenum) *param; 1349 if (e != GL_MODULATE && 1350 e != GL_DECAL && 1351 e != GL_BLEND && 1352 e != GL_ADD && 1353 e != GL_REPLACE && 1354 e != GL_COMBINE_ARB) 1355 { 1356 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1357 "glTexEnvfv: invalid param: %f", *param); 1358 return; 1359 } 1360 t->unit[t->curTextureUnit].envMode = e; 1361 break; 1362 case GL_TEXTURE_ENV_COLOR: 1363 c.r = param[0]; 1364 c.g = param[1]; 1365 c.b = param[2]; 1366 c.a = param[3]; 1367 if (c.r > 1.0f) c.r = 1.0f; 1368 if (c.g > 1.0f) c.g = 1.0f; 1369 if (c.b > 1.0f) c.b = 1.0f; 1370 if (c.a > 1.0f) c.a = 1.0f; 1371 if (c.r < 0.0f) c.r = 0.0f; 1372 if (c.g < 0.0f) c.g = 0.0f; 1373 if (c.b < 0.0f) c.b = 0.0f; 1374 if (c.a < 0.0f) c.a = 0.0f; 1375 t->unit[t->curTextureUnit].envColor = c; 1376 break; 1377 1377 1378 1378 #ifdef CR_ARB_texture_env_combine 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1379 case GL_COMBINE_RGB_ARB: 1380 e = (GLenum) (GLint) *param; 1381 if (g->extensions.ARB_texture_env_combine && 1382 (e == GL_REPLACE || 1383 e == GL_MODULATE || 1384 e == GL_ADD || 1385 e == GL_ADD_SIGNED_ARB || 1386 e == GL_INTERPOLATE_ARB || 1387 e == GL_SUBTRACT_ARB)) { 1388 t->unit[t->curTextureUnit].combineModeRGB = e; 1389 } 1390 1390 #ifdef CR_ARB_texture_env_dot3 1391 1392 1393 1394 1395 1396 1397 1398 #endif 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1391 else if (g->extensions.ARB_texture_env_dot3 && 1392 (e == GL_DOT3_RGB_ARB || 1393 e == GL_DOT3_RGBA_ARB || 1394 e == GL_DOT3_RGB_EXT || 1395 e == GL_DOT3_RGBA_EXT)) { 1396 t->unit[t->curTextureUnit].combineModeRGB = e; 1397 } 1398 #endif 1399 else { 1400 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv(param=0x%x", e); 1401 return; 1402 } 1403 break; 1404 case GL_COMBINE_ALPHA_EXT: 1405 e = (GLenum) *param; 1406 if (g->extensions.ARB_texture_env_combine && 1407 (e == GL_REPLACE || 1408 e == GL_MODULATE || 1409 e == GL_ADD || 1410 e == GL_ADD_SIGNED_ARB || 1411 e == GL_INTERPOLATE_ARB || 1412 e == GL_SUBTRACT_ARB)) { 1413 t->unit[t->curTextureUnit].combineModeA = e; 1414 } 1415 else { 1416 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv"); 1417 return; 1418 } 1419 break; 1420 case GL_SOURCE0_RGB_ARB: 1421 case GL_SOURCE1_RGB_ARB: 1422 case GL_SOURCE2_RGB_ARB: 1423 e = (GLenum) *param; 1424 stage = pname - GL_SOURCE0_RGB_ARB; 1425 if (g->extensions.ARB_texture_env_combine && 1426 (e == GL_TEXTURE || 1427 e == GL_CONSTANT_ARB || 1428 e == GL_PRIMARY_COLOR_ARB || 1429 e == GL_PREVIOUS_ARB)) { 1430 t->unit[t->curTextureUnit].combineSourceRGB[stage] = e; 1431 } 1432 else if (g->extensions.ARB_texture_env_crossbar && 1433 e >= GL_TEXTURE0_ARB && 1434 e < GL_TEXTURE0_ARB + g->limits.maxTextureUnits) { 1435 t->unit[t->curTextureUnit].combineSourceRGB[stage] = e; 1436 } 1437 else { 1438 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv"); 1439 return; 1440 } 1441 break; 1442 case GL_SOURCE0_ALPHA_ARB: 1443 case GL_SOURCE1_ALPHA_ARB: 1444 case GL_SOURCE2_ALPHA_ARB: 1445 e = (GLenum) *param; 1446 stage = pname - GL_SOURCE0_ALPHA_ARB; 1447 if (g->extensions.ARB_texture_env_combine && 1448 (e == GL_TEXTURE || 1449 e == GL_CONSTANT_ARB || 1450 e == GL_PRIMARY_COLOR_ARB || 1451 e == GL_PREVIOUS_ARB)) { 1452 t->unit[t->curTextureUnit].combineSourceA[stage] = e; 1453 } 1454 else if (g->extensions.ARB_texture_env_crossbar && 1455 e >= GL_TEXTURE0_ARB && 1456 e < GL_TEXTURE0_ARB + g->limits.maxTextureUnits) { 1457 t->unit[t->curTextureUnit].combineSourceA[stage] = e; 1458 } 1459 else { 1460 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv"); 1461 return; 1462 } 1463 break; 1464 case GL_OPERAND0_RGB_ARB: 1465 case GL_OPERAND1_RGB_ARB: 1466 case GL_OPERAND2_RGB_ARB: 1467 e = (GLenum) *param; 1468 stage = pname - GL_OPERAND0_RGB_ARB; 1469 if (g->extensions.ARB_texture_env_combine && 1470 (e == GL_SRC_COLOR || 1471 e == GL_ONE_MINUS_SRC_COLOR || 1472 e == GL_SRC_ALPHA || 1473 e == GL_ONE_MINUS_SRC_ALPHA)) { 1474 t->unit[t->curTextureUnit].combineOperandRGB[stage] = e; 1475 } 1476 else { 1477 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv"); 1478 return; 1479 } 1480 break; 1481 case GL_OPERAND0_ALPHA_ARB: 1482 case GL_OPERAND1_ALPHA_ARB: 1483 case GL_OPERAND2_ALPHA_ARB: 1484 e = (GLenum) *param; 1485 stage = pname - GL_OPERAND0_ALPHA_ARB; 1486 if (g->extensions.ARB_texture_env_combine && 1487 (e == GL_SRC_ALPHA || 1488 e == GL_ONE_MINUS_SRC_ALPHA)) { 1489 t->unit[t->curTextureUnit].combineOperandA[stage] = e; 1490 } 1491 else { 1492 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv(param=0x%x)", e); 1493 return; 1494 } 1495 break; 1496 case GL_RGB_SCALE_ARB: 1497 if (g->extensions.ARB_texture_env_combine && 1498 (*param == 1.0 || 1499 *param == 2.0 || 1500 *param == 4.0)) { 1501 t->unit[t->curTextureUnit].combineScaleRGB = *param; 1502 } 1503 else { 1504 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexEnvfv"); 1505 return; 1506 } 1507 break; 1508 case GL_ALPHA_SCALE: 1509 if (g->extensions.ARB_texture_env_combine && 1510 (*param == 1.0 || 1511 *param == 2.0 || 1512 *param == 4.0)) { 1513 t->unit[t->curTextureUnit].combineScaleA = *param; 1514 } 1515 else { 1516 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexEnvfv"); 1517 return; 1518 } 1519 break; 1520 1520 #endif /* CR_ARB_texture_env_combine */ 1521 1521 1522 1523 1524 1525 1526 1527 1528 1529 1522 default: 1523 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1524 "glTexEnvfv: invalid pname: %d", pname); 1525 return; 1526 } 1527 1528 DIRTY(tb->envBit[t->curTextureUnit], g->neg_bitid); 1529 DIRTY(tb->dirty, g->neg_bitid); 1530 1530 } 1531 1531 … … 1534 1534 crStateTexEnviv(GLenum target, GLenum pname, const GLint *param) 1535 1535 { 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1536 GLfloat f_param; 1537 GLcolor f_color; 1538 1539 switch (pname) { 1540 case GL_TEXTURE_ENV_MODE: 1541 f_param = (GLfloat) (*param); 1542 crStateTexEnvfv( target, pname, &f_param ); 1543 break; 1544 case GL_TEXTURE_ENV_COLOR: 1545 f_color.r = ((GLfloat) param[0]) / CR_MAXINT; 1546 f_color.g = ((GLfloat) param[1]) / CR_MAXINT; 1547 f_color.b = ((GLfloat) param[2]) / CR_MAXINT; 1548 f_color.a = ((GLfloat) param[3]) / CR_MAXINT; 1549 crStateTexEnvfv( target, pname, (const GLfloat *) &f_color ); 1550 break; 1551 1551 #ifdef CR_ARB_texture_env_combine 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1552 case GL_COMBINE_RGB_ARB: 1553 case GL_COMBINE_ALPHA_EXT: 1554 case GL_SOURCE0_RGB_ARB: 1555 case GL_SOURCE1_RGB_ARB: 1556 case GL_SOURCE2_RGB_ARB: 1557 case GL_SOURCE0_ALPHA_ARB: 1558 case GL_SOURCE1_ALPHA_ARB: 1559 case GL_SOURCE2_ALPHA_ARB: 1560 case GL_OPERAND0_RGB_ARB: 1561 case GL_OPERAND1_RGB_ARB: 1562 case GL_OPERAND2_RGB_ARB: 1563 case GL_OPERAND0_ALPHA_ARB: 1564 case GL_OPERAND1_ALPHA_ARB: 1565 case GL_OPERAND2_ALPHA_ARB: 1566 case GL_RGB_SCALE_ARB: 1567 case GL_ALPHA_SCALE: 1568 f_param = (GLfloat) (*param); 1569 crStateTexEnvfv( target, pname, &f_param ); 1570 break; 1571 1571 #endif 1572 1572 #ifdef CR_EXT_texture_lod_bias 1573 1574 1575 1576 1573 case GL_TEXTURE_LOD_BIAS_EXT: 1574 f_param = (GLfloat) (*param); 1575 crStateTexEnvfv( target, pname, &f_param); 1576 break; 1577 1577 #endif 1578 1578 #ifdef CR_ARB_point_sprite 1579 1580 1581 1582 1583 #endif 1584 1585 1586 1587 1588 1589 1579 case GL_COORD_REPLACE_ARB: 1580 f_param = (GLfloat) *param; 1581 crStateTexEnvfv( target, pname, &f_param); 1582 break; 1583 #endif 1584 1585 default: 1586 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1587 "glTexEnvfv: invalid pname: %d", pname); 1588 return; 1589 } 1590 1590 } 1591 1591 … … 1594 1594 crStateTexEnvf(GLenum target, GLenum pname, GLfloat param) 1595 1595 { 1596 1596 crStateTexEnvfv( target, pname, ¶m ); 1597 1597 } 1598 1598 … … 1601 1601 crStateTexEnvi(GLenum target, GLenum pname, GLint param) 1602 1602 { 1603 1604 1603 GLfloat f_param = (GLfloat) param; 1604 crStateTexEnvfv( target, pname, &f_param ); 1605 1605 } 1606 1606 … … 1609 1609 crStateGetTexEnvfv(GLenum target, GLenum pname, GLfloat *param) 1610 1610 { 1611 1612 1613 1614 1615 1616 1617 1618 1619 1611 CRContext *g = GetCurrentContext(); 1612 CRTextureState *t = &(g->texture); 1613 1614 if (g->current.inBeginEnd) 1615 { 1616 crStateError(__LINE__, __FILE__,GL_INVALID_OPERATION, 1617 "glGetTexEnvfv called in begin/end"); 1618 return; 1619 } 1620 1620 1621 1621 #if CR_EXT_texture_lod_bias 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1622 if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { 1623 if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) { 1624 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv"); 1625 } 1626 else { 1627 *param = t->unit[t->curTextureUnit].lodBias; 1628 } 1629 return; 1630 } 1631 else 1632 1632 #endif 1633 1633 #if CR_ARB_point_sprite 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 #endif 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1634 if (target == GL_POINT_SPRITE_ARB) { 1635 if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) { 1636 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv"); 1637 } 1638 else { 1639 *param = (GLfloat) g->point.coordReplacement[t->curTextureUnit]; 1640 } 1641 return; 1642 } 1643 else 1644 #endif 1645 if (target != GL_TEXTURE_ENV) 1646 { 1647 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1648 "glGetTexEnvfv: target != GL_TEXTURE_ENV: %d", target); 1649 return; 1650 } 1651 1652 switch (pname) { 1653 case GL_TEXTURE_ENV_MODE: 1654 *param = (GLfloat) t->unit[t->curTextureUnit].envMode; 1655 break; 1656 case GL_TEXTURE_ENV_COLOR: 1657 param[0] = t->unit[t->curTextureUnit].envColor.r; 1658 param[1] = t->unit[t->curTextureUnit].envColor.g; 1659 param[2] = t->unit[t->curTextureUnit].envColor.b; 1660 param[3] = t->unit[t->curTextureUnit].envColor.a; 1661 break; 1662 case GL_COMBINE_RGB_ARB: 1663 if (g->extensions.ARB_texture_env_combine) { 1664 *param = (GLfloat) t->unit[t->curTextureUnit].combineModeRGB; 1665 } 1666 else { 1667 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1668 return; 1669 } 1670 break; 1671 case GL_COMBINE_ALPHA_ARB: 1672 if (g->extensions.ARB_texture_env_combine) { 1673 *param = (GLfloat) t->unit[t->curTextureUnit].combineModeA; 1674 } 1675 else { 1676 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1677 return; 1678 } 1679 break; 1680 case GL_SOURCE0_RGB_ARB: 1681 if (g->extensions.ARB_texture_env_combine) { 1682 *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[0]; 1683 } 1684 else { 1685 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1686 return; 1687 } 1688 break; 1689 case GL_SOURCE1_RGB_ARB: 1690 if (g->extensions.ARB_texture_env_combine) { 1691 *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[1]; 1692 } 1693 else { 1694 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1695 return; 1696 } 1697 break; 1698 case GL_SOURCE2_RGB_ARB: 1699 if (g->extensions.ARB_texture_env_combine) { 1700 *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[2]; 1701 } 1702 else { 1703 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1704 return; 1705 } 1706 break; 1707 case GL_SOURCE0_ALPHA_ARB: 1708 if (g->extensions.ARB_texture_env_combine) { 1709 *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[0]; 1710 } 1711 else { 1712 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1713 return; 1714 } 1715 break; 1716 case GL_SOURCE1_ALPHA_ARB: 1717 if (g->extensions.ARB_texture_env_combine) { 1718 *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[1]; 1719 } 1720 else { 1721 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1722 return; 1723 } 1724 break; 1725 case GL_SOURCE2_ALPHA_ARB: 1726 if (g->extensions.ARB_texture_env_combine) { 1727 *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[2]; 1728 } 1729 else { 1730 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1731 return; 1732 } 1733 break; 1734 case GL_OPERAND0_RGB_ARB: 1735 if (g->extensions.ARB_texture_env_combine) { 1736 *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[0]; 1737 } 1738 else { 1739 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1740 return; 1741 } 1742 break; 1743 case GL_OPERAND1_RGB_ARB: 1744 if (g->extensions.ARB_texture_env_combine) { 1745 *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[1]; 1746 } 1747 else { 1748 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1749 return; 1750 } 1751 break; 1752 case GL_OPERAND2_RGB_ARB: 1753 if (g->extensions.ARB_texture_env_combine) { 1754 *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[2]; 1755 } 1756 else { 1757 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1758 return; 1759 } 1760 break; 1761 case GL_OPERAND0_ALPHA_ARB: 1762 if (g->extensions.ARB_texture_env_combine) { 1763 *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[0]; 1764 } 1765 else { 1766 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1767 return; 1768 } 1769 break; 1770 case GL_OPERAND1_ALPHA_ARB: 1771 if (g->extensions.ARB_texture_env_combine) { 1772 *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[1]; 1773 } 1774 else { 1775 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1776 return; 1777 } 1778 break; 1779 case GL_OPERAND2_ALPHA_ARB: 1780 if (g->extensions.ARB_texture_env_combine) { 1781 *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[2]; 1782 } 1783 else { 1784 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1785 return; 1786 } 1787 break; 1788 case GL_RGB_SCALE_ARB: 1789 if (g->extensions.ARB_texture_env_combine) { 1790 *param = t->unit[t->curTextureUnit].combineScaleRGB; 1791 } 1792 else { 1793 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1794 return; 1795 } 1796 break; 1797 case GL_ALPHA_SCALE: 1798 if (g->extensions.ARB_texture_env_combine) { 1799 *param = t->unit[t->curTextureUnit].combineScaleA; 1800 } 1801 else { 1802 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); 1803 return; 1804 } 1805 break; 1806 default: 1807 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1808 "glGetTexEnvfv: invalid pname: %d", pname); 1809 return; 1810 } 1811 1811 } 1812 1812 … … 1815 1815 crStateGetTexEnviv(GLenum target, GLenum pname, GLint *param) 1816 1816 { 1817 1818 1819 1820 1821 1822 1823 1824 1825 1817 CRContext *g = GetCurrentContext(); 1818 CRTextureState *t = &(g->texture); 1819 1820 if (g->current.inBeginEnd) 1821 { 1822 crStateError(__LINE__, __FILE__,GL_INVALID_OPERATION, 1823 "glGetTexEnviv called in begin/end"); 1824 return; 1825 } 1826 1826 1827 1827 #if CR_EXT_texture_lod_bias 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1828 if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { 1829 if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) { 1830 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv"); 1831 } 1832 else { 1833 *param = (GLint) t->unit[t->curTextureUnit].lodBias; 1834 } 1835 return; 1836 } 1837 else 1838 1838 #endif 1839 1839 #if CR_ARB_point_sprite 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 #endif 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 1840 if (target == GL_POINT_SPRITE_ARB) { 1841 if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) { 1842 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv"); 1843 } 1844 else { 1845 *param = (GLint) g->point.coordReplacement[t->curTextureUnit]; 1846 } 1847 return; 1848 } 1849 else 1850 #endif 1851 if (target != GL_TEXTURE_ENV) 1852 { 1853 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 1854 "glGetTexEnviv: target != GL_TEXTURE_ENV: %d", target); 1855 return; 1856 } 1857 1858 switch (pname) { 1859 case GL_TEXTURE_ENV_MODE: 1860 *param = (GLint) t->unit[t->curTextureUnit].envMode; 1861 break; 1862 case GL_TEXTURE_ENV_COLOR: 1863 param[0] = (GLint) (t->unit[t->curTextureUnit].envColor.r * CR_MAXINT); 1864 param[1] = (GLint) (t->unit[t->curTextureUnit].envColor.g * CR_MAXINT); 1865 param[2] = (GLint) (t->unit[t->curTextureUnit].envColor.b * CR_MAXINT); 1866 param[3] = (GLint) (t->unit[t->curTextureUnit].envColor.a * CR_MAXINT); 1867 break; 1868 case GL_COMBINE_RGB_ARB: 1869 if (g->extensions.ARB_texture_env_combine) { 1870 *param = (GLint) t->unit[t->curTextureUnit].combineModeRGB; 1871 } 1872 else { 1873 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1874 return; 1875 } 1876 break; 1877 case GL_COMBINE_ALPHA_ARB: 1878 if (g->extensions.ARB_texture_env_combine) { 1879 *param = (GLint) t->unit[t->curTextureUnit].combineModeA; 1880 } 1881 else { 1882 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1883 return; 1884 } 1885 break; 1886 case GL_SOURCE0_RGB_ARB: 1887 if (g->extensions.ARB_texture_env_combine) { 1888 *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[0]; 1889 } 1890 else { 1891 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1892 return; 1893 } 1894 break; 1895 case GL_SOURCE1_RGB_ARB: 1896 if (g->extensions.ARB_texture_env_combine) { 1897 *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[1]; 1898 } 1899 else { 1900 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1901 return; 1902 } 1903 break; 1904 case GL_SOURCE2_RGB_ARB: 1905 if (g->extensions.ARB_texture_env_combine) { 1906 *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[2]; 1907 } 1908 else { 1909 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1910 return; 1911 } 1912 break; 1913 case GL_SOURCE0_ALPHA_ARB: 1914 if (g->extensions.ARB_texture_env_combine) { 1915 *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[0]; 1916 } 1917 else { 1918 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1919 return; 1920 } 1921 break; 1922 case GL_SOURCE1_ALPHA_ARB: 1923 if (g->extensions.ARB_texture_env_combine) { 1924 *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[1]; 1925 } 1926 else { 1927 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1928 return; 1929 } 1930 break; 1931 case GL_SOURCE2_ALPHA_ARB: 1932 if (g->extensions.ARB_texture_env_combine) { 1933 *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[2]; 1934 } 1935 else { 1936 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1937 return; 1938 } 1939 break; 1940 case GL_OPERAND0_RGB_ARB: 1941 if (g->extensions.ARB_texture_env_combine) { 1942 *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[0]; 1943 } 1944 else { 1945 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1946 return; 1947 } 1948 break; 1949 case GL_OPERAND1_RGB_ARB: 1950 if (g->extensions.ARB_texture_env_combine) { 1951 *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[1]; 1952 } 1953 else { 1954 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1955 return; 1956 } 1957 break; 1958 case GL_OPERAND2_RGB_ARB: 1959 if (g->extensions.ARB_texture_env_combine) { 1960 *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[2]; 1961 } 1962 else { 1963 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1964 return; 1965 } 1966 break; 1967 case GL_OPERAND0_ALPHA_ARB: 1968 if (g->extensions.ARB_texture_env_combine) { 1969 *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[0]; 1970 } 1971 else { 1972 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1973 return; 1974 } 1975 break; 1976 case GL_OPERAND1_ALPHA_ARB: 1977 if (g->extensions.ARB_texture_env_combine) { 1978 *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[1]; 1979 } 1980 else { 1981 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1982 return; 1983 } 1984 break; 1985 case GL_OPERAND2_ALPHA_ARB: 1986 if (g->extensions.ARB_texture_env_combine) { 1987 *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[2]; 1988 } 1989 else { 1990 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 1991 return; 1992 } 1993 break; 1994 case GL_RGB_SCALE_ARB: 1995 if (g->extensions.ARB_texture_env_combine) { 1996 *param = (GLint) t->unit[t->curTextureUnit].combineScaleRGB; 1997 } 1998 else { 1999 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 2000 return; 2001 } 2002 break; 2003 case GL_ALPHA_SCALE: 2004 if (g->extensions.ARB_texture_env_combine) { 2005 *param = (GLint) t->unit[t->curTextureUnit].combineScaleA; 2006 } 2007 else { 2008 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); 2009 return; 2010 } 2011 break; 2012 default: 2013 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2014 "glGetTexEnviv: invalid pname: %d", pname); 2015 return; 2016 } 2017 2017 } 2018 2018 … … 2021 2021 crStateTexGendv(GLenum coord, GLenum pname, const GLdouble *param) 2022 2022 { 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2023 CRContext *g = GetCurrentContext(); 2024 CRTextureState *t = &(g->texture); 2025 CRTransformState *trans = &(g->transform); 2026 GLvectorf v; 2027 GLenum e; 2028 CRmatrix inv; 2029 CRStateBits *sb = GetCurrentBits(); 2030 CRTextureBits *tb = &(sb->texture); 2031 2032 FLUSH(); 2033 2034 if (g->current.inBeginEnd) 2035 { 2036 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 2037 "glTexGen called in begin/end"); 2038 return; 2039 } 2040 2041 switch (coord) 2042 { 2043 case GL_S: 2044 switch (pname) 2045 { 2046 case GL_TEXTURE_GEN_MODE: 2047 e = (GLenum) *param; 2048 if (e == GL_OBJECT_LINEAR || 2049 e == GL_EYE_LINEAR || 2050 e == GL_SPHERE_MAP 2051 2051 #if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection) 2052 2053 2054 #endif 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2052 || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB) 2053 && g->extensions.ARB_texture_cube_map) 2054 #endif 2055 ) { 2056 t->unit[t->curTextureUnit].gen.s = e; 2057 DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid); 2058 DIRTY(tb->dirty, g->neg_bitid); 2059 } 2060 else { 2061 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2062 "glTexGendv called with bad param: %lf", *param); 2063 return; 2064 } 2065 break; 2066 case GL_OBJECT_PLANE: 2067 v.x = (GLfloat) param[0]; 2068 v.y = (GLfloat) param[1]; 2069 v.z = (GLfloat) param[2]; 2070 v.w = (GLfloat) param[3]; 2071 t->unit[t->curTextureUnit].objSCoeff = v; 2072 DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid); 2073 DIRTY(tb->dirty, g->neg_bitid); 2074 break; 2075 case GL_EYE_PLANE: 2076 v.x = (GLfloat) param[0]; 2077 v.y = (GLfloat) param[1]; 2078 v.z = (GLfloat) param[2]; 2079 v.w = (GLfloat) param[3]; 2080 crMatrixInvertTranspose(&inv, trans->modelViewStack.top); 2081 crStateTransformXformPointMatrixf(&inv, &v); 2082 t->unit[t->curTextureUnit].eyeSCoeff = v; 2083 DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid); 2084 DIRTY(tb->dirty, g->neg_bitid); 2085 break; 2086 default: 2087 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2088 "glTexGendv called with bogus pname: %d", pname); 2089 return; 2090 } 2091 break; 2092 case GL_T: 2093 switch (pname) { 2094 case GL_TEXTURE_GEN_MODE: 2095 e = (GLenum) *param; 2096 if (e == GL_OBJECT_LINEAR || 2097 e == GL_EYE_LINEAR || 2098 e == GL_SPHERE_MAP 2099 2099 #if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection) 2100 2101 2102 #endif 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2100 || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB) 2101 && g->extensions.ARB_texture_cube_map) 2102 #endif 2103 ) { 2104 t->unit[t->curTextureUnit].gen.t = e; 2105 DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid); 2106 DIRTY(tb->dirty, g->neg_bitid); 2107 } 2108 else { 2109 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2110 "glTexGendv called with bad param: %lf", *param); 2111 return; 2112 } 2113 break; 2114 case GL_OBJECT_PLANE: 2115 v.x = (GLfloat) param[0]; 2116 v.y = (GLfloat) param[1]; 2117 v.z = (GLfloat) param[2]; 2118 v.w = (GLfloat) param[3]; 2119 t->unit[t->curTextureUnit].objTCoeff = v; 2120 DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid); 2121 DIRTY(tb->dirty, g->neg_bitid); 2122 break; 2123 case GL_EYE_PLANE: 2124 v.x = (GLfloat) param[0]; 2125 v.y = (GLfloat) param[1]; 2126 v.z = (GLfloat) param[2]; 2127 v.w = (GLfloat) param[3]; 2128 crMatrixInvertTranspose(&inv, trans->modelViewStack.top); 2129 crStateTransformXformPointMatrixf(&inv, &v); 2130 t->unit[t->curTextureUnit].eyeTCoeff = v; 2131 DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid); 2132 DIRTY(tb->dirty, g->neg_bitid); 2133 break; 2134 default: 2135 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2136 "glTexGen called with bogus pname: %d", pname); 2137 return; 2138 } 2139 break; 2140 case GL_R: 2141 switch (pname) { 2142 case GL_TEXTURE_GEN_MODE: 2143 e = (GLenum) *param; 2144 if (e == GL_OBJECT_LINEAR || 2145 e == GL_EYE_LINEAR || 2146 e == GL_SPHERE_MAP 2147 2147 #if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection) 2148 2149 2150 #endif 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2148 || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB) 2149 && g->extensions.ARB_texture_cube_map) 2150 #endif 2151 ) { 2152 t->unit[t->curTextureUnit].gen.r = e; 2153 DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid); 2154 DIRTY(tb->dirty, g->neg_bitid); 2155 } 2156 else { 2157 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2158 "glTexGen called with bad param: %lf", *param); 2159 return; 2160 } 2161 break; 2162 case GL_OBJECT_PLANE: 2163 v.x = (GLfloat) param[0]; 2164 v.y = (GLfloat) param[1]; 2165 v.z = (GLfloat) param[2]; 2166 v.w = (GLfloat) param[3]; 2167 t->unit[t->curTextureUnit].objRCoeff = v; 2168 DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid); 2169 DIRTY(tb->dirty, g->neg_bitid); 2170 break; 2171 case GL_EYE_PLANE: 2172 v.x = (GLfloat) param[0]; 2173 v.y = (GLfloat) param[1]; 2174 v.z = (GLfloat) param[2]; 2175 v.w = (GLfloat) param[3]; 2176 crMatrixInvertTranspose(&inv, trans->modelViewStack.top); 2177 crStateTransformXformPointMatrixf(&inv, &v); 2178 t->unit[t->curTextureUnit].eyeRCoeff = v; 2179 DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid); 2180 DIRTY(tb->dirty, g->neg_bitid); 2181 break; 2182 default: 2183 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2184 "glTexGen called with bogus pname: %d", pname); 2185 return; 2186 } 2187 break; 2188 case GL_Q: 2189 switch (pname) { 2190 case GL_TEXTURE_GEN_MODE: 2191 e = (GLenum) *param; 2192 if (e == GL_OBJECT_LINEAR || 2193 e == GL_EYE_LINEAR || 2194 e == GL_SPHERE_MAP 2195 2195 #if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection) 2196 2197 2198 #endif 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2196 || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB) 2197 && g->extensions.ARB_texture_cube_map) 2198 #endif 2199 ) { 2200 t->unit[t->curTextureUnit].gen.q = e; 2201 DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid); 2202 DIRTY(tb->dirty, g->neg_bitid); 2203 } 2204 else { 2205 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2206 "glTexGen called with bad param: %lf", *param); 2207 return; 2208 } 2209 break; 2210 case GL_OBJECT_PLANE: 2211 v.x = (GLfloat) param[0]; 2212 v.y = (GLfloat) param[1]; 2213 v.z = (GLfloat) param[2]; 2214 v.w = (GLfloat) param[3]; 2215 t->unit[t->curTextureUnit].objQCoeff = v; 2216 DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid); 2217 DIRTY(tb->dirty, g->neg_bitid); 2218 break; 2219 case GL_EYE_PLANE: 2220 v.x = (GLfloat) param[0]; 2221 v.y = (GLfloat) param[1]; 2222 v.z = (GLfloat) param[2]; 2223 v.w = (GLfloat) param[3]; 2224 crMatrixInvertTranspose(&inv, trans->modelViewStack.top); 2225 crStateTransformXformPointMatrixf(&inv, &v); 2226 t->unit[t->curTextureUnit].eyeQCoeff = v; 2227 DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid); 2228 DIRTY(tb->dirty, g->neg_bitid); 2229 break; 2230 default: 2231 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2232 "glTexGen called with bogus pname: %d", pname); 2233 return; 2234 } 2235 break; 2236 default: 2237 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2238 "glTexGen called with bogus coord: %d", coord); 2239 return; 2240 } 2241 2241 } 2242 2242 … … 2245 2245 crStateTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) 2246 2246 { 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2247 GLdouble d_param; 2248 GLvectord d_vector; 2249 switch (pname) 2250 { 2251 case GL_TEXTURE_GEN_MODE: 2252 d_param = (GLdouble) *param; 2253 crStateTexGendv( coord, pname, &d_param ); 2254 break; 2255 case GL_OBJECT_PLANE: 2256 case GL_EYE_PLANE: 2257 d_vector.x = (GLdouble) param[0]; 2258 d_vector.y = (GLdouble) param[1]; 2259 d_vector.z = (GLdouble) param[2]; 2260 d_vector.w = (GLdouble) param[3]; 2261 crStateTexGendv( coord, pname, (const double *) &d_vector ); 2262 break; 2263 default: 2264 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2265 "glTexGen called with bogus pname: %d", pname); 2266 return; 2267 } 2268 2268 } 2269 2269 … … 2272 2272 crStateTexGeniv(GLenum coord, GLenum pname, const GLint *param) 2273 2273 { 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2274 GLdouble d_param; 2275 GLvectord d_vector; 2276 switch (pname) 2277 { 2278 case GL_TEXTURE_GEN_MODE: 2279 d_param = (GLdouble) *param; 2280 crStateTexGendv( coord, pname, &d_param ); 2281 break; 2282 case GL_OBJECT_PLANE: 2283 case GL_EYE_PLANE: 2284 d_vector.x = (GLdouble) param[0]; 2285 d_vector.y = (GLdouble) param[1]; 2286 d_vector.z = (GLdouble) param[2]; 2287 d_vector.w = (GLdouble) param[3]; 2288 crStateTexGendv( coord, pname, (const double *) &d_vector ); 2289 break; 2290 default: 2291 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2292 "glTexGen called with bogus pname: %d", pname); 2293 return; 2294 } 2295 2295 } 2296 2296 … … 2299 2299 crStateTexGend (GLenum coord, GLenum pname, GLdouble param) 2300 2300 { 2301 2301 crStateTexGendv( coord, pname, ¶m ); 2302 2302 } 2303 2303 … … 2306 2306 crStateTexGenf(GLenum coord, GLenum pname, GLfloat param) 2307 2307 { 2308 2309 2308 GLdouble d_param = (GLdouble) param; 2309 crStateTexGendv( coord, pname, &d_param ); 2310 2310 } 2311 2311 … … 2314 2314 crStateTexGeni(GLenum coord, GLenum pname, GLint param) 2315 2315 { 2316 2317 2316 GLdouble d_param = (GLdouble) param; 2317 crStateTexGendv( coord, pname, &d_param ); 2318 2318 } 2319 2319 … … 2322 2322 crStateGetTexGendv(GLenum coord, GLenum pname, GLdouble *param) 2323 2323 { 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2324 CRContext *g = GetCurrentContext(); 2325 CRTextureState *t = &(g->texture); 2326 2327 if (g->current.inBeginEnd) 2328 { 2329 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 2330 "glGetTexGen called in begin/end"); 2331 return; 2332 } 2333 2334 switch (pname) { 2335 case GL_TEXTURE_GEN_MODE: 2336 switch (coord) { 2337 case GL_S: 2338 *param = (GLdouble) t->unit[t->curTextureUnit].gen.s; 2339 break; 2340 case GL_T: 2341 *param = (GLdouble) t->unit[t->curTextureUnit].gen.t; 2342 break; 2343 case GL_R: 2344 *param = (GLdouble) t->unit[t->curTextureUnit].gen.r; 2345 break; 2346 case GL_Q: 2347 *param = (GLdouble) t->unit[t->curTextureUnit].gen.q; 2348 break; 2349 default: 2350 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2351 "glGetTexGen called with bogus coord: %d", coord); 2352 return; 2353 } 2354 break; 2355 case GL_OBJECT_PLANE: 2356 switch (coord) { 2357 case GL_S: 2358 param[0] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.x; 2359 param[1] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.y; 2360 param[2] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.z; 2361 param[3] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.w; 2362 break; 2363 case GL_T: 2364 param[0] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.x; 2365 param[1] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.y; 2366 param[2] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.z; 2367 param[3] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.w; 2368 break; 2369 case GL_R: 2370 param[0] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.x; 2371 param[1] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.y; 2372 param[2] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.z; 2373 param[3] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.w; 2374 break; 2375 case GL_Q: 2376 param[0] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.x; 2377 param[1] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.y; 2378 param[2] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.z; 2379 param[3] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.w; 2380 break; 2381 default: 2382 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2383 "glGetTexGen called with bogus coord: %d", coord); 2384 return; 2385 } 2386 break; 2387 case GL_EYE_PLANE: 2388 switch (coord) { 2389 case GL_S: 2390 param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.x; 2391 param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.y; 2392 param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.z; 2393 param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.w; 2394 break; 2395 case GL_T: 2396 param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.x; 2397 param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.y; 2398 param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.z; 2399 param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.w; 2400 break; 2401 case GL_R: 2402 param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.x; 2403 param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.y; 2404 param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.z; 2405 param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.w; 2406 break; 2407 case GL_Q: 2408 param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.x; 2409 param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.y; 2410 param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.z; 2411 param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.w; 2412 break; 2413 default: 2414 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2415 "glGetTexGen called with bogus coord: %d", coord); 2416 return; 2417 } 2418 break; 2419 default: 2420 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2421 "glGetTexGen called with bogus pname: %d", pname); 2422 return; 2423 } 2424 2424 } 2425 2425 … … 2428 2428 crStateGetTexGenfv(GLenum coord, GLenum pname, GLfloat *param) 2429 2429 { 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2430 CRContext *g = GetCurrentContext(); 2431 CRTextureState *t = &(g->texture); 2432 2433 if (g->current.inBeginEnd) 2434 { 2435 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 2436 "glGetTexGenfv called in begin/end"); 2437 return; 2438 } 2439 2440 switch (pname) { 2441 case GL_TEXTURE_GEN_MODE: 2442 switch (coord) { 2443 case GL_S: 2444 *param = (GLfloat) t->unit[t->curTextureUnit].gen.s; 2445 break; 2446 case GL_T: 2447 *param = (GLfloat) t->unit[t->curTextureUnit].gen.t; 2448 break; 2449 case GL_R: 2450 *param = (GLfloat) t->unit[t->curTextureUnit].gen.r; 2451 break; 2452 case GL_Q: 2453 *param = (GLfloat) t->unit[t->curTextureUnit].gen.q; 2454 break; 2455 default: 2456 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2457 "glGetTexGenfv called with bogus coord: %d", coord); 2458 return; 2459 } 2460 break; 2461 case GL_OBJECT_PLANE: 2462 switch (coord) { 2463 case GL_S: 2464 param[0] = t->unit[t->curTextureUnit].objSCoeff.x; 2465 param[1] = t->unit[t->curTextureUnit].objSCoeff.y; 2466 param[2] = t->unit[t->curTextureUnit].objSCoeff.z; 2467 param[3] = t->unit[t->curTextureUnit].objSCoeff.w; 2468 break; 2469 case GL_T: 2470 param[0] = t->unit[t->curTextureUnit].objTCoeff.x; 2471 param[1] = t->unit[t->curTextureUnit].objTCoeff.y; 2472 param[2] = t->unit[t->curTextureUnit].objTCoeff.z; 2473 param[3] = t->unit[t->curTextureUnit].objTCoeff.w; 2474 break; 2475 case GL_R: 2476 param[0] = t->unit[t->curTextureUnit].objRCoeff.x; 2477 param[1] = t->unit[t->curTextureUnit].objRCoeff.y; 2478 param[2] = t->unit[t->curTextureUnit].objRCoeff.z; 2479 param[3] = t->unit[t->curTextureUnit].objRCoeff.w; 2480 break; 2481 case GL_Q: 2482 param[0] = t->unit[t->curTextureUnit].objQCoeff.x; 2483 param[1] = t->unit[t->curTextureUnit].objQCoeff.y; 2484 param[2] = t->unit[t->curTextureUnit].objQCoeff.z; 2485 param[3] = t->unit[t->curTextureUnit].objQCoeff.w; 2486 break; 2487 default: 2488 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2489 "glGetTexGenfv called with bogus coord: %d", coord); 2490 return; 2491 } 2492 break; 2493 case GL_EYE_PLANE: 2494 switch (coord) { 2495 case GL_S: 2496 param[0] = t->unit[t->curTextureUnit].eyeSCoeff.x; 2497 param[1] = t->unit[t->curTextureUnit].eyeSCoeff.y; 2498 param[2] = t->unit[t->curTextureUnit].eyeSCoeff.z; 2499 param[3] = t->unit[t->curTextureUnit].eyeSCoeff.w; 2500 break; 2501 case GL_T: 2502 param[0] = t->unit[t->curTextureUnit].eyeTCoeff.x; 2503 param[1] = t->unit[t->curTextureUnit].eyeTCoeff.y; 2504 param[2] = t->unit[t->curTextureUnit].eyeTCoeff.z; 2505 param[3] = t->unit[t->curTextureUnit].eyeTCoeff.w; 2506 break; 2507 case GL_R: 2508 param[0] = t->unit[t->curTextureUnit].eyeRCoeff.x; 2509 param[1] = t->unit[t->curTextureUnit].eyeRCoeff.y; 2510 param[2] = t->unit[t->curTextureUnit].eyeRCoeff.z; 2511 param[3] = t->unit[t->curTextureUnit].eyeRCoeff.w; 2512 break; 2513 case GL_Q: 2514 param[0] = t->unit[t->curTextureUnit].eyeQCoeff.x; 2515 param[1] = t->unit[t->curTextureUnit].eyeQCoeff.y; 2516 param[2] = t->unit[t->curTextureUnit].eyeQCoeff.z; 2517 param[3] = t->unit[t->curTextureUnit].eyeQCoeff.w; 2518 break; 2519 default: 2520 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2521 "glGetTexGenfv called with bogus coord: %d", coord); 2522 return; 2523 } 2524 break; 2525 default: 2526 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2527 "glGetTexGenfv called with bogus pname: %d", pname); 2528 return; 2529 } 2530 2530 } 2531 2531 … … 2534 2534 crStateGetTexGeniv(GLenum coord, GLenum pname, GLint *param) 2535 2535 { 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2536 CRContext *g = GetCurrentContext(); 2537 CRTextureState *t = &(g->texture); 2538 2539 if (g->current.inBeginEnd) 2540 { 2541 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 2542 "glGetTexGeniv called in begin/end"); 2543 return; 2544 } 2545 2546 switch (pname) { 2547 case GL_TEXTURE_GEN_MODE: 2548 switch (coord) { 2549 case GL_S: 2550 *param = (GLint) t->unit[t->curTextureUnit].gen.s; 2551 break; 2552 case GL_T: 2553 *param = (GLint) t->unit[t->curTextureUnit].gen.t; 2554 break; 2555 case GL_R: 2556 *param = (GLint) t->unit[t->curTextureUnit].gen.r; 2557 break; 2558 case GL_Q: 2559 *param = (GLint) t->unit[t->curTextureUnit].gen.q; 2560 break; 2561 default: 2562 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2563 "glGetTexGeniv called with bogus coord: %d", coord); 2564 return; 2565 } 2566 break; 2567 case GL_OBJECT_PLANE: 2568 switch (coord) { 2569 case GL_S: 2570 param[0] = (GLint) t->unit[t->curTextureUnit].objSCoeff.x; 2571 param[1] = (GLint) t->unit[t->curTextureUnit].objSCoeff.y; 2572 param[2] = (GLint) t->unit[t->curTextureUnit].objSCoeff.z; 2573 param[3] = (GLint) t->unit[t->curTextureUnit].objSCoeff.w; 2574 break; 2575 case GL_T: 2576 param[0] = (GLint) t->unit[t->curTextureUnit].objTCoeff.x; 2577 param[1] = (GLint) t->unit[t->curTextureUnit].objTCoeff.y; 2578 param[2] = (GLint) t->unit[t->curTextureUnit].objTCoeff.z; 2579 param[3] = (GLint) t->unit[t->curTextureUnit].objTCoeff.w; 2580 break; 2581 case GL_R: 2582 param[0] = (GLint) t->unit[t->curTextureUnit].objRCoeff.x; 2583 param[1] = (GLint) t->unit[t->curTextureUnit].objRCoeff.y; 2584 param[2] = (GLint) t->unit[t->curTextureUnit].objRCoeff.z; 2585 param[3] = (GLint) t->unit[t->curTextureUnit].objRCoeff.w; 2586 break; 2587 case GL_Q: 2588 param[0] = (GLint) t->unit[t->curTextureUnit].objQCoeff.x; 2589 param[1] = (GLint) t->unit[t->curTextureUnit].objQCoeff.y; 2590 param[2] = (GLint) t->unit[t->curTextureUnit].objQCoeff.z; 2591 param[3] = (GLint) t->unit[t->curTextureUnit].objQCoeff.w; 2592 break; 2593 default: 2594 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2595 "glGetTexGeniv called with bogus coord: %d", coord); 2596 return; 2597 } 2598 break; 2599 case GL_EYE_PLANE: 2600 switch (coord) { 2601 case GL_S: 2602 param[0] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.x; 2603 param[1] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.y; 2604 param[2] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.z; 2605 param[3] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.w; 2606 break; 2607 case GL_T: 2608 param[0] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.x; 2609 param[1] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.y; 2610 param[2] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.z; 2611 param[3] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.w; 2612 break; 2613 case GL_R: 2614 param[0] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.x; 2615 param[1] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.y; 2616 param[2] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.z; 2617 param[3] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.w; 2618 break; 2619 case GL_Q: 2620 param[0] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.x; 2621 param[1] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.y; 2622 param[2] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.z; 2623 param[3] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.w; 2624 break; 2625 default: 2626 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2627 "glGetTexGeniv called with bogus coord: %d", coord); 2628 return; 2629 } 2630 break; 2631 default: 2632 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2633 "glGetTexGen called with bogus pname: %d", pname); 2634 return; 2635 } 2636 2636 } 2637 2637 … … 2639 2639 void STATE_APIENTRY 2640 2640 crStateGetTexLevelParameterfv(GLenum target, GLint level, 2641 2642 { 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2641 GLenum pname, GLfloat *params) 2642 { 2643 CRContext *g = GetCurrentContext(); 2644 CRTextureState *t = &(g->texture); 2645 CRTextureObj *tobj; 2646 CRTextureLevel *timg; 2647 2648 if (g->current.inBeginEnd) 2649 { 2650 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 2651 "glGetTexLevelParameterfv called in begin/end"); 2652 return; 2653 } 2654 2655 if (level < 0 && level > t->maxLevel) 2656 { 2657 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 2658 "glGetTexLevelParameterfv: Invalid level: %d", level); 2659 return; 2660 } 2661 2662 crStateGetTextureObjectAndImage(g, target, level, &tobj, &timg); 2663 if (!timg) 2664 { 2665 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2666 "GetTexLevelParameterfv: invalid target: 0x%x or level %d", 2667 target, level); 2668 return; 2669 } 2670 2671 switch (pname) 2672 { 2673 case GL_TEXTURE_WIDTH: 2674 *params = (GLfloat) timg->width; 2675 break; 2676 case GL_TEXTURE_HEIGHT: 2677 *params = (GLfloat) timg->height; 2678 break; 2679 2679 #ifdef CR_OPENGL_VERSION_1_2 2680 2681 2682 2683 #endif 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2680 case GL_TEXTURE_DEPTH: 2681 *params = (GLfloat) timg->depth; 2682 break; 2683 #endif 2684 case GL_TEXTURE_INTERNAL_FORMAT: 2685 *params = (GLfloat) timg->internalFormat; 2686 break; 2687 case GL_TEXTURE_BORDER: 2688 *params = (GLfloat) timg->border; 2689 break; 2690 case GL_TEXTURE_RED_SIZE: 2691 *params = (GLfloat) timg->texFormat->redbits; 2692 break; 2693 case GL_TEXTURE_GREEN_SIZE: 2694 *params = (GLfloat) timg->texFormat->greenbits; 2695 break; 2696 case GL_TEXTURE_BLUE_SIZE: 2697 *params = (GLfloat) timg->texFormat->bluebits; 2698 break; 2699 case GL_TEXTURE_ALPHA_SIZE: 2700 *params = (GLfloat) timg->texFormat->alphabits; 2701 break; 2702 case GL_TEXTURE_INTENSITY_SIZE: 2703 *params = (GLfloat) timg->texFormat->intensitybits; 2704 break; 2705 case GL_TEXTURE_LUMINANCE_SIZE: 2706 *params = (GLfloat) timg->texFormat->luminancebits; 2707 break; 2708 2708 #if CR_ARB_texture_compression 2709 2710 2711 2712 2713 2714 2715 #endif 2716 2717 2718 2719 2720 2721 2709 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB: 2710 *params = (GLfloat) timg->bytes; 2711 break; 2712 case GL_TEXTURE_COMPRESSED_ARB: 2713 *params = (GLfloat) timg->compressed; 2714 break; 2715 #endif 2716 default: 2717 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2718 "GetTexLevelParameterfv: invalid pname: 0x%x", 2719 pname); 2720 return; 2721 } 2722 2722 } 2723 2723 … … 2725 2725 void STATE_APIENTRY 2726 2726 crStateGetTexLevelParameteriv(GLenum target, GLint level, 2727 2728 { 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2727 GLenum pname, GLint *params) 2728 { 2729 CRContext *g = GetCurrentContext(); 2730 CRTextureState *t = &(g->texture); 2731 CRTextureObj *tobj; 2732 CRTextureLevel *timg; 2733 2734 if (g->current.inBeginEnd) 2735 { 2736 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 2737 "glGetTexLevelParameteriv called in begin/end"); 2738 return; 2739 } 2740 2741 if (level < 0 && level > t->maxLevel) 2742 { 2743 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 2744 "glGetTexLevelParameteriv: Invalid level: %d", level); 2745 return; 2746 } 2747 2748 crStateGetTextureObjectAndImage(g, target, level, &tobj, &timg); 2749 if (!timg) 2750 { 2751 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2752 "GetTexLevelParameteriv: invalid target: 0x%x", 2753 target); 2754 return; 2755 } 2756 2757 switch (pname) 2758 { 2759 case GL_TEXTURE_WIDTH: 2760 *params = (GLint) timg->width; 2761 break; 2762 case GL_TEXTURE_HEIGHT: 2763 *params = (GLint) timg->height; 2764 break; 2765 2765 #ifdef CR_OPENGL_VERSION_1_2 2766 2767 2768 2769 #endif 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2766 case GL_TEXTURE_DEPTH: 2767 *params = (GLint) timg->depth; 2768 break; 2769 #endif 2770 case GL_TEXTURE_INTERNAL_FORMAT: 2771 *params = (GLint) timg->internalFormat; 2772 break; 2773 case GL_TEXTURE_BORDER: 2774 *params = (GLint) timg->border; 2775 break; 2776 case GL_TEXTURE_RED_SIZE: 2777 *params = (GLint) timg->texFormat->redbits; 2778 break; 2779 case GL_TEXTURE_GREEN_SIZE: 2780 *params = (GLint) timg->texFormat->greenbits; 2781 break; 2782 case GL_TEXTURE_BLUE_SIZE: 2783 *params = (GLint) timg->texFormat->bluebits; 2784 break; 2785 case GL_TEXTURE_ALPHA_SIZE: 2786 *params = (GLint) timg->texFormat->alphabits; 2787 break; 2788 case GL_TEXTURE_INTENSITY_SIZE: 2789 *params = (GLint) timg->texFormat->intensitybits; 2790 break; 2791 case GL_TEXTURE_LUMINANCE_SIZE: 2792 *params = (GLint) timg->texFormat->luminancebits; 2793 break; 2794 2794 2795 2795 #if 0 2796 2797 2798 2799 2796 /* XXX TODO */ 2797 case GL_TEXTURE_DEPTH_SIZE: 2798 *params = (GLint) timg->texFormat->depthSize; 2799 break; 2800 2800 #endif 2801 2801 #if CR_ARB_texture_compression 2802 2803 2804 2805 2806 2807 2808 #endif 2809 2810 2811 2812 2813 2814 2802 case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB: 2803 *params = (GLint) timg->bytes; 2804 break; 2805 case GL_TEXTURE_COMPRESSED_ARB: 2806 *params = (GLint) timg->compressed; 2807 break; 2808 #endif 2809 default: 2810 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2811 "GetTexLevelParameteriv: invalid pname: 0x%x", 2812 pname); 2813 return; 2814 } 2815 2815 } 2816 2816 … … 2819 2819 crStateGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) 2820 2820 { 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2821 CRContext *g = GetCurrentContext(); 2822 CRTextureObj *tobj; 2823 CRTextureLevel *tl; 2824 2825 if (g->current.inBeginEnd) 2826 { 2827 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 2828 "glGetTexParameterfv called in begin/end"); 2829 return; 2830 } 2831 2832 crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl); 2833 if (!tobj) 2834 { 2835 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2836 "glGetTexParameterfv: invalid target: 0x%x", target); 2837 return; 2838 } 2839 2840 switch (pname) 2841 { 2842 case GL_TEXTURE_MAG_FILTER: 2843 *params = (GLfloat) tobj->magFilter; 2844 break; 2845 case GL_TEXTURE_MIN_FILTER: 2846 *params = (GLfloat) tobj->minFilter; 2847 break; 2848 case GL_TEXTURE_WRAP_S: 2849 *params = (GLfloat) tobj->wrapS; 2850 break; 2851 case GL_TEXTURE_WRAP_T: 2852 *params = (GLfloat) tobj->wrapT; 2853 break; 2854 2854 #ifdef CR_OPENGL_VERSION_1_2 2855 2856 2857 2858 2859 2860 2861 #endif 2862 2863 2864 2865 2866 2867 2855 case GL_TEXTURE_WRAP_R: 2856 *params = (GLfloat) tobj->wrapR; 2857 break; 2858 case GL_TEXTURE_PRIORITY: 2859 *params = (GLfloat) tobj->priority; 2860 break; 2861 #endif 2862 case GL_TEXTURE_BORDER_COLOR: 2863 params[0] = tobj->borderColor.r; 2864 params[1] = tobj->borderColor.g; 2865 params[2] = tobj->borderColor.b; 2866 params[3] = tobj->borderColor.a; 2867 break; 2868 2868 #ifdef CR_EXT_texture_filter_anisotropic 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2869 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 2870 if (g->extensions.EXT_texture_filter_anisotropic) { 2871 *params = (GLfloat) tobj->maxAnisotropy; 2872 } 2873 else { 2874 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2875 "glGetTexParameterfv: invalid pname: 0x%x", pname); 2876 return; 2877 } 2878 break; 2879 2879 #endif 2880 2880 #ifdef CR_ARB_depth_texture 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2881 case GL_DEPTH_TEXTURE_MODE_ARB: 2882 if (g->extensions.ARB_depth_texture) { 2883 *params = (GLfloat) tobj->depthMode; 2884 } 2885 else { 2886 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2887 "glGetTexParameter: invalid pname: 0x%x", pname); 2888 return; 2889 } 2890 break; 2891 2891 #endif 2892 2892 #ifdef CR_ARB_shadow 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2893 case GL_TEXTURE_COMPARE_MODE_ARB: 2894 if (g->extensions.ARB_shadow) { 2895 *params = (GLfloat) tobj->compareMode; 2896 } 2897 else { 2898 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2899 "glGetTexParameter: invalid pname: 0x%x", pname); 2900 return; 2901 } 2902 break; 2903 case GL_TEXTURE_COMPARE_FUNC_ARB: 2904 if (g->extensions.ARB_shadow) { 2905 *params = (GLfloat) tobj->compareFunc; 2906 } 2907 else { 2908 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2909 "glGetTexParameter: invalid pname: 0x%x", pname); 2910 return; 2911 } 2912 break; 2913 2913 #endif 2914 2914 #ifdef CR_ARB_shadow_ambient 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2915 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: 2916 if (g->extensions.ARB_shadow_ambient) { 2917 *params = (GLfloat) tobj->compareFailValue; 2918 } 2919 else { 2920 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2921 "glGetTexParameter: invalid pname: 0x%x", pname); 2922 return; 2923 } 2924 break; 2925 2925 #endif 2926 2926 #ifdef CR_SGIS_generate_mipmap 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2927 case GL_GENERATE_MIPMAP_SGIS: 2928 if (g->extensions.SGIS_generate_mipmap) { 2929 *params = (GLfloat) tobj->generateMipmap; 2930 } 2931 else { 2932 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2933 "glGetTexParameter: invalid pname: 0x%x", pname); 2934 return; 2935 } 2936 break; 2937 2937 #endif 2938 2938 #ifdef CR_OPENGL_VERSION_1_2 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2939 case GL_TEXTURE_MIN_LOD: 2940 *params = (GLfloat) tobj->minLod; 2941 break; 2942 case GL_TEXTURE_MAX_LOD: 2943 *params = (GLfloat) tobj->maxLod; 2944 break; 2945 case GL_TEXTURE_BASE_LEVEL: 2946 *params = (GLfloat) tobj->baseLevel; 2947 break; 2948 case GL_TEXTURE_MAX_LEVEL: 2949 *params = (GLfloat) tobj->maxLevel; 2950 break; 2951 2951 #endif 2952 2952 #if 0 2953 2954 2955 2956 2957 #endif 2958 2959 2960 2961 2962 2963 2964 2965 2966 2953 case GL_TEXTURE_LOD_BIAS_EXT: 2954 /* XXX todo */ 2955 *params = (GLfloat) tobj->lodBias; 2956 break; 2957 #endif 2958 case GL_TEXTURE_RESIDENT: 2959 /* XXX todo */ 2960 crWarning("glGetTexParameterfv GL_TEXTURE_RESIDENT is unimplemented"); 2961 break; 2962 default: 2963 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2964 "glGetTexParameterfv: invalid pname: %d", pname); 2965 return; 2966 } 2967 2967 } 2968 2968 … … 2971 2971 crStateGetTexParameteriv(GLenum target, GLenum pname, GLint *params) 2972 2972 { 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 2973 CRContext *g = GetCurrentContext(); 2974 CRTextureObj *tobj; 2975 CRTextureLevel *tl; 2976 2977 if (g->current.inBeginEnd) 2978 { 2979 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 2980 "glGetTexParameter called in begin/end"); 2981 return; 2982 } 2983 2984 crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl); 2985 if (!tobj) 2986 { 2987 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 2988 "glGetTexParameteriv: invalid target: 0x%x", target); 2989 return; 2990 } 2991 2992 switch (pname) 2993 { 2994 case GL_TEXTURE_MAG_FILTER: 2995 *params = (GLint) tobj->magFilter; 2996 break; 2997 case GL_TEXTURE_MIN_FILTER: 2998 *params = (GLint) tobj->minFilter; 2999 break; 3000 case GL_TEXTURE_WRAP_S: 3001 *params = (GLint) tobj->wrapS; 3002 break; 3003 case GL_TEXTURE_WRAP_T: 3004 *params = (GLint) tobj->wrapT; 3005 break; 3006 3006 #ifdef CR_OPENGL_VERSION_1_2 3007 3008 3009 3010 3011 3012 3013 #endif 3014 3015 3016 3017 3018 3019 3007 case GL_TEXTURE_WRAP_R: 3008 *params = (GLint) tobj->wrapR; 3009 break; 3010 case GL_TEXTURE_PRIORITY: 3011 *params = (GLint) tobj->priority; 3012 break; 3013 #endif 3014 case GL_TEXTURE_BORDER_COLOR: 3015 params[0] = (GLint) (tobj->borderColor.r * CR_MAXINT); 3016 params[1] = (GLint) (tobj->borderColor.g * CR_MAXINT); 3017 params[2] = (GLint) (tobj->borderColor.b * CR_MAXINT); 3018 params[3] = (GLint) (tobj->borderColor.a * CR_MAXINT); 3019 break; 3020 3020 #ifdef CR_OPENGL_VERSION_1_2 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3021 case GL_TEXTURE_MIN_LOD: 3022 *params = (GLint) tobj->minLod; 3023 break; 3024 case GL_TEXTURE_MAX_LOD: 3025 *params = (GLint) tobj->maxLod; 3026 break; 3027 case GL_TEXTURE_BASE_LEVEL: 3028 *params = (GLint) tobj->baseLevel; 3029 break; 3030 case GL_TEXTURE_MAX_LEVEL: 3031 *params = (GLint) tobj->maxLevel; 3032 break; 3033 3033 #endif 3034 3034 #ifdef CR_EXT_texture_filter_anisotropic 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3035 case GL_TEXTURE_MAX_ANISOTROPY_EXT: 3036 if (g->extensions.EXT_texture_filter_anisotropic) { 3037 *params = (GLint) tobj->maxAnisotropy; 3038 } 3039 else { 3040 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 3041 "glGetTexParameter: invalid pname: 0x%x", pname); 3042 return; 3043 } 3044 break; 3045 3045 #endif 3046 3046 #ifdef CR_ARB_depth_texture 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3047 case GL_DEPTH_TEXTURE_MODE_ARB: 3048 if (g->extensions.ARB_depth_texture) { 3049 *params = (GLint) tobj->depthMode; 3050 } 3051 else { 3052 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 3053 "glGetTexParameter: invalid pname: 0x%x", pname); 3054 return; 3055 } 3056 break; 3057 3057 #endif 3058 3058 #ifdef CR_ARB_shadow 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3059 case GL_TEXTURE_COMPARE_MODE_ARB: 3060 if (g->extensions.ARB_shadow) { 3061 *params = (GLint) tobj->compareMode; 3062 } 3063 else { 3064 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 3065 "glGetTexParameter: invalid pname: 0x%x", pname); 3066 return; 3067 } 3068 break; 3069 case GL_TEXTURE_COMPARE_FUNC_ARB: 3070 if (g->extensions.ARB_shadow) { 3071 *params = (GLint) tobj->compareFunc; 3072 } 3073 else { 3074 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 3075 "glGetTexParameter: invalid pname: 0x%x", pname); 3076 return; 3077 } 3078 break; 3079 3079 #endif 3080 3080 #ifdef CR_ARB_shadow_ambient 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3081 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: 3082 if (g->extensions.ARB_shadow_ambient) { 3083 *params = (GLint) tobj->compareFailValue; 3084 } 3085 else { 3086 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 3087 "glGetTexParameter: invalid pname: 0x%x", pname); 3088 return; 3089 } 3090 break; 3091 3091 #endif 3092 3092 #ifdef CR_SGIS_generate_mipmap 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 #endif 3104 3105 3106 3107 3108 3109 3110 3111 3112 3093 case GL_GENERATE_MIPMAP_SGIS: 3094 if (g->extensions.SGIS_generate_mipmap) { 3095 *params = (GLint) tobj->generateMipmap; 3096 } 3097 else { 3098 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 3099 "glGetTexParameter: invalid pname: 0x%x", pname); 3100 return; 3101 } 3102 break; 3103 #endif 3104 case GL_TEXTURE_RESIDENT: 3105 /* XXX todo */ 3106 crWarning("glGetTexParameteriv GL_TEXTURE_RESIDENT is unimplemented"); 3107 break; 3108 default: 3109 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 3110 "glGetTexParameter: invalid pname: %d", pname); 3111 return; 3112 } 3113 3113 } 3114 3114 … … 3116 3116 void STATE_APIENTRY 3117 3117 crStatePrioritizeTextures(GLsizei n, const GLuint *textures, 3118 3119 { 3120 3121 3122 3123 3124 3118 const GLclampf *priorities) 3119 { 3120 UNUSED(n); 3121 UNUSED(textures); 3122 UNUSED(priorities); 3123 /* TODO: */ 3124 return; 3125 3125 } 3126 3126 … … 3128 3128 GLboolean STATE_APIENTRY 3129 3129 crStateAreTexturesResident(GLsizei n, const GLuint *textures, 3130 3131 { 3132 3133 3134 3135 3136 3130 GLboolean *residences) 3131 { 3132 UNUSED(n); 3133 UNUSED(textures); 3134 UNUSED(residences); 3135 /* TODO: */ 3136 return GL_TRUE; 3137 3137 } 3138 3138 … … 3141 3141 crStateIsTexture(GLuint texture) 3142 3142 { 3143 3144 3145 3146 3147 3148 } 3143 CRContext *g = GetCurrentContext(); 3144 CRTextureObj *tobj; 3145 3146 GET_TOBJ(tobj, g, texture); 3147 return tobj != NULL; 3148 }
Note:
See TracChangeset
for help on using the changeset viewer.