VAPOR3 3.9.4
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
VAPoR::ShaderProgram Class Reference

Provides a C++ interface to the OpenGL shader program construct. More...

#include <ShaderProgram.h>

Inheritance diagram for VAPoR::ShaderProgram:
Wasp::MyBase

Public Types

enum class  Policy { Strict , Relaxed }
 
- Public Types inherited from Wasp::MyBase
typedef void(* ErrMsgCB_T) (const char *msg, int err_code)
 
typedef void(* DiagMsgCB_T) (const char *msg)
 

Public Member Functions

 ShaderProgram ()
 
 ~ShaderProgram ()
 
int Link ()
 
void Bind ()
 
bool IsBound () const
 
void AddShader (Shader *s)
 
int AddShaderFromSource (unsigned int type, const char *source)
 
unsigned int GetID () const
 
unsigned int WasLinkingSuccessful () const
 
int GetAttributeLocation (const std::string &name) const
 
int GetUniformLocation (const std::string &name) const
 
bool HasUniform (const std::string &name) const
 
void ComputeSamplerLocations ()
 
template<typename T >
bool SetUniform (const std::string &name, const T &value) const
 
void SetUniform (int location, const int &value) const
 
void SetUniform (int location, const float &value) const
 
void SetUniform (int location, const glm::vec2 &value) const
 
void SetUniform (int location, const glm::vec3 &value) const
 
void SetUniform (int location, const glm::vec4 &value) const
 
void SetUniform (int location, const glm::mat4 &value) const
 
void SetUniform (int location, const glm::ivec2 &value) const
 
void SetUniform (int location, const glm::ivec3 &value) const
 
void SetUniform (int location, const std::vector< float > &value) const
 
template<typename T >
void SetUniformArray (const std::string &name, int count, const T *values) const
 
void SetUniformArray (int location, int count, const int *values) const
 
void SetUniformArray (int location, int count, const float *values) const
 
void SetUniformArray (int location, int count, const glm::vec3 *values) const
 
void SetUniformArray (int location, int count, const glm::vec4 *values) const
 
template<typename T >
bool SetSampler (const std::string &name, const T &texture) const
 
std::string GetLog () const
 
void PrintUniforms () const
 
- Public Member Functions inherited from Wasp::MyBase
 MyBase ()
 
const string & getClassName () const
 

Static Public Member Functions

static void UnBind ()
 
static int GetBoundProgramID ()
 
static const char * GLTypeToString (const unsigned int type)
 
static bool IsGLTypeSampler (const unsigned int type)
 
- 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 ()
 

Static Public Attributes

static Policy UniformNotFoundPolicy
 
- 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
 

Additional Inherited Members

- Protected Member Functions inherited from Wasp::MyBase
void SetClassName (const string &name)
 

Detailed Description

Provides a C++ interface to the OpenGL shader program construct.

Author
Stanislaw Jaroszynski
Date
August, 2018

Automatically manages sampler uniforms and the active gl texture. This allows samplers to be set simply like uniforms.

Definition at line 25 of file ShaderProgram.h.

Member Enumeration Documentation

◆ Policy

enum class VAPoR::ShaderProgram::Policy
strong
Enumerator
Strict 
Relaxed 

Definition at line 33 of file ShaderProgram.h.

Constructor & Destructor Documentation

◆ ShaderProgram()

VAPoR::ShaderProgram::ShaderProgram ( )

◆ ~ShaderProgram()

VAPoR::ShaderProgram::~ShaderProgram ( )

Member Function Documentation

◆ AddShader()

void VAPoR::ShaderProgram::AddShader ( Shader s)

◆ AddShaderFromSource()

int VAPoR::ShaderProgram::AddShaderFromSource ( unsigned int  type,
const char *  source 
)
Parameters
[in]typeOpenGL shader type enum
[in]sourceGLSL source code
Return values
1is returned on success
-1is returned on failure

◆ Bind()

void VAPoR::ShaderProgram::Bind ( )

◆ ComputeSamplerLocations()

void VAPoR::ShaderProgram::ComputeSamplerLocations ( )

◆ GetAttributeLocation()

int VAPoR::ShaderProgram::GetAttributeLocation ( const std::string &  name) const

◆ GetBoundProgramID()

static int VAPoR::ShaderProgram::GetBoundProgramID ( )
static

◆ GetID()

unsigned int VAPoR::ShaderProgram::GetID ( ) const

◆ GetLog()

std::string VAPoR::ShaderProgram::GetLog ( ) const

◆ GetUniformLocation()

int VAPoR::ShaderProgram::GetUniformLocation ( const std::string &  name) const

◆ GLTypeToString()

static const char * VAPoR::ShaderProgram::GLTypeToString ( const unsigned int  type)
static

◆ HasUniform()

bool VAPoR::ShaderProgram::HasUniform ( const std::string &  name) const

◆ IsBound()

bool VAPoR::ShaderProgram::IsBound ( ) const

◆ IsGLTypeSampler()

static bool VAPoR::ShaderProgram::IsGLTypeSampler ( const unsigned int  type)
static

◆ Link()

int VAPoR::ShaderProgram::Link ( )
Return values
1is returned on success
-1is returned on failure

◆ PrintUniforms()

void VAPoR::ShaderProgram::PrintUniforms ( ) const

◆ SetSampler()

template<typename T >
bool VAPoR::ShaderProgram::SetSampler ( const std::string &  name,
const T &  texture 
) const

This function behaves just like setting a uniform

Parameters
[in]nameuniform name
[in]valuean instance of VAPoR::Texture
Return values
falseif uniform name is not found

◆ SetUniform() [1/10]

template<typename T >
bool VAPoR::ShaderProgram::SetUniform ( const std::string &  name,
const T &  value 
) const

◆ SetUniform() [2/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const float &  value 
) const

◆ SetUniform() [3/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const glm::ivec2 &  value 
) const

◆ SetUniform() [4/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const glm::ivec3 &  value 
) const

◆ SetUniform() [5/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const glm::mat4 &  value 
) const

◆ SetUniform() [6/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const glm::vec2 &  value 
) const

◆ SetUniform() [7/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const glm::vec3 &  value 
) const

◆ SetUniform() [8/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const glm::vec4 &  value 
) const

◆ SetUniform() [9/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const int &  value 
) const

◆ SetUniform() [10/10]

void VAPoR::ShaderProgram::SetUniform ( int  location,
const std::vector< float > &  value 
) const

◆ SetUniformArray() [1/5]

template<typename T >
void VAPoR::ShaderProgram::SetUniformArray ( const std::string &  name,
int  count,
const T *  values 
) const

◆ SetUniformArray() [2/5]

void VAPoR::ShaderProgram::SetUniformArray ( int  location,
int  count,
const float *  values 
) const

◆ SetUniformArray() [3/5]

void VAPoR::ShaderProgram::SetUniformArray ( int  location,
int  count,
const glm::vec3 *  values 
) const

◆ SetUniformArray() [4/5]

void VAPoR::ShaderProgram::SetUniformArray ( int  location,
int  count,
const glm::vec4 *  values 
) const

◆ SetUniformArray() [5/5]

void VAPoR::ShaderProgram::SetUniformArray ( int  location,
int  count,
const int *  values 
) const

◆ UnBind()

static void VAPoR::ShaderProgram::UnBind ( )
static

◆ WasLinkingSuccessful()

unsigned int VAPoR::ShaderProgram::WasLinkingSuccessful ( ) const

Member Data Documentation

◆ UniformNotFoundPolicy

Policy VAPoR::ShaderProgram::UniformNotFoundPolicy
static

Definition at line 34 of file ShaderProgram.h.


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