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

# Ogre::GpuProgramUsage Class Reference

This class makes the usage of a vertex and fragment programs (low-level or high-level), with a given set of parameters, explicit. More...

`#include <OgreGpuProgramUsage.h>`

List of all members.

## Public Methods

| GpuProgramUsage (GpuProgramType gptype)
| Default constructor.
| GpuProgramUsage (const GpuProgramUsage &rhs)
| Copy constructor.
GpuProgramType | getType (void) const
| Gets the type of program we're trying to link to.
void | setProgramName (const String &name, bool resetParams=true)
| Sets the name of the program to use.
void | setProgram (GpuProgram *prog)
| Sets the program to use.
GpuProgram * | getProgram () const
| Gets the program being used.
const String & | getProgramName (void) const
| Gets the program being used.
void | setParameters (GpuProgramParametersSharedPtr params)
| Sets the program parameters that should be used; because parameters can be shared between multiple usages for efficiency, this method is here for you to register externally created parameter objects.
GpuProgramParametersSharedPtr | getParameters (void)
| Gets the parameters being used here.
void | _load (void)
| Load this usage (and ensure program is loaded).
void | _unload (void)
| Unload this usage.

## Protected Attributes

GpuProgramType | mType
GpuProgram * | mProgram
GpuProgramParametersSharedPtr | mParameters
| program parameters

## Detailed Description

This class makes the usage of a vertex and fragment programs (low-level or high-level), with a given set of parameters, explicit.

Remarks:
  Using a vertex or fragment program can get fairly complex; besides the fairly rudimentary process of binding a program to the GPU for rendering, managing usage has few complications, such as:
  - Programs can be high level (e.g. Cg, RenderMonkey) or low level (assembler). Using either should be relatively seamless, although high-level programs give you the advantage of being able to use named parameters, instead of just indexed registers
  - Programs and parameters can be shared between multiple usages, in order to save memory
  - When you define a user of a program, such as a material, you often want to be able to set up the definition but not load / compile / assemble the program at that stage, because it is not needed just yet. The program should be loaded when it is first needed, or earlier if specifically requested. The program may not be defined at this time, you may want to have scripts that can set up the definitions independent of the order in which those scripts are loaded.
  This class packages up those details so you don't have to worry about them. For example, this class lets you define a high-level program and set up the parameters for it, without having loaded the program (which you normally could not do). When the program is loaded and compiled, this class will then validate the parameters you supplied earlier and turn them into runtime parameters.

  Just incase it wasn't clear from the above, this class provides linkage to both GpuProgram and HighLevelGpuProgram, despite its name.

Definition at line 62 of file OgreGpuProgramUsage.h.

## Constructor & Destructor Documentation

Ogre::GpuProgramUsage::GpuProgramUsage | ( | GpuProgramType | gptype | ) |

Default constructor.

Parameters:

  gptype | The type of program to link to

Definition at line 34 of file OgreGpuProgramUsage.cpp.

References Ogre::GpuProgramType.

Ogre::GpuProgramUsage::GpuProgramUsage | ( | const GpuProgramUsage & | rhs | ) |

| Copy constructor. Definition at line 39 of file OgreGpuProgramUsage.cpp. References mParameters, mProgram, and mType.

## Member Function Documentation

void Ogre::GpuProgramUsage::_load | ( | void |  | ) |

| Load this usage (and ensure program is loaded). Definition at line 87 of file OgreGpuProgramUsage.cpp. References Ogre::Resource::isLoaded(), Ogre::GpuProgram::load(), and mProgram. Referenced by Ogre::Pass::_load().

void Ogre::GpuProgramUsage::_unload | ( | void |  | ) |

| Unload this usage. Definition at line 93 of file OgreGpuProgramUsage.cpp.

GpuProgramParametersSharedPtr Ogre::GpuProgramUsage::getParameters | ( | void |  | ) |

Gets the parameters being used here.

Definition at line 69 of file OgreGpuProgramUsage.cpp.

References Except, Ogre::GpuProgramParametersSharedPtr, and mParameters.

Referenced by Ogre::Pass::_updateAutoParamsLightsOnly(), Ogre::Pass::_updateAutoParamsNoLights(), Ogre::Pass::getFragmentProgramParameters(), Ogre::Pass::getShadowCasterVertexProgramParameters(), Ogre::Pass::getShadowReceiverVertexProgramParameters(), and Ogre::Pass::getVertexProgramParameters().

GpuProgram* Ogre::GpuProgramUsage::getProgram | ( |  | ) | const

| Gets the program being used. Definition at line 104 of file OgreGpuProgramUsage.h. Referenced by Ogre::Pass::getFragmentProgram(), Ogre::Pass::getShadowCasterVertexProgram(), Ogre::Pass::getShadowReceiverVertexProgram(), and Ogre::Pass::getVertexProgram().

const String& Ogre::GpuProgramUsage::getProgramName | ( | void |  | ) | const

| Gets the program being used. Definition at line 106 of file OgreGpuProgramUsage.h. References Ogre::Resource::getName(), and Ogre::String. Referenced by Ogre::Pass::getFragmentProgramName(), Ogre::Pass::getShadowCasterVertexProgramName(), Ogre::Pass::getShadowReceiverVertexProgramName(), and Ogre::Pass::getVertexProgramName().

GpuProgramType Ogre::GpuProgramUsage::getType | ( | void |  | ) | const

| Gets the type of program we're trying to link to. Definition at line 83 of file OgreGpuProgramUsage.h. References Ogre::GpuProgramType.

void Ogre::GpuProgramUsage::setParameters | ( | GpuProgramParametersSharedPtr | params | ) |

Sets the program parameters that should be used; because parameters can be shared between multiple usages for efficiency, this method is here for you to register externally created parameter objects.

Otherwise, the parameters will be created for you when a program is linked.

Definition at line 64 of file OgreGpuProgramUsage.cpp.

References Ogre::GpuProgramParametersSharedPtr, mParameters, and params.

Referenced by Ogre::Pass::setFragmentProgramParameters(), Ogre::Pass::setShadowCasterVertexProgramParameters(), Ogre::Pass::setShadowReceiverVertexProgramParameters(), and Ogre::Pass::setVertexProgramParameters().

void Ogre::GpuProgramUsage::setProgram | ( | GpuProgram * | prog | ) |

Sets the program to use.

Remarks:
  Note that this will create a fresh set of parameters from the new program being linked, so if you had previously set parameters you will have to set them again.

Definition at line 80 of file OgreGpuProgramUsage.cpp.

References Ogre::GpuProgram::createParameters(), mParameters, and mProgram.

void Ogre::GpuProgramUsage::setProgramName | ( | const String & | name,
|  | bool | resetParams = true
| ) |

Sets the name of the program to use.

Parameters:

  name | The name of the program to use
  resetParams | If true, this will create a fresh set of parameters from the new program being linked, so if you had previously set parameters you will have to set them again. If you set this to false, you must be absolutely sure that the parameters match perfectly, and in the case of named parameters refers to the indexes underlying them, not just the names.

Definition at line 46 of file OgreGpuProgramUsage.cpp.

References Ogre::GpuProgram::createParameters(), Except, Ogre::GPT_VERTEX_PROGRAM, mParameters, mProgram, mType, and Ogre::String.

Referenced by Ogre::Pass::setFragmentProgram(), Ogre::Pass::setShadowCasterVertexProgram(), Ogre::Pass::setShadowReceiverVertexProgram(), and Ogre::Pass::setVertexProgram().

## Member Data Documentation

GpuProgramParametersSharedPtr Ogre::GpuProgramUsage::mParameters`[protected]`

| program parameters Definition at line 70 of file OgreGpuProgramUsage.h. Referenced by getParameters(), GpuProgramUsage(), setParameters(), setProgram(), and setProgramName().

GpuProgram* Ogre::GpuProgramUsage::mProgram`[protected]`

| Definition at line 67 of file OgreGpuProgramUsage.h. Referenced by _load(), GpuProgramUsage(), setProgram(), and setProgramName().

GpuProgramType Ogre::GpuProgramUsage::mType`[protected]`

| Definition at line 65 of file OgreGpuProgramUsage.h. Referenced by GpuProgramUsage(), and setProgramName().

The documentation for this class was generated from the following files:

- OgreGpuProgramUsage.h
- OgreGpuProgramUsage.cpp

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:50:59 2004