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 "OSGDepthChunk.h"
00054
00055 OSG_USING_NAMESPACE
00056
00057
00058
00059
00060
00070
00071
00072
00073
00074 StateChunkClass DepthChunk::_class("Depth");
00075
00076
00077
00078
00079
00080 void DepthChunk::initMethod (void)
00081 {
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 DepthChunk::DepthChunk(void) :
00096 Inherited()
00097 {
00098 }
00099
00100 DepthChunk::DepthChunk(const DepthChunk &source) :
00101 Inherited(source)
00102 {
00103 }
00104
00105 DepthChunk::~DepthChunk(void)
00106 {
00107 }
00108
00109
00110
00111 const StateChunkClass *DepthChunk::getClass(void) const
00112 {
00113 return &_class;
00114 }
00115
00116
00117
00118 void DepthChunk::changed(BitVector whichField, UInt32 origin)
00119 {
00120 Inherited::changed(whichField, origin);
00121 }
00122
00123 void DepthChunk::dump( UInt32 ,
00124 const BitVector ) const
00125 {
00126 SLOG << "Dump DepthChunk NI" << std::endl;
00127 }
00128
00129
00130
00131
00132 void DepthChunk::activate(DrawActionBase *, UInt32)
00133 {
00134 if(_sfFunc.getValue() != GL_NONE)
00135 {
00136 glDepthFunc(_sfFunc.getValue());
00137 }
00138
00139 if(getNear() >= 0 && getFar() >= 0)
00140 {
00141 glDepthRange(getNear(), getFar());
00142 }
00143
00144 if(getEnable())
00145 {
00146 glEnable(GL_DEPTH_TEST);
00147 }
00148 else
00149 {
00150 glDisable(GL_DEPTH_TEST);
00151 }
00152
00153 glDepthMask(!getReadOnly());
00154 }
00155
00156 void DepthChunk::changeFrom( DrawActionBase *act, StateChunk * old_chunk, UInt32 index )
00157 {
00158 old_chunk->deactivate( act, index );
00159 activate( act, index );
00160 }
00161
00162 void DepthChunk::deactivate ( DrawActionBase *, UInt32 )
00163 {
00164 if(_sfFunc.getValue() != GL_NONE)
00165 {
00166 glDepthFunc(GL_LEQUAL);
00167 }
00168
00169 if(getNear() >= 0 && getFar() >= 0)
00170 {
00171 glDepthRange(0, 1);
00172 }
00173
00174 if(!getEnable())
00175 {
00176 glEnable(GL_DEPTH_TEST);
00177 }
00178
00179 glDepthMask(GL_TRUE);
00180 }
00181
00182
00183
00184 Real32 DepthChunk::switchCost(StateChunk *)
00185 {
00186 return 0;
00187 }
00188
00192 bool DepthChunk::operator < (const StateChunk &other) const
00193 {
00194 return this < &other;
00195 }
00196
00200 bool DepthChunk::operator == (const StateChunk &other) const
00201 {
00202 DepthChunk const *tother = dynamic_cast<DepthChunk const*>(&other);
00203
00204 if(!tother)
00205 return false;
00206
00207 if(tother == this)
00208 return true;
00209
00210 if(getEnable() != tother->getEnable() ||
00211 getFunc() != tother->getFunc() ||
00212 getFar() != tother->getFar() ||
00213 getNear() != tother->getNear() ||
00214 getReadOnly() != tother->getReadOnly() )
00215 return false;
00216
00217 return true;
00218 }
00219
00223 bool DepthChunk::operator != (const StateChunk &other) const
00224 {
00225 return ! (*this == other);
00226 }
00227
00228
00229
00230
00231 #ifdef OSG_SGI_CC
00232 #pragma set woff 1174
00233 #endif
00234
00235 #ifdef OSG_LINUX_ICC
00236 #pragma warning( disable : 177 )
00237 #endif
00238
00239 namespace
00240 {
00241 static Char8 cvsid_cpp [] = "@(#)$Id: OSGDepthChunk.cpp,v 1.2 2005/06/07 09:35:15 yjung Exp $";
00242 static Char8 cvsid_hpp [] = OSGDEPTHCHUNKBASE_HEADER_CVSID;
00243 static Char8 cvsid_inl [] = OSGDEPTHCHUNKBASE_INLINE_CVSID;
00244
00245 static Char8 cvsid_fields_hpp[] = OSGDEPTHCHUNKFIELDS_HEADER_CVSID;
00246 }
00247
00248 #ifdef __sgi
00249 #pragma reset woff 1174
00250 #endif
00251