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

program.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                        program.h  -  Pipeline programs
00003                              -------------------
00004     begin       : Mon May 05 2003
00005     copyright   : (C) 2003 by Reality Rift Studios
00006     email       : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, program.h
00020 
00021  The Initial Developer of the Original Code is Matt Holmes.
00022  Portions created by Matt Holmes are Copyright (C) 2003
00023  Matt Holmes. All Rights Reserved.
00024 
00025  Contributors: Mattias Jansson (mattias@realityrift.com)
00026                Cody Russell (cody [at] jhu.edu)
00027 
00028  ***************************************************************************/
00029 
00030 #ifndef __NEPROGRAM_H
00031 #define __NEPROGRAM_H
00032 
00033 
00040 #include "base.h"
00041 #include "hashtable.h"
00042 #include "loadableentity.h"
00043 #include "pointer.h"
00044 
00045 
00046 namespace NeoEngine
00047 {
00048 
00049 
00050 // External classes
00051 class RenderDevice;
00052 class Vector3d;
00053 class Color;
00054 class Matrix;
00055 class Quaternion;
00056 
00057 
00058 // Forward declarations
00059 class Program;
00060 
00061 
00068 class NEOENGINE_API ProgramParam
00069 {
00070     public:
00071 
00076         enum PROGRAMPARAMTYPE
00077         {
00078           PPT_NULL,
00079           PPT_SYSTEM,
00080           PPT_FLOAT4,
00081           PPT_VECTOR,
00082           PPT_COLOR,
00083           PPT_QUAT,
00084           PPT_MATRIX
00085         };
00086 
00091         enum PROGRAMSYSTEMPARAM
00092         {
00094           SYSTEMMATRIXPARAM                          = 0x00010000,
00095 
00097           PSP_MODEL_MATRIX                           = 0x00010001,
00098 
00100           PSP_VIEW_MATRIX                            = 0x00010002,
00101 
00103           PSP_PROJECTION_MATRIX                      = 0x00010003,
00104 
00106           PSP_MODELVIEW_MATRIX                       = 0x00010004,
00107 
00109           PSP_MODELVIEWPROJ_MATRIX                   = 0x00010005,
00110 
00112           PSP_INV_MODEL_MATRIX                       = 0000010006,
00113 
00114 
00116           LIGHTPARAM                                 = 0x00020000,
00117 
00119           PSP_LIGHT_POSITION                         = 0x00020001,
00120 
00122           PSP_LIGHT_DIFFUSE_COLOR                    = 0x00020002,
00123 
00125           PSP_LIGHT_AMBIENT_COLOR                    = 0x00020003,
00126 
00127 
00129           PSP_TOTAL_LIGHT_AMBIENT_COLOR              = 0x00040001
00130         };
00131 
00133         unsigned int                                m_uiIndex;
00134 
00136         PROGRAMPARAMTYPE                            m_eType;
00137 
00139         union ProgramParamValue
00140         {
00142           PROGRAMSYSTEMPARAM                        m_eSystemID;
00143 
00145           float                                     m_afFloat[4];
00146 
00148           const Vector3d                           *m_pkVector;
00149 
00151           const Color                              *m_pkColor;
00152 
00154           const Quaternion                         *m_pkQuaternion;
00155 
00157           const Matrix                             *m_pkMatrix;
00158 
00159         }                                           m_Value;
00160 
00162         unsigned int                                m_uiLight;
00163 };
00164 
00165 
00166 HashTableExport( ProgramParam );
00167 
00168 
00169 typedef HashTable<ProgramParam> ProgramParamHash;
00170 
00171 
00172 #ifdef WIN32
00173 #  ifndef __HAVE_VECTOR_NEPROGRAMPARAM
00174      UDTVectorEXPIMP( class ProgramParam* );
00175 #    define __HAVE_VECTOR_NEPROGRAMPARAM
00176 #  endif
00177 #endif
00178 
00179 
00180 
00192 class NEOENGINE_API Program : public RefCounter, public LoadableEntity
00193 {
00194     friend class RenderDevice;
00195 
00196     public:
00197 
00202         enum PROGRAMTYPE
00203         {
00205           VERTEXPROGRAM                                      = 0,
00206 
00208           FRAGMENTPROGRAM                                    = 1
00209         };
00210 
00215         enum PROGRAMTARGET
00216         {
00218           NOTSUPPORTED                                       = 0,
00219 
00220 
00222           NEPT_DX9_VS_MASK                                   = 0x110,
00223 
00225           NEPT_DX9_VS_1_1                                    = 0x111,
00226 
00228           NEPT_DX9_VS_2_0                                    = 0x112,
00229 
00231           NEPT_DX9_VS_2_X                                    = 0x113,
00232 
00233 
00235           NEPT_DX9_PS_MASK                                   = 0x120,
00236 
00238           NEPT_DX9_PS_1_1                                    = 0x121,
00239 
00241           NEPT_DX9_PS_1_2                                    = 0x122,
00242 
00244           NEPT_DX9_PS_1_3                                    = 0x123,
00245 
00247           NEPT_DX9_PS_1_4                                    = 0x124,
00248 
00250           NEPT_DX9_PS_2_0                                    = 0x125,
00251 
00253           NEPT_DX9_PS_2_X                                    = 0x126,
00254 
00255 
00257           NEPT_GL_VP_MASK                                    = 0x210,
00258 
00260           NEPT_GL_ARBVP_1                                    = 0x211,
00261 
00262 
00264           NEPT_GL_FP_MASK                                    = 0x220,
00265 
00267           NEPT_GL_ARBFP_1                                    = 0x221,
00268 
00270           NEPT_GL_ATIFS                                      = 0x222,
00271 
00273           NEPT_GL_NVRC                                       = 0x223,
00274 
00276           NEPT_GL_NVRC_2                                     = 0x224
00277         };
00278 
00279 
00280 #ifdef WIN32
00281 #  ifndef __HAVE_VECTOR_NEPROGRAMTARGET
00282      UDTVectorEXPIMP( PROGRAMTARGET );
00283 #    define __HAVE_VECTOR_NEPROGRAMTARGET
00284 #  endif
00285 #endif
00286 
00287 
00288     protected:
00289 
00291         static NE_STATIC PROGRAMTARGET                       s_eVPTarget;
00292 
00294         static NE_STATIC PROGRAMTARGET                       s_eFPTarget;
00295 
00297         static NE_STATIC std::vector< PROGRAMTARGET >        s_veVPPriority;
00298 
00300         static NE_STATIC std::vector< PROGRAMTARGET >        s_veFPPriority;
00301 
00303         static NE_STATIC unsigned int                        s_uiCount;
00304 
00305 
00307         std::string                                          m_strSource;
00308 
00310         PROGRAMTYPE                                          m_eProgramType;
00311 
00313         HashString                                           m_strName;
00314 
00316         unsigned int                                         m_uiID;
00317 
00319         ProgramParamHash                                     m_kParams;
00320 
00322         ProgramParam                                       **m_ppkParams;
00323 
00325         std::vector< ProgramParam* >                         m_vpkParams;
00326 
00328         std::vector< ProgramParam* >                         m_vpkUpdatedParams;
00329 
00330 
00331 
00337         bool                                                 LoadNode( unsigned int uiFlags );
00338 
00342         void                                                 ClearParams();
00343 
00347         void                                                 ParseParams();
00348 
00349 
00350     public:
00351 
00357                                                              Program( PROGRAMTYPE eType, FileManager *pkFileManager = 0 );
00358 
00362         virtual                                             ~Program();
00363 
00369         virtual bool                                         Compile( const std::string *pstrSource = 0 ) = 0;
00370 
00375         virtual void                                         SetName( const HashString &rstrName );
00376 
00380         inline const HashString                             &GetName() const { return m_strName; }
00381 
00385         inline unsigned int                                  GetID() const { return m_uiID; }
00386 
00392         inline ProgramParam                                 *GetParameter( const HashString &rstrName ) { return m_kParams.Find( rstrName ); }
00393 
00399         inline ProgramParam                                 *GetParameter( unsigned int uiIndex ) { return m_ppkParams[ uiIndex ]; }
00400 
00405         inline const std::vector< ProgramParam* >           &GetAllParameters() { return m_vpkParams; }
00406 
00411         void                                                 UpdateParameter( ProgramParam *pkParameter );
00412 
00416         inline PROGRAMTYPE                                   GetType() const { return m_eProgramType; }
00417 
00422         static inline PROGRAMTARGET                          GetTarget( PROGRAMTYPE eType ) { return( eType == VERTEXPROGRAM ? s_eVPTarget : s_eFPTarget ); }
00423 
00430         static void                                          SetPriority( PROGRAMTYPE eType, const std::vector< PROGRAMTARGET > &rvePriority );
00431 
00437         static std::string                                   GetTargetAsString( PROGRAMTARGET eTarget );
00438 
00444         static PROGRAMTARGET                                 GetTargetFromString( const std::string &rstrTarget );
00445 };
00446 
00447 
00448 #ifndef __HAVE_SMARTPOINTER_NEPROGRAM
00449    //Define smart pointer
00450 #  ifdef _MSC_VER
00451 #    pragma warning( disable : 4231 )
00452 #  endif
00453    SmartPointer( Program );
00454 #  define __HAVE_SMARTPOINTER_NEPROGRAM
00455 #endif
00456 
00457 
00458 };
00459 
00460 
00461 #endif
00462 

Generated on Wed Jan 21 14:21:07 2004 for NeoEngine by doxygen 1.3.5