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

# OgreHighLevelGpuProgram.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __HighLevelGpuProgram_H__
    00030 #define __HighLevelGpuProgram_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreGpuProgram.h"
    00034
    00035 namespace Ogre {
    00036
    00058     class _OgreExport HighLevelGpuProgram : public GpuProgram
    00059     {
    00060     protected:
    00062         bool mHighLevelLoaded;
    00064         GpuProgramPtr mAssemblerProgram;
    00066         mutable bool mConstantDefsBuilt;
    00068         mutable GpuNamedConstants mConstantDefs;
    00069
    00071         virtual void loadHighLevel(void);
    00073         virtual void unloadHighLevel(void);
    00077         virtual void loadHighLevelImpl(void);
    00080         virtual void createLowLevelImpl(void) = 0;
    00082         virtual void unloadHighLevelImpl(void) = 0;
    00084         virtual void populateParameterNames(GpuProgramParametersSharedPtr params);
    00091         virtual void buildConstantDefinitions() const = 0;
    00092
    00094         void loadImpl();
    00096         void unloadImpl();
    00097     public:
    00099         HighLevelGpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
    00100             const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
    00101         ~HighLevelGpuProgram();
    00102
    00103
    00111         GpuProgramParametersSharedPtr createParameters(void);
    00113         GpuProgram* _getBindingDelegate(void) { return mAssemblerProgram.getPointer(); }
    00114
    00119         const GpuNamedConstants& getConstantDefinitions() const;
    00120
    00121
    00122
    00123
    00124     };
    00125
    00132     class _OgreExport HighLevelGpuProgramPtr : public SharedPtr<HighLevelGpuProgram>
    00133     {
    00134     public:
    00135         HighLevelGpuProgramPtr() : SharedPtr<HighLevelGpuProgram>() {}
    00136         explicit HighLevelGpuProgramPtr(HighLevelGpuProgram* rep) : SharedPtr<HighLevelGpuProgram>(rep) {}
    00137         HighLevelGpuProgramPtr(const HighLevelGpuProgramPtr& r) : SharedPtr<HighLevelGpuProgram>(r) {}
    00138         HighLevelGpuProgramPtr(const ResourcePtr& r) : SharedPtr<HighLevelGpuProgram>()
    00139         {
    00140             // lock & copy other mutex pointer
    00141             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00142             {
    00143                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00144                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00145                 pRep = static_cast<HighLevelGpuProgram*>(r.getPointer());
    00146                 pUseCount = r.useCountPointer();
    00147                 if (pUseCount)
    00148                 {
    00149                     ++(*pUseCount);
    00150                 }
    00151             }
    00152         }
    00153
    00155         HighLevelGpuProgramPtr& operator=(const ResourcePtr& r)
    00156         {
    00157             if (pRep == static_cast<HighLevelGpuProgram*>(r.getPointer()))
    00158                 return *this;
    00159             release();
    00160             // lock & copy other mutex pointer
    00161             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00162             {
    00163                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00164                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00165                 pRep = static_cast<HighLevelGpuProgram*>(r.getPointer());
    00166                 pUseCount = r.useCountPointer();
    00167                 if (pUseCount)
    00168                 {
    00169                     ++(*pUseCount);
    00170                 }
    00171             }
    00172             else
    00173             {
    00174                 // RHS must be a null pointer
    00175                 assert(r.isNull() && "RHS must be null if it has no mutex!");
    00176                 setNull();
    00177             }
    00178             return *this;
    00179         }
    00181         HighLevelGpuProgramPtr& operator=(const GpuProgramPtr& r);
    00182     };
    00183
    00184 }
    00185 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:25 2008