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

OSGSHLChunk.h

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 #ifndef _OSGSHLCHUNK_H_
00040 #define _OSGSHLCHUNK_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include <OSGConfig.h>
00046 
00047 #include <string>
00048 #include <vector>
00049 #include <map>
00050 
00051 #include "OSGDrawActionBase.h"
00052 #include "OSGWindow.h"
00053 
00054 #include <OSGSHLChunkBase.h>
00055 
00056 OSG_BEGIN_NAMESPACE
00057 
00062 class OSG_SYSTEMLIB_DLLMAPPING SHLChunk : public SHLChunkBase
00063 {
00064   private:
00065 
00066     typedef SHLChunkBase Inherited;
00067 
00068     /*==========================  PUBLIC  =================================*/
00069   public:
00070 
00071     virtual const StateChunkClass * getClass         (void) const;
00072 
00073     /*---------------------------------------------------------------------*/
00077     virtual void changed(BitVector  whichField,
00078                          UInt32     origin    );
00079 
00081     /*---------------------------------------------------------------------*/
00085     virtual void dump(      UInt32     uiIndent = 0,
00086                       const BitVector  bvFlags  = 0) const;
00087 
00089     /*---------------------------------------------------------------------*/
00093     void updateParameters(Window *win, const MFShaderParameterPtr &parameters,
00094                           bool useProgram = true, bool force = false,
00095                           bool keepProgramActive = false);
00096 
00098     /*---------------------------------------------------------------------*/
00102     virtual void activate   ( DrawActionBase * action, UInt32 index = 0 );
00103 
00104     virtual void changeFrom ( DrawActionBase * action, StateChunk * old,
00105                              UInt32 index = 0 );
00106 
00107     virtual void deactivate ( DrawActionBase * action, UInt32 index = 0 );
00108 
00110     /*---------------------------------------------------------------------*/
00114     virtual Real32 switchCost  ( StateChunk * chunk );
00115 
00116     virtual bool   operator <  (const StateChunk &other) const;
00117 
00118     virtual bool   operator == (const StateChunk &other) const;
00119     virtual bool   operator != (const StateChunk &other) const;
00120 
00122     /*---------------------------------------------------------------------*/
00126     typedef GLint (OSG_APIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC)
00127             (GLuint programObj, const char *name);
00128 
00129     typedef void (*paramtercbfp) (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00130                                   DrawActionBase *action, GLuint program);
00131 
00132     void addParameterCallback(const char *name, paramtercbfp fp);
00133 
00135     /*---------------------------------------------------------------------*/
00139     static inline UInt32 getFuncUniform1i(void);
00140     static inline UInt32 getFuncUniform2iv(void);
00141     static inline UInt32 getFuncUniform3iv(void);
00142     static inline UInt32 getFuncUniform4iv(void);
00143 
00144     static inline UInt32 getFuncUniform1f(void);
00145     static inline UInt32 getFuncUniform2fv(void);
00146     static inline UInt32 getFuncUniform3fv(void);
00147     static inline UInt32 getFuncUniform4fv(void);
00148 
00149     static inline UInt32 getFuncUniformMatrix4fv(void);
00150 
00151     static inline UInt32 getFuncGetUniformiv(void);
00152     static inline UInt32 getFuncGetUniformfv(void);
00153 
00155     /*---------------------------------------------------------------------*/
00159     static void setClusterId(Int32 id);
00160 
00162     /*=========================  PROTECTED  ===============================*/
00163   protected:
00164 
00165     // Variables should all be in SHLChunkBase.
00166 
00167     void onCreate(const SHLChunk *source = NULL);
00168     void onDestroy(void);
00169 
00170     /*---------------------------------------------------------------------*/
00174     SHLChunk(void);
00175     SHLChunk(const SHLChunk &source);
00176 
00178     /*---------------------------------------------------------------------*/
00182     virtual ~SHLChunk(void);
00183 
00186     /*==========================  PRIVATE  ================================*/
00187   private:
00188 
00189     friend class FieldContainer;
00190     friend class SHLChunkBase;
00191 
00192     // class. Used for indexing in State
00193     static StateChunkClass _class;
00194 
00195     /*---------------------------------------------------------------------*/
00199     static UInt32 _shl_extension;
00200     static UInt32 _cg_extension;
00201 
00202     static UInt32 _funcCreateProgramObject;
00203     static UInt32 _funcCreateShaderObject;
00204     static UInt32 _funcDeleteObject;
00205     static UInt32 _funcDetachObject;
00206     static UInt32 _funcAttachObject;
00207 
00208     static UInt32 _funcShaderSource;
00209     static UInt32 _funcCompileShader;
00210     static UInt32 _funcLinkProgram;
00211     static UInt32 _funcGetInfoLog;
00212     static UInt32 _funcUseProgramObject;
00213 
00214     static UInt32 _funcGetObjectParameteriv;
00215     static UInt32 _funcGetObjectParameterfv;
00216     static UInt32 _funcGetUniformLocation;
00217 
00218     static UInt32 _funcBindAttribLocation;
00219     static UInt32 _funcGetAttribLocation;
00220 
00221     static UInt32 _funcUniform1i;
00222     static UInt32 _funcUniform2iv;
00223     static UInt32 _funcUniform3iv;
00224     static UInt32 _funcUniform4iv;
00225     
00226     static UInt32 _funcUniform1f;
00227     static UInt32 _funcUniform2fv;
00228     static UInt32 _funcUniform3fv;
00229     static UInt32 _funcUniform4fv;
00230 
00231     static UInt32 _funcUniformMatrix4fv;
00232 
00233     static UInt32 _funcGetUniformiv;
00234     static UInt32 _funcGetUniformfv;
00235 
00236     static Int32 _clusterId;
00237 
00240     static void initMethod(void);
00241 
00242     void handleGL(Window *win, UInt32 id);
00243 
00244     // prohibit default functions (move to 'public' if you need one)
00245     void operator =(const SHLChunk &source);
00246 
00247     void updateProgram(Window *win);
00248     void checkOSGParameters(void);
00249     void updateOSGParameters(DrawActionBase *action, GLuint program);
00250 
00251     static void updateCameraOrientation (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00252                                          DrawActionBase *action, GLuint program);
00253     static void updateCameraPosition    (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00254                                          DrawActionBase *action, GLuint program);
00255     static void updateViewMatrix        (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00256                                          DrawActionBase *action, GLuint program);
00257     static void updateInvViewMatrix     (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00258                                          DrawActionBase *action, GLuint program);
00259     static void updateStereoLeftEye     (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00260                                          DrawActionBase *action, GLuint program);
00261     static void updateClusterId         (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00262                                          DrawActionBase *action, GLuint program);
00263     static void updateActiveLightsMask  (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00264                                          DrawActionBase *action, GLuint program);
00265     static void updateLight0Active      (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00266                                          DrawActionBase *action, GLuint program);
00267     static void updateLight1Active      (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00268                                          DrawActionBase *action, GLuint program);
00269     static void updateLight2Active      (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00270                                          DrawActionBase *action, GLuint program);
00271     static void updateLight3Active      (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00272                                          DrawActionBase *action, GLuint program);
00273     static void updateLight4Active      (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00274                                          DrawActionBase *action, GLuint program);
00275     static void updateLight5Active      (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00276                                          DrawActionBase *action, GLuint program);
00277     static void updateLight6Active      (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00278                                          DrawActionBase *action, GLuint program);
00279     static void updateLight7Active      (PFNGLGETUNIFORMLOCATIONARBPROC getUniformLocation,
00280                                          DrawActionBase *action, GLuint program);
00281 
00282     std::vector<paramtercbfp> _osgParametersCallbacks;
00283 
00284     UInt32 _oldParameterSize;
00285 
00286     typedef std::map<std::string, paramtercbfp> userParameterCallbacksMap;
00287     userParameterCallbacksMap _userParameterCallbacks;
00288 };
00289 
00290 typedef SHLChunk *SHLChunkP;
00291 
00292 OSG_END_NAMESPACE
00293 
00294 #include <OSGSHLChunkBase.inl>
00295 #include <OSGSHLChunk.inl>
00296 
00297 #define OSGSHLCHUNK_HEADER_CVSID "@(#)$Id: OSGSHLChunk.h,v 1.21 2005/07/29 11:39:17 a-m-z Exp $"
00298 
00299 #endif /* _OSGCGCHUNK_H_ */

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