Ogre::GpuProgramUsage Class Reference
Core » Materials

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>`

Inheritance diagram for Ogre::GpuProgramUsage:
[legend]

## Public Member Functions

| GpuProgramUsage (GpuProgramType gptype, Pass *parent)
| Default constructor. More...
| GpuProgramUsage (const GpuProgramUsage &rhs, Pass *newparent)
| Copy constructor. More...
| ~GpuProgramUsage ()
void | _load (void)
| Load this usage (and ensure program is loaded) More...
void | _unload (void)
| Unload this usage. More...
virtual OGRE_DEPRECATED void | backgroundLoadingComplete (Resource *)
| Callback to indicate that background loading has completed. More...
virtual OGRE_DEPRECATED void | backgroundPreparingComplete (Resource *)
| Callback to indicate that background preparing has completed. More...
size_t | calculateSize (void) const
GpuProgramParametersSharedPtr | getParameters (void)
| Gets the parameters being used here. More...
const GpuProgramPtr & | getProgram () const
| Gets the program being used. More...
const String & | getProgramName (void) const
| Gets the program being used. More...
GpuProgramType | getType (void) const
| Gets the type of program we're trying to link to. More...
void | loadingComplete (Resource *prog)
| Called whenever the resource finishes loading. More...
void | operator delete (void *ptr)
void | operator delete (void *ptr, void *)
void | operator delete (void *ptr, const char *, int, const char *)
void | operator delete[] (void *ptr)
void | operator delete[] (void *ptr, const char *, int, const char *)
void * | operator new (size_t sz, const char *file, int line, const char *func)
| operator new, with debug line info More...
void * | operator new (size_t sz)
void * | operator new (size_t sz, void *ptr)
| placement operator new More...
void * | operator new[] (size_t sz, const char *file, int line, const char *func)
| array operator new, with debug line info More...
void * | operator new[] (size_t sz)
virtual void | preparingComplete (Resource *)
| Called whenever the resource finishes preparing (paging into memory). More...
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. More...
void | setProgram (GpuProgramPtr &prog)
| Sets the program to use. More...
void | setProgramName (const String &name, bool resetParams=true)
| Sets the name of the program to use. More...
void | unloadingComplete (Resource *prog)
| Called whenever the resource has been unloaded. More...

## Protected Member Functions

void | recreateParameters ()

## Protected Attributes

GpuProgramParametersSharedPtr | mParameters
| Program parameters. More...
Pass * | mParent
GpuProgramPtr | mProgram
| The program link. More...
bool | mRecreateParams
| Whether to recreate parameters next load. More...
GpuProgramType | mType

## 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 73 of file OgreGpuProgramUsage.h.

## Constructor & Destructor Documentation

## GpuProgramUsage() [1/2]

Ogre::GpuProgramUsage::GpuProgramUsage | ( | GpuProgramType | gptype,
|  | Pass * | parent
| ) |  |

Default constructor.

Parameters

  gptype | The type of program to link to

## GpuProgramUsage() [2/2]

Ogre::GpuProgramUsage::GpuProgramUsage | ( | const GpuProgramUsage & | rhs,
|  | Pass * | newparent
| ) |  |

Copy constructor.

## ~GpuProgramUsage()

Ogre::GpuProgramUsage::~GpuProgramUsage | ( |  | ) |

## Member Function Documentation

## _load()

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

Load this usage (and ensure program is loaded)

## _unload()

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

Unload this usage.

## backgroundLoadingComplete()

virtual OGRE_DEPRECATED void Ogre::Resource::Listener::backgroundLoadingComplete | ( | Resource * |  | ) |

virtual inherited

Callback to indicate that background loading has completed.

Deprecated:
  Use loadingComplete instead.

Reimplemented in Ogre::Entity.

Definition at line 93 of file OgreResource.h.

## backgroundPreparingComplete()

virtual OGRE_DEPRECATED void Ogre::Resource::Listener::backgroundPreparingComplete | ( | Resource * |  | ) |

virtual inherited

Callback to indicate that background preparing has completed.

Deprecated:
  Use preparingComplete instead.

Definition at line 99 of file OgreResource.h.

## calculateSize()

size_t Ogre::GpuProgramUsage::calculateSize | ( | void |  | ) | const

## getParameters()

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

Gets the parameters being used here.

## getProgram()

const GpuProgramPtr& Ogre::GpuProgramUsage::getProgram | ( |  | ) | const

Gets the program being used.

Definition at line 122 of file OgreGpuProgramUsage.h.

## getProgramName()

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

Gets the program being used.

Definition at line 124 of file OgreGpuProgramUsage.h.

References Ogre::Resource::getName().

## getType()

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

Gets the type of program we're trying to link to.

Definition at line 101 of file OgreGpuProgramUsage.h.

## loadingComplete()

void Ogre::GpuProgramUsage::loadingComplete | ( | Resource * |  | ) |

virtual

Called whenever the resource finishes loading.

Remarks
  If a Resource has been marked as background loaded (

See also
  Resource::setBackgroundLoaded), the call does not itself occur in the thread which is doing the loading; when loading is complete a response indicator is placed with the ResourceGroupManager, which will then be sent back to the listener as part of the application's primary frame loop thread.

Reimplemented from Ogre::Resource::Listener.

## operator delete() [1/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr | ) |

inherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

## operator delete() [2/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | void * |
| ) |  |

inherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

## operator delete() [3/3]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 108 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [1/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr | ) |

inherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

## operator delete[]() [2/2]

template<class Alloc >

void Ogre::AllocatedObject< Alloc >::operator delete[] | ( | void * | ptr,
|  | const char * | ,
|  | int | ,
|  | const char * |
| ) |  |

inherited

Definition at line 119 of file OgreMemoryAllocatedObject.h.

## operator new() [1/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

## operator new() [2/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz | ) |

inherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

## operator new() [3/3]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new | ( | size_t | sz,
|  | void * | ptr
| ) |  |

inherited

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

## operator new[]() [1/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz,
|  | const char * | file,
|  | int | line,
|  | const char * | func
| ) |  |

inherited

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

## operator new[]() [2/2]

template<class Alloc >

void* Ogre::AllocatedObject< Alloc >::operator new[] | ( | size_t | sz | ) |

inherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

## preparingComplete()

virtual void Ogre::Resource::Listener::preparingComplete | ( | Resource * |  | ) |

virtual inherited

Called whenever the resource finishes preparing (paging into memory).

Remarks
  If a Resource has been marked as background loaded (

See also
  Resource::setBackgroundLoaded) the call does not itself occur in the thread which is doing the preparing; when preparing is complete a response indicator is placed with the ResourceGroupManager, which will then be sent back to the listener as part of the application's primary frame loop thread.

Definition at line 120 of file OgreResource.h.

## recreateParameters()

void Ogre::GpuProgramUsage::recreateParameters | ( |  | ) |

protected

## setParameters()

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.

## setProgram()

void Ogre::GpuProgramUsage::setProgram | ( | GpuProgramPtr & | 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.

## setProgramName()

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.

## unloadingComplete()

void Ogre::GpuProgramUsage::unloadingComplete | ( | Resource * |  | ) |

virtual

Called whenever the resource has been unloaded.

Reimplemented from Ogre::Resource::Listener.

## Member Data Documentation

## mParameters

GpuProgramParametersSharedPtr Ogre::GpuProgramUsage::mParameters

protected

Program parameters.

Definition at line 82 of file OgreGpuProgramUsage.h.

## mParent

Pass* Ogre::GpuProgramUsage::mParent

protected

Definition at line 77 of file OgreGpuProgramUsage.h.

## mProgram

GpuProgramPtr Ogre::GpuProgramUsage::mProgram

protected

The program link.

Definition at line 79 of file OgreGpuProgramUsage.h.

## mRecreateParams

bool Ogre::GpuProgramUsage::mRecreateParams

protected

Whether to recreate parameters next load.

Definition at line 85 of file OgreGpuProgramUsage.h.

## mType

GpuProgramType Ogre::GpuProgramUsage::mType

protected

Definition at line 76 of file OgreGpuProgramUsage.h.

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

- OgreGpuProgramUsage.h

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.