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 #ifndef _OSGPROGRAMCHUNK_H_
00040 #define _OSGPROGRAMCHUNK_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #include <OSGConfig.h>
00046
00047 #include <iostream>
00048
00049 #include <OSGProgramChunkBase.h>
00050
00051 OSG_BEGIN_NAMESPACE
00052
00057 class OSG_SYSTEMLIB_DLLMAPPING ProgramChunk : public ProgramChunkBase
00058 {
00059 private:
00060
00061 typedef ProgramChunkBase Inherited;
00062
00063
00064 public:
00065
00066
00070 virtual const StateChunkClass * getClass (void) const;
00071
00073
00077 inline static UInt32 getStaticClassId (void);
00078 inline static const StateChunkClass * getStaticClass (void);
00079
00081
00085 virtual void changed(BitVector whichField,
00086 UInt32 origin );
00087
00089
00093 virtual void dump( UInt32 uiIndent = 0,
00094 const BitVector bvFlags = 0) const;
00095
00097
00101 bool read (const char *file);
00102 bool read (std::istream &stream);
00103
00104 bool addParameter(const char *name,
00105 Int16 index);
00106 inline bool addParameter(const char *name,
00107 Int16 index,
00108 const Vec4f &value);
00109
00110 const Vec4f &getParameter( Int16 index);
00111 inline const Vec4f &getParameter(const char *name );
00112 inline const Vec4f &getParameter(const std::string &name );
00113
00114 bool setParameter( Int16 index, const Vec4f& value);
00115 inline bool setParameter(const char *name, const Vec4f& value);
00116 inline bool setParameter(const std::string &name,
00117 const Vec4f & value);
00118
00119
00120 inline Int16 findParameter(const char *name);
00121 Int16 findParameter(const std::string &name);
00122
00124
00128 virtual void activate ( DrawActionBase * action, UInt32 index = 0 );
00129
00130 virtual void changeFrom ( DrawActionBase * action, StateChunk * old,
00131 UInt32 index = 0 );
00132
00133 virtual void deactivate ( DrawActionBase * action, UInt32 index = 0 );
00134
00135 virtual bool isTransparent ( void ) const;
00136
00138
00142 virtual Real32 switchCost ( StateChunk * chunk );
00143
00144 virtual bool operator < (const StateChunk &other) const;
00145
00146 virtual bool operator == (const StateChunk &other) const;
00147 virtual bool operator != (const StateChunk &other) const;
00148
00151
00152 protected:
00153
00154
00155
00156
00160 void onCreate(const ProgramChunk *source = NULL);
00161
00163
00167 ProgramChunk(void);
00168 ProgramChunk(const ProgramChunk &source);
00169
00171
00175 virtual ~ProgramChunk(void);
00176
00178
00182 virtual UInt32 getExtension(void) const;
00183 virtual GLenum getTarget(void) const;
00184 virtual const char *getTargetName(void) const;
00185
00186 void printCompileError(Window *win, UInt32 idstatus);
00187
00190
00194 void handleGL(Window *win, UInt32 id, GLenum target, UInt32 extension);
00195
00198
00199 private:
00200
00201 friend class FieldContainer;
00202 friend class ProgramChunkBase;
00203
00204 static StateChunkClass _class;
00205
00206
00210 static UInt32 _funcGenPrograms;
00211 static UInt32 _funcProgramString;
00212 static UInt32 _funcBindProgram;
00213 static UInt32 _funcDeletePrograms;
00214 static UInt32 _funcProgramLocalParameter4fv;
00215 static UInt32 _funcGetProgramiv;
00216
00219 static void initMethod(void);
00220
00221
00222
00223 void operator =(const ProgramChunk &source);
00224 };
00225
00226 typedef ProgramChunk *ProgramChunkP;
00227
00228 OSG_END_NAMESPACE
00229
00230 #include <OSGProgramChunkBase.inl>
00231 #include <OSGProgramChunk.inl>
00232
00233 #define OSGPROGRAMCHUNK_HEADER_CVSID "@(#)$Id: $"
00234
00235 #endif