You.i Engine
CYIAssetShaderObject Class Reference

Detailed Description

Shader object asset. Can either be loaded from a precompiled binary, or loaded as source and compiled at run-time.

#include <asset/YiAssetShaderObject.h>

Inheritance diagram for CYIAssetShaderObject:

Public Types

enum  ShaderType {
enum  CodeType {
- Public Types inherited from CYIAsset
enum  PathType {
  PathType::Absolute = 0,

Public Member Functions

 CYIAssetShaderObject ()
 CYIAssetShaderObject (const CYIString &path, PathType pathType=PathType::Relative)
virtual ~CYIAssetShaderObject ()
void GetCode (uint8_t **ppCode, size_t *pCodeSize) const
CodeType GetCodeType () const
ShaderType GetType () const
bool IsFromDisk () const
void SetFromDisk (bool fromDisk)
void SetCode (const uint8_t *pCode, size_t codeSize, CodeType type)
void SetType (ShaderType type)
- 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)
virtual bool Prepare ()

Protected Member Functions

virtual void OnUnload () 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 OnLoad ()

Additional Inherited Members

- Static Protected Attributes inherited from CYIAsset
static ssize_t INVALID_ID

Member Enumeration Documentation

◆ CodeType


Binary data that is compiled off-line prior to program execution. This data can come from disk or from memory. See IsFromDisk.


String data that is compiled at run-time. This data can come from disk or from memory. See IsFromDisk.

◆ ShaderType

Describes the supported shader types. Together these form a shader program that describes how to render geometry.


Describes code that will be executed per-vertex.


Describes code that will be executed per-fragment.


Describes code that will be executed as groups of threads.

Constructor & Destructor Documentation

◆ CYIAssetShaderObject() [1/2]

CYIAssetShaderObject::CYIAssetShaderObject ( )

◆ CYIAssetShaderObject() [2/2]

CYIAssetShaderObject::CYIAssetShaderObject ( const CYIString path,
PathType  pathType = PathType::Relative 

◆ ~CYIAssetShaderObject()

virtual CYIAssetShaderObject::~CYIAssetShaderObject ( )

Member Function Documentation

◆ GetCode()

void CYIAssetShaderObject::GetCode ( uint8_t **  ppCode,
size_t pCodeSize 
) const

Returns a pointer to the data defining this asset. The data will be of size pCodeSize in bytes.

If the data type of the shader, specified by GetDataType(), is CYIAssetShaderObject::CodeType::PrecompiledBinary, the data will be a binary blob representing a compiled shader object. If the data type is CYIAssetShaderObject::CodeType::UncompiledSource, the data will be a string containing the shader source code. This source code will be compiled at run-time prior to usage, but will not be accessible as binary data.

◆ GetCodeType()

CodeType CYIAssetShaderObject::GetCodeType ( ) const

Returns the format of the data contained in this asset.

◆ GetType()

ShaderType CYIAssetShaderObject::GetType ( ) const

Returns the type of shader object.

◆ IsFromDisk()

bool CYIAssetShaderObject::IsFromDisk ( ) const

Returns true if this asset is loaded from disk and false if it is defined in-memory.

◆ OnUnload()

virtual void CYIAssetShaderObject::OnUnload ( )

Reimplemented from CYIAsset.

◆ SetCode()

void CYIAssetShaderObject::SetCode ( const uint8_t *  pCode,
size_t  codeSize,
CodeType  type 

Sets the data defining this asset to be pCode with size codeSize in bytes. If the code is a null-terminated string, it is up to the user to specify the size (not including the terminating character).

It is up to the user to delete any memory that has been allocated to store the code, this object maintains its own copy.

◆ SetFromDisk()

void CYIAssetShaderObject::SetFromDisk ( bool  fromDisk)
See also

◆ SetType()

void CYIAssetShaderObject::SetType ( ShaderType  type)

Sets the type of shader object.

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