Pyrogenesis
13997
|
A compiled vertex+fragment shader program. More...
#include <ShaderProgram.h>
Classes | |
struct | Binding |
Represents a uniform attribute or texture binding. More... | |
Public Types | |
typedef CStrIntern | attrib_id_t |
typedef CStrIntern | texture_id_t |
typedef CStrIntern | uniform_id_t |
typedef std::pair< int, GLenum > | frag_index_pair_t |
Public Member Functions | |
virtual | ~CShaderProgram () |
virtual void | Reload ()=0 |
bool | IsValid () const |
Returns whether this shader was successfully loaded. More... | |
virtual void | Bind ()=0 |
Binds the shader into the GL context. More... | |
virtual void | Unbind ()=0 |
Unbinds the shader from the GL context. More... | |
int | GetStreamFlags () const |
Returns bitset of STREAM_* value, indicating what vertex data streams the vertex shader needs (e.g. More... | |
virtual Binding | GetTextureBinding (texture_id_t id)=0 |
void | BindTexture (texture_id_t id, CTexturePtr tex) |
virtual void | BindTexture (texture_id_t id, Handle tex)=0 |
virtual void | BindTexture (texture_id_t id, GLuint tex)=0 |
virtual void | BindTexture (Binding id, Handle tex)=0 |
virtual Binding | GetUniformBinding (uniform_id_t id)=0 |
virtual void | Uniform (Binding id, float v0, float v1, float v2, float v3)=0 |
virtual void | Uniform (Binding id, const CMatrix3D &v)=0 |
virtual void | Uniform (Binding id, size_t count, const CMatrix3D *v)=0 |
void | Uniform (Binding id, int v) |
void | Uniform (Binding id, float v) |
void | Uniform (Binding id, float v0, float v1) |
void | Uniform (Binding id, const CVector3D &v) |
void | Uniform (Binding id, const CColor &v) |
void | Uniform (uniform_id_t id, int v) |
void | Uniform (uniform_id_t id, float v) |
void | Uniform (uniform_id_t id, float v0, float v1) |
void | Uniform (uniform_id_t id, const CVector3D &v) |
void | Uniform (uniform_id_t id, const CColor &v) |
void | Uniform (uniform_id_t id, float v0, float v1, float v2, float v3) |
void | Uniform (uniform_id_t id, const CMatrix3D &v) |
void | Uniform (uniform_id_t id, size_t count, const CMatrix3D *v) |
virtual void | VertexPointer (GLint size, GLenum type, GLsizei stride, void *pointer) |
virtual void | NormalPointer (GLenum type, GLsizei stride, void *pointer) |
virtual void | ColorPointer (GLint size, GLenum type, GLsizei stride, void *pointer) |
virtual void | TexCoordPointer (GLenum texture, GLint size, GLenum type, GLsizei stride, void *pointer) |
virtual void | VertexAttribPointer (attrib_id_t id, GLint size, GLenum type, GLboolean normalized, GLsizei stride, void *pointer) |
virtual void | VertexAttribIPointer (attrib_id_t id, GLint size, GLenum type, GLsizei stride, void *pointer) |
void | AssertPointersBound () |
Checks that all the required vertex attributes have been set. More... | |
Static Public Member Functions | |
static CShaderProgram * | ConstructARB (const VfsPath &vertexFile, const VfsPath &fragmentFile, const CShaderDefines &defines, const std::map< CStrIntern, int > &vertexIndexes, const std::map< CStrIntern, frag_index_pair_t > &fragmentIndexes, int streamflags) |
Construct based on ARB vertex/fragment program files. More... | |
static CShaderProgram * | ConstructGLSL (const VfsPath &vertexFile, const VfsPath &fragmentFile, const CShaderDefines &defines, const std::map< CStrIntern, int > &vertexAttribs, int streamflags) |
Construct based on GLSL vertex/fragment shader files. More... | |
static CShaderProgram * | ConstructFFP (const std::string &id, const CShaderDefines &defines) |
Construct an instance of a pre-defined fixed-function pipeline setup. More... | |
Protected Member Functions | |
CShaderProgram (int streamflags) | |
void | BindClientStates () |
void | UnbindClientStates () |
Protected Attributes | |
bool | m_IsValid |
int | m_StreamFlags |
int | m_ValidStreams |
Private Member Functions | |
NONCOPYABLE (CShaderProgram) | |
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 GetTextureBinding/GetUniformBinding 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
Definition at line 65 of file ShaderProgram.h.
Definition at line 70 of file ShaderProgram.h.
typedef std::pair<int, GLenum> CShaderProgram::frag_index_pair_t |
Definition at line 73 of file ShaderProgram.h.
Definition at line 71 of file ShaderProgram.h.
Definition at line 72 of file ShaderProgram.h.
|
inlinevirtual |
Definition at line 121 of file ShaderProgram.h.
|
protected |
Definition at line 655 of file ShaderProgram.cpp.
void CShaderProgram::AssertPointersBound | ( | ) |
Checks that all the required vertex attributes have been set.
Call this before calling glDrawArrays/glDrawElements etc to avoid potential crashes.
Definition at line 889 of file ShaderProgram.cpp.
|
pure virtual |
Binds the shader into the GL context.
Call this before calling Uniform() or trying to render with it.
Implemented in CShaderProgramFFP_ModelSolidTex, CShaderProgramFFP_ModelSolid, CShaderProgramFFP_ModelColor, CShaderProgramFFP_Model, CShaderProgramFFP_Model_Base, CShaderProgramFFP_GuiSolid, CShaderProgramFFP_GuiGrayscale, CShaderProgramGLSL, CShaderProgramFFP_GuiAdd, CShaderProgramFFP_GuiBasic, CShaderProgramFFP_Gui_Base, CShaderProgramFFP_GuiText, CShaderProgramFFP_OverlayLine, CShaderProgramFFP_Dummy, and CShaderProgramARB.
|
protected |
Definition at line 838 of file ShaderProgram.cpp.
void CShaderProgram::BindTexture | ( | texture_id_t | id, |
CTexturePtr | tex | ||
) |
Definition at line 698 of file ShaderProgram.cpp.
|
pure virtual |
Implemented in CShaderProgramGLSL, CShaderProgramARB, and CShaderProgramFFP.
|
pure virtual |
Implemented in CShaderProgramGLSL, CShaderProgramARB, and CShaderProgramFFP.
Implemented in CShaderProgramGLSL, CShaderProgramARB, and CShaderProgramFFP.
|
virtual |
Reimplemented in CShaderProgramGLSL.
Definition at line 824 of file ShaderProgram.cpp.
|
static |
Construct based on ARB vertex/fragment program files.
Definition at line 671 of file ShaderProgram.cpp.
|
static |
Construct an instance of a pre-defined fixed-function pipeline setup.
Definition at line 1000 of file ShaderProgramFFP.cpp.
|
static |
Construct based on GLSL vertex/fragment shader files.
Definition at line 680 of file ShaderProgram.cpp.
int CShaderProgram::GetStreamFlags | ( | ) | const |
Returns bitset of STREAM_* value, indicating what vertex data streams the vertex shader needs (e.g.
position, color, UV, ...).
Definition at line 693 of file ShaderProgram.cpp.
|
pure virtual |
Implemented in CShaderProgramGLSL, CShaderProgramARB, and CShaderProgramFFP.
|
pure virtual |
Implemented in CShaderProgramGLSL, CShaderProgramARB, and CShaderProgramFFP.
bool CShaderProgram::IsValid | ( | ) | const |
Returns whether this shader was successfully loaded.
Definition at line 688 of file ShaderProgram.cpp.
|
private |
|
virtual |
Reimplemented in CShaderProgramGLSL.
Definition at line 818 of file ShaderProgram.cpp.
|
pure virtual |
Implemented in CShaderProgramGLSL, CShaderProgramARB, and CShaderProgramFFP.
|
virtual |
Reimplemented in CShaderProgramGLSL.
Definition at line 830 of file ShaderProgram.cpp.
|
pure virtual |
Unbinds the shader from the GL context.
Call this after rendering with it.
Implemented in CShaderProgramFFP_ModelColor, CShaderProgramFFP_Model, CShaderProgramFFP_Model_Base, CShaderProgramFFP_GuiGrayscale, CShaderProgramFFP_GuiAdd, CShaderProgramGLSL, CShaderProgramFFP_GuiBasic, CShaderProgramFFP_Gui_Base, CShaderProgramFFP_GuiText, CShaderProgramFFP_OverlayLine, CShaderProgramFFP_Dummy, and CShaderProgramARB.
|
protected |
Definition at line 867 of file ShaderProgram.cpp.
|
pure virtual |
Implemented in CShaderProgramGLSL, CShaderProgramARB, and CShaderProgramFFP.
void CShaderProgram::Uniform | ( | Binding | id, |
int | v | ||
) |
Definition at line 703 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | Binding | id, |
float | v | ||
) |
Definition at line 708 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | Binding | id, |
float | v0, | ||
float | v1 | ||
) |
Definition at line 713 of file ShaderProgram.cpp.
Definition at line 718 of file ShaderProgram.cpp.
Definition at line 723 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | uniform_id_t | id, |
int | v | ||
) |
Definition at line 728 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | uniform_id_t | id, |
float | v | ||
) |
Definition at line 733 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | uniform_id_t | id, |
float | v0, | ||
float | v1 | ||
) |
Definition at line 738 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | uniform_id_t | id, |
const CVector3D & | v | ||
) |
Definition at line 743 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | uniform_id_t | id, |
const CColor & | v | ||
) |
Definition at line 748 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | uniform_id_t | id, |
float | v0, | ||
float | v1, | ||
float | v2, | ||
float | v3 | ||
) |
Definition at line 753 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | uniform_id_t | id, |
const CMatrix3D & | v | ||
) |
Definition at line 758 of file ShaderProgram.cpp.
void CShaderProgram::Uniform | ( | uniform_id_t | id, |
size_t | count, | ||
const CMatrix3D * | v | ||
) |
Definition at line 763 of file ShaderProgram.cpp.
|
virtual |
Reimplemented in CShaderProgramGLSL.
Definition at line 778 of file ShaderProgram.cpp.
|
virtual |
Reimplemented in CShaderProgramGLSL.
Definition at line 772 of file ShaderProgram.cpp.
|
virtual |
Reimplemented in CShaderProgramGLSL.
Definition at line 812 of file ShaderProgram.cpp.
|
protected |
Definition at line 199 of file ShaderProgram.h.
|
protected |
Definition at line 200 of file ShaderProgram.h.
|
protected |
Definition at line 205 of file ShaderProgram.h.