|
22 | 22 | #include "textureContext.h" |
23 | 23 | #include "renderBuffer.h" |
24 | 24 | #include "colorAttrib.h" |
| 25 | +#include "renderState.h" |
| 26 | +#include "depthWriteAttrib.h" |
| 27 | +#include "colorWriteAttrib.h" |
25 | 28 |
|
26 | 29 | #include "clockObject.h" |
27 | 30 | #include "geomNode.h" |
@@ -892,6 +895,101 @@ void GraphicsStateGuardian:: |
892 | 895 | end_decal(GeomNode *) { |
893 | 896 | } |
894 | 897 |
|
| 898 | +//////////////////////////////////////////////////////////////////// |
| 899 | +// Function: GraphicsStateGuardian::polygon_offset_decals |
| 900 | +// Access: Public, Virtual |
| 901 | +// Description: Returns true if this GSG can implement decals using a |
| 902 | +// PolygonOffsetAttrib, or false if that is unreliable |
| 903 | +// and the three-step rendering process should be used |
| 904 | +// instead. |
| 905 | +//////////////////////////////////////////////////////////////////// |
| 906 | +bool GraphicsStateGuardian:: |
| 907 | +polygon_offset_decals() { |
| 908 | + return false; |
| 909 | +} |
| 910 | + |
| 911 | +//////////////////////////////////////////////////////////////////// |
| 912 | +// Function: GraphicsStateGuardian::begin_decal_base_first |
| 913 | +// Access: Public, Virtual |
| 914 | +// Description: Called during draw to begin a three-step rendering |
| 915 | +// phase to draw decals. The first step, |
| 916 | +// begin_decal_base_first(), is called prior to drawing the |
| 917 | +// base geometry. It should set up whatever internal |
| 918 | +// state is appropriate, as well as returning a |
| 919 | +// RenderState object that should be applied to the base |
| 920 | +// geometry for rendering. |
| 921 | +//////////////////////////////////////////////////////////////////// |
| 922 | +CPT(RenderState) GraphicsStateGuardian:: |
| 923 | +begin_decal_base_first() { |
| 924 | + // Turn off writing the depth buffer to render the base geometry. |
| 925 | + static CPT(RenderState) decal_base_first; |
| 926 | + if (decal_base_first == (const RenderState *)NULL) { |
| 927 | + decal_base_first = RenderState::make |
| 928 | + (DepthWriteAttrib::make(DepthWriteAttrib::M_off)); |
| 929 | + } |
| 930 | + return decal_base_first; |
| 931 | +} |
| 932 | + |
| 933 | +//////////////////////////////////////////////////////////////////// |
| 934 | +// Function: GraphicsStateGuardian::begin_decal_nested |
| 935 | +// Access: Public, Virtual |
| 936 | +// Description: Called during draw to begin a three-step rendering |
| 937 | +// phase to draw decals. The second step, |
| 938 | +// begin_decal_nested(), is called after drawing the |
| 939 | +// base geometry and prior to drawing any of the nested |
| 940 | +// decal geometry that is to be applied to the base |
| 941 | +// geometry. |
| 942 | +//////////////////////////////////////////////////////////////////// |
| 943 | +CPT(RenderState) GraphicsStateGuardian:: |
| 944 | +begin_decal_nested() { |
| 945 | + // We keep the depth buffer off during this operation, although |
| 946 | + // perhaps it doesn't matter so much here. |
| 947 | + static CPT(RenderState) decal_nested; |
| 948 | + if (decal_nested == (const RenderState *)NULL) { |
| 949 | + decal_nested = RenderState::make |
| 950 | + (DepthWriteAttrib::make(DepthWriteAttrib::M_off)); |
| 951 | + } |
| 952 | + return decal_nested; |
| 953 | +} |
| 954 | + |
| 955 | +//////////////////////////////////////////////////////////////////// |
| 956 | +// Function: GraphicsStateGuardian::begin_decal_base_second |
| 957 | +// Access: Public, Virtual |
| 958 | +// Description: Called during draw to begin a three-step rendering |
| 959 | +// phase to draw decals. The third step, |
| 960 | +// begin_decal_base_second(), is called after drawing the |
| 961 | +// base geometry and the nested decal geometry, and |
| 962 | +// prior to drawing the base geometry one more time (if |
| 963 | +// needed). |
| 964 | +// |
| 965 | +// It should return a RenderState object appropriate for |
| 966 | +// rendering the base geometry the second time, or NULL |
| 967 | +// if it is not necessary to re-render the base |
| 968 | +// geometry. |
| 969 | +//////////////////////////////////////////////////////////////////// |
| 970 | +CPT(RenderState) GraphicsStateGuardian:: |
| 971 | +begin_decal_base_second() { |
| 972 | + // Now let the depth buffer go back on, but turn off writing the |
| 973 | + // color buffer to render the base geometry after the second pass. |
| 974 | + static CPT(RenderState) decal_base_second; |
| 975 | + if (decal_base_second == (const RenderState *)NULL) { |
| 976 | + decal_base_second = RenderState::make |
| 977 | + (ColorWriteAttrib::make(ColorWriteAttrib::M_off)); |
| 978 | + } |
| 979 | + return decal_base_second; |
| 980 | +} |
| 981 | + |
| 982 | +//////////////////////////////////////////////////////////////////// |
| 983 | +// Function: GraphicsStateGuardian::finish_decal |
| 984 | +// Access: Public, Virtual |
| 985 | +// Description: Called during draw to clean up after decals are |
| 986 | +// finished. |
| 987 | +//////////////////////////////////////////////////////////////////// |
| 988 | +void GraphicsStateGuardian:: |
| 989 | +finish_decal() { |
| 990 | + // No need to do anything special here. |
| 991 | +} |
| 992 | + |
895 | 993 | //////////////////////////////////////////////////////////////////// |
896 | 994 | // Function: GraphicsStateGuardian::get_internal_coordinate_system |
897 | 995 | // Access: Public, Virtual |
|
0 commit comments