source: GTP/trunk/Lib/Geom/OgreStuff/include/OgreGpuProgram.h @ 1809

Revision 1809, 53.7 KB checked in by gumbau, 18 years ago (diff)
RevLine 
[1809]1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://ogre.sourceforge.net/
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 __GpuProgram_H_
26#define __GpuProgram_H_
27
28// Precompiler options
29#include "OgrePrerequisites.h"
30#include "OgreResource.h"
31#include "OgreSharedPtr.h"
32#include "OgreIteratorWrappers.h"
33
34namespace Ogre {
35
36        /** Enumerates the types of programs which can run on the GPU. */
37        enum GpuProgramType
38        {
39                GPT_VERTEX_PROGRAM,
40                GPT_FRAGMENT_PROGRAM
41        };
42
43   
44    /** Collects together the program parameters used for a GpuProgram.
45    @remarks
46        Gpu program state includes constant parameters used by the program, and
47        bindings to render system state which is propagated into the constants
48        by the engine automatically if requested.
49    @par
50        GpuProgramParameters objects should be created through the GpuProgramManager and
51        may be shared between multiple GpuProgram instances. For this reason they
52        are managed using a shared pointer, which will ensure they are automatically
53        deleted when no program is using them anymore.
54    */
55    class _OgreExport GpuProgramParameters
56    {
57    public:
58        /** Defines the types of automatically updated values that may be bound to GpuProgram
59        parameters, or used to modify parameters on a per-object basis.
60        */
61        enum AutoConstantType
62        {
63            /// The current world matrix
64            ACT_WORLD_MATRIX,
65            /// The current world matrix, inverted
66            ACT_INVERSE_WORLD_MATRIX,
67                        /** Provides transpose of world matrix.
68                        Equivalent to RenderMonkey's "WorldTranspose".
69                        */
70                        ACT_TRANSPOSE_WORLD_MATRIX,
71            /// The current world matrix, inverted & transposed
72            ACT_INVERSE_TRANSPOSE_WORLD_MATRIX,
73
74
75            /// The current array of world matrices, as a 3x4 matrix, used for blending
76            ACT_WORLD_MATRIX_ARRAY_3x4,
77            /// The current array of world matrices, used for blending
78            ACT_WORLD_MATRIX_ARRAY,
79
80
81            /// The current view matrix
82            ACT_VIEW_MATRIX,
83                        /// The current view matrix, inverted
84                        ACT_INVERSE_VIEW_MATRIX,
85                        /** Provides transpose of view matrix.
86                        Equivalent to RenderMonkey's "ViewTranspose".
87                        */
88                        ACT_TRANSPOSE_VIEW_MATRIX,
89                        /** Provides inverse transpose of view matrix.
90                        Equivalent to RenderMonkey's "ViewInverseTranspose".
91                        */
92                        ACT_INVERSE_TRANSPOSE_VIEW_MATRIX,
93
94
95            /// The current projection matrix
96            ACT_PROJECTION_MATRIX,
97                        /** Provides inverse of projection matrix.
98                        Equivalent to RenderMonkey's "ProjectionInverse".
99                        */
100                        ACT_INVERSE_PROJECTION_MATRIX,
101                        /** Provides transpose of projection matrix.
102                        Equivalent to RenderMonkey's "ProjectionTranspose".
103                        */
104                        ACT_TRANSPOSE_PROJECTION_MATRIX,
105                        /** Provides inverse transpose of projection matrix.
106                        Equivalent to RenderMonkey's "ProjectionInverseTranspose".
107                        */
108                        ACT_INVERSE_TRANSPOSE_PROJECTION_MATRIX,
109
110
111            /// The current view & projection matrices concatenated
112            ACT_VIEWPROJ_MATRIX,
113                        /** Provides inverse of concatenated view and projection matrices.
114                        Equivalent to RenderMonkey's "ViewProjectionInverse".
115                        */
116                        ACT_INVERSE_VIEWPROJ_MATRIX,
117                        /** Provides transpose of concatenated view and projection matrices.
118                        Equivalent to RenderMonkey's "ViewProjectionTranspose".
119                        */
120                        ACT_TRANSPOSE_VIEWPROJ_MATRIX,
121                        /** Provides inverse transpose of concatenated view and projection matrices.
122                        Equivalent to RenderMonkey's "ViewProjectionInverseTranspose".
123                        */
124                        ACT_INVERSE_TRANSPOSE_VIEWPROJ_MATRIX,
125
126
127            /// The current world & view matrices concatenated
128            ACT_WORLDVIEW_MATRIX,
129            /// The current world & view matrices concatenated, then inverted
130            ACT_INVERSE_WORLDVIEW_MATRIX,
131                        /** Provides transpose of concatenated world and view matrices.
132                                Equivalent to RenderMonkey's "WorldViewTranspose".
133                        */
134                        ACT_TRANSPOSE_WORLDVIEW_MATRIX,
135            /// The current world & view matrices concatenated, then inverted & tranposed
136            ACT_INVERSE_TRANSPOSE_WORLDVIEW_MATRIX,
137                        /// view matrices.
138
139
140            /// The current world, view & projection matrices concatenated
141            ACT_WORLDVIEWPROJ_MATRIX,
142                        /** Provides inverse of concatenated world, view and projection matrices.
143                        Equivalent to RenderMonkey's "WorldViewProjectionInverse".
144                        */
145                        ACT_INVERSE_WORLDVIEWPROJ_MATRIX,
146                        /** Provides transpose of concatenated world, view and projection matrices.
147                        Equivalent to RenderMonkey's "WorldViewProjectionTranspose".
148                        */
149                        ACT_TRANSPOSE_WORLDVIEWPROJ_MATRIX,
150                        /** Provides inverse transpose of concatenated world, view and projection
151                        matrices. Equivalent to RenderMonkey's "WorldViewProjectionInverseTranspose".
152                        */
153                        ACT_INVERSE_TRANSPOSE_WORLDVIEWPROJ_MATRIX,
154
155
156            /// render target related values
157            /** -1 if requires texture flipping, +1 otherwise. It's useful when you bypassed
158            projection matrix transform, still able use this value to adjust transformed y position.
159            */
160            ACT_RENDER_TARGET_FLIPPING,
161
162
163            /// Fog colour
164            ACT_FOG_COLOUR,
165            /// Fog params: density, linear start, linear end, 1/(end-start)
166            ACT_FOG_PARAMS,
167
168
169                        /// The ambient light colour set in the scene
170                        ACT_AMBIENT_LIGHT_COLOUR,
171
172            /// Light diffuse colour (index determined by setAutoConstant call)
173            ACT_LIGHT_DIFFUSE_COLOUR,
174            /// Light diffuse colour (index determined by setAutoConstant call)
175            ACT_LIGHT_SPECULAR_COLOUR,
176            /// Light attenuation parameters, Vector4(range, constant, linear, quadric)
177            ACT_LIGHT_ATTENUATION,
178            /// A light position in world space (index determined by setAutoConstant call)
179            ACT_LIGHT_POSITION,
180            /// A light position in object space (index determined by setAutoConstant call)
181            ACT_LIGHT_POSITION_OBJECT_SPACE,
182                        /// A light position in view space (index determined by setAutoConstant call)
183            ACT_LIGHT_POSITION_VIEW_SPACE,
184            /// A light direction in world space (index determined by setAutoConstant call)
185            ACT_LIGHT_DIRECTION,
186            /// A light direction in object space (index determined by setAutoConstant call)
187            ACT_LIGHT_DIRECTION_OBJECT_SPACE,
188                        /// A light direction in view space (index determined by setAutoConstant call)
189                        ACT_LIGHT_DIRECTION_VIEW_SPACE,
190                        /** The distance of the light from the center of the object
191                                a useful approximation as an alternative to per-vertex distance
192                                calculations.
193                        */
194                        ACT_LIGHT_DISTANCE_OBJECT_SPACE,
195                        /** Light power level, a single scalar as set in Light::setPowerScale  (index determined by setAutoConstant call) */
196                        ACT_LIGHT_POWER_SCALE,
197                        /** The distance a shadow volume should be extruded when using
198                            finite extrusion programs.
199                        */
200                        ACT_SHADOW_EXTRUSION_DISTANCE,
201            /// The current camera's position in world space
202            ACT_CAMERA_POSITION,
203            /// The current camera's position in object space
204            ACT_CAMERA_POSITION_OBJECT_SPACE,
205            /// The view/projection matrix of the assigned texture projection frustum
206            ACT_TEXTURE_VIEWPROJ_MATRIX,
207            /// A custom parameter which will come from the renderable, using 'data' as the identifier
208            ACT_CUSTOM,
209            /** provides current elapsed time
210            */
211            ACT_TIME,
212                        /** Single float value, which repeats itself based on given as
213                        parameter "cycle time". Equivalent to RenderMonkey's "Time0_X".
214                        */
215                        ACT_TIME_0_X,
216                        /// Cosine of "Time0_X". Equivalent to RenderMonkey's "CosTime0_X".
217                        ACT_COSTIME_0_X,
218                        /// Sine of "Time0_X". Equivalent to RenderMonkey's "SinTime0_X".
219                        ACT_SINTIME_0_X,
220                        /// Tangent of "Time0_X". Equivalent to RenderMonkey's "TanTime0_X".
221                        ACT_TANTIME_0_X,
222                        /** Vector of "Time0_X", "SinTime0_X", "CosTime0_X",
223                        "TanTime0_X". Equivalent to RenderMonkey's "Time0_X_Packed".
224                        */
225                        ACT_TIME_0_X_PACKED,
226                        /** Single float value, which represents scaled time value [0..1],
227                        which repeats itself based on given as parameter "cycle time".
228                        Equivalent to RenderMonkey's "Time0_1".
229                        */
230                        ACT_TIME_0_1,
231                        /// Cosine of "Time0_1". Equivalent to RenderMonkey's "CosTime0_1".
232                        ACT_COSTIME_0_1,
233                        /// Sine of "Time0_1". Equivalent to RenderMonkey's "SinTime0_1".
234                        ACT_SINTIME_0_1,
235                        /// Tangent of "Time0_1". Equivalent to RenderMonkey's "TanTime0_1".
236                        ACT_TANTIME_0_1,
237                        /** Vector of "Time0_1", "SinTime0_1", "CosTime0_1",
238                        "TanTime0_1". Equivalent to RenderMonkey's "Time0_1_Packed".
239                        */
240                        ACT_TIME_0_1_PACKED,
241                        /**     Single float value, which represents scaled time value [0..2*Pi],
242                        which repeats itself based on given as parameter "cycle time".
243                        Equivalent to RenderMonkey's "Time0_2PI".
244                        */
245                        ACT_TIME_0_2PI,
246                        /// Cosine of "Time0_2PI". Equivalent to RenderMonkey's "CosTime0_2PI".
247                        ACT_COSTIME_0_2PI,
248                        /// Sine of "Time0_2PI". Equivalent to RenderMonkey's "SinTime0_2PI".
249                        ACT_SINTIME_0_2PI,
250                        /// Tangent of "Time0_2PI". Equivalent to RenderMonkey's "TanTime0_2PI".
251                        ACT_TANTIME_0_2PI,
252                        /** Vector of "Time0_2PI", "SinTime0_2PI", "CosTime0_2PI",
253                        "TanTime0_2PI". Equivalent to RenderMonkey's "Time0_2PI_Packed".
254                        */
255                        ACT_TIME_0_2PI_PACKED,
256                        /// provides the scaled frame time, returned as a floating point value.
257            ACT_FRAME_TIME,
258                        /// provides the calculated frames per second, returned as a floating point value.
259                        ACT_FPS,
260                        /// viewport-related values
261                        /** Current viewport width (in pixels) as floating point value.
262                        Equivalent to RenderMonkey's "ViewportWidth".
263                        */
264                        ACT_VIEWPORT_WIDTH,
265                        /** Current viewport height (in pixels) as floating point value.
266                        Equivalent to RenderMonkey's "ViewportHeight".
267                        */
268                        ACT_VIEWPORT_HEIGHT,
269                        /** This variable represents 1.0/ViewportWidth.
270                        Equivalent to RenderMonkey's "ViewportWidthInverse".
271                        */
272                        ACT_INVERSE_VIEWPORT_WIDTH,
273                        /** This variable represents 1.0/ViewportHeight.
274                        Equivalent to RenderMonkey's "ViewportHeightInverse".
275                        */
276                        ACT_INVERSE_VIEWPORT_HEIGHT,
277            /** Packed of "ViewportWidth", "ViewportHeight", "ViewportWidthInverse",
278            "ViewportHeightInverse".
279            */
280            ACT_VIEWPORT_SIZE,
281
282                        /// view parameters
283                        /** This variable provides the view direction vector (world space).
284                        Equivalent to RenderMonkey's "ViewDirection".
285                        */
286                        ACT_VIEW_DIRECTION,
287                        /** This variable provides the view side vector (world space).
288                        Equivalent to RenderMonkey's "ViewSideVector".
289                        */
290                        ACT_VIEW_SIDE_VECTOR,
291                        /** This variable provides the view up vector (world space).
292                        Equivalent to RenderMonkey's "ViewUpVector".
293                        */
294                        ACT_VIEW_UP_VECTOR,
295                        /** This variable provides the field of view as a floating point value.
296                        Equivalent to RenderMonkey's "FOV".
297                        */
298                        ACT_FOV,
299                        /**     This variable provides the near clip distance as a floating point value.
300                        Equivalent to RenderMonkey's "NearClipPlane".
301                        */
302                        ACT_NEAR_CLIP_DISTANCE,
303                        /**     This variable provides the far clip distance as a floating point value.
304                        Equivalent to RenderMonkey's "FarClipPlane".
305                        */
306                        ACT_FAR_CLIP_DISTANCE,
307
308            /** provides the pass index number within the technique
309                of the active materil.
310            */
311            ACT_PASS_NUMBER,
312
313            /** provides the current iteration number of the pass. The iteration
314                number is the number of times the current render operation has
315                been drawn for the acitve pass.
316            */
317            ACT_PASS_ITERATION_NUMBER,
318
319
320                        /** Provides a parametric animation value [0..1], only available
321                                where the renderable specifically implements it.
322                        */
323                        ACT_ANIMATION_PARAMETRIC
324
325        };
326
327        /** Defines the type of the extra data item used by the auto constant.
328
329        */
330        enum ACDataType {
331            /// no data is required
332            ACDT_NONE,
333            /// the auto constant requires data of type int
334            ACDT_INT,
335            /// the auto constant requires data of type real
336            ACDT_REAL
337        };
338
339        /** Defines the base element type of the auto constant
340        */
341        enum ElementType {
342            ET_INT,
343            ET_REAL
344        };
345
346        struct AutoConstantDefinition
347        {
348            AutoConstantType acType;
349            String name;
350            size_t elementCount;
351                        /// The type of the constant in the program
352            ElementType elementType;
353                        /// The type of any extra data
354            ACDataType dataType;
355
356                        AutoConstantDefinition(AutoConstantType _acType, const String& _name,
357                                size_t _elementCount, ElementType _elementType,
358                                ACDataType _dataType)
359                                :acType(_acType), name(_name), elementCount(_elementCount),
360                                elementType(_elementType), dataType(_dataType)
361                        {
362                               
363                        }
364        };
365
366        /** Structure recording the use of an automatic parameter. */
367        class _OgrePrivate AutoConstantEntry
368        {
369        public:
370            /// The type of parameter
371            AutoConstantType paramType;
372            /// The target constant index
373            size_t index;
374            /// Additional information to go with the parameter
375                        union{
376                                size_t data;
377                                Real fData;
378                        };
379
380            AutoConstantEntry(AutoConstantType theType, size_t theIndex, size_t theData)
381                : paramType(theType), index(theIndex), data(theData) {}
382
383                        AutoConstantEntry(AutoConstantType theType, size_t theIndex, Real theData)
384                                : paramType(theType), index(theIndex), fData(theData) {}
385
386        };
387        /** Real parameter entry; contains both a group of 4 values and
388        an indicator to say if it's been set or not. This allows us to
389        filter out constant entries which have not been set by the renderer
390        and may actually be being used internally by the program. */
391        struct RealConstantEntry
392        {
393            float val[4];
394            bool isSet;
395            RealConstantEntry() : isSet(false)  {}
396        };
397        /** Int parameter entry; contains both a group of 4 values and
398        an indicator to say if it's been set or not. This allows us to
399        filter out constant entries which have not been set by the renderer
400        and may actually be being used internally by the program. */
401        struct IntConstantEntry
402        {
403            int val[4];
404            bool isSet;
405            IntConstantEntry() : isSet(false) {}
406        };
407
408        // nfz
409        /** stucture used to keep track of attributes for a constant definition.
410
411        */
412
413        struct ConstantDefinition
414        {
415            String name;
416            size_t entryIndex;
417            size_t elementCount;
418            size_t arraySize;
419            ElementType elementType;
420            size_t autoIndex;
421            bool   isAllocated;
422            bool   isAuto;
423
424            ConstantDefinition()
425                : entryIndex(0)
426                , elementCount(0)
427                , arraySize(1)
428                , elementType(ET_INT)
429                , autoIndex(0)
430                , isAllocated(false)
431                , isAuto(false)
432            {}
433
434        };
435
436    protected:
437        static AutoConstantDefinition AutoConstantDictionary[];
438        // Constant lists
439        typedef std::vector<RealConstantEntry> RealConstantList;
440        typedef std::vector<IntConstantEntry> IntConstantList;
441        // Auto parameter storage
442        typedef std::vector<AutoConstantEntry> AutoConstantList;
443        // parameter dictionary container
444        typedef std::vector<ConstantDefinition> ConstantDefinitionContainer;
445        /// Packed list of floating-point constants
446        RealConstantList mRealConstants;
447        /// Packed list of integer constants
448        IntConstantList mIntConstants;
449        /// List of automatically updated parameters
450        AutoConstantList mAutoConstants;
451        /// Container of parameter definitions
452        ConstantDefinitionContainer mConstantDefinitions;
453        /// Mapping from parameter names to NamedConstantEntry - high-level programs are expected to populate this
454        typedef std::map<String, size_t> ParamNameMap;
455        ParamNameMap mParamNameMap;
456        /// Do we need to transpose matrices?
457        bool mTransposeMatrices;
458                /// flag to indicate if names not found will be automatically added
459                bool mAutoAddParamName;
460        /// active pass iteration parameter real constant entry;
461        RealConstantEntry* mActivePassIterationEntry;
462        /// index for active pass iteration parameter real constant entry;
463        size_t mActivePassIterationEntryIndex;
464
465
466    public:
467                GpuProgramParameters();
468                ~GpuProgramParameters() {}
469
470        /// Copy constructor
471        GpuProgramParameters(const GpuProgramParameters& oth);
472        /// Operator = overload
473        GpuProgramParameters& operator=(const GpuProgramParameters& oth);
474
475
476                /** Sets a 4-element floating-point parameter to the program.
477                @param index The constant index at which to place the parameter (each constant is
478            a 4D float)
479                @param vec The value to set
480                */
481                void setConstant(size_t index, const Vector4& vec);
482                /** Sets a single floating-point parameter to the program.
483                @note This is actually equivalent to calling
484                setConstant(index Vector4(val, 0, 0, 0)) since all constants are 4D.
485                @param index The constant index at which to place the parameter (each constant is
486                a 4D float)
487                @param val The value to set
488                */
489                void setConstant(size_t index, Real val);
490                /** Sets a 4-element floating-point parameter to the program via Vector3.
491                @param index The constant index at which to place the parameter (each constant is
492            a 4D float).
493            Note that since you're passing a Vector3, the last element of the 4-element
494            value will be set to 1 (a homogenous vector)
495                @param vec The value to set
496                */
497                void setConstant(size_t index, const Vector3& vec);
498                /** Sets a Matrix4 parameter to the program.
499                @param index The constant index at which to place the parameter (each constant is
500            a 4D float).
501            NB since a Matrix4 is 16 floats long, this parameter will take up 4 indexes.
502                @param m The value to set
503                */
504                void setConstant(size_t index, const Matrix4& m);
505        /** Sets a list of Matrix4 parameters to the program.
506        @param index The constant index at which to start placing the parameter (each constant is
507        a 4D float).
508        NB since a Matrix4 is 16 floats long, so each entry will take up 4 indexes.
509        @param m Pointer to an array of matrices to set
510        @param numEntries Number of Matrix4 entries
511        */
512        void setConstant(size_t index, const Matrix4* m, size_t numEntries);
513                /** Sets a multiple value constant floating-point parameter to the program.
514                @param index The constant index at which to start placing parameters (each constant is
515            a 4D float)
516                @param val Pointer to the values to write, must contain 4*count floats
517                @param count The number of groups of 4 floats to write
518                */
519                void setConstant(size_t index, const float *val, size_t count);
520                /** Sets a multiple value constant floating-point parameter to the program.
521                @param index The constant index at which to start placing parameters (each constant is
522            a 4D float)
523                @param val Pointer to the values to write, must contain 4*count floats
524                @param count The number of groups of 4 floats to write
525                */
526                void setConstant(size_t index, const double *val, size_t count);
527                /** Sets a ColourValue parameter to the program.
528                @param index The constant index at which to place the parameter (each constant is
529            a 4D float)
530                @param colour The value to set
531                */
532        void setConstant(size_t index, const ColourValue& colour);
533               
534                /** Sets a multiple value constant integer parameter to the program.
535        @remarks
536            Different types of GPU programs support different types of constant parameters.
537            For example, it's relatively common to find that vertex programs only support
538            floating point constants, and that fragment programs only support integer (fixed point)
539            parameters. This can vary depending on the program version supported by the
540            graphics card being used. You should consult the documentation for the type of
541            low level program you are using, or alternatively use the methods
542            provided on RenderSystemCapabilities to determine the options.
543                @param index The constant index at which to place the parameter (each constant is
544            a 4D integer)
545                @param val Pointer to the values to write, must contain 4*count ints
546                @param count The number of groups of 4 ints to write
547                */
548                void setConstant(size_t index, const int *val, size_t count);
549
550        /** Deletes the contents of the Real constants registers. */
551        void resetRealConstants(void) { mRealConstants.clear(); }
552        /** Deletes the contents of the int constants registers. */
553        void resetIntConstants(void) { mIntConstants.clear(); }
554
555        typedef ConstVectorIterator<RealConstantList> RealConstantIterator;
556        typedef ConstVectorIterator<IntConstantList> IntConstantIterator;
557        /// Gets an iterator over the Real constant parameters
558        RealConstantIterator getRealConstantIterator(void) const;
559        /// Gets an iterator over the integer constant parameters
560        IntConstantIterator getIntConstantIterator(void) const;
561
562                /** Gets a specific Real Constant entry if index is in valid range
563                        otherwise returns a NULL
564                @parem index which entry is to be retrieved
565                */
566                RealConstantEntry* getRealConstantEntry(const size_t index);
567                /** Gets a specific Int Constant entry if index is in valid range
568                        otherwise returns a NULL
569                @parem index which entry is to be retrieved
570                */
571                IntConstantEntry* getIntConstantEntry(const size_t index);
572       
573                /** Gets a Named Real Constant entry if the name is found otherwise returns a NULL
574                @parem name The name of the entry  to be retrieved
575                */
576                RealConstantEntry* getNamedRealConstantEntry(const String& name);
577                /** Gets a named Int Constant entry if name is found otherwise returns a NULL
578                @parem name The name of the entry to be retrieved
579                */
580                IntConstantEntry* getNamedIntConstantEntry(const String& name);
581        /// Gets the number of Real constants that have been set
582        size_t getRealConstantCount(void) const { return mRealConstants.size(); }
583        /// Gets the number of int constants that have been set
584        size_t getIntConstantCount(void) const { return mIntConstants.size(); }
585        /// Returns true if there are any Real constants contained here
586        bool hasRealConstantParams(void) const { return !(mRealConstants.empty()); }
587        /// Returns true if there are any int constants contained here
588        bool hasIntConstantParams(void) const { return !(mIntConstants.empty()); }
589
590        /** Sets up a constant which will automatically be updated by the system.
591        @remarks
592            Vertex and fragment programs often need parameters which are to do with the
593            current render state, or particular values which may very well change over time,
594            and often between objects which are being rendered. This feature allows you
595            to set up a certain number of predefined parameter mappings that are kept up to
596            date for you.
597        @param index The location in the constant list to place this updated constant every time
598            it is changed. Note that because of the nature of the types, we know how big the
599            parameter details will be so you don't need to set that like you do for manual constants.
600        @param acType The type of automatic constant to set
601        @param extraInfo If the constant type needs more information (like a light index) put it here.
602        */
603        void setAutoConstant(size_t index, AutoConstantType acType, size_t extraInfo = 0);
604                void setAutoConstantReal(size_t index, AutoConstantType acType, Real rData);
605        /** Sets a named parameter up to track a derivation of the current time.
606        @param index The index of the parameter
607        @param factor The amount by which to scale the time value
608        */ 
609        void setConstantFromTime(size_t index, Real factor);
610
611        /** Clears all the existing automatic constants. */
612        void clearAutoConstants(void);
613        typedef ConstVectorIterator<AutoConstantList> AutoConstantIterator;
614        /** Gets an iterator over the automatic constant bindings currently in place. */
615        AutoConstantIterator getAutoConstantIterator(void) const;
616        /// Gets the number of int constants that have been set
617        size_t getAutoConstantCount(void) const { return mAutoConstants.size(); }
618                /** Gets a specific Auto Constant entry if index is in valid range
619                        otherwise returns a NULL
620                @parem index which entry is to be retrieved
621                */
622                AutoConstantEntry* getAutoConstantEntry(const size_t index);
623        /** Returns true if this instance has any automatic constants. */
624        bool hasAutoConstants(void) const { return !(mAutoConstants.empty()); }
625        /** Updates the automatic parameters (except lights) based on the details provided. */
626        void _updateAutoParamsNoLights(const AutoParamDataSource& source);
627        /** Updates the automatic parameters for lights based on the details provided. */
628        void _updateAutoParamsLightsOnly(const AutoParamDataSource& source);
629
630                /** Sets the auto add parameter name flag
631                @remarks
632                        Not all GPU programs make named parameters available after the high level
633                        source is compiled.  GLSL is one such case.  If parameter names are not loaded
634                        prior to the material serializer reading in parameter names in a script then
635                        an exception is generated.  Set AutoAddParamName to true to have names not found
636                        in the map added to the map.
637                @note
638                        The index of the parameter name will be set to the end of the Real Constant List.
639                @param state true to enable automatic name
640                */
641                void setAutoAddParamName(bool state) { mAutoAddParamName = state; }
642
643                /** Sets a single value constant floating-point parameter to the program.
644        @remarks
645            Different types of GPU programs support different types of constant parameters.
646            For example, it's relatively common to find that vertex programs only support
647            floating point constants, and that fragment programs only support integer (fixed point)
648            parameters. This can vary depending on the program version supported by the
649            graphics card being used. You should consult the documentation for the type of
650            low level program you are using, or alternatively use the methods
651            provided on RenderSystemCapabilities to determine the options.
652        @par
653            Another possible limitation is that some systems only allow constants to be set
654            on certain boundaries, e.g. in sets of 4 values for example. Again, see
655            RenderSystemCapabilities for full details.
656        @note
657            This named option will only work if you are using a parameters object created
658            from a high-level program (HighLevelGpuProgram).
659                @param name The name of the parameter
660                @param val The value to set
661                */
662                void setNamedConstant(const String& name, Real val);
663                /** Sets a single value constant integer parameter to the program.
664        @remarks
665            Different types of GPU programs support different types of constant parameters.
666            For example, it's relatively common to find that vertex programs only support
667            floating point constants, and that fragment programs only support integer (fixed point)
668            parameters. This can vary depending on the program version supported by the
669            graphics card being used. You should consult the documentation for the type of
670            low level program you are using, or alternatively use the methods
671            provided on RenderSystemCapabilities to determine the options.
672        @par
673            Another possible limitation is that some systems only allow constants to be set
674            on certain boundaries, e.g. in sets of 4 values for example. Again, see
675            RenderSystemCapabilities for full details.
676        @note
677            This named option will only work if you are using a parameters object created
678            from a high-level program (HighLevelGpuProgram).
679        @param name The name of the parameter
680                @param val The value to set
681                */
682                void setNamedConstant(const String& name, int val);
683                /** Sets a Vector4 parameter to the program.
684        @param name The name of the parameter
685                @param vec The value to set
686                */
687                void setNamedConstant(const String& name, const Vector4& vec);
688                /** Sets a Vector3 parameter to the program.
689        @note
690            This named option will only work if you are using a parameters object created
691            from a high-level program (HighLevelGpuProgram).
692                @param index The index at which to place the parameter
693                        NB this index refers to the number of floats, so a Vector3 is 3. Note that many
694            rendersystems & programs assume that every floating point parameter is passed in
695            as a vector of 4 items, so you are strongly advised to check with
696            RenderSystemCapabilities before using this version - if in doubt use Vector4
697            or ColourValue instead (both are 4D).
698                @param vec The value to set
699                */
700                void setNamedConstant(const String& name, const Vector3& vec);
701                /** Sets a Matrix4 parameter to the program.
702        @param name The name of the parameter
703                @param m The value to set
704                */
705                void setNamedConstant(const String& name, const Matrix4& m);
706        /** Sets a list of Matrix4 parameters to the program.
707        @param name The name of the parameter; this must be the first index of an array,
708            for examples 'matrices[0]'
709        NB since a Matrix4 is 16 floats long, so each entry will take up 4 indexes.
710        @param m Pointer to an array of matrices to set
711        @param numEntries Number of Matrix4 entries
712        */
713        void setNamedConstant(const String& name, const Matrix4* m, size_t numEntries);
714                /** Sets a multiple value constant floating-point parameter to the program.
715        @remarks
716            Different types of GPU programs support different types of constant parameters.
717            For example, it's relatively common to find that vertex programs only support
718            floating point constants, and that fragment programs only support integer (fixed point)
719            parameters. This can vary depending on the program version supported by the
720            graphics card being used. You should consult the documentation for the type of
721            low level program you are using, or alternatively use the methods
722            provided on RenderSystemCapabilities to determine the options.
723        @par
724            Another possible limitation is that some systems only allow constants to be set
725            on certain boundaries, e.g. in sets of 4 values for example. Again, see
726            RenderSystemCapabilities for full details.
727        @note
728            This named option will only work if you are using a parameters object created
729            from a high-level program (HighLevelGpuProgram).
730        @param name The name of the parameter
731                @param val Pointer to the values to write
732                @param count The number of floats to write
733                */
734                void setNamedConstant(const String& name, const float *val, size_t count);
735                /** Sets a multiple value constant floating-point parameter to the program.
736        @remarks
737            Different types of GPU programs support different types of constant parameters.
738            For example, it's relatively common to find that vertex programs only support
739            floating point constants, and that fragment programs only support integer (fixed point)
740            parameters. This can vary depending on the program version supported by the
741            graphics card being used. You should consult the documentation for the type of
742            low level program you are using, or alternatively use the methods
743            provided on RenderSystemCapabilities to determine the options.
744        @par
745            Another possible limitation is that some systems only allow constants to be set
746            on certain boundaries, e.g. in sets of 4 values for example. Again, see
747            RenderSystemCapabilities for full details.
748        @note
749            This named option will only work if you are using a parameters object created
750            from a high-level program (HighLevelGpuProgram).
751        @param name The name of the parameter
752                @param val Pointer to the values to write
753                @param count The number of floats to write
754                */
755                void setNamedConstant(const String& name, const double *val, size_t count);
756                /** Sets a ColourValue parameter to the program.
757        @param name The name of the parameter
758                @param colour The value to set
759                */
760        void setNamedConstant(const String& name, const ColourValue& colour);
761               
762                /** Sets a multiple value constant integer parameter to the program.
763        @remarks
764            Different types of GPU programs support different types of constant parameters.
765            For example, it's relatively common to find that vertex programs only support
766            floating point constants, and that fragment programs only support integer (fixed point)
767            parameters. This can vary depending on the program version supported by the
768            graphics card being used. You should consult the documentation for the type of
769            low level program you are using, or alternatively use the methods
770            provided on RenderSystemCapabilities to determine the options.
771        @par
772            Another possible limitation is that some systems only allow constants to be set
773            on certain boundaries, e.g. in sets of 4 values for example. Again, see
774            RenderSystemCapabilities for full details.
775        @note
776            This named option will only work if you are using a parameters object created
777            from a high-level program (HighLevelGpuProgram).
778        @param name The name of the parameter
779                @param val Pointer to the values to write
780                @param count The number of integers to write
781                */
782                void setNamedConstant(const String& name, const int *val, size_t count);
783
784        /** Sets up a constant which will automatically be updated by the system.
785        @remarks
786            Vertex and fragment programs often need parameters which are to do with the
787            current render state, or particular values which may very well change over time,
788            and often between objects which are being rendered. This feature allows you
789            to set up a certain number of predefined parameter mappings that are kept up to
790            date for you.
791        @note
792            This named option will only work if you are using a parameters object created
793            from a high-level program (HighLevelGpuProgram).
794        @param name The name of the parameter
795        @param acType The type of automatic constant to set
796        @param extraInfo If the constant type needs more information (like a light index) put it here.
797        */
798        void setNamedAutoConstant(const String& name, AutoConstantType acType, size_t extraInfo = 0);
799
800        /** Sets a named parameter up to track a derivation of the current time.
801        @note
802            This named option will only work if you are using a parameters object created
803            from a high-level program (HighLevelGpuProgram).
804        @param name The name of the parameter
805        @param factor The amount by which to scale the time value
806        */ 
807        void setNamedConstantFromTime(const String& name, Real factor);
808        /// Internal method for associating a parameter name with an index
809        void _mapParameterNameToIndex(const String& name, const size_t index );
810
811        /** Gets the constant index associated with a named parameter. */
812        size_t getParamIndex(const String& name);
813
814
815        /** Sets whether or not we need to transpose the matrices passed in from the rest of OGRE.
816        @remarks
817            D3D uses transposed matrices compared to GL and OGRE; this is not important when you
818            use programs which are written to process row-major matrices, such as those generated
819            by Cg, but if you use a program written to D3D's matrix layout you will need to enable
820            this flag.
821        */
822        void setTransposeMatrices(bool val) { mTransposeMatrices = val; }
823        /// Gets whether or not matrices are to be transposed when set
824        bool getTransposeMatrices(void) const { return mTransposeMatrices; }
825
826                /** Copies the values of all constants (including auto constants) from another
827                        GpuProgramParameters object.
828                */
829                void copyConstantsFrom(const GpuProgramParameters& source);
830
831        /** Add (or update) a constant definition which describes a constant. 
832                @remarks
833                        Mainly used for Material serialization but could also be used by material
834            editors. Returns the index of the constant definition.
835        @param name The name of the parameter.
836        @param index The constant index at which to place the parameter (each constant is
837            a 4D float).
838        @param elementCount The number of elements that make up the parameter.
839                        An example is if the parameter is a matrix4x4 then there are 16
840                        elements.
841        @param isReal If true then indicates that the elements are float else they are int.
842        */
843        size_t addConstantDefinition(const String& name, const size_t index,
844                        const size_t elementCount, const ElementType elementType);
845
846        /** gets the constant definition associated with name if found else returns NULL
847        @param name The name of the constant
848        */
849        const ConstantDefinition* getConstantDefinition(const String& name) const;
850        /** gets the constant definition using an index into the constant definition array.
851            If the index is out of bounds then NULL is returned;
852        @param idx The constant index
853        */
854        const ConstantDefinition* getConstantDefinition(const size_t idx) const;
855        /** Find a matching constant defintion.  Matches name, entry index, and element type.
856        @returns NULL if no match is found.
857        */
858        const ConstantDefinition* findMatchingConstantDefinition(const String& name,
859            const size_t entryIndex, const ElementType elementType) const;
860
861        /** Returns the number of constant definitions
862        */
863        size_t getNumConstantDefinitions(void) const { return mConstantDefinitions.size(); }
864        /** Set the constant definition's Auto state.
865        @param index The index of the constant definition.
866        @param isAuto If true then constant is being updated automatically.
867        @param autoIndex Index for AutoConstantEntry.
868        */
869        void setConstantDefinitionAutoState( const size_t index,
870                        const bool isAuto, const size_t autoIndex );
871        /** gets the auto constant definition associated with name if found else returns NULL
872        @param name The name of the auto constant
873        */
874        static const AutoConstantDefinition* getAutoConstantDefinition(const String& name);
875        /** gets the auto constant definition using an index into the auto constant definition array.
876            If the index is out of bounds then NULL is returned;
877        @param idx The auto constant index
878        */
879        static const AutoConstantDefinition* getAutoConstantDefinition(const size_t idx);
880        /** Returns the number of auto constant definitions
881        */
882        static size_t getNumAutoConstantDefinitions(void);
883        /** increments the multipass number entry by 1 if it exists
884        */
885        void incPassIterationNumber(void);
886        /** gets the MultipassEntry if it exists.
887        @returns NULL if a Multipass constant entry does not exist.
888        */
889        RealConstantEntry* getPassIterationEntry(void);
890        /** gets the MultipassEntry index.  The value returned is only valid if if
891            getMultipassEntry() does not return NULL.
892        */
893        size_t getPassIterationEntryIndex(void) const { return mActivePassIterationEntryIndex; }
894    };
895
896    /// Shared pointer used to hold references to GpuProgramParameters instances
897    typedef SharedPtr<GpuProgramParameters> GpuProgramParametersSharedPtr;
898
899    // Forward declaration
900    class GpuProgramPtr;
901
902        /** Defines a program which runs on the GPU such as a vertex or fragment program.
903        @remarks
904                This class defines the low-level program in assembler code, the sort used to
905                directly assemble into machine instructions for the GPU to execute. By nature,
906                this means that the assembler source is rendersystem specific, which is why this
907                is an abstract class - real instances are created through the RenderSystem.
908                If you wish to use higher level shading languages like HLSL and Cg, you need to
909                use the HighLevelGpuProgram class instead.
910        */
911        class _OgreExport GpuProgram : public Resource
912        {
913        protected:
914                /// Command object - see ParamCommand
915                class _OgreExport CmdType : public ParamCommand
916                {
917                public:
918                        String doGet(const void* target) const;
919                        void doSet(void* target, const String& val);
920                };
921                class _OgreExport CmdSyntax : public ParamCommand
922                {
923                public:
924                        String doGet(const void* target) const;
925                        void doSet(void* target, const String& val);
926                };
927                class _OgreExport CmdSkeletal : public ParamCommand
928                {
929                public:
930                        String doGet(const void* target) const;
931                        void doSet(void* target, const String& val);
932                };
933                // Command object for setting / getting parameters
934                static CmdType msTypeCmd;
935                static CmdSyntax msSyntaxCmd;
936                static CmdSkeletal msSkeletalCmd;
937       
938                /// The type of the program
939                GpuProgramType mType;
940                /// The name of the file to load source from (may be blank)
941                String mFilename;
942        /// The assembler source of the program (may be blank until file loaded)
943        String mSource;
944        /// Whether we need to load source from file or not
945        bool mLoadFromFile;
946        /// Syntax code eg arbvp1, vs_2_0 etc
947        String mSyntaxCode;
948        /// Does this (vertex) program include skeletal animation?
949        bool mSkeletalAnimation;
950                /// Does this (vertex) program include morph animation?
951                bool mMorphAnimation;
952                /// Does this (vertex) program include pose animation (count of number of poses supported)
953                ushort mPoseAnimation;
954                /// The default parameters for use with this object
955                GpuProgramParametersSharedPtr mDefaultParams;
956                /// Does this program want light states passed through fixed pipeline
957                bool mPassSurfaceAndLightStates;
958                /// Did we encounter a compilation error?
959                bool mCompileError;
960
961                /** Internal method for setting up the basic parameter definitions for a subclass.
962                @remarks
963                Because StringInterface holds a dictionary of parameters per class, subclasses need to
964                call this to ask the base class to add it's parameters to their dictionary as well.
965                Can't do this in the constructor because that runs in a non-virtual context.
966                @par
967                The subclass must have called it's own createParamDictionary before calling this method.
968                */
969                void setupBaseParamDictionary(void);
970
971                /// @copydoc Resource::calculateSize
972                size_t calculateSize(void) const { return 0; } // TODO
973
974                /// @copydoc Resource::loadImpl
975                void loadImpl(void);
976        public:
977
978                GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
979                        const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
980
981                virtual ~GpuProgram() {}
982
983        /** Sets the filename of the source assembly for this program.
984        @remarks
985            Setting this will have no effect until you (re)load the program.
986        */
987        virtual void setSourceFile(const String& filename);
988
989                /** Sets the source assembly for this program from an in-memory string.
990        @remarks
991            Setting this will have no effect until you (re)load the program.
992        */
993        virtual void setSource(const String& source);
994
995        /** Gets the syntax code for this program e.g. arbvp1, fp20, vs_1_1 etc */
996        virtual const String& getSyntaxCode(void) const { return mSyntaxCode; }
997
998                /** Sets the syntax code for this program e.g. arbvp1, fp20, vs_1_1 etc */
999                virtual void setSyntaxCode(const String& syntax);
1000
1001                /** Gets the name of the file used as source for this program. */
1002                virtual const String& getSourceFile(void) const { return mFilename; }
1003        /** Gets the assembler source for this program. */
1004        virtual const String& getSource(void) const { return mSource; }
1005                /// Set the program type (only valid before load)
1006                virtual void setType(GpuProgramType t);
1007        /// Get the program type
1008        virtual GpuProgramType getType(void) const { return mType; }
1009
1010        /** Returns the GpuProgram which should be bound to the pipeline.
1011        @remarks
1012            This method is simply to allow some subclasses of GpuProgram to delegate
1013            the program which is bound to the pipeline to a delegate, if required. */
1014        virtual GpuProgram* _getBindingDelegate(void) { return this; }
1015
1016        /** Returns whether this program can be supported on the current renderer and hardware. */
1017        virtual bool isSupported(void) const;
1018
1019        /** Creates a new parameters object compatible with this program definition.
1020        @remarks
1021            It is recommended that you use this method of creating parameters objects
1022            rather than going direct to GpuProgramManager, because this method will
1023            populate any implementation-specific extras (like named parameters) where
1024            they are appropriate.
1025        */
1026        virtual GpuProgramParametersSharedPtr createParameters(void);
1027
1028        /** Sets whether a vertex program includes the required instructions
1029        to perform skeletal animation.
1030        @remarks
1031        If this is set to true, OGRE will not blend the geometry according to
1032        skeletal animation, it will expect the vertex program to do it.
1033        */
1034        virtual void setSkeletalAnimationIncluded(bool included)
1035        { mSkeletalAnimation = included; }
1036
1037        /** Returns whether a vertex program includes the required instructions
1038            to perform skeletal animation.
1039        @remarks
1040            If this returns true, OGRE will not blend the geometry according to
1041            skeletal animation, it will expect the vertex program to do it.
1042        */
1043        virtual bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; }
1044
1045        /** Sets whether a vertex program includes the required instructions
1046        to perform morph animation.
1047        @remarks
1048        If this is set to true, OGRE will not blend the geometry according to
1049        morph animation, it will expect the vertex program to do it.
1050        */
1051        virtual void setMorphAnimationIncluded(bool included)
1052                { mMorphAnimation = included; }
1053
1054        /** Sets whether a vertex program includes the required instructions
1055        to perform pose animation.
1056        @remarks
1057        If this is set to true, OGRE will not blend the geometry according to
1058        pose animation, it will expect the vertex program to do it.
1059                @param poseCount The number of simultaneous poses the program can blend
1060        */
1061        virtual void setPoseAnimationIncluded(ushort poseCount)
1062                { mPoseAnimation = poseCount; }
1063
1064                /** Returns whether a vertex program includes the required instructions
1065            to perform morph animation.
1066        @remarks
1067            If this returns true, OGRE will not blend the geometry according to
1068            morph animation, it will expect the vertex program to do it.
1069        */
1070        virtual bool isMorphAnimationIncluded(void) const { return mMorphAnimation; }
1071
1072                /** Returns whether a vertex program includes the required instructions
1073            to perform pose animation.
1074        @remarks
1075            If this returns true, OGRE will not blend the geometry according to
1076            pose animation, it will expect the vertex program to do it.
1077        */
1078        virtual bool isPoseAnimationIncluded(void) const { return mPoseAnimation > 0; }
1079                /** Returns the number of simultaneous poses the vertex program can
1080                        blend, for use in pose animation.
1081        */
1082        virtual ushort getNumberOfPosesIncluded(void) const { return mPoseAnimation; }
1083
1084                /** Get a reference to the default parameters which are to be used for all
1085                        uses of this program.
1086                @remarks
1087                        A program can be set up with a list of default parameters, which can save time when
1088                        using a program many times in a material with roughly the same settings. By
1089                        retrieving the default parameters and populating it with the most used options,
1090                        any new parameter objects created from this program afterwards will automatically include
1091                        the default parameters; thus users of the program need only change the parameters
1092                        which are unique to their own usage of the program.
1093                */
1094                virtual GpuProgramParametersSharedPtr getDefaultParameters(void);
1095
1096        /** Returns true if default parameters have been set up. 
1097        */
1098        virtual bool hasDefaultParameters(void) const { return !mDefaultParams.isNull(); }
1099
1100                /** Sets whether a vertex program requires light and material states to be passed
1101                to through fixed pipeline low level API rendering calls.
1102                @remarks
1103                If this is set to true, OGRE will pass all active light states to the fixed function
1104                pipeline.  This is useful for high level shaders like GLSL that can read the OpenGL
1105                light and material states.  This way the user does not have to use autoparameters to
1106                pass light position, color etc.
1107                */
1108                virtual void setSurfaceAndPassLightStates(bool state)
1109                        { mPassSurfaceAndLightStates = state; }
1110
1111                /** Returns whether a vertex program wants light and material states to be passed
1112                through fixed pipeline low level API rendering calls
1113                */
1114                virtual bool getPassSurfaceAndLightStates(void) const { return mPassSurfaceAndLightStates; }
1115
1116        /** Returns a string that specifies the language of the gpu programs as specified
1117        in a material script. ie: asm, cg, hlsl, glsl
1118        */
1119        virtual const String& getLanguage(void) const;
1120
1121                /** Did this program encounter a compile error when loading?
1122                */
1123                virtual bool hasCompileError(void) const { return mCompileError; }
1124
1125                /** Reset a compile error if it occurred, allowing the load to be retried
1126                */
1127                virtual void resetCompileError(void) { mCompileError = false; }
1128    protected:
1129        /// Virtual method which must be implemented by subclasses, load from mSource
1130        virtual void loadFromSource(void) = 0;
1131
1132        };
1133
1134
1135        /** Specialisation of SharedPtr to allow SharedPtr to be assigned to GpuProgramPtr
1136        @note Has to be a subclass since we need operator=.
1137        We could templatise this instead of repeating per Resource subclass,
1138        except to do so requires a form VC6 does not support i.e.
1139        ResourceSubclassPtr<T> : public SharedPtr<T>
1140        */
1141        class _OgreExport GpuProgramPtr : public SharedPtr<GpuProgram>
1142        {
1143        public:
1144                GpuProgramPtr() : SharedPtr<GpuProgram>() {}
1145                explicit GpuProgramPtr(GpuProgram* rep) : SharedPtr<GpuProgram>(rep) {}
1146                GpuProgramPtr(const GpuProgramPtr& r) : SharedPtr<GpuProgram>(r) {}
1147                GpuProgramPtr(const ResourcePtr& r) : SharedPtr<GpuProgram>()
1148                {
1149                        // lock & copy other mutex pointer
1150            OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
1151            {
1152                            OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
1153                            OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
1154                            pRep = static_cast<GpuProgram*>(r.getPointer());
1155                            pUseCount = r.useCountPointer();
1156                            if (pUseCount)
1157                            {
1158                                    ++(*pUseCount);
1159                            }
1160            }
1161                }
1162
1163                /// Operator used to convert a ResourcePtr to a GpuProgramPtr
1164                GpuProgramPtr& operator=(const ResourcePtr& r)
1165                {
1166                        if (pRep == static_cast<GpuProgram*>(r.getPointer()))
1167                                return *this;
1168                        release();
1169                        // lock & copy other mutex pointer
1170            OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
1171            {
1172                OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
1173                            OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
1174                            pRep = static_cast<GpuProgram*>(r.getPointer());
1175                            pUseCount = r.useCountPointer();
1176                            if (pUseCount)
1177                            {
1178                                    ++(*pUseCount);
1179                            }
1180            }
1181                        return *this;
1182                }
1183        /// Operator used to convert a HighLevelGpuProgramPtr to a GpuProgramPtr
1184        GpuProgramPtr& operator=(const HighLevelGpuProgramPtr& r);
1185        };
1186}
1187
1188#endif
Note: See TracBrowser for help on using the repository browser.