Changeset 22154 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker
- Timestamp:
- Aug 11, 2009 10:33:21 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 50928
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.c
r15532 r22154 12 12 void crStateBufferInit (CRContext *ctx) 13 13 { 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 14 CRBufferState *b = &ctx->buffer; 15 CRStateBits *sb = GetCurrentBits(); 16 CRBufferBits *bb = &(sb->buffer); 17 GLcolorf zero_colorf = {0.0f, 0.0f, 0.0f, 0.0f}; 18 19 b->depthTest = GL_FALSE; 20 b->blend = GL_FALSE; 21 b->alphaTest = GL_FALSE; 22 b->dither = GL_TRUE; 23 RESET(bb->enable, ctx->bitid); 24 25 b->logicOp = GL_FALSE; 26 RESET(bb->logicOp, ctx->bitid); 27 b->indexLogicOp = GL_FALSE; 28 RESET(bb->indexLogicOp, ctx->bitid); 29 b->depthMask = GL_TRUE; 30 RESET(bb->depthMask, ctx->bitid); 31 32 b->alphaTestFunc = GL_ALWAYS; 33 b->alphaTestRef = 0; 34 RESET(bb->alphaFunc, ctx->bitid); 35 b->depthFunc = GL_LESS; 36 RESET(bb->depthFunc, ctx->bitid); 37 b->blendSrcRGB = GL_ONE; 38 b->blendDstRGB = GL_ZERO; 39 RESET(bb->blendFunc, ctx->bitid); 40 40 #ifdef CR_EXT_blend_func_separate 41 42 43 44 #endif 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 41 b->blendSrcA = GL_ONE; 42 b->blendDstA = GL_ZERO; 43 RESET(bb->blendFuncSeparate, ctx->bitid); 44 #endif 45 b->logicOpMode = GL_COPY; 46 b->drawBuffer = GL_BACK; 47 RESET(bb->drawBuffer, ctx->bitid); 48 b->readBuffer = GL_BACK; 49 RESET(bb->readBuffer, ctx->bitid); 50 b->indexWriteMask = 0xffffffff; 51 RESET(bb->indexMask, ctx->bitid); 52 b->colorWriteMask.r = GL_TRUE; 53 b->colorWriteMask.g = GL_TRUE; 54 b->colorWriteMask.b = GL_TRUE; 55 b->colorWriteMask.a = GL_TRUE; 56 RESET(bb->colorWriteMask, ctx->bitid); 57 b->colorClearValue = zero_colorf; 58 RESET(bb->clearColor, ctx->bitid); 59 b->indexClearValue = 0; 60 RESET(bb->clearIndex, ctx->bitid); 61 b->depthClearValue = (GLdefault) 1.0; 62 RESET(bb->clearDepth, ctx->bitid); 63 b->accumClearValue = zero_colorf; 64 RESET(bb->clearAccum, ctx->bitid); 65 65 66 66 #ifdef CR_EXT_blend_color 67 68 67 b->blendColor = zero_colorf; 68 RESET(bb->blendColor, ctx->bitid); 69 69 #endif 70 70 #if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) 71 72 73 #endif 74 75 71 b->blendEquation = GL_FUNC_ADD_EXT; 72 RESET(bb->blendEquation, ctx->bitid); 73 #endif 74 75 RESET(bb->dirty, ctx->bitid); 76 76 } 77 77 78 78 void STATE_APIENTRY crStateAlphaFunc (GLenum func, GLclampf ref) 79 79 { 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 80 CRContext *g = GetCurrentContext(); 81 CRBufferState *b = &(g->buffer); 82 CRStateBits *sb = GetCurrentBits(); 83 CRBufferBits *bb = &(sb->buffer); 84 85 if (g->current.inBeginEnd) 86 { 87 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glAlphaFunc called in begin/end"); 88 return; 89 } 90 91 FLUSH(); 92 93 switch (func) 94 { 95 case GL_NEVER: 96 case GL_LESS: 97 case GL_EQUAL: 98 case GL_LEQUAL: 99 case GL_GREATER: 100 case GL_GEQUAL: 101 case GL_NOTEQUAL: 102 case GL_ALWAYS: 103 break; 104 default: 105 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glAlphaFunc: Invalid func: %d", func); 106 return; 107 } 108 109 if (ref < 0.0f) ref = 0.0f; 110 if (ref > 1.0f) ref = 1.0f; 111 112 b->alphaTestFunc = func; 113 b->alphaTestRef = ref; 114 DIRTY(bb->dirty, g->neg_bitid); 115 DIRTY(bb->alphaFunc, g->neg_bitid); 116 116 } 117 117 118 118 void STATE_APIENTRY crStateDepthFunc (GLenum func) 119 119 { 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 120 CRContext *g = GetCurrentContext(); 121 CRBufferState *b = &(g->buffer); 122 CRStateBits *sb = GetCurrentBits(); 123 CRBufferBits *bb = &(sb->buffer); 124 125 if (g->current.inBeginEnd) 126 { 127 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDepthFunc called in begin/end"); 128 return; 129 } 130 131 FLUSH(); 132 133 switch (func) 134 { 135 case GL_NEVER: 136 case GL_LESS: 137 case GL_EQUAL: 138 case GL_LEQUAL: 139 case GL_GREATER: 140 case GL_NOTEQUAL: 141 case GL_GEQUAL: 142 case GL_ALWAYS: 143 break; 144 default: 145 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glDepthFunc: Invalid func: %d", func); 146 return; 147 } 148 149 150 b->depthFunc = func; 151 DIRTY(bb->dirty, g->neg_bitid); 152 DIRTY(bb->depthFunc, g->neg_bitid); 153 153 } 154 154 155 155 void STATE_APIENTRY crStateBlendFunc (GLenum sfactor, GLenum dfactor) 156 156 { 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 157 CRContext *g = GetCurrentContext(); 158 CRBufferState *b = &(g->buffer); 159 CRStateBits *sb = GetCurrentBits(); 160 CRBufferBits *bb = &(sb->buffer); 161 162 if (g->current.inBeginEnd) 163 { 164 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBlendFunc called in begin/end"); 165 return; 166 } 167 168 FLUSH(); 169 170 switch (sfactor) 171 { 172 case GL_ZERO: 173 case GL_ONE: 174 case GL_DST_COLOR: 175 case GL_ONE_MINUS_DST_COLOR: 176 case GL_SRC_ALPHA: 177 case GL_ONE_MINUS_SRC_ALPHA: 178 case GL_DST_ALPHA: 179 case GL_ONE_MINUS_DST_ALPHA: 180 case GL_SRC_ALPHA_SATURATE: 181 break; /* OK */ 182 182 #ifdef CR_EXT_blend_color 183 184 185 186 187 188 189 #endif 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 183 case GL_CONSTANT_COLOR_EXT: 184 case GL_ONE_MINUS_CONSTANT_COLOR_EXT: 185 case GL_CONSTANT_ALPHA_EXT: 186 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: 187 if (g->extensions.EXT_blend_color) 188 break; /* OK */ 189 #endif 190 default: 191 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactor passed to glBlendFunc: %d", sfactor); 192 return; 193 } 194 195 switch (dfactor) 196 { 197 case GL_ZERO: 198 case GL_ONE: 199 case GL_SRC_COLOR: 200 case GL_ONE_MINUS_SRC_COLOR: 201 case GL_SRC_ALPHA: 202 case GL_ONE_MINUS_SRC_ALPHA: 203 case GL_DST_ALPHA: 204 case GL_ONE_MINUS_DST_ALPHA: 205 break; /* OK */ 206 206 #ifdef CR_EXT_blend_color 207 208 209 210 211 212 213 #endif 214 215 216 217 218 219 220 221 222 223 224 207 case GL_CONSTANT_COLOR_EXT: 208 case GL_ONE_MINUS_CONSTANT_COLOR_EXT: 209 case GL_CONSTANT_ALPHA_EXT: 210 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: 211 if (g->extensions.EXT_blend_color) 212 break; /* OK */ 213 #endif 214 default: 215 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactor passed to glBlendFunc: %d", dfactor); 216 return; 217 } 218 219 b->blendSrcRGB = sfactor; 220 b->blendDstRGB = dfactor; 221 b->blendSrcA = sfactor; 222 b->blendDstA = dfactor; 223 DIRTY(bb->dirty, g->neg_bitid); 224 DIRTY(bb->blendFunc, g->neg_bitid); 225 225 } 226 226 227 227 void STATE_APIENTRY crStateBlendColorEXT( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) 228 228 { 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 229 CRContext *g = GetCurrentContext(); 230 CRBufferState *b = &(g->buffer); 231 CRStateBits *sb = GetCurrentBits(); 232 CRBufferBits *bb = &(sb->buffer); 233 234 if (g->current.inBeginEnd) 235 { 236 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendColorEXT called inside a Begin/End" ); 237 return; 238 } 239 240 b->blendColor.r = red; 241 b->blendColor.g = green; 242 b->blendColor.b = blue; 243 b->blendColor.a = alpha; 244 DIRTY(bb->blendColor, g->neg_bitid); 245 DIRTY(bb->dirty, g->neg_bitid); 246 246 } 247 247 … … 249 249 void STATE_APIENTRY crStateBlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA ) 250 250 { 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 251 CRContext *g = GetCurrentContext(); 252 CRBufferState *b = &(g->buffer); 253 CRStateBits *sb = GetCurrentBits(); 254 CRBufferBits *bb = &(sb->buffer); 255 256 if (g->current.inBeginEnd) 257 { 258 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendFuncSeparateEXT called inside a Begin/End" ); 259 return; 260 } 261 262 FLUSH(); 263 264 switch (sfactorRGB) 265 { 266 case GL_ZERO: 267 case GL_ONE: 268 case GL_DST_COLOR: 269 case GL_ONE_MINUS_DST_COLOR: 270 case GL_SRC_ALPHA: 271 case GL_ONE_MINUS_SRC_ALPHA: 272 case GL_DST_ALPHA: 273 case GL_ONE_MINUS_DST_ALPHA: 274 case GL_SRC_ALPHA_SATURATE: 275 break; /* OK */ 276 276 #ifdef CR_EXT_blend_color 277 278 279 280 281 282 283 #endif 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 277 case GL_CONSTANT_COLOR_EXT: 278 case GL_ONE_MINUS_CONSTANT_COLOR_EXT: 279 case GL_CONSTANT_ALPHA_EXT: 280 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: 281 if (g->extensions.EXT_blend_color) 282 break; /* OK */ 283 #endif 284 default: 285 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactorRGB passed to glBlendFuncSeparateEXT: %d", sfactorRGB); 286 return; 287 } 288 289 switch (sfactorA) 290 { 291 case GL_ZERO: 292 case GL_ONE: 293 case GL_DST_COLOR: 294 case GL_ONE_MINUS_DST_COLOR: 295 case GL_SRC_ALPHA: 296 case GL_ONE_MINUS_SRC_ALPHA: 297 case GL_DST_ALPHA: 298 case GL_ONE_MINUS_DST_ALPHA: 299 case GL_SRC_ALPHA_SATURATE: 300 break; /* OK */ 301 301 #ifdef CR_EXT_blend_color 302 303 304 305 306 307 308 #endif 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 302 case GL_CONSTANT_COLOR_EXT: 303 case GL_ONE_MINUS_CONSTANT_COLOR_EXT: 304 case GL_CONSTANT_ALPHA_EXT: 305 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: 306 if (g->extensions.EXT_blend_color) 307 break; /* OK */ 308 #endif 309 default: 310 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactorA passed to glBlendFuncSeparateEXT: %d", sfactorA); 311 return; 312 } 313 314 switch (dfactorRGB) 315 { 316 case GL_ZERO: 317 case GL_ONE: 318 case GL_SRC_COLOR: 319 case GL_DST_COLOR: 320 case GL_ONE_MINUS_DST_COLOR: 321 case GL_ONE_MINUS_SRC_COLOR: 322 case GL_SRC_ALPHA: 323 case GL_ONE_MINUS_SRC_ALPHA: 324 case GL_DST_ALPHA: 325 case GL_ONE_MINUS_DST_ALPHA: 326 case GL_SRC_ALPHA_SATURATE: 327 break; /* OK */ 328 328 #ifdef CR_EXT_blend_color 329 330 331 332 333 334 335 #endif 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 329 case GL_CONSTANT_COLOR_EXT: 330 case GL_ONE_MINUS_CONSTANT_COLOR_EXT: 331 case GL_CONSTANT_ALPHA_EXT: 332 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: 333 if (g->extensions.EXT_blend_color) 334 break; /* OK */ 335 #endif 336 default: 337 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactorRGB passed to glBlendFuncSeparateEXT: %d", dfactorRGB); 338 return; 339 } 340 341 switch (dfactorA) 342 { 343 case GL_ZERO: 344 case GL_ONE: 345 case GL_DST_COLOR: 346 case GL_SRC_COLOR: 347 case GL_ONE_MINUS_SRC_COLOR: 348 case GL_ONE_MINUS_DST_COLOR: 349 case GL_SRC_ALPHA: 350 case GL_ONE_MINUS_SRC_ALPHA: 351 case GL_DST_ALPHA: 352 case GL_ONE_MINUS_DST_ALPHA: 353 case GL_SRC_ALPHA_SATURATE: 354 break; /* OK */ 355 355 #ifdef CR_EXT_blend_color 356 357 358 359 360 361 362 #endif 363 364 365 366 367 368 369 370 371 372 373 356 case GL_CONSTANT_COLOR_EXT: 357 case GL_ONE_MINUS_CONSTANT_COLOR_EXT: 358 case GL_CONSTANT_ALPHA_EXT: 359 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: 360 if (g->extensions.EXT_blend_color) 361 break; /* OK */ 362 #endif 363 default: 364 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactorA passed to glBlendFuncSeparateEXT: %d", dfactorA); 365 return; 366 } 367 368 b->blendSrcRGB = sfactorRGB; 369 b->blendDstRGB = dfactorRGB; 370 b->blendSrcA = sfactorA; 371 b->blendDstA = dfactorA; 372 DIRTY(bb->dirty, g->neg_bitid); 373 DIRTY(bb->blendFuncSeparate, g->neg_bitid); 374 374 } 375 375 #endif … … 377 377 void STATE_APIENTRY crStateBlendEquationEXT( GLenum mode ) 378 378 { 379 380 381 382 383 384 385 386 387 388 389 390 379 CRContext *g = GetCurrentContext(); 380 CRBufferState *b = &(g->buffer); 381 CRStateBits *sb = GetCurrentBits(); 382 CRBufferBits *bb = &(sb->buffer); 383 384 if( g->current.inBeginEnd ) 385 { 386 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendEquationEXT called inside a Begin/End" ); 387 return; 388 } 389 switch( mode ) 390 { 391 391 #if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) 392 392 case GL_FUNC_ADD_EXT: 393 393 #ifdef CR_EXT_blend_subtract 394 395 394 case GL_FUNC_SUBTRACT_EXT: 395 case GL_FUNC_REVERSE_SUBTRACT_EXT: 396 396 #endif /* CR_EXT_blend_subtract */ 397 397 #ifdef CR_EXT_blend_minmax 398 399 398 case GL_MIN_EXT: 399 case GL_MAX_EXT: 400 400 #endif /* CR_EXT_blend_minmax */ 401 401 #ifdef CR_EXT_blend_logic_op 402 402 case GL_LOGIC_OP: 403 403 #endif /* CR_EXT_blend_logic_op */ 404 405 404 b->blendEquation = mode; 405 break; 406 406 #endif /* defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) */ 407 408 409 410 411 412 413 407 default: 408 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, 409 "BlendEquationEXT: mode called with illegal parameter: 0x%x", (GLenum) mode ); 410 return; 411 } 412 DIRTY(bb->blendEquation, g->neg_bitid); 413 DIRTY(bb->dirty, g->neg_bitid); 414 414 } 415 415 416 416 void STATE_APIENTRY crStateLogicOp (GLenum opcode) 417 417 { 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 418 CRContext *g = GetCurrentContext(); 419 CRBufferState *b = &(g->buffer); 420 CRStateBits *sb = GetCurrentBits(); 421 CRBufferBits *bb = &(sb->buffer); 422 423 if (g->current.inBeginEnd) 424 { 425 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glLogicOp called in begin/end"); 426 return; 427 } 428 429 FLUSH(); 430 431 switch (opcode) 432 { 433 case GL_CLEAR: 434 case GL_SET: 435 case GL_COPY: 436 case GL_COPY_INVERTED: 437 case GL_NOOP: 438 case GL_INVERT: 439 case GL_AND: 440 case GL_NAND: 441 case GL_OR: 442 case GL_NOR: 443 case GL_XOR: 444 case GL_EQUIV: 445 case GL_AND_REVERSE: 446 case GL_AND_INVERTED: 447 case GL_OR_REVERSE: 448 case GL_OR_INVERTED: 449 break; 450 default: 451 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glLogicOp called with bogus opcode: %d", opcode); 452 return; 453 } 454 455 b->logicOpMode = opcode; 456 DIRTY(bb->dirty, g->neg_bitid); 457 DIRTY(bb->logicOp, g->neg_bitid); 458 DIRTY(bb->indexLogicOp, g->neg_bitid); 459 459 } 460 460 461 461 void STATE_APIENTRY crStateDrawBuffer (GLenum mode) 462 462 { 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 488 489 490 491 492 493 494 495 496 497 498 499 500 463 CRContext *g = GetCurrentContext(); 464 CRBufferState *b = &(g->buffer); 465 CRStateBits *sb = GetCurrentBits(); 466 CRBufferBits *bb = &(sb->buffer); 467 468 if (g->current.inBeginEnd) 469 { 470 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDrawBuffer called in begin/end"); 471 return; 472 } 473 474 FLUSH(); 475 476 switch (mode) 477 { 478 case GL_NONE: 479 case GL_FRONT_LEFT: 480 case GL_FRONT_RIGHT: 481 case GL_BACK_LEFT: 482 case GL_BACK_RIGHT: 483 case GL_FRONT: 484 case GL_BACK: 485 case GL_LEFT: 486 case GL_RIGHT: 487 case GL_FRONT_AND_BACK: 488 case GL_AUX0: 489 case GL_AUX1: 490 case GL_AUX2: 491 case GL_AUX3: 492 break; 493 default: 494 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glDrawBuffer called with bogus mode: %d", mode); 495 return; 496 } 497 498 b->drawBuffer = mode; 499 DIRTY(bb->dirty, g->neg_bitid); 500 DIRTY(bb->drawBuffer, g->neg_bitid); 501 501 } 502 502 503 503 void STATE_APIENTRY crStateReadBuffer (GLenum mode) 504 504 { 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 505 CRContext *g = GetCurrentContext(); 506 CRBufferState *b = &(g->buffer); 507 CRStateBits *sb = GetCurrentBits(); 508 CRBufferBits *bb = &(sb->buffer); 509 510 if (g->current.inBeginEnd) 511 { 512 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end"); 513 return; 514 } 515 516 FLUSH(); 517 518 switch (mode) 519 { 520 case GL_NONE: 521 case GL_FRONT_LEFT: 522 case GL_FRONT_RIGHT: 523 case GL_BACK_LEFT: 524 case GL_BACK_RIGHT: 525 case GL_FRONT: 526 case GL_BACK: 527 case GL_LEFT: 528 case GL_RIGHT: 529 case GL_FRONT_AND_BACK: 530 case GL_AUX0: 531 case GL_AUX1: 532 case GL_AUX2: 533 case GL_AUX3: 534 break; 535 default: 536 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glReadBuffer called with bogus mode: %d", mode); 537 return; 538 } 539 540 b->readBuffer = mode; 541 DIRTY(bb->dirty, g->neg_bitid); 542 DIRTY(bb->readBuffer, g->neg_bitid); 543 543 } 544 544 545 545 void STATE_APIENTRY crStateIndexMask (GLuint mask) 546 546 { 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 547 CRContext *g = GetCurrentContext(); 548 CRBufferState *b = &(g->buffer); 549 CRStateBits *sp = GetCurrentBits(); 550 CRBufferBits *bb = &(sp->buffer); 551 552 if (g->current.inBeginEnd) 553 { 554 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end"); 555 return; 556 } 557 558 FLUSH(); 559 560 b->indexWriteMask = mask; 561 DIRTY(bb->dirty, g->neg_bitid); 562 DIRTY(bb->indexMask, g->neg_bitid); 563 563 } 564 564 565 565 void STATE_APIENTRY crStateColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) 566 566 { 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 567 CRContext *g = GetCurrentContext(); 568 CRBufferState *b = &(g->buffer); 569 CRStateBits *sp = GetCurrentBits(); 570 CRBufferBits *bb = &(sp->buffer); 571 572 if (g->current.inBeginEnd) 573 { 574 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end"); 575 return; 576 } 577 578 FLUSH(); 579 580 b->colorWriteMask.r = red; 581 b->colorWriteMask.g = green; 582 b->colorWriteMask.b = blue; 583 b->colorWriteMask.a = alpha; 584 DIRTY(bb->dirty, g->neg_bitid); 585 DIRTY(bb->colorWriteMask, g->neg_bitid); 586 586 } 587 587 588 588 void STATE_APIENTRY crStateClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) 589 589 { 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 590 CRContext *g = GetCurrentContext(); 591 CRBufferState *b = &(g->buffer); 592 CRStateBits *sp = GetCurrentBits(); 593 CRBufferBits *bb = &(sp->buffer); 594 595 if (g->current.inBeginEnd) 596 { 597 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearColor called in begin/end"); 598 return; 599 } 600 601 FLUSH(); 602 603 if (red < 0.0f) red = 0.0f; 604 if (red > 1.0f) red = 1.0f; 605 if (green < 0.0f) green = 0.0f; 606 if (green > 1.0f) green = 1.0f; 607 if (blue < 0.0f) blue = 0.0f; 608 if (blue > 1.0f) blue = 1.0f; 609 if (alpha < 0.0f) alpha = 0.0f; 610 if (alpha > 1.0f) alpha = 1.0f; 611 612 b->colorClearValue.r = red; 613 b->colorClearValue.g = green; 614 b->colorClearValue.b = blue; 615 b->colorClearValue.a = alpha; 616 DIRTY(bb->dirty, g->neg_bitid); 617 DIRTY(bb->clearColor, g->neg_bitid); 618 618 } 619 619 620 620 void STATE_APIENTRY crStateClearIndex (GLfloat c) 621 621 { 622 623 624 625 626 627 628 629 630 631 632 633 634 635 622 CRContext *g = GetCurrentContext(); 623 CRBufferState *b = &(g->buffer); 624 CRStateBits *sp = GetCurrentBits(); 625 CRBufferBits *bb = &(sp->buffer); 626 627 if (g->current.inBeginEnd) 628 { 629 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearIndex called in begin/end"); 630 return; 631 } 632 633 b->indexClearValue = c; 634 DIRTY(bb->dirty, g->neg_bitid); 635 DIRTY(bb->clearIndex, g->neg_bitid); 636 636 } 637 637 638 638 void STATE_APIENTRY crStateClearDepth (GLclampd depth) 639 639 { 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 640 CRContext *g = GetCurrentContext(); 641 CRBufferState *b = &(g->buffer); 642 CRStateBits *sp = GetCurrentBits(); 643 CRBufferBits *bb = &(sp->buffer); 644 645 if (g->current.inBeginEnd) 646 { 647 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearDepth called in begin/end"); 648 return; 649 } 650 651 FLUSH(); 652 653 if (depth < 0.0) depth = 0.0; 654 if (depth > 1.0) depth = 1.0; 655 656 b->depthClearValue = (GLdefault) depth; 657 DIRTY(bb->dirty, g->neg_bitid); 658 DIRTY(bb->clearDepth, g->neg_bitid); 659 659 } 660 660 661 661 void STATE_APIENTRY crStateClearAccum (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) 662 662 { 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 663 CRContext *g = GetCurrentContext(); 664 CRBufferState *b = &(g->buffer); 665 CRStateBits *sp = GetCurrentBits(); 666 CRBufferBits *bb = &(sp->buffer); 667 668 if (g->current.inBeginEnd) 669 { 670 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearAccum called in begin/end"); 671 return; 672 } 673 674 FLUSH(); 675 676 if (red < -1.0f) red = 0.0f; 677 if (red > 1.0f) red = 1.0f; 678 if (green < -1.0f) green = 0.0f; 679 if (green > 1.0f) green = 1.0f; 680 if (blue < -1.0f) blue = 0.0f; 681 if (blue > 1.0f) blue = 1.0f; 682 if (alpha < -1.0f) alpha = 0.0f; 683 if (alpha > 1.0f) alpha = 1.0f; 684 685 b->accumClearValue.r = red; 686 b->accumClearValue.g = green; 687 b->accumClearValue.b = blue; 688 b->accumClearValue.a = alpha; 689 DIRTY(bb->dirty, g->neg_bitid); 690 DIRTY(bb->clearAccum, g->neg_bitid); 691 691 } 692 692 693 693 void STATE_APIENTRY crStateDepthMask (GLboolean b) 694 694 { 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 } 695 CRContext *g = GetCurrentContext(); 696 CRBufferState *bs = &(g->buffer); 697 CRStateBits *sp = GetCurrentBits(); 698 CRBufferBits *bb = &(sp->buffer); 699 700 if (g->current.inBeginEnd) 701 { 702 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "DepthMask called in begin/end"); 703 return; 704 } 705 706 FLUSH(); 707 708 bs->depthMask = b; 709 DIRTY(bb->dirty, g->neg_bitid); 710 DIRTY(bb->depthMask, g->neg_bitid); 711 }
Note:
See TracChangeset
for help on using the changeset viewer.