|
22 | 22 | #define RWFORCEENUMSIZEINT ((std::int32_t)((~((std::uint32_t)0)) >> 1)) |
23 | 23 | #endif |
24 | 24 | #define RWPLUGINOFFSET(_type, _base, _offset) ((_type*)((std::uint8_t*)(_base) + (_offset))) |
| 25 | +#define RWSRCGLOBAL(variable) ((*(RwGlobals**)0xC97B24)->variable) // 0xC97B24 = RwEngineInstance pointer |
| 26 | +#define RWRSTATE(a) (reinterpret_cast<void*>(a)) |
25 | 27 | #define RW_STRUCT_ALIGN ((int)((~((unsigned int)0))>>1)) |
26 | 28 | #define RW_TEXTURE_NAME_LENGTH 32 |
27 | 29 | #define RW_FRAME_NAME_LENGTH 23 |
28 | 30 | #define RW_MAX_TEXTURE_COORDS 8 |
29 | 31 |
|
| 32 | +#define RwRenderStateGet(_state, _value) RwRenderStateGetMacro(_state, _value) |
| 33 | +#define RwRenderStateSet(_state, _value) RwRenderStateSetMacro(_state, _value) |
| 34 | + |
| 35 | +#define RwRenderStateGetMacro(_state, _value) (RWSRCGLOBAL(dOpenDevice).fpRenderStateGet(_state, _value)) |
| 36 | +#define RwRenderStateSetMacro(_state, _value) (RWSRCGLOBAL(dOpenDevice).fpRenderStateSet(_state, _value)) |
| 37 | + |
30 | 38 | /* Type IDs */ |
31 | 39 |
|
32 | 40 | #define RP_TYPE_ATOMIC 1 |
@@ -487,6 +495,177 @@ enum RwStreamMode |
487 | 495 | STREAM_MODE_LAST = RW_STRUCT_ALIGN |
488 | 496 | }; |
489 | 497 |
|
| 498 | +enum RwRenderState |
| 499 | +{ |
| 500 | + rwRENDERSTATENARENDERSTATE = 0, |
| 501 | + |
| 502 | + rwRENDERSTATETEXTURERASTER, |
| 503 | + /**<Raster used for texturing (normally used in immediate mode). |
| 504 | + * The value is a pointer to an \ref RwRaster. |
| 505 | + * Default: NULL. |
| 506 | + */ |
| 507 | + rwRENDERSTATETEXTUREADDRESS, |
| 508 | + /**<\ref RwTextureAddressMode: wrap, clamp, mirror or border. |
| 509 | + * Default: rwTEXTUREADDRESSWRAP. |
| 510 | + */ |
| 511 | + rwRENDERSTATETEXTUREADDRESSU, |
| 512 | + /**<\ref RwTextureAddressMode in u only. |
| 513 | + * Default: rwTEXTUREADDRESSWRAP. |
| 514 | + */ |
| 515 | + rwRENDERSTATETEXTUREADDRESSV, |
| 516 | + /**<\ref RwTextureAddressMode in v only. |
| 517 | + * Default: rwTEXTUREADDRESSWRAP. |
| 518 | + */ |
| 519 | + rwRENDERSTATETEXTUREPERSPECTIVE, |
| 520 | + /**<Perspective correction on/off (always enabled on many platforms). |
| 521 | + */ |
| 522 | + rwRENDERSTATEZTESTENABLE, |
| 523 | + /**<Z-buffer test on/off. |
| 524 | + * Default: TRUE. |
| 525 | + */ |
| 526 | + rwRENDERSTATESHADEMODE, |
| 527 | + /**<\ref RwShadeMode: flat or gouraud shading. |
| 528 | + * Default: rwSHADEMODEGOURAUD. |
| 529 | + */ |
| 530 | + rwRENDERSTATEZWRITEENABLE, |
| 531 | + /**<Z-buffer write on/off. |
| 532 | + * Default: TRUE. |
| 533 | + */ |
| 534 | + rwRENDERSTATETEXTUREFILTER, |
| 535 | + /**<\ref RwTextureFilterMode: point sample, bilinear, trilinear, etc. |
| 536 | + * Default: rwFILTERLINEAR. |
| 537 | + */ |
| 538 | + rwRENDERSTATESRCBLEND, |
| 539 | + /**<\ref RwBlendFunction used to modulate the source pixel color |
| 540 | + * when blending to the frame buffer. |
| 541 | + * Default: rwBLENDSRCALPHA. |
| 542 | + */ |
| 543 | + rwRENDERSTATEDESTBLEND, |
| 544 | + /**<\ref RwBlendFunction used to modulate the destination pixel |
| 545 | + * color in the frame buffer when blending. The resulting pixel |
| 546 | + * color is given by the formula |
| 547 | + * (SRCBLEND * srcColor + DESTBLEND * destColor) for each RGB |
| 548 | + * component. For a particular platform, not all combinations |
| 549 | + * of blend function are allowed (see platform specific |
| 550 | + * restrictions). |
| 551 | + * Default: rwBLENDINVSRCALPHA. |
| 552 | + */ |
| 553 | + rwRENDERSTATEVERTEXALPHAENABLE, |
| 554 | + /**<Alpha blending on/off (always enabled on some platforms). |
| 555 | + * This is normally used in immediate mode to enable alpha blending |
| 556 | + * when vertex colors or texture rasters have transparency. Retained |
| 557 | + * mode pipelines will usually set this state based on material colors |
| 558 | + * and textures. |
| 559 | + * Default: FALSE. |
| 560 | + */ |
| 561 | + rwRENDERSTATEBORDERCOLOR, |
| 562 | + /**<Border color for \ref RwTextureAddressMode |
| 563 | + * \ref rwTEXTUREADDRESSBORDER. The value should be a packed |
| 564 | + * RwUInt32 in a platform specific format. The macro |
| 565 | + * RWRGBALONG(r, g, b, a) may be used to construct this using |
| 566 | + * 8-bit color components. |
| 567 | + * Default: RWRGBALONG(0, 0, 0, 0). |
| 568 | + */ |
| 569 | + rwRENDERSTATEFOGENABLE, |
| 570 | + /**<Fogging on/off (all polygons will be fogged). |
| 571 | + * Default: FALSE. |
| 572 | + */ |
| 573 | + rwRENDERSTATEFOGCOLOR, |
| 574 | + /**<Color used for fogging. The value should be a packed RwUInt32 |
| 575 | + * in a platform specific format. The macro RWRGBALONG(r, g, b, a) |
| 576 | + * may be used to construct this using 8-bit color components. |
| 577 | + * Default: RWRGBALONG(0, 0, 0, 0). |
| 578 | + */ |
| 579 | + rwRENDERSTATEFOGTYPE, |
| 580 | + /**<\ref RwFogType, the type of fogging to use. |
| 581 | + * Default: rwFOGTYPELINEAR. |
| 582 | + */ |
| 583 | + rwRENDERSTATEFOGDENSITY, |
| 584 | + /**<Fog density for \ref RwFogType of |
| 585 | + * \ref rwFOGTYPEEXPONENTIAL or \ref rwFOGTYPEEXPONENTIAL2. |
| 586 | + * The value should be a pointer to an RwReal in the |
| 587 | + * range 0 to 1. |
| 588 | + * Default: 1. |
| 589 | + */ |
| 590 | + rwRENDERSTATECULLMODE = 20, |
| 591 | + /**<\ref RwCullMode, for selecting front/back face culling, or |
| 592 | + * no culling. |
| 593 | + * Default: rwCULLMODECULLBACK. |
| 594 | + */ |
| 595 | + rwRENDERSTATESTENCILENABLE, |
| 596 | + /**<Stenciling on/off. |
| 597 | + * <i> Supported on Xbox, D3D8, D3D9, and OpenGL only. </i> |
| 598 | + * Default: FALSE. |
| 599 | + */ |
| 600 | + rwRENDERSTATESTENCILFAIL, |
| 601 | + /**<\ref RwStencilOperation used when the stencil test passes. |
| 602 | + * <i> Supported on Xbox, D3D8, D3D9, and OpenGL only. </i> |
| 603 | + * Default: rwSTENCILOPERATIONKEEP. |
| 604 | + */ |
| 605 | + rwRENDERSTATESTENCILZFAIL, |
| 606 | + /**<\ref RwStencilOperation used when the stencil test passes and |
| 607 | + * the depth test (z-test) fails. |
| 608 | + * <i> Supported on Xbox, D3D8, D3D9, and OpenGL only. </i> |
| 609 | + * Default: rwSTENCILOPERATIONKEEP. |
| 610 | + */ |
| 611 | + rwRENDERSTATESTENCILPASS, |
| 612 | + /**<\ref RwStencilOperation used when both the stencil and the depth |
| 613 | + * (z) tests pass. |
| 614 | + * <i> Supported on Xbox, D3D8, D3D9, and OpenGL only. </i> |
| 615 | + * Default: rwSTENCILOPERATIONKEEP. |
| 616 | + */ |
| 617 | + rwRENDERSTATESTENCILFUNCTION, |
| 618 | + /**<\ref RwStencilFunction for the stencil test. |
| 619 | + * <i> Supported on Xbox, D3D8, D3D9, and OpenGL only. </i> |
| 620 | + * Default: rwSTENCILFUNCTIONALWAYS. |
| 621 | + */ |
| 622 | + rwRENDERSTATESTENCILFUNCTIONREF, |
| 623 | + /**<Integer reference value for the stencil test. |
| 624 | + * <i> Supported on Xbox, D3D8, D3D9, and OpenGL only. </i> |
| 625 | + * Default: 0. |
| 626 | + */ |
| 627 | + rwRENDERSTATESTENCILFUNCTIONMASK, |
| 628 | + /**<Mask applied to the reference value and each stencil buffer |
| 629 | + * entry to determine the significant bits for the stencil test. |
| 630 | + * <i> Supported on Xbox, D3D8, D3D9, and OpenGL only. </i> |
| 631 | + * Default: 0xffffffff. |
| 632 | + */ |
| 633 | + rwRENDERSTATESTENCILFUNCTIONWRITEMASK, |
| 634 | + /**<Write mask applied to values written into the stencil buffer. |
| 635 | + * <i> Supported on Xbox, D3D8, D3D9, and OpenGL only. </i> |
| 636 | + * Default: 0xffffffff. |
| 637 | + */ |
| 638 | + rwRENDERSTATEALPHATESTFUNCTION, |
| 639 | + /**<\ref RwAlphaTestFunction for the alpha test. When a pixel fails, |
| 640 | + * neither the frame buffer nor the Z-buffer are updated. |
| 641 | + * Default: rwALPHATESTFUNCTIONGREATER (GameCube, Xbox, D3D8, D3D9 |
| 642 | + * and OpenGL). The default PS2 behaviour is to always update the |
| 643 | + * frame buffer and update the Z-buffer only if a greater than or |
| 644 | + * equal test passes. |
| 645 | + */ |
| 646 | + rwRENDERSTATEALPHATESTFUNCTIONREF, |
| 647 | + /**<Integer reference value for the alpha test. |
| 648 | + * <i> Range is 0 to 255, mapped to the platform's actual range </i> |
| 649 | + * Default: 128 (PS2) 0 (GameCube, Xbox, D3D8, D3D9 and OpenGL). |
| 650 | + */ |
| 651 | + |
| 652 | + rwRENDERSTATEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT |
| 653 | +}; |
| 654 | + |
| 655 | +enum RwCullMode |
| 656 | +{ |
| 657 | + rwCULLMODENACULLMODE = 0, |
| 658 | + |
| 659 | + rwCULLMODECULLNONE, |
| 660 | + /**<Both front and back-facing triangles are drawn. */ |
| 661 | + rwCULLMODECULLBACK, |
| 662 | + /**<Only front-facing triangles are drawn */ |
| 663 | + rwCULLMODECULLFRONT, |
| 664 | + /**<Only back-facing triangles are drawn */ |
| 665 | + |
| 666 | + rwCULLMODEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT |
| 667 | +}; |
| 668 | + |
490 | 669 | // RenderWare base types |
491 | 670 | struct RwBuffer |
492 | 671 | { |
@@ -532,14 +711,17 @@ struct RwError |
532 | 711 | /*****************************************************************************/ |
533 | 712 |
|
534 | 713 | typedef bool (*RwSystemFunc)(std::int32_t, void*, void*, std::int32_t); |
| 714 | +using RwRenderStateSetFunction = bool(*)(RwRenderState, void*); |
| 715 | +using RwRenderStateGetFunction = bool(*)(RwRenderState, void*); |
| 716 | + |
535 | 717 | struct RwDevice |
536 | 718 | { |
537 | 719 | float gammaCorrection; |
538 | 720 | RwSystemFunc fpSystem; |
539 | 721 | float zBufferNear; |
540 | 722 | float zBufferFar; |
541 | | - // RwRenderStateSetFunction fpRenderStateSet; |
542 | | - // RwRenderStateGetFunction fpRenderStateGet; |
| 723 | + RwRenderStateSetFunction fpRenderStateSet; |
| 724 | + RwRenderStateGetFunction fpRenderStateGet; |
543 | 725 | // RwIm2DRenderLineFunction fpIm2DRenderLine; |
544 | 726 | // RwIm2DRenderTriangleFunction fpIm2DRenderTriangle; |
545 | 727 | // RwIm2DRenderPrimitiveFunction fpIm2DRenderPrimitive; |
|
0 commit comments