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

Revision 2354, 5.5 KB checked in by szirmay, 17 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
83                /** Internal load implementation, loads just the high-level portion, enough to
84            get parameters.
85        */
86        void loadHighLevelImpl(void);
87                virtual void loadFromFile(void);       
88#endif
89        /** Internal load implementation, must be implemented by subclasses.
90        */
91        void loadFromSource(void);
92                /** Internal method for creating an appropriate low-level program from this
93        high-level program, must be implemented by subclasses. */
94        void createLowLevelImpl(void);
95        /// Internal unload implementation, must be implemented by subclasses
96        void unloadHighLevelImpl(void);
97        /// Populate the passed parameters with name->index map, must be overridden
98        void populateParameterNames(GpuProgramParametersSharedPtr params);
99
100        // Recursive utility method for populateParameterNames
101        void processParamElement(D3DXHANDLE parent, String prefix, unsigned int index, GpuProgramParametersSharedPtr params);
102
103        String mTarget;
104        String mEntryPoint;
105
106#ifdef GAMETOOLS_ILLUMINATION_MODULE
107                DWORD mCompilerFlags;
108                bool mOptimalization;
109                int mFlowControl;
110#endif
111
112        LPD3DXBUFFER mpMicroCode;
113        LPD3DXCONSTANTTABLE mpConstTable;
114
115    public:
116        D3D9HLSLProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
117            const String& group, bool isManual, ManualResourceLoader* loader);
118        ~D3D9HLSLProgram();
119
120        /** Sets the entry point for this program ie the first method called. */
121        void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
122        /** Gets the entry point defined for this program. */
123        const String& getEntryPoint(void) const { return mEntryPoint; }
124        /** Sets the shader target to compile down to, e.g. 'vs_1_1'. */
125        void setTarget(const String& target);
126        /** Gets the shader target to compile down to, e.g. 'vs_1_1'. */
127        const String& getTarget(void) const { return mTarget; }
128        /// Overridden from GpuProgram
129        bool isSupported(void) const;
130        /// Overridden from GpuProgram
131        GpuProgramParametersSharedPtr createParameters(void);
132        /// Overridden from GpuProgram
133        const String& getLanguage(void) const;
134
135        #ifdef GAMETOOLS_ILLUMINATION_MODULE
136                void setOptimalization(const String& optimalization);
137                const String& getOptimalization() const;
138                void setFlowControl(const String& control);
139                const String& getFlowControl() const;
140        #endif
141    };
142}
143
144#endif
Note: See TracBrowser for help on using the repository browser.