You.i Engine
CYIAssetShaderProgram Class Reference

Detailed Description

Shader program asset. Contains a vector of CYIAssetShaderObject types.

#include <asset/YiAssetShaderProgram.h>

Inheritance diagram for CYIAssetShaderProgram:

Public Member Functions

 CYIAssetShaderProgram ()
 
 CYIAssetShaderProgram (const CYIString &path, PathType pathType=PathType::Relative)
 
virtual ~CYIAssetShaderProgram ()
 
void AddShaderObject (const std::shared_ptr< CYIAssetShaderObject > &pShaderObjectAsset)
 
const std::vector< std::shared_ptr< CYIAssetShaderObject > > & GetShaderObjects ()
 
void RemoveShaderObject (const std::shared_ptr< CYIAssetShaderObject > &pShaderObjectAsset)
 
void SetAttributeLocation (CYIString name, uint32_t location)
 
void UnsetAttributeLocation (CYIString name)
 
const std::vector< std::pair< uint32_t, CYIString > > & GetAttributeLocations ()
 
bool Load ()
 
- Public Member Functions inherited from CYIAssetHardware
 CYIAssetHardware ()
 
virtual ~CYIAssetHardware () override
 
virtual bool RequestHardwareLoad ()
 
virtual bool RequestHardwareUnload ()
 
virtual bool RequestInvalidate ()
 
virtual bool RequestRestore ()
 
virtual bool Prepare () override
 
const std::shared_ptr< IYIGPUObject > & GetGPUObject () const
 
bool IsLoadedOnGPU () const
 
RetentionPolicy GetRetentionPolicy () const
 
void SetRetentionPolicy (RetentionPolicy policy)
 
- Public Member Functions inherited from CYIAsset
virtual ~CYIAsset ()
 
const CYIStringGetPath () const
 
CYIAssetLoadParamsGetLoadParameters () const
 
virtual std::pair< size_t, size_tGetApproximateSize () const
 
bool SetName (const CYIString &name)
 
const CYIStringGetName () const
 
bool Load ()
 
void Unload ()
 
bool IsLoaded () const
 
bool Equals (const std::shared_ptr< CYIAsset > &pAsset)
 

Protected Member Functions

virtual std::shared_ptr< IYIGPUObjectCreateGPUObject () const override
 
void UpdateApproximateSize ()
 
- Protected Member Functions inherited from CYIAssetHardware
virtual void ApplyRetainmentPolicy ()
 
virtual void OnLoad () override
 
- Protected Member Functions inherited from CYIAsset
 CYIAsset ()
 
ssize_t GetID () const
 
void SetPath (const CYIString &path, PathType pathType)
 
void SetApproximateSize (size_t size)
 
void SetLoaded (bool assetLoaded)
 
void SetLoadParameters (std::unique_ptr< CYIAssetLoadParams > pParams)
 
virtual void OnUnload ()
 

Additional Inherited Members

- Public Types inherited from CYIAssetHardware
enum  RetentionPolicy {
  RetentionPolicy::Retain = 0,
  RetentionPolicy::Unload
}
 The CYIAssetHardware::RetentionPolicy enum specifies the retention policy of static hardware assets from the CPU memory once they are loaded onto the GPU. It is globally configurable, where new CYIAssetHardware will be making use of it and the can also change directly per assets. Be aware that on some platform, it is best to leave the assets retained on the CPU side when the platform lifecycle has the ability to destroy the graphic context while the app still runs, giving You.i Engine the ability to re-load every assets back onto GPU memory really fast. A good example of such platform would be Android. More...
 
- Public Types inherited from CYIAsset
enum  PathType {
  PathType::Absolute = 0,
  PathType::Relative
}
 
- Protected Attributes inherited from CYIAssetHardware
bool m_hardwareLoadRequested
 
std::shared_ptr< IYIGPUObjectm_pGPUObject
 
RetentionPolicy m_retentionPolicy
 
- Static Protected Attributes inherited from CYIAsset
static ssize_t INVALID_ID
 

Constructor & Destructor Documentation

◆ CYIAssetShaderProgram() [1/2]

CYIAssetShaderProgram::CYIAssetShaderProgram ( )

◆ CYIAssetShaderProgram() [2/2]

CYIAssetShaderProgram::CYIAssetShaderProgram ( const CYIString path,
PathType  pathType = PathType::Relative 
)

◆ ~CYIAssetShaderProgram()

virtual CYIAssetShaderProgram::~CYIAssetShaderProgram ( )
virtual

Member Function Documentation

◆ AddShaderObject()

void CYIAssetShaderProgram::AddShaderObject ( const std::shared_ptr< CYIAssetShaderObject > &  pShaderObjectAsset)

Adds a pShaderObjectAsset to the list of managed shader objects.

◆ CreateGPUObject()

virtual std::shared_ptr<IYIGPUObject> CYIAssetShaderProgram::CreateGPUObject ( ) const
overrideprotectedvirtual

Subclasses must implement this function to instance a new IYIGPUObject concrete type corresponding to the asset container. This function will be called by the CreateGPUObject implementation of CYIAssetHardware

Warning
This function may not return null!

Implements CYIAssetHardware.

◆ GetAttributeLocations()

const std::vector<std::pair<uint32_t, CYIString> >& CYIAssetShaderProgram::GetAttributeLocations ( )

Get attribute locations as a vector of pairs. The shader will be reloaded, if necessary.

◆ GetShaderObjects()

const std::vector<std::shared_ptr<CYIAssetShaderObject> >& CYIAssetShaderProgram::GetShaderObjects ( )

Returns a vector of shader objects. The shaders will be reloaded, if necessary.

◆ Load()

bool CYIAssetShaderProgram::Load ( )

◆ RemoveShaderObject()

void CYIAssetShaderProgram::RemoveShaderObject ( const std::shared_ptr< CYIAssetShaderObject > &  pShaderObjectAsset)

Removes a pShaderObjectAsset from the list of managed shader objects.

◆ SetAttributeLocation()

void CYIAssetShaderProgram::SetAttributeLocation ( CYIString  name,
uint32_t  location 
)

Declare a vertex attribute to be at a particular location. See CYIMesh for more information about You.i Engine default attribute locations.

This should ALWAYS be used to declare your attribute locations, for performance we do not provide a means for reading automatically generated attribute locations back from shaders.

//Default You.i Engine attribute locations
SetAttributeLocation("YiVertexPosition", CYIMesh::YI_F3POSITION);
SetAttributeLocation("YiVertexTexCoord", CYIMesh::YI_F2TEXCOORD);
//My custom vertex attributes
SetAttributeLocation("VertexFooness", 2);
SetAttributeLocation("Vertexibility", 3);

◆ UnsetAttributeLocation()

void CYIAssetShaderProgram::UnsetAttributeLocation ( CYIString  name)

Unset an attribute location setting

◆ UpdateApproximateSize()

void CYIAssetShaderProgram::UpdateApproximateSize ( )
protected

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