Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Renderer::Backend::GL::CShaderProgram Class Referenceabstract

A compiled vertex+fragment shader program. More...

#include <ShaderProgram.h>

Inheritance diagram for Renderer::Backend::GL::CShaderProgram:
Collaboration diagram for Renderer::Backend::GL::CShaderProgram:

Classes

struct  TextureUnit
 

Public Types

typedef CStrIntern attrib_id_t
 

Public Member Functions

 ~CShaderProgram () override
 
virtual void Bind (CShaderProgram *previousShaderProgram)=0
 Binds the shader into the GL context. More...
 
virtual void Unbind ()=0
 Unbinds the shader from the GL context. More...
 
virtual TextureUnit GetTextureUnit (const int32_t bindingSlot)=0
 
virtual void SetUniform (const int32_t bindingSlot, const float value)=0
 
virtual void SetUniform (const int32_t bindingSlot, const float valueX, const float valueY)=0
 
virtual void SetUniform (const int32_t bindingSlot, const float valueX, const float valueY, const float valueZ)=0
 
virtual void SetUniform (const int32_t bindingSlot, const float valueX, const float valueY, const float valueZ, const float valueW)=0
 
virtual void SetUniform (const int32_t bindingSlot, PS::span< const float > values)=0
 
virtual void VertexAttribPointer (const VertexAttributeStream stream, const Format format, const uint32_t offset, const uint32_t stride, const VertexAttributeRate rate, const void *data)
 
bool IsStreamActive (const VertexAttributeStream stream) const
 
void AssertPointersBound ()
 Checks that all the required vertex attributes have been set. More...
 
- Public Member Functions inherited from Renderer::Backend::IShaderProgram
virtual int32_t GetBindingSlot (const CStrIntern name) const =0
 
virtual std::vector< VfsPathGetFileDependencies () const =0
 
- Public Member Functions inherited from Renderer::Backend::IDeviceObject< IShaderProgram >
virtual ~IDeviceObject ()
 
virtual IDeviceGetDevice ()=0
 
TAs ()
 

Static Public Member Functions

static std::unique_ptr< CShaderProgramCreate (CDevice *device, const CStr &name, const CShaderDefines &baseDefines)
 

Protected Member Functions

 CShaderProgram (int streamflags)
 
void VertexPointer (const Renderer::Backend::Format format, GLsizei stride, const void *pointer)
 
void NormalPointer (const Renderer::Backend::Format format, GLsizei stride, const void *pointer)
 
void ColorPointer (const Renderer::Backend::Format format, GLsizei stride, const void *pointer)
 
void TexCoordPointer (GLenum texture, const Renderer::Backend::Format format, GLsizei stride, const void *pointer)
 
void BindClientStates ()
 
void UnbindClientStates ()
 

Protected Attributes

int m_StreamFlags
 
int m_ValidStreams
 

Private Member Functions

 NONCOPYABLE (CShaderProgram)
 

Detailed Description

A compiled vertex+fragment shader program.

The implementation may use GL_ARB_{vertex,fragment}_program (ARB assembly syntax) or GL_ARB_{vertex,fragment}_shader (GLSL), or may use hard-coded fixed-function multitexturing setup code; the difference is hidden from the caller.

Texture/uniform IDs are typically strings, corresponding to the names defined in the shader .xml file. Alternatively (and more efficiently, if used very frequently), call GetBindingSlot and pass its return value as the ID. Setting uniforms that the shader .xml doesn't support is harmless.

For a high-level overview of shaders and materials, see http://trac.wildfiregames.com/wiki/MaterialSystem

Member Typedef Documentation

◆ attrib_id_t

Constructor & Destructor Documentation

◆ ~CShaderProgram()

CShaderProgram::~CShaderProgram ( )
overridedefault

◆ CShaderProgram()

CShaderProgram::CShaderProgram ( int  streamflags)
protected

Member Function Documentation

◆ AssertPointersBound()

void CShaderProgram::AssertPointersBound ( )

Checks that all the required vertex attributes have been set.

Call this before calling Draw/DrawIndexed etc to avoid potential crashes.

◆ Bind()

virtual void Renderer::Backend::GL::CShaderProgram::Bind ( CShaderProgram previousShaderProgram)
pure virtual

Binds the shader into the GL context.

Call this before calling Uniform() or trying to render with it.

Implemented in Renderer::Backend::GL::CShaderProgramARB, and Renderer::Backend::GL::CShaderProgramGLSL.

◆ BindClientStates()

void CShaderProgram::BindClientStates ( )
protected

◆ ColorPointer()

void CShaderProgram::ColorPointer ( const Renderer::Backend::Format  format,
GLsizei  stride,
const void *  pointer 
)
protected

◆ Create()

std::unique_ptr< CShaderProgram > CShaderProgram::Create ( CDevice device,
const CStr &  name,
const CShaderDefines baseDefines 
)
static

◆ GetTextureUnit()

virtual TextureUnit Renderer::Backend::GL::CShaderProgram::GetTextureUnit ( const int32_t  bindingSlot)
pure virtual

◆ IsStreamActive()

bool CShaderProgram::IsStreamActive ( const VertexAttributeStream  stream) const

◆ NONCOPYABLE()

Renderer::Backend::GL::CShaderProgram::NONCOPYABLE ( CShaderProgram  )
private

◆ NormalPointer()

void CShaderProgram::NormalPointer ( const Renderer::Backend::Format  format,
GLsizei  stride,
const void *  pointer 
)
protected

◆ SetUniform() [1/5]

virtual void Renderer::Backend::GL::CShaderProgram::SetUniform ( const int32_t  bindingSlot,
const float  value 
)
pure virtual

◆ SetUniform() [2/5]

virtual void Renderer::Backend::GL::CShaderProgram::SetUniform ( const int32_t  bindingSlot,
const float  valueX,
const float  valueY 
)
pure virtual

◆ SetUniform() [3/5]

virtual void Renderer::Backend::GL::CShaderProgram::SetUniform ( const int32_t  bindingSlot,
const float  valueX,
const float  valueY,
const float  valueZ 
)
pure virtual

◆ SetUniform() [4/5]

virtual void Renderer::Backend::GL::CShaderProgram::SetUniform ( const int32_t  bindingSlot,
const float  valueX,
const float  valueY,
const float  valueZ,
const float  valueW 
)
pure virtual

◆ SetUniform() [5/5]

virtual void Renderer::Backend::GL::CShaderProgram::SetUniform ( const int32_t  bindingSlot,
PS::span< const float >  values 
)
pure virtual

◆ TexCoordPointer()

void CShaderProgram::TexCoordPointer ( GLenum  texture,
const Renderer::Backend::Format  format,
GLsizei  stride,
const void *  pointer 
)
protected

◆ Unbind()

virtual void Renderer::Backend::GL::CShaderProgram::Unbind ( )
pure virtual

Unbinds the shader from the GL context.

Call this after rendering with it.

Implemented in Renderer::Backend::GL::CShaderProgramARB, and Renderer::Backend::GL::CShaderProgramGLSL.

◆ UnbindClientStates()

void CShaderProgram::UnbindClientStates ( )
protected

◆ VertexAttribPointer()

void CShaderProgram::VertexAttribPointer ( const VertexAttributeStream  stream,
const Format  format,
const uint32_t  offset,
const uint32_t  stride,
const VertexAttributeRate  rate,
const void *  data 
)
virtual

◆ VertexPointer()

void CShaderProgram::VertexPointer ( const Renderer::Backend::Format  format,
GLsizei  stride,
const void *  pointer 
)
protected

Member Data Documentation

◆ m_StreamFlags

int Renderer::Backend::GL::CShaderProgram::m_StreamFlags
protected

◆ m_ValidStreams

int Renderer::Backend::GL::CShaderProgram::m_ValidStreams
protected

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