source: OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/include/OgreD3D9HLSLProgram.h @ 1728

Revision 1728, 5.3 KB checked in by szirmay, 18 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __D3D9HLSLProgram_H__
26#define __D3D9HLSLProgram_H__
27
28#include "OgreD3D9Prerequisites.h"
29#include "OgreHighLevelGpuProgram.h"
30
31namespace Ogre {
32    /** Specialisation of HighLevelGpuProgram to provide support for D3D9
33        High-Level Shader Language (HLSL).
34    @remarks
35        Note that the syntax of D3D9 HLSL is identical to nVidia's Cg language, therefore
36        unless you know you will only ever be deploying on Direct3D, or you have some specific
37        reason for not wanting to use the Cg plugin, I suggest you use Cg instead since that
38        can produce programs for OpenGL too.
39    */
40    class D3D9HLSLProgram : public HighLevelGpuProgram
41    {
42    public:
43        /// Command object for setting entry point
44        class CmdEntryPoint : public ParamCommand
45        {
46        public:
47            String doGet(const void* target) const;
48            void doSet(void* target, const String& val);
49        };
50        /// Command object for setting target assembler
51        class CmdTarget : public ParamCommand
52        {
53        public:
54            String doGet(const void* target) const;
55            void doSet(void* target, const String& val);
56        };
57#ifdef GAMETOOLS_ILLUMINATION_MODULE
58                /// Command object for setting compolir flags
59        class CmdOptimalization : public ParamCommand
60        {
61        public:
62            String doGet(const void* target) const;
63            void doSet(void* target, const String& val);
64        };
65
66                class CmdFlowControl : public ParamCommand
67        {
68        public:
69            String doGet(const void* target) const;
70            void doSet(void* target, const String& val);
71        };
72#endif
73
74    protected:
75
76        static CmdEntryPoint msCmdEntryPoint;
77        static CmdTarget msCmdTarget;
78
79#ifdef GAMETOOLS_ILLUMINATION_MODULE
80                static CmdOptimalization msCmdOptimalization;
81        static CmdFlowControl msCmdFlowControl;
82#endif
83        /** Internal load implementation, must be implemented by subclasses.
84        */
85        void loadFromSource(void);
86        /** Internal method for creating an appropriate low-level program from this
87        high-level program, must be implemented by subclasses. */
88        void createLowLevelImpl(void);
89        /// Internal unload implementation, must be implemented by subclasses
90        void unloadHighLevelImpl(void);
91        /// Populate the passed parameters with name->index map, must be overridden
92        void populateParameterNames(GpuProgramParametersSharedPtr params);
93
94        // Recursive utility method for populateParameterNames
95        void processParamElement(D3DXHANDLE parent, String prefix, unsigned int index, GpuProgramParametersSharedPtr params);
96
97        String mTarget;
98        String mEntryPoint;
99
100#ifdef GAMETOOLS_ILLUMINATION_MODULE
101                DWORD mCompilerFlags;
102                bool mOptimalization;
103                int mFlowControl;
104#endif
105
106        LPD3DXBUFFER mpMicroCode;
107        LPD3DXCONSTANTTABLE mpConstTable;
108
109    public:
110        D3D9HLSLProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
111            const String& group, bool isManual, ManualResourceLoader* loader);
112        ~D3D9HLSLProgram();
113
114        /** Sets the entry point for this program ie the first method called. */
115        void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
116        /** Gets the entry point defined for this program. */
117        const String& getEntryPoint(void) const { return mEntryPoint; }
118        /** Sets the shader target to compile down to, e.g. 'vs_1_1'. */
119        void setTarget(const String& target);
120        /** Gets the shader target to compile down to, e.g. 'vs_1_1'. */
121        const String& getTarget(void) const { return mTarget; }
122        /// Overridden from GpuProgram
123        bool isSupported(void) const;
124        /// Overridden from GpuProgram
125        GpuProgramParametersSharedPtr createParameters(void);
126        /// Overridden from GpuProgram
127        const String& getLanguage(void) const;
128
129        #ifdef GAMETOOLS_ILLUMINATION_MODULE
130                void setOptimalization(const String& optimalization);
131                const String& getOptimalization() const;
132                void setFlowControl(const String& control);
133                const String& getFlowControl() const;
134        #endif
135    };
136}
137
138#endif
Note: See TracBrowser for help on using the repository browser.