VAPOR3 3.9.4
Public Member Functions | Static Public Member Functions | List of all members
VAPoR::ShaderManager Class Reference

Resource management class for shaders. More...

#include <ShaderManager.h>

Inheritance diagram for VAPoR::ShaderManager:
VAPoR::IResourceManager< std::string, ShaderProgram > Wasp::MyBase

Public Member Functions

ShaderProgramGetShader (const std::string &name)
 
SmartShaderProgram GetSmartShader (const std::string &name)
 
int LoadResourceByKey (const std::string &key)
 
- Public Member Functions inherited from VAPoR::IResourceManager< std::string, ShaderProgram >
virtual ~IResourceManager ()
 
bool HasResource (const std::string &key) const
 
bool HasResource (const ShaderProgram *resource) const
 
virtual int LoadResourceByKey (const std::string &key)=0
 
bool AddResource (const std::string &key, ShaderProgram *resource)
 
void DeleteResource (const std::string &key)
 
- Public Member Functions inherited from Wasp::MyBase
 MyBase ()
 
const string & getClassName () const
 

Static Public Member Functions

static ShaderCompileNewShaderFromFile (const std::string &path, const std::vector< std::string > &defines={})
 
static unsigned int GetShaderTypeFromPath (const std::string &path)
 
static std::string PreProcessShader (const std::string &path, const std::vector< std::string > &defines={})
 
static std::vector< std::string > GetShaderDependencies (const std::string &path)
 
- Static Public Member Functions inherited from Wasp::MyBase
static void SetErrMsg (const char *format,...)
 Record a formatted error message.
 
static void SetErrMsg (int errcode, const char *format,...)
 Record a formatted error message and an error code.
 
static const char * GetErrMsg ()
 
static void SetErrCode (int err_code)
 Record an error code.
 
static int GetErrCode ()
 Retrieve the current error code.
 
static void SetErrMsgCB (ErrMsgCB_T cb)
 
static ErrMsgCB_T GetErrMsgCB ()
 
static void SetErrMsgFilePtr (FILE *fp)
 
static const FILE * SetErrMsgFilePtr ()
 
static void SetDiagMsg (const char *format,...)
 Record a formatted diagnostic message.
 
static const char * GetDiagMsg ()
 
static void SetDiagMsgCB (DiagMsgCB_T cb)
 
static DiagMsgCB_T GetDiagMsgCB ()
 
static void SetDiagMsgFilePtr (FILE *fp)
 
static bool EnableErrMsg (bool enable)
 
static bool GetEnableErrMsg ()
 

Additional Inherited Members

- Public Types inherited from Wasp::MyBase
typedef void(* ErrMsgCB_T) (const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T) (const char *msg)
 
- Static Public Attributes inherited from Wasp::MyBase
static char * ErrMsg
 
static int ErrCode
 
static int ErrMsgSize
 
static FILE * ErrMsgFilePtr
 
static ErrMsgCB_T ErrMsgCB
 
static char * DiagMsg
 
static int DiagMsgSize
 
static FILE * DiagMsgFilePtr
 
static DiagMsgCB_T DiagMsgCB
 
static bool Enabled
 
- Protected Member Functions inherited from VAPoR::IResourceManager< std::string, ShaderProgram >
ShaderProgramGetResource (const std::string &key)
 
- Protected Member Functions inherited from Wasp::MyBase
void SetClassName (const string &name)
 
- Protected Attributes inherited from VAPoR::IResourceManager< std::string, ShaderProgram >
std::map< std::string, ShaderProgram * > _map
 

Detailed Description

Resource management class for shaders.

Author
Stanislaw Jaroszynski
Date
August, 2018

Definition at line 18 of file ShaderManager.h.

Member Function Documentation

◆ CompileNewShaderFromFile()

static Shader * VAPoR::ShaderManager::CompileNewShaderFromFile ( const std::string &  path,
const std::vector< std::string > &  defines = {} 
)
static
Parameters
[in]pathto GLSL source code file
Return values
Shader*is returned on success
nullptris returned on failure

◆ GetShader()

ShaderProgram * VAPoR::ShaderManager::GetShader ( const std::string &  name)

◆ GetShaderDependencies()

static std::vector< std::string > VAPoR::ShaderManager::GetShaderDependencies ( const std::string &  path)
static

◆ GetShaderTypeFromPath()

static unsigned int VAPoR::ShaderManager::GetShaderTypeFromPath ( const std::string &  path)
static

Returns an OpenGL shader type enum based on the file extension. Valid extensions are .vert, .frag, and .geom

Parameters
[in]pathto GLSL source code file

◆ GetSmartShader()

SmartShaderProgram VAPoR::ShaderManager::GetSmartShader ( const std::string &  name)

◆ LoadResourceByKey()

int VAPoR::ShaderManager::LoadResourceByKey ( const std::string &  key)
virtual

◆ PreProcessShader()

static std::string VAPoR::ShaderManager::PreProcessShader ( const std::string &  path,
const std::vector< std::string > &  defines = {} 
)
static

Implements the following preprocessor directives:

  • #pragma auto_version This sets the GLSL version to the highest available
  • #include FileName.glsl c-style include without quotes. Path is relative to shader base path This will also update line numbers with the #line directive
  • #define X Each item in the defines list is added to the GLSL code after the #version directive
Parameters
[in]pathto GLSL source code file
[in]defineslist of definitions to be added to source

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