00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include <OSGGL.h>
00049
00050 #include "OSGDrawActionBase.h"
00051 #include "OSGWindow.h"
00052
00053 #include "OSGStencilChunk.h"
00054
00055 OSG_USING_NAMESPACE
00056
00057
00058
00059
00060
00066
00067
00068
00069 StateChunkClass StencilChunk::_class("Stencil");
00070
00071
00072
00073
00074
00075 void StencilChunk::initMethod (void)
00076 {
00077 Inherited::initMethod();
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 StencilChunk::StencilChunk(void) :
00092 Inherited()
00093 {
00094 }
00095
00096 StencilChunk::StencilChunk(const StencilChunk &source) :
00097 Inherited(source)
00098 {
00099 }
00100
00101 StencilChunk::~StencilChunk(void)
00102 {
00103 }
00104
00105
00106 const StateChunkClass *StencilChunk::getClass(void) const
00107 {
00108 return &_class;
00109 }
00110
00111 void StencilChunk::changed(BitVector whichField, UInt32 origin)
00112 {
00113 Inherited::changed(whichField, origin);
00114 }
00115
00116 void StencilChunk::dump( UInt32 OSG_CHECK_ARG(uiIndent),
00117 const BitVector OSG_CHECK_ARG(bvFlags ) ) const
00118 {
00119 SLOG << "Dump StencilChunk NI" << std::endl;
00120 }
00121
00122
00123
00124 void StencilChunk::activate(DrawActionBase *action, UInt32)
00125 {
00126 if (_sfStencilFunc.getValue() != GL_NONE)
00127 {
00128 glEnable(GL_STENCIL_TEST);
00129
00130 if (_sfClearBuffer.getValue() == 1)
00131 {
00132 glClearStencil(0x0);
00133 glClear(GL_STENCIL_BUFFER_BIT);
00134 }
00135
00136 glStencilMask( _sfBitMask.getValue() );
00137
00138 glStencilFunc( _sfStencilFunc.getValue(),
00139 _sfStencilValue.getValue(),
00140 _sfStencilMask.getValue() );
00141 glStencilOp( _sfStencilOpFail.getValue(),
00142 _sfStencilOpZFail.getValue(),
00143 _sfStencilOpZPass.getValue() );
00144 }
00145 }
00146
00147 void StencilChunk::changeFrom( DrawActionBase *action,
00148 StateChunk *old,
00149 UInt32 index )
00150 {
00151 old->deactivate( action, index );
00152 activate( action, index );
00153 }
00154
00155 void StencilChunk::deactivate(DrawActionBase *action, UInt32 )
00156 {
00157 if (_sfStencilFunc.getValue() != GL_NONE)
00158 {
00159 if (_sfClearBuffer.getValue() == 2)
00160 {
00161 glClearStencil(0x0);
00162 glClear(GL_STENCIL_BUFFER_BIT);
00163 }
00164
00165 glDisable(GL_STENCIL_TEST);
00166 }
00167 }
00168
00169
00170
00171 Real32 StencilChunk::switchCost(StateChunk *)
00172 {
00173 return 0;
00174 }
00175
00176 bool StencilChunk::operator < (const StateChunk &other) const
00177 {
00178 return this < &other;
00179 }
00180
00181 bool StencilChunk::operator == (const StateChunk &other) const
00182 {
00183 StencilChunk const *tother = dynamic_cast<StencilChunk const*>(&other);
00184
00185 if (!tother)
00186 return false;
00187
00188 if (tother == this)
00189 return true;
00190
00191 if (getStencilFunc() != tother->getStencilFunc() ||
00192 getStencilValue() != tother->getStencilValue() ||
00193 getStencilMask() != tother->getStencilMask() ||
00194 getStencilOpFail() != tother->getStencilOpFail() ||
00195 getStencilOpZFail() != tother->getStencilOpZFail() ||
00196 getStencilOpZPass() != tother->getStencilOpZPass() ||
00197 getClearBuffer() != tother->getClearBuffer())
00198 return false;
00199
00200 return true;
00201 }
00202
00203 bool StencilChunk::operator != (const StateChunk &other) const
00204 {
00205 return ! (*this == other);
00206 }
00207
00208
00209
00210
00211
00212 #ifdef OSG_SGI_CC
00213 #pragma set woff 1174
00214 #endif
00215
00216 #ifdef OSG_LINUX_ICC
00217 #pragma warning( disable : 177 )
00218 #endif
00219
00220 namespace
00221 {
00222 static Char8 cvsid_cpp [] = "@(#)$Id: OSGStencilChunk.cpp,v 1.2 2006/09/08 13:45:30 yjung Exp $";
00223 static Char8 cvsid_hpp [] = OSGSTENCILCHUNKBASE_HEADER_CVSID;
00224 static Char8 cvsid_inl [] = OSGSTENCILCHUNKBASE_INLINE_CVSID;
00225
00226 static Char8 cvsid_fields_hpp[] = OSGSTENCILCHUNKFIELDS_HEADER_CVSID;
00227 }
00228
00229 #ifdef __sgi
00230 #pragma reset woff 1174
00231 #endif
00232