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

OgreD3D9GpuProgram.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-2005 The OGRE Team
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 */
00025 #ifndef __D3D9GpuProgram_H_
00026 #define __D3D9GpuProgram_H_
00027 
00028 // Precompiler options
00029 #include "OgreD3D9Prerequisites.h"
00030 #include "OgreGpuProgram.h"
00031 
00032 namespace Ogre {
00033 
00035     class D3D9GpuProgram : public GpuProgram
00036     {
00037     protected:
00038         LPDIRECT3DDEVICE9 mpDevice;
00039         LPD3DXBUFFER mpExternalMicrocode; // microcode from elsewhere, we do NOT delete this ourselves
00040     public:
00041         D3D9GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
00042             const String& group, bool isManual, ManualResourceLoader* loader, LPDIRECT3DDEVICE9 pDev);
00043         
00044 
00049         void setExternalMicrocode(LPD3DXBUFFER pMicrocode) { mpExternalMicrocode = pMicrocode; }
00051         LPD3DXBUFFER getExternalMicrocode(void) { return mpExternalMicrocode; }
00052     protected:
00054         void loadImpl(void);
00056         void loadFromSource(void);
00058         virtual void loadFromMicrocode(LPD3DXBUFFER microcode) = 0;
00059 
00060 
00061     };
00062 
00064     class D3D9GpuVertexProgram : public D3D9GpuProgram
00065     {
00066     protected:
00067         LPDIRECT3DVERTEXSHADER9 mpVertexShader;
00068     public:
00069         D3D9GpuVertexProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
00070             const String& group, bool isManual, ManualResourceLoader* loader, LPDIRECT3DDEVICE9 pDev);
00071 
00073         LPDIRECT3DVERTEXSHADER9 getVertexShader(void) const { return mpVertexShader; }
00074     protected:
00076         void unloadImpl(void);
00077         void loadFromMicrocode(LPD3DXBUFFER microcode);
00078     };
00079 
00081     class D3D9GpuFragmentProgram : public D3D9GpuProgram
00082     {
00083     protected:
00084         LPDIRECT3DPIXELSHADER9 mpPixelShader;
00085     public:
00086         D3D9GpuFragmentProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
00087             const String& group, bool isManual, ManualResourceLoader* loader, LPDIRECT3DDEVICE9 pDev);
00089         LPDIRECT3DPIXELSHADER9 getPixelShader(void) const { return mpPixelShader; }
00090     protected:
00092         void unloadImpl(void);
00093         void loadFromMicrocode(LPD3DXBUFFER microcode);
00094     };
00101     class _OgreExport D3D9GpuProgramPtr : public SharedPtr<D3D9GpuProgram> 
00102     {
00103     public:
00104         D3D9GpuProgramPtr() : SharedPtr<D3D9GpuProgram>() {}
00105         explicit D3D9GpuProgramPtr(D3D9GpuProgram* rep) : SharedPtr<D3D9GpuProgram>(rep) {}
00106         D3D9GpuProgramPtr(const D3D9GpuProgramPtr& r) : SharedPtr<D3D9GpuProgram>(r) {} 
00107         D3D9GpuProgramPtr(const ResourcePtr& r) : SharedPtr<D3D9GpuProgram>()
00108         {
00109             // lock & copy other mutex pointer
00110             OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00111             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00112             pRep = static_cast<D3D9GpuProgram*>(r.getPointer());
00113             pUseCount = r.useCountPointer();
00114             if (pUseCount)
00115             {
00116                 ++(*pUseCount);
00117             }
00118         }
00119 
00121         D3D9GpuProgramPtr& operator=(const ResourcePtr& r)
00122         {
00123             if (pRep == static_cast<D3D9GpuProgram*>(r.getPointer()))
00124                 return *this;
00125             release();
00126             // lock & copy other mutex pointer
00127             OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
00128             OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
00129             pRep = static_cast<D3D9GpuProgram*>(r.getPointer());
00130             pUseCount = r.useCountPointer();
00131             if (pUseCount)
00132             {
00133                 ++(*pUseCount);
00134             }
00135             return *this;
00136         }
00137     };
00138 
00139 }
00140 
00141 
00142 #endif

Copyright © 2000-2005 by The OGRE Team
Last modified Wed Feb 23 00:19:04 2005