Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGDepthChunk.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *               Copyright (C) 2000-2002 by the OpenSG Forum                 *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 //---------------------------------------------------------------------------
00040 //  Includes
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  *                            Description                                  *
00059 \***************************************************************************/
00060 
00070 /***************************************************************************\
00071  *                           Class variables                               *
00072 \***************************************************************************/
00073 
00074 StateChunkClass DepthChunk::_class("Depth");
00075 
00076 /***************************************************************************\
00077  *                           Class methods                                 *
00078 \***************************************************************************/
00079 
00080 void DepthChunk::initMethod (void)
00081 {
00082 }
00083 
00084 
00085 /***************************************************************************\
00086  *                           Instance methods                              *
00087 \***************************************************************************/
00088 
00089 /*-------------------------------------------------------------------------*\
00090  -  private                                                                 -
00091 \*-------------------------------------------------------------------------*/
00092 
00093 /*----------------------- constructors & destructors ----------------------*/
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 /*------------------------- Chunk Class Access ---------------------------*/
00110 
00111 const StateChunkClass *DepthChunk::getClass(void) const
00112 {
00113     return &_class;
00114 }
00115 
00116 /*----------------------------- class specific ----------------------------*/
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 /*------------------------------ State ------------------------------------*/
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 /*-------------------------- Comparison -----------------------------------*/
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 /*                              cvs id's                                  */
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 

Generated on Thu Aug 25 04:02:32 2005 for OpenSG by  doxygen 1.4.3