1 /*! @header QuesaShader.h 2 Declares the Quesa shader objects. 3 */ 4 /* NAME: 5 QuesaShader.h 6 7 DESCRIPTION: 8 Quesa public header. 9 10 COPYRIGHT: 11 Copyright (c) 1999-2004, Quesa Developers. All rights reserved. 12 13 For the current release of Quesa, please see: 14 15 <http://www.quesa.org/> 16 17 Redistribution and use in source and binary forms, with or without 18 modification, are permitted provided that the following conditions 19 are met: 20 21 o Redistributions of source code must retain the above copyright 22 notice, this list of conditions and the following disclaimer. 23 24 o Redistributions in binary form must reproduce the above 25 copyright notice, this list of conditions and the following 26 disclaimer in the documentation and/or other materials provided 27 with the distribution. 28 29 o Neither the name of Quesa nor the names of its contributors 30 may be used to endorse or promote products derived from this 31 software without specific prior written permission. 32 33 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 34 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 35 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 36 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 37 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 38 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 39 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 40 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 41 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 42 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 43 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 44 ___________________________________________________________________________ 45 */ 46 #ifndef QUESA_SHADER_HDR 47 #define QUESA_SHADER_HDR 48 //============================================================================= 49 // Include files 50 //----------------------------------------------------------------------------- 51 #include "Quesa.h" 52 53 // Disable QD3D header 54 #ifdef __QD3DSHADER__ 55 #error 56 #endif 57 58 #define __QD3DSHADER__ 59 60 61 62 63 64 //============================================================================= 65 // C++ preamble 66 //----------------------------------------------------------------------------- 67 #ifdef __cplusplus 68 extern "C" { 69 #endif 70 71 72 73 74 75 //============================================================================= 76 // Constants 77 //----------------------------------------------------------------------------- 78 /*! 79 * @enum 80 * TQ3ShaderUVBoundary 81 * @discussion 82 * Shader UV boundary behaviour. 83 * 84 * @constant kQ3ShaderUVBoundaryWrap Wrap UV values outside of 0..1. 85 * @constant kQ3ShaderUVBoundaryClamp Clamp UV values to 0..1. 86 */ 87 typedef enum TQ3ShaderUVBoundary { 88 kQ3ShaderUVBoundaryWrap = 0, 89 kQ3ShaderUVBoundaryClamp = 1, 90 kQ3ShaderUVBoundarySize32 = 0xFFFFFFFF 91 } TQ3ShaderUVBoundary; 92 93 94 95 96 97 //============================================================================= 98 // Function prototypes 99 //----------------------------------------------------------------------------- 100 /*! 101 * @function 102 * Q3ColorARGB_Set 103 * @discussion 104 * Set an ARGB color. 105 * 106 * Available in inline form as Q3FastColorARGB_Set. 107 * 108 * @param color The color to set. 109 * @param a The alpha component for the color. 110 * @param r The red component for the color. 111 * @param g The green component for the color. 112 * @param b The blue component for the color. 113 * @result Convenience pointer to the result. 114 */ 115 Q3_EXTERN_API_C ( TQ3ColorARGB * ) 116 Q3ColorARGB_Set ( 117 TQ3ColorARGB *color, 118 float a, 119 float r, 120 float g, 121 float b 122 ); 123 124 125 126 /*! 127 * @function 128 * Q3ColorARGB_Add 129 * @discussion 130 * Add c1 to c2. 131 * 132 * Available in inline form as Q3FastColorARGB_Add. 133 * 134 * <em>This function is not available in QD3D.</em> 135 * 136 * @param c1 The first color. 137 * @param c2 The second color. 138 * @param result Receives the sum of c1 and c2. 139 * @result Convenience pointer to the result. 140 */ 141 #if QUESA_ALLOW_QD3D_EXTENSIONS 142 143 Q3_EXTERN_API_C ( TQ3ColorARGB * ) 144 Q3ColorARGB_Add ( 145 const TQ3ColorARGB *c1, 146 const TQ3ColorARGB *c2, 147 TQ3ColorARGB *result 148 ); 149 150 #endif // QUESA_ALLOW_QD3D_EXTENSIONS 151 152 153 154 /*! 155 * @function 156 * Q3ColorARGB_Subtract 157 * @discussion 158 * Subtract c1 from c2. 159 * 160 * Available in inline form as Q3FastColorARGB_Subtract. 161 * 162 * <em>This function is not available in QD3D.</em> 163 * 164 * @param c1 The first color. 165 * @param c2 The second color. 166 * @param result Receives c2 minus c1. 167 * @result Convenience pointer to the result. 168 */ 169 #if QUESA_ALLOW_QD3D_EXTENSIONS 170 171 Q3_EXTERN_API_C ( TQ3ColorARGB * ) 172 Q3ColorARGB_Subtract ( 173 const TQ3ColorARGB *c1, 174 const TQ3ColorARGB *c2, 175 TQ3ColorARGB *result 176 ); 177 178 #endif // QUESA_ALLOW_QD3D_EXTENSIONS 179 180 181 182 /*! 183 * @function 184 * Q3ColorARGB_Scale 185 * @discussion 186 * Scale a color. 187 * 188 * Available in inline form as Q3FastColorARGB_Scale. 189 * 190 * <em>This function is not available in QD3D.</em> 191 * 192 * @param color The color to scale. 193 * @param scale The factor to scale by. 194 * @param result Receives the scaled color. 195 * @result Convenience pointer to the result. 196 */ 197 #if QUESA_ALLOW_QD3D_EXTENSIONS 198 199 Q3_EXTERN_API_C ( TQ3ColorARGB * ) 200 Q3ColorARGB_Scale ( 201 const TQ3ColorARGB *color, 202 float scale, 203 TQ3ColorARGB *result 204 ); 205 206 #endif // QUESA_ALLOW_QD3D_EXTENSIONS 207 208 209 210 /*! 211 * @function 212 * Q3ColorARGB_Clamp 213 * @discussion 214 * Clamp the components of a color to within 0.0 to 1.0. 215 * 216 * Available in inline form as Q3FastColorARGB_Clamp. 217 * 218 * <em>This function is not available in QD3D.</em> 219 * 220 * @param color The color to clamp. 221 * @param result Receives the clamped color. 222 * @result Convenience pointer to the result. 223 */ 224 #if QUESA_ALLOW_QD3D_EXTENSIONS 225 226 Q3_EXTERN_API_C ( TQ3ColorARGB * ) 227 Q3ColorARGB_Clamp ( 228 const TQ3ColorARGB *color, 229 TQ3ColorARGB *result 230 ); 231 232 #endif // QUESA_ALLOW_QD3D_EXTENSIONS 233 234 235 236 /*! 237 * @function 238 * Q3ColorARGB_Lerp 239 * @discussion 240 * Linearly interpolate between two colors. 241 * 242 * Available in inline form as Q3FastColorARGB_Lerp. 243 * 244 * <em>This function is not available in QD3D.</em> 245 * 246 * @param first The first color. 247 * @param last The second color. 248 * @param alpha The blend factor to interpolate by. 249 * @param result Receives the interpolated color. 250 * @result Convenience pointer to the result. 251 */ 252 #if QUESA_ALLOW_QD3D_EXTENSIONS 253 254 Q3_EXTERN_API_C ( TQ3ColorARGB * ) 255 Q3ColorARGB_Lerp ( 256 const TQ3ColorARGB *first, 257 const TQ3ColorARGB *last, 258 float alpha, 259 TQ3ColorARGB *result 260 ); 261 262 #endif // QUESA_ALLOW_QD3D_EXTENSIONS 263 264 265 266 /*! 267 * @function 268 * Q3ColorARGB_Accumulate 269 * @discussion 270 * Add a colour to an existing color. 271 * 272 * The result is not clamped, and its components may increase past 1.0. 273 * 274 * Available in inline form as Q3FastColorARGB_Accumulate. 275 * 276 * <em>This function is not available in QD3D.</em> 277 * 278 * @param src The color to accumulate. 279 * @param result The color to accumulate into. 280 * @result Convenience pointer to the result. 281 */ 282 #if QUESA_ALLOW_QD3D_EXTENSIONS 283 284 Q3_EXTERN_API_C ( TQ3ColorARGB * ) 285 Q3ColorARGB_Accumulate ( 286 const TQ3ColorARGB *src, 287 TQ3ColorARGB *result 288 ); 289 290 #endif // QUESA_ALLOW_QD3D_EXTENSIONS 291 292 293 294 /*! 295 * @function 296 * Q3ColorRGB_Set 297 * @discussion 298 * Set an RGB color. 299 * 300 * Available in inline form as Q3FastColorRGB_Set. 301 * 302 * @param color The color to set. 303 * @param r The red component for the color. 304 * @param g The green component for the color. 305 * @param b The blue component for the color. 306 * @result Convenience pointer to the result. 307 */ 308 Q3_EXTERN_API_C ( TQ3ColorRGB * ) 309 Q3ColorRGB_Set ( 310 TQ3ColorRGB *color, 311 float r, 312 float g, 313 float b 314 ); 315 316 317 318 /*! 319 * @function 320 * Q3ColorRGB_Add 321 * @discussion 322 * Add c1 to c2. 323 * 324 * Available in inline form as Q3FastColorRGB_Add. 325 * 326 * @param c1 The first color. 327 * @param c2 The second color. 328 * @param result Receives the sum of c1 and c2. 329 * @result Convenience pointer to the result. 330 */ 331 Q3_EXTERN_API_C ( TQ3ColorRGB * ) 332 Q3ColorRGB_Add ( 333 const TQ3ColorRGB *c1, 334 const TQ3ColorRGB *c2, 335 TQ3ColorRGB *result 336 ); 337 338 339 340 /*! 341 * @function 342 * Q3ColorRGB_Subtract 343 * @discussion 344 * Subtract c1 from c2. 345 * 346 * Available in inline form as Q3FastColorRGB_Subtract. 347 * 348 * @param c1 The first color. 349 * @param c2 The second color. 350 * @param result Receives c2 minus c1. 351 * @result Convenience pointer to the result. 352 */ 353 Q3_EXTERN_API_C ( TQ3ColorRGB * ) 354 Q3ColorRGB_Subtract ( 355 const TQ3ColorRGB *c1, 356 const TQ3ColorRGB *c2, 357 TQ3ColorRGB *result 358 ); 359 360 361 362 /*! 363 * @function 364 * Q3ColorRGB_Scale 365 * @discussion 366 * Scale a color. 367 * 368 * Available in inline form as Q3FastColorRGB_Scale. 369 * 370 * @param color The color to scale. 371 * @param scale The factor to scale by. 372 * @param result Receives the scaled color. 373 * @result Convenience pointer to the result. 374 */ 375 Q3_EXTERN_API_C ( TQ3ColorRGB * ) 376 Q3ColorRGB_Scale ( 377 const TQ3ColorRGB *color, 378 float scale, 379 TQ3ColorRGB *result 380 ); 381 382 383 384 /*! 385 * @function 386 * Q3ColorRGB_Clamp 387 * @discussion 388 * Clamp the components of a color to within 0.0 to 1.0. 389 * 390 * Available in inline form as Q3FastColorRGB_Clamp. 391 * 392 * @param color The color to clamp. 393 * @param result Receives the clamped color. 394 * @result Convenience pointer to the result. 395 */ 396 Q3_EXTERN_API_C ( TQ3ColorRGB * ) 397 Q3ColorRGB_Clamp ( 398 const TQ3ColorRGB *color, 399 TQ3ColorRGB *result 400 ); 401 402 403 404 /*! 405 * @function 406 * Q3ColorRGB_Lerp 407 * @discussion 408 * Linearly interpolate between two colors. 409 * 410 * Available in inline form as Q3FastColorRGB_Lerp. 411 * 412 * @param first The first color. 413 * @param last The second color. 414 * @param alpha The blend factor to interpolate by. 415 * @param result Receives the interpolated color. 416 * @result Convenience pointer to the result. 417 */ 418 Q3_EXTERN_API_C ( TQ3ColorRGB * ) 419 Q3ColorRGB_Lerp ( 420 const TQ3ColorRGB *first, 421 const TQ3ColorRGB *last, 422 float alpha, 423 TQ3ColorRGB *result 424 ); 425 426 427 428 /*! 429 * @function 430 * Q3ColorRGB_Accumulate 431 * @discussion 432 * Add a colour to an existing color. 433 * 434 * The result is not clamped, and its components may increase past 1.0. 435 * 436 * Available in inline form as Q3FastColorRGB_Accumulate. 437 * 438 * @param src The color to accumulate. 439 * @param result The color to accumulate into. 440 * @result Convenience pointer to the result. 441 */ 442 Q3_EXTERN_API_C ( TQ3ColorRGB * ) 443 Q3ColorRGB_Accumulate ( 444 const TQ3ColorRGB *src, 445 TQ3ColorRGB *result 446 ); 447 448 449 450 /*! 451 * @function 452 * Q3ColorRGB_Luminance 453 * @discussion 454 * Calculate the luminance of a color. 455 * 456 * The luminance is calculated with the factors used by QD3D, i.e.,: 457 * 458 * <tt>l = (r * 0.30078125f) +</tt> 459 * <tt> (g * 0.58984375f) +</tt> 460 * <tt> (b * 0.109375f)</tt> 461 * 462 * Available in inline form as Q3FastColorRGB_Luminance. 463 * 464 * @param color The color whose luminance is to be calculated. 465 * @param luminance Receives the luminance value for the color. 466 * @result Convenience pointer to the result. 467 */ 468 Q3_EXTERN_API_C ( float * ) 469 Q3ColorRGB_Luminance ( 470 const TQ3ColorRGB *color, 471 float *luminance 472 ); 473 474 475 476 /*! 477 * @function 478 * Q3Shader_GetType 479 * @discussion 480 * Get the type of a shader object. 481 * 482 * @param shader The shader to query. 483 * @result The type of the shader. 484 */ 485 Q3_EXTERN_API_C ( TQ3ObjectType ) 486 Q3Shader_GetType ( 487 TQ3ShaderObject shader 488 ); 489 490 491 492 /*! 493 * @function 494 * Q3Shader_Submit 495 * @discussion 496 * Submit a shader to a view. 497 * 498 * @param shader The shader to submit. 499 * @param view The view to submit the shader to. 500 * @result Success or failure of the operation. 501 */ 502 Q3_EXTERN_API_C ( TQ3Status ) 503 Q3Shader_Submit ( 504 TQ3ShaderObject shader, 505 TQ3ViewObject view 506 ); 507 508 509 510 /*! 511 * @function 512 * Q3Shader_SetUVTransform 513 * @discussion 514 * Set the UV transform for a shader. 515 * 516 * @param shader The shader to update. 517 * @param uvTransform The new UV transform for the shader. 518 * @result Success or failure of the operation. 519 */ 520 Q3_EXTERN_API_C ( TQ3Status ) 521 Q3Shader_SetUVTransform ( 522 TQ3ShaderObject shader, 523 const TQ3Matrix3x3 *uvTransform 524 ); 525 526 527 528 /*! 529 * @function 530 * Q3Shader_GetUVTransform 531 * @discussion 532 * Get the UV transform for a shader. 533 * 534 * @param shader The shader to query. 535 * @param uvTransform Receives the UV transform of the shader. 536 * @result Success or failure of the operation. 537 */ 538 Q3_EXTERN_API_C ( TQ3Status ) 539 Q3Shader_GetUVTransform ( 540 TQ3ShaderObject shader, 541 TQ3Matrix3x3 *uvTransform 542 ); 543 544 545 546 /*! 547 * @function 548 * Q3Shader_SetUBoundary 549 * @discussion 550 * Set the U boundary behaviour for a shader. 551 * 552 * The initial U boundary behaviour for a shader is kQ3ShaderUVBoundaryWrap. 553 * 554 * @param shader The shader to update. 555 * @param uBoundary The U boundary behaviour for the shader. 556 * @result Success or failure of the operation. 557 */ 558 Q3_EXTERN_API_C ( TQ3Status ) 559 Q3Shader_SetUBoundary ( 560 TQ3ShaderObject shader, 561 TQ3ShaderUVBoundary uBoundary 562 ); 563 564 565 566 /*! 567 * @function 568 * Q3Shader_SetVBoundary 569 * @discussion 570 * Set the V boundary behaviour for a shader. 571 * 572 * The initial V boundary behaviour for a shader is kQ3ShaderUVBoundaryWrap. 573 * 574 * @param shader The shader to update. 575 * @param vBoundary The V boundary behaviour for the shader. 576 * @result Success or failure of the operation. 577 */ 578 Q3_EXTERN_API_C ( TQ3Status ) 579 Q3Shader_SetVBoundary ( 580 TQ3ShaderObject shader, 581 TQ3ShaderUVBoundary vBoundary 582 ); 583 584 585 586 /*! 587 * @function 588 * Q3Shader_GetUBoundary 589 * @discussion 590 * Get the U boundary behaviour of a shader. 591 * 592 * @param shader The shader to query. 593 * @param uBoundary Receives the U boundary behaviour of the shader. 594 * @result Success or failure of the operation. 595 */ 596 Q3_EXTERN_API_C ( TQ3Status ) 597 Q3Shader_GetUBoundary ( 598 TQ3ShaderObject shader, 599 TQ3ShaderUVBoundary *uBoundary 600 ); 601 602 603 604 /*! 605 * @function 606 * Q3Shader_GetVBoundary 607 * @discussion 608 * Get the V boundary behaviour of a shader. 609 * 610 * @param shader The shader to query. 611 * @param vBoundary Receives the V boundary behaviour of the shader. 612 * @result Success or failure of the operation. 613 */ 614 Q3_EXTERN_API_C ( TQ3Status ) 615 Q3Shader_GetVBoundary ( 616 TQ3ShaderObject shader, 617 TQ3ShaderUVBoundary *vBoundary 618 ); 619 620 621 622 /*! 623 * @function 624 * Q3IlluminationShader_GetType 625 * @discussion 626 * Get the type of an illumination shader. 627 * 628 * @param shader The shader to query. 629 * @result The type of the illumination shader. 630 */ 631 Q3_EXTERN_API_C ( TQ3ObjectType ) 632 Q3IlluminationShader_GetType ( 633 TQ3ShaderObject shader 634 ); 635 636 637 638 /*! 639 * @function 640 * Q3PhongIllumination_New 641 * @discussion 642 * Create a Phong illumination shader. 643 * 644 * @result The new illumination shader. 645 */ 646 Q3_EXTERN_API_C ( TQ3ShaderObject ) 647 Q3PhongIllumination_New ( 648 void 649 ); 650 651 652 653 /*! 654 * @function 655 * Q3LambertIllumination_New 656 * @discussion 657 * Create a Lambert illumination shader. 658 * 659 * @result The new illumination shader. 660 */ 661 Q3_EXTERN_API_C ( TQ3ShaderObject ) 662 Q3LambertIllumination_New ( 663 void 664 ); 665 666 667 668 /*! 669 * @function 670 * Q3NULLIllumination_New 671 * @discussion 672 * Create a NULL illumination shader. 673 * 674 * @result The new illumination shader. 675 */ 676 Q3_EXTERN_API_C ( TQ3ShaderObject ) 677 Q3NULLIllumination_New ( 678 void 679 ); 680 681 682 683 /*! 684 * @function 685 * Q3SurfaceShader_GetType 686 * @discussion 687 * Get the type of a surface shader. 688 * 689 * @param shader The shader to query. 690 * @result The type of the surface shader. 691 */ 692 Q3_EXTERN_API_C ( TQ3ObjectType ) 693 Q3SurfaceShader_GetType ( 694 TQ3SurfaceShaderObject shader 695 ); 696 697 698 699 /*! 700 * @function 701 * Q3TextureShader_New 702 * @discussion 703 * Create a texture shader. 704 * 705 * @param texture The texture object for the shader. 706 * @result The new texture shader. 707 */ 708 Q3_EXTERN_API_C ( TQ3ShaderObject ) 709 Q3TextureShader_New ( 710 TQ3TextureObject texture 711 ); 712 713 714 715 /*! 716 * @function 717 * Q3TextureShader_GetTexture 718 * @discussion 719 * Get the texture from a texture shader. 720 * 721 * The reference count of the returned shader is incremented, and the 722 * caller must release their reference when done. 723 * 724 * @param shader The shader to query. 725 * @param texture Receives the texture from the texture shader. 726 * @result Success or failure of the operation. 727 */ 728 Q3_EXTERN_API_C ( TQ3Status ) 729 Q3TextureShader_GetTexture ( 730 TQ3ShaderObject shader, 731 TQ3TextureObject *texture 732 ); 733 734 735 736 /*! 737 * @function 738 * Q3TextureShader_SetTexture 739 * @discussion 740 * Set the texture for a texture shader. 741 * 742 * @param shader The shader to update. 743 * @param texture The texture for the shader. 744 * @result Success or failure of the operation. 745 */ 746 Q3_EXTERN_API_C ( TQ3Status ) 747 Q3TextureShader_SetTexture ( 748 TQ3ShaderObject shader, 749 TQ3TextureObject texture 750 ); 751 752 753 754 /*! 755 * @function 756 * Q3Texture_GetType 757 * @discussion 758 * Get the type of a texture object. 759 * 760 * @param texture The texture to query. 761 * @result The type of the texture object. 762 */ 763 Q3_EXTERN_API_C ( TQ3ObjectType ) 764 Q3Texture_GetType ( 765 TQ3TextureObject texture 766 ); 767 768 769 770 /*! 771 * @function 772 * Q3Texture_GetWidth 773 * @discussion 774 * Get the width of a texture object. 775 * 776 * @param texture The texture to query. 777 * @param width Receives the width of the texture object. 778 * @result Success or failure of the operation. 779 */ 780 Q3_EXTERN_API_C ( TQ3Status ) 781 Q3Texture_GetWidth ( 782 TQ3TextureObject texture, 783 TQ3Uns32 *width 784 ); 785 786 787 788 /*! 789 * @function 790 * Q3Texture_GetHeight 791 * @discussion 792 * Get the height of a texture object. 793 * 794 * @param texture The texture to query. 795 * @param height Receives the height of the texture object. 796 * @result Success or failure of the operation. 797 */ 798 Q3_EXTERN_API_C ( TQ3Status ) 799 Q3Texture_GetHeight ( 800 TQ3TextureObject texture, 801 TQ3Uns32 *height 802 ); 803 804 805 806 /*! 807 * @function 808 * Q3PixmapTexture_New 809 * @discussion 810 * Create a pixmap texture. 811 * 812 * @param pixmap The pixmap to be used by the texture. 813 * @result The new pixmap texture. 814 */ 815 Q3_EXTERN_API_C ( TQ3TextureObject ) 816 Q3PixmapTexture_New ( 817 const TQ3StoragePixmap *pixmap 818 ); 819 820 821 822 /*! 823 * @function 824 * Q3PixmapTexture_GetPixmap 825 * @discussion 826 * Get the pixmap from a pixmap texture. 827 * 828 * @param texture The texture to query. 829 * @param pixmap Receives the pixmap of the texture. 830 * @result Success or failure of the operation. 831 */ 832 Q3_EXTERN_API_C ( TQ3Status ) 833 Q3PixmapTexture_GetPixmap ( 834 TQ3TextureObject texture, 835 TQ3StoragePixmap *pixmap 836 ); 837 838 839 840 /*! 841 * @function 842 * Q3PixmapTexture_SetPixmap 843 * @discussion 844 * Set the pixmap for a pixmap texture. 845 * 846 * @param texture The texture to update. 847 * @param pixmap The new pixmap for the texture. 848 * @result Success or failure of the operation. 849 */ 850 Q3_EXTERN_API_C ( TQ3Status ) 851 Q3PixmapTexture_SetPixmap ( 852 TQ3TextureObject texture, 853 const TQ3StoragePixmap *pixmap 854 ); 855 856 857 858 /*! 859 * @function 860 * Q3MipmapTexture_New 861 * @discussion 862 * Create a mipmap texture. 863 * 864 * @param mipmap The mipmap to be used by the texture. 865 * @result The new mipmap texture. 866 */ 867 Q3_EXTERN_API_C ( TQ3TextureObject ) 868 Q3MipmapTexture_New ( 869 const TQ3Mipmap *mipmap 870 ); 871 872 873 874 /*! 875 * @function 876 * Q3MipmapTexture_GetMipmap 877 * @discussion 878 * Get the mipmap from a mipmap texture. 879 * 880 * @param texture The texture to query. 881 * @param mipmap Receives the mipmap of the texture. 882 * @result Success or failure of the operation. 883 */ 884 Q3_EXTERN_API_C ( TQ3Status ) 885 Q3MipmapTexture_GetMipmap ( 886 TQ3TextureObject texture, 887 TQ3Mipmap *mipmap 888 ); 889 890 891 892 /*! 893 * @function 894 * Q3MipmapTexture_SetMipmap 895 * @discussion 896 * Set the mipmap for a mipmap texture. 897 * 898 * @param texture The texture to update. 899 * @param mipmap The new mipmap for the texture. 900 * @result Success or failure of the operation. 901 */ 902 Q3_EXTERN_API_C ( TQ3Status ) 903 Q3MipmapTexture_SetMipmap ( 904 TQ3TextureObject texture, 905 const TQ3Mipmap *mipmap 906 ); 907 908 909 #if QUESA_SUPPORT_QUICKTIME 910 /*! 911 * @function 912 * Q3CompressedPixmapTexture_New 913 * @discussion 914 * Create a compressed pixmap texture. 915 * 916 * This function is only available on platforms that support QuickTime. 917 * 918 * @param compressedPixmap The compressed pixmap for the texture. 919 * @result The new compressed pixmap texture. 920 */ 921 Q3_EXTERN_API_C ( TQ3TextureObject ) 922 Q3CompressedPixmapTexture_New ( 923 const TQ3CompressedPixmap *compressedPixmap 924 ); 925 926 927 928 /*! 929 * @function 930 * Q3CompressedPixmapTexture_GetCompressedPixmap 931 * @discussion 932 * Get the compressed pixmap from a compressed pixmap texture. 933 * 934 * This function is only available on platforms that support QuickTime. 935 * 936 * @param texture The texture to query. 937 * @param compressedPixmap Receives the compressed pixmap of the texture. 938 * @result Success or failure of the operation. 939 */ 940 Q3_EXTERN_API_C ( TQ3Status ) 941 Q3CompressedPixmapTexture_GetCompressedPixmap ( 942 TQ3TextureObject texture, 943 TQ3CompressedPixmap *compressedPixmap 944 ); 945 946 947 948 /*! 949 * @function 950 * Q3CompressedPixmapTexture_SetCompressedPixmap 951 * @discussion 952 * Set the compressed pixmap for a compressed pixmap texture. 953 * 954 * This function is only available on platforms that support QuickTime. 955 * 956 * @param texture The texture to update. 957 * @param compressedPixmap The new compressed pixmap for the texture. 958 * @result Success or failure of the operation. 959 */ 960 Q3_EXTERN_API_C ( TQ3Status ) 961 Q3CompressedPixmapTexture_SetCompressedPixmap ( 962 TQ3TextureObject texture, 963 const TQ3CompressedPixmap *compressedPixmap 964 ); 965 966 967 968 /*! 969 * @function 970 * Q3CompressedPixmapTexture_CompressImage 971 * @discussion 972 * Create a compressed pixmap from a PixMapHandle. 973 * 974 * This function is only available on platforms that support QuickTime. 975 * 976 * @param compressedPixmap Receives the compressed pixmap. 977 * @param sourcePixMap The uncompressed PixMapHandle. 978 * @param codecType The QuickTime codec to use for compression. 979 * @param codecComponent The QuickTime component to use for compression. 980 * @param codedDepth The depth the codec should compress to. 981 * @param codecQuality The quality the codec should compress to. 982 * @result Success or failure of the operation. 983 */ 984 Q3_EXTERN_API_C ( TQ3Status ) 985 Q3CompressedPixmapTexture_CompressImage ( 986 TQ3CompressedPixmap *compressedPixmap, 987 PixMapHandle sourcePixMap, 988 CodecType codecType, 989 CodecComponent codecComponent, 990 TQ3Int16 codedDepth, 991 CodecQ codecQuality 992 ); 993 994 #endif // QUESA_SUPPORT_QUICKTIME 995 996 997 998 999 1000 //============================================================================= 1001 // Inline APIs 1002 //----------------------------------------------------------------------------- 1003 // Note : Preserve the order of functions when adding new inline APIs. 1004 //----------------------------------------------------------------------------- 1005 #if QUESA_ALLOW_QD3D_EXTENSIONS 1006 1007 // Implementation 1008 #define __Q3FastColorARGB_Set(_c, _a, _r, _g, _b) \ 1009 do \ 1010 { \ 1011 (_c)->a = (_a); \ 1012 (_c)->r = (_r); \ 1013 (_c)->g = (_g); \ 1014 (_c)->b = (_b); \ 1015 } \ 1016 while (0) 1017 1018 #define __Q3FastColorARGB_Add(_c1, _c2, _r) \ 1019 do \ 1020 { \ 1021 (_r)->a = (_c1)->a + (_c2)->a; \ 1022 (_r)->r = (_c1)->r + (_c2)->r; \ 1023 (_r)->g = (_c1)->g + (_c2)->g; \ 1024 (_r)->b = (_c1)->b + (_c2)->b; \ 1025 } \ 1026 while (0) 1027 1028 #define __Q3FastColorARGB_Subtract(_c1, _c2, _r) \ 1029 do \ 1030 { \ 1031 (_r)->a = (_c2)->a - (_c1)->a; \ 1032 (_r)->r = (_c2)->r - (_c1)->r; \ 1033 (_r)->g = (_c2)->g - (_c1)->g; \ 1034 (_r)->b = (_c2)->b - (_c1)->b; \ 1035 } \ 1036 while (0) 1037 1038 #define __Q3FastColorARGB_Scale(_c, _s, _r) \ 1039 do \ 1040 { \ 1041 (_r)->a = (_c)->a * (_s); \ 1042 (_r)->r = (_c)->r * (_s); \ 1043 (_r)->g = (_c)->g * (_s); \ 1044 (_r)->b = (_c)->b * (_s); \ 1045 } \ 1046 while (0) 1047 1048 #define __Q3FastColorARGB_Clamp(_c, _r) \ 1049 do \ 1050 { \ 1051 float ca = (_c)->a; \ 1052 float cr = (_c)->r; \ 1053 float cg = (_c)->g; \ 1054 float cb = (_c)->b; \ 1055 \ 1056 (_r)->a = (ca < 0.0f ? 0.0f : (ca > 1.0f ? 1.0f : ca)); \ 1057 (_r)->r = (cr < 0.0f ? 0.0f : (cr > 1.0f ? 1.0f : cr)); \ 1058 (_r)->g = (cg < 0.0f ? 0.0f : (cg > 1.0f ? 1.0f : cg)); \ 1059 (_r)->b = (cb < 0.0f ? 0.0f : (cb > 1.0f ? 1.0f : cb)); \ 1060 } \ 1061 while (0) 1062 1063 #define __Q3FastColorARGB_Lerp(_f, _l, _a, _r) \ 1064 do \ 1065 { \ 1066 (_r)->a = (_f)->a + ( ((_l)->a - (_f)->a) * (_a) ); \ 1067 (_r)->r = (_f)->r + ( ((_l)->r - (_f)->r) * (_a) ); \ 1068 (_r)->g = (_f)->g + ( ((_l)->g - (_f)->g) * (_a) ); \ 1069 (_r)->b = (_f)->b + ( ((_l)->b - (_f)->b) * (_a) ); \ 1070 } \ 1071 while (0) 1072 1073 #define __Q3FastColorARGB_Accumulate(_c, _r) \ 1074 do \ 1075 { \ 1076 (_r)->a += (_c)->a; \ 1077 (_r)->r += (_c)->r; \ 1078 (_r)->g += (_c)->g; \ 1079 (_r)->b += (_c)->b; \ 1080 } \ 1081 while (0) 1082 1083 #define __Q3FastColorRGB_Set(_c, _r, _g, _b) \ 1084 do \ 1085 { \ 1086 (_c)->r = (_r); \ 1087 (_c)->g = (_g); \ 1088 (_c)->b = (_b); \ 1089 } \ 1090 while (0) 1091 1092 #define __Q3FastColorRGB_Add(_c1, _c2, _r) \ 1093 do \ 1094 { \ 1095 (_r)->r = (_c1)->r + (_c2)->r; \ 1096 (_r)->g = (_c1)->g + (_c2)->g; \ 1097 (_r)->b = (_c1)->b + (_c2)->b; \ 1098 } \ 1099 while (0) 1100 1101 #define __Q3FastColorRGB_Subtract(_c1, _c2, _r) \ 1102 do \ 1103 { \ 1104 (_r)->r = (_c2)->r - (_c1)->r; \ 1105 (_r)->g = (_c2)->g - (_c1)->g; \ 1106 (_r)->b = (_c2)->b - (_c1)->b; \ 1107 } \ 1108 while (0) 1109 1110 #define __Q3FastColorRGB_Scale(_c, _s, _r) \ 1111 do \ 1112 { \ 1113 (_r)->r = (_c)->r * (_s); \ 1114 (_r)->g = (_c)->g * (_s); \ 1115 (_r)->b = (_c)->b * (_s); \ 1116 } \ 1117 while (0) 1118 1119 #define __Q3FastColorRGB_Clamp(_c, _r) \ 1120 do \ 1121 { \ 1122 float cr = (_c)->r; \ 1123 float cg = (_c)->g; \ 1124 float cb = (_c)->b; \ 1125 \ 1126 (_r)->r = (cr < 0.0f ? 0.0f : (cr > 1.0f ? 1.0f : cr)); \ 1127 (_r)->g = (cg < 0.0f ? 0.0f : (cg > 1.0f ? 1.0f : cg)); \ 1128 (_r)->b = (cb < 0.0f ? 0.0f : (cb > 1.0f ? 1.0f : cb)); \ 1129 } \ 1130 while (0) 1131 1132 #define __Q3FastColorRGB_Lerp(_f, _l, _a, _r) \ 1133 do \ 1134 { \ 1135 (_r)->r = (_f)->r + ( ((_l)->r - (_f)->r) * (_a) ); \ 1136 (_r)->g = (_f)->g + ( ((_l)->g - (_f)->g) * (_a) ); \ 1137 (_r)->b = (_f)->b + ( ((_l)->b - (_f)->b) * (_a) ); \ 1138 } \ 1139 while (0) 1140 1141 #define __Q3FastColorRGB_Accumulate(_c, _r) \ 1142 do \ 1143 { \ 1144 (_r)->r += (_c)->r; \ 1145 (_r)->g += (_c)->g; \ 1146 (_r)->b += (_c)->b; \ 1147 } \ 1148 while (0) 1149 1150 #define __Q3FastColorRGB_Luminance(_c, _l) \ 1151 do \ 1152 { \ 1153 *(_l) = ((_c)->r * 0.30078125f) + \ 1154 ((_c)->g * 0.58984375f) + \ 1155 ((_c)->b * 0.109375f); \ 1156 } \ 1157 while (0) 1158 1159 1160 1161 // Wrappers 1162 #ifdef __cplusplus 1163 Q3FastColorARGB_Set(TQ3ColorARGB * color,float a,float r,float g,float b)1164 inline TQ3ColorARGB *Q3FastColorARGB_Set(TQ3ColorARGB *color, float a, float r, float g, float b) 1165 { 1166 __Q3FastColorARGB_Set(color, a, r, g, b); 1167 return(color); 1168 } 1169 Q3FastColorARGB_Add(const TQ3ColorARGB * c1,const TQ3ColorARGB * c2,TQ3ColorARGB * result)1170 inline TQ3ColorARGB *Q3FastColorARGB_Add(const TQ3ColorARGB *c1, const TQ3ColorARGB *c2, TQ3ColorARGB *result) 1171 { 1172 __Q3FastColorARGB_Add(c1, c2, result); 1173 return(result); 1174 } 1175 Q3FastColorARGB_Subtract(const TQ3ColorARGB * c1,const TQ3ColorARGB * c2,TQ3ColorARGB * result)1176 inline TQ3ColorARGB *Q3FastColorARGB_Subtract(const TQ3ColorARGB *c1, const TQ3ColorARGB *c2, TQ3ColorARGB *result) 1177 { 1178 __Q3FastColorARGB_Subtract(c1, c2, result); 1179 return(result); 1180 } 1181 Q3FastColorARGB_Scale(const TQ3ColorARGB * color,float scale,TQ3ColorARGB * result)1182 inline TQ3ColorARGB *Q3FastColorARGB_Scale(const TQ3ColorARGB *color, float scale, TQ3ColorARGB *result) 1183 { 1184 __Q3FastColorARGB_Scale(color, scale, result); 1185 return(result); 1186 } 1187 Q3FastColorARGB_Clamp(const TQ3ColorARGB * color,TQ3ColorARGB * result)1188 inline TQ3ColorARGB *Q3FastColorARGB_Clamp(const TQ3ColorARGB *color, TQ3ColorARGB *result) 1189 { 1190 __Q3FastColorARGB_Clamp(color, result); 1191 return(result); 1192 } 1193 Q3FastColorARGB_Lerp(const TQ3ColorARGB * first,const TQ3ColorARGB * last,float alpha,TQ3ColorARGB * result)1194 inline TQ3ColorARGB *Q3FastColorARGB_Lerp(const TQ3ColorARGB *first, const TQ3ColorARGB *last, float alpha, TQ3ColorARGB *result) 1195 { 1196 __Q3FastColorARGB_Lerp(first, last, alpha, result); 1197 return(result); 1198 } 1199 Q3FastColorARGB_Accumulate(const TQ3ColorARGB * src,TQ3ColorARGB * result)1200 inline TQ3ColorARGB *Q3FastColorARGB_Accumulate(const TQ3ColorARGB *src, TQ3ColorARGB *result) 1201 { 1202 __Q3FastColorARGB_Accumulate(src, result); 1203 return(result); 1204 } 1205 Q3FastColorRGB_Set(TQ3ColorRGB * color,float r,float g,float b)1206 inline TQ3ColorRGB *Q3FastColorRGB_Set(TQ3ColorRGB *color, float r, float g, float b) 1207 { 1208 __Q3FastColorRGB_Set(color, r, g, b); 1209 return(color); 1210 } 1211 Q3FastColorRGB_Add(const TQ3ColorRGB * c1,const TQ3ColorRGB * c2,TQ3ColorRGB * result)1212 inline TQ3ColorRGB *Q3FastColorRGB_Add(const TQ3ColorRGB *c1, const TQ3ColorRGB *c2, TQ3ColorRGB *result) 1213 { 1214 __Q3FastColorRGB_Add(c1, c2, result); 1215 return(result); 1216 } 1217 Q3FastColorRGB_Subtract(const TQ3ColorRGB * c1,const TQ3ColorRGB * c2,TQ3ColorRGB * result)1218 inline TQ3ColorRGB *Q3FastColorRGB_Subtract(const TQ3ColorRGB *c1, const TQ3ColorRGB *c2, TQ3ColorRGB *result) 1219 { 1220 __Q3FastColorRGB_Subtract(c1, c2, result); 1221 return(result); 1222 } 1223 Q3FastColorRGB_Scale(const TQ3ColorRGB * color,float scale,TQ3ColorRGB * result)1224 inline TQ3ColorRGB *Q3FastColorRGB_Scale(const TQ3ColorRGB *color, float scale, TQ3ColorRGB *result) 1225 { 1226 __Q3FastColorRGB_Scale(color, scale, result); 1227 return(result); 1228 } 1229 Q3FastColorRGB_Clamp(const TQ3ColorRGB * color,TQ3ColorRGB * result)1230 inline TQ3ColorRGB *Q3FastColorRGB_Clamp(const TQ3ColorRGB *color, TQ3ColorRGB *result) 1231 { 1232 __Q3FastColorRGB_Clamp(color, result); 1233 return(result); 1234 } 1235 Q3FastColorRGB_Lerp(const TQ3ColorRGB * first,const TQ3ColorRGB * last,float alpha,TQ3ColorRGB * result)1236 inline TQ3ColorRGB *Q3FastColorRGB_Lerp(const TQ3ColorRGB *first, const TQ3ColorRGB *last, float alpha, TQ3ColorRGB *result) 1237 { 1238 __Q3FastColorRGB_Lerp(first, last, alpha, result); 1239 return(result); 1240 } 1241 Q3FastColorRGB_Accumulate(const TQ3ColorRGB * src,TQ3ColorRGB * result)1242 inline TQ3ColorRGB *Q3FastColorRGB_Accumulate(const TQ3ColorRGB *src, TQ3ColorRGB *result) 1243 { 1244 __Q3FastColorRGB_Accumulate(src, result); 1245 return(result); 1246 } 1247 Q3FastColorRGB_Luminance(const TQ3ColorRGB * color,float * luminance)1248 inline float *Q3FastColorRGB_Luminance(const TQ3ColorRGB *color, float *luminance) 1249 { 1250 __Q3FastColorRGB_Luminance(color, luminance); 1251 return(luminance); 1252 } 1253 1254 #else 1255 #define Q3FastColorARGB_Set __Q3FastColorARGB_Set 1256 #define Q3FastColorARGB_Add __Q3FastColorARGB_Add 1257 #define Q3FastColorARGB_Subtract __Q3FastColorARGB_Subtract 1258 #define Q3FastColorARGB_Scale __Q3FastColorARGB_Scale 1259 #define Q3FastColorARGB_Clamp __Q3FastColorARGB_Clamp 1260 #define Q3FastColorARGB_Lerp __Q3FastColorARGB_Lerp 1261 #define Q3FastColorARGB_Accumulate __Q3FastColorARGB_Accumulate 1262 #define Q3FastColorRGB_Set __Q3FastColorRGB_Set 1263 #define Q3FastColorRGB_Add __Q3FastColorRGB_Add 1264 #define Q3FastColorRGB_Subtract __Q3FastColorRGB_Subtract 1265 #define Q3FastColorRGB_Scale __Q3FastColorRGB_Scale 1266 #define Q3FastColorRGB_Clamp __Q3FastColorRGB_Clamp 1267 #define Q3FastColorRGB_Lerp __Q3FastColorRGB_Lerp 1268 #define Q3FastColorRGB_Accumulate __Q3FastColorRGB_Accumulate 1269 #define Q3FastColorRGB_Luminance __Q3FastColorRGB_Luminance 1270 #endif 1271 1272 1273 1274 // Redirection 1275 // 1276 // Unfortunately the Q3Color[A]RGB_Set functions are allowed to be called with either 1277 // individual arguments or with a macro such as kQ3ViewDefaultDiffuseColor. We can 1278 // support this using __VA_ARGS__, however this is not supported by all compilers. 1279 // 1280 // For gcc we have a workaround, for Visual C++ we do not - so for now only CW/gcc can 1281 // automatically remap these two Q3 calls to their Q3Fast equivalents. 1282 #if QUESA_ALLOW_INLINE_APIS 1283 #ifdef __MWERKS__ 1284 #define Q3ColorARGB_Set(...) Q3FastColorARGB_Set(__VA_ARGS__) 1285 #define Q3ColorRGB_Set(...) Q3FastColorRGB_Set(__VA_ARGS__) 1286 #endif 1287 1288 #ifdef __GNUC__ 1289 #define Q3ColorARGB_Set(args...) Q3FastColorARGB_Set(args) 1290 #define Q3ColorRGB_Set(args...) Q3FastColorRGB_Set(args) 1291 #endif 1292 1293 #define Q3ColorARGB_Add Q3FastColorARGB_Add 1294 #define Q3ColorARGB_Subtract Q3FastColorARGB_Subtract 1295 #define Q3ColorARGB_Scale Q3FastColorARGB_Scale 1296 #define Q3ColorARGB_Clamp Q3FastColorARGB_Clamp 1297 #define Q3ColorARGB_Lerp Q3FastColorARGB_Lerp 1298 #define Q3ColorARGB_Accumulate Q3FastColorARGB_Accumulate 1299 #define Q3ColorRGB_Add Q3FastColorRGB_Add 1300 #define Q3ColorRGB_Subtract Q3FastColorRGB_Subtract 1301 #define Q3ColorRGB_Scale Q3FastColorRGB_Scale 1302 #define Q3ColorRGB_Clamp Q3FastColorRGB_Clamp 1303 #define Q3ColorRGB_Lerp Q3FastColorRGB_Lerp 1304 #define Q3ColorRGB_Accumulate Q3FastColorRGB_Accumulate 1305 #define Q3ColorRGB_Luminance Q3FastColorRGB_Luminance 1306 #endif 1307 1308 #endif // QUESA_ALLOW_QD3D_EXTENSIONS 1309 1310 1311 1312 1313 1314 //============================================================================= 1315 // C++ postamble 1316 //----------------------------------------------------------------------------- 1317 #ifdef __cplusplus 1318 } 1319 #endif 1320 1321 #endif 1322 1323 1324