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

OSGDVRSimpleLUTShader.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000,2001 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 #ifndef _OSGDVRSIMPLELUTSHADER_H_
00040 #define _OSGDVRSIMPLELUTSHADER_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include <OSGConfig.h>
00046 
00047 #include <OSGDVRSimpleLUTShaderBase.h>
00048 
00049 #include <OSGTextureChunk.h>
00050 #include <OSGFragmentProgramChunk.h>
00051 
00052 OSG_BEGIN_NAMESPACE
00053 
00057 class OSG_SYSTEMLIB_DLLMAPPING DVRSimpleLUTShader : 
00058     public DVRSimpleLUTShaderBase
00059 {
00060   private:
00061 
00062     typedef DVRSimpleLUTShaderBase Inherited;
00063 
00064     /*==========================  PUBLIC  =================================*/
00065   public:
00066 
00067     /*---------------------------------------------------------------------*/
00071     virtual void changed(BitVector  whichField, 
00072                          UInt32     from);
00073 
00075     /*---------------------------------------------------------------------*/
00079     virtual void dump(      UInt32     uiIndent = 0, 
00080                       const BitVector  bvFlags  = 0) const;
00081 
00083     /*---------------------------------------------------------------------*/
00087     // Callback to set up shader - register textures here
00088     virtual bool initialize   (DVRVolume      *volume, 
00089                                DrawActionBase *action);
00090     
00091     // Callback before any slice is rendered - setup per volume
00092     virtual void activate     (DVRVolume      *volume, 
00093                                DrawActionBase *action);
00094 
00095     // Callback before any brick - state setup per brick
00096     virtual void brickActivate(DVRVolume      *volume, 
00097                                DrawActionBase *action, 
00098                                Brick          *brick );
00099 
00100     // Callback after all rendering of the volume is done
00101     virtual void deactivate   (DVRVolume      *volume, 
00102                                DrawActionBase *action);
00103 
00104     // Callback to clean up shader resources
00105     virtual void cleanup      (DVRVolume      *volume, 
00106                                DrawActionBase *action);
00107     
00109     /*=========================  PROTECTED  ===============================*/
00110 
00111   protected:
00112 
00113     // Variables should all be in DVRSimpleLUTShaderBase.
00114 
00115     UInt8                   m_nTexturePaletteMode;
00116     Int8                    m_nTextureMode; 
00117     FragmentProgramChunkPtr m_pFragProg;
00118     TextureChunkPtr         m_pDepTexture;
00119 
00120     enum LutMode 
00121     {
00122         LM_AUTO = 0,
00123         LM_TABLE_SGI,
00124         LM_PALETTE_EXT,
00125         LM_DEPENDENT,
00126         LM_FRAGPROG,
00127         LM_RELOAD,
00128         LM_NO
00129     };
00130     
00131     /*---------------------------------------------------------------------*/
00135     DVRSimpleLUTShader(void);
00136     DVRSimpleLUTShader(const DVRSimpleLUTShader &source);
00137 
00139     /*---------------------------------------------------------------------*/
00143     virtual ~DVRSimpleLUTShader(void); 
00144 
00146     /*---------------------------------------------------------------------*/
00150     // Returns suitable lookup table mode and texture formate for 
00151     // graphics adapter
00152     void getPaletteFormat(DrawActionBase *action, 
00153                           UInt8           lutMode,
00154                           GLenum         &internalFormat, 
00155                           GLenum         &externalFormat);
00156 
00157     // Checks whether the selected mode is supported
00158     bool isModeSupported (DrawActionBase *action, 
00159                           UInt8           mode, 
00160                           Int8            textureMode);
00161     // Automatically select a lookup table mode
00162     UInt8 selectMode     (DrawActionBase *action, 
00163                           Int8            textureMode);
00164     
00165     // Enable/disable palette
00166     void enablePalette (void);
00167     void disablePalette(void);
00168 
00169     // Handle dependent texture
00170     void initDependentTexture   (      Int32  size);
00171     void updateDependentTexture (      Int32  size, 
00172                                  const UInt8 *data);
00173     void destroyDependentTexture(      void       );
00174 
00175     // Register combiners
00176     void setupAlphaCorrectionRegisterCombiners(DrawActionBase *action);
00177 
00179     /*==========================  PRIVATE  ================================*/
00180 
00181   private:
00182 
00183     // fragment programs used by fragment shader mode
00184     static char _fragProg2D[];   
00185     static char _fragProg3D[];
00186     static char _fragProg2DMulti[];
00187     
00188     // extension indices for used extensions;
00189     static UInt32 _sgiTexColorTable;
00190     static UInt32 _extPalettedTexture;
00191     static UInt32 _extSharedPalettedTexture;
00192     static UInt32 _arbMultitexture;
00193     static UInt32 _nvTextureShader2;
00194     static UInt32 _arbFragmentProgram;
00195     static UInt32 _nvRegisterCombiners;
00196 
00197     // extension indices for used fucntions;
00198     static UInt32 _funcColorTableSGI;
00199     static UInt32 _funcColorTableEXT;
00200     static UInt32 _funcActiveTextureARB;
00201     static UInt32 _funcFinalCombinerInputNV;
00202     static UInt32 _funcCombinerInputNV;
00203     static UInt32 _funcCombinerOutputNV;
00204     
00205     friend class FieldContainer;
00206     friend class DVRSimpleLUTShaderBase;
00207 
00208     static void initMethod(void);
00209 
00210     // prohibit default functions (move to 'public' if you need one)
00211     void operator =(const DVRSimpleLUTShader &source);
00212 };
00213 
00214 typedef DVRSimpleLUTShader *DVRSimpleLUTShaderP;
00215 
00216 OSG_END_NAMESPACE
00217 
00218 #include <OSGDVRSimpleLUTShader.inl>
00219 #include <OSGDVRSimpleLUTShaderBase.inl>
00220 
00221 #define OSGDVRSIMPLELUTSHADER_HEADER_CVSID "@(#)$Id: $"
00222 
00223 #endif /* _OSGDVRSIMPLELUTSHADER_H_ */

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