CUGL 3.0
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
cugl::scene3::BillboardShader Class Reference

#include <CUBillboardShader.h>

Inheritance diagram for cugl::scene3::BillboardShader:
cugl::graphics::Shader

Public Member Functions

 BillboardShader ()
 
 ~BillboardShader ()
 
void dispose () override
 
bool init ()
 
bool init (const std::string vsource, const std::string fsource) override
 
void setStyle (Uint32 style)
 
void setPerspective (const Mat4 &matrix)
 
void setModelMatrix (const Mat4 &matrix)
 
void setCameraRight (const Vec3 v)
 
void setCameraUp (const Vec3 v)
 
void setTextureOffset (const Vec2 v)
 
void setTextureOffset (float x, float y)
 
void setTexture (const std::shared_ptr< graphics::Texture > &texture)
 
void setGradient (const std::shared_ptr< graphics::Gradient > &grad)
 
- Public Member Functions inherited from cugl::graphics::Shader
 Shader ()
 
 ~Shader ()
 
virtual void dispose ()
 
virtual bool init (const std::string vsource, const std::string fsource)
 
void bind ()
 
void unbind ()
 
bool isReady () const
 
bool isBound () const
 
const std::string getVertSource () const
 
const std::string getFragSource () const
 
GLuint getProgram () const
 
std::vector< std::string > getAttributes () const
 
GLint getAttributeLocation (const std::string name) const
 
GLint getAttributeSize (const std::string name) const
 
GLenum getAttributeType (const std::string name) const
 
GLint getOutputLocation (const std::string name) const
 
std::vector< std::string > getUniforms () const
 
GLint getUniformLocation (const std::string name) const
 
GLint getUniformSize (const std::string name) const
 
GLenum getUniformType (const std::string name) const
 
std::vector< std::string > getSamplers () const
 
GLint getSamplerLocation (const std::string name) const
 
void setSampler (GLint pos, GLuint bpoint)
 
void setSampler (const std::string name, GLuint bpoint)
 
void setSampler (GLint pos, const std::shared_ptr< Texture > &texture)
 
void setSampler (const std::string name, const std::shared_ptr< Texture > &texture)
 
GLuint getSampler (GLint pos) const
 
GLuint getSampler (const std::string name) const
 
void setCullMode (GLenum mode)
 
void enableCulling (bool enable)
 
void enableDepthTest (bool enable)
 
void enableDepthWrite (bool enable)
 
void setDepthCompareOp (GLenum compareOp)
 
void setBlendFunc (GLenum srcFactor, GLenum dstFactor)
 
void setBlendFuncSeperate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
 
void setBlendEquation (GLenum op)
 
void setBlendEquationSeperate (GLenum opRGB, GLenum opAlpha)
 
void enableBlending (bool enable)
 
void enableStencil (bool enable)
 
void setStencilOp (GLenum fail, GLenum dpfail, GLenum pass)
 
void setStencilOpFront (GLenum fail, GLenum dpfail, GLenum pass)
 
void setStencilOpBack (GLenum fail, GLenum dpfail, GLenum pass)
 
void setStencilFunc (GLenum compareOp, uint32_t ref, uint32_t compareMask)
 
void setStencilMask (uint32_t writeMask)
 
void setColorMask (GLboolean r, GLboolean g, GLboolean b, GLboolean a)
 
std::vector< std::string > getUniformBlocks () const
 
std::vector< std::string > getUniformsForBlock (GLint pos) const
 
std::vector< std::string > getUniformsForBlock (std::string name) const
 
void setUniformBlock (GLint pos, GLuint bpoint)
 
void setUniformBlock (const std::string name, GLuint bpoint)
 
void setUniformBlock (GLint pos, const std::shared_ptr< UniformBuffer > &buffer)
 
void setUniformBlock (const std::string name, const std::shared_ptr< UniformBuffer > &buffer)
 
GLuint getUniformBlock (GLint pos) const
 
GLuint getUniformBlock (const std::string name) const
 
void setUniformVec2 (GLint pos, const Vec2 vec)
 
void setUniformVec2 (const std::string name, const Vec2 vec)
 
bool getUniformVec2 (GLint pos, Vec2 &vec) const
 
bool getUniformVec2 (const std::string name, Vec2 &vec) const
 
void setUniformVec3 (GLint pos, const Vec3 vec)
 
void setUniformVec3 (const std::string name, const Vec3 vec)
 
bool getUniformVec3 (GLint pos, Vec3 &vec) const
 
bool getUniformVec3 (const std::string name, Vec3 &vec) const
 
void setUniformVec4 (GLint pos, const Vec4 vec)
 
void setUniformVec4 (const std::string name, const Vec4 vec)
 
bool getUniformVec4 (GLint pos, Vec4 &vec) const
 
bool getUniformVec4 (const std::string name, Vec4 &vec) const
 
void setUniformColor4 (GLint pos, const Color4 color)
 
void setUniformColor4 (const std::string name, const Color4 color)
 
bool getUniformColor4 (GLint pos, Color4 &color) const
 
bool getUniformColor4 (const std::string name, Color4 &color) const
 
void setUniformColor4f (GLint pos, const Color4f color)
 
void setUniformColor4f (const std::string name, const Color4f color)
 
bool getUniformColor4f (GLint pos, Color4f &color) const
 
bool getUniformColor4f (const std::string name, Color4f &color) const
 
void setUniformMat4 (GLint pos, const Mat4 &mat)
 
void setUniformMat4 (const std::string name, const Mat4 &mat)
 
bool getUniformMat4 (GLint pos, Mat4 &mat) const
 
bool getUniformMat4 (const std::string name, Mat4 &mat) const
 
void setUniformAffine2 (GLint pos, const Affine2 &mat)
 
void setUniformAffine2 (const std::string name, const Affine2 &mat)
 
bool getUniformAffine2 (GLint pos, Affine2 &mat) const
 
bool getUniformAffine2 (const std::string name, Affine2 &mat) const
 
void setUniformQuaternion (GLint pos, const Quaternion &quat)
 
void setUniformQuaternion (const std::string name, const Quaternion &quat)
 
bool getUniformQuaternion (GLint pos, Quaternion &quat) const
 
bool getUniformQuaternion (const std::string name, Quaternion &quat) const
 
void setUniform1f (GLint pos, GLfloat v0)
 
void setUniform1f (const std::string name, GLfloat v0)
 
void setUniform2f (GLint pos, GLfloat v0, GLfloat v1)
 
void setUniform2f (const std::string name, GLfloat v0, GLfloat v1)
 
void setUniform3f (GLint pos, GLfloat v0, GLfloat v1, GLfloat v2)
 
void setUniform3f (const std::string name, GLfloat v0, GLfloat v1, GLfloat v2)
 
void setUniform4f (GLint pos, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
 
void setUniform4f (const std::string name, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
 
void setUniform1i (GLint pos, GLint v0)
 
void setUniform1i (const std::string name, GLint v0)
 
void setUniform2i (GLint pos, GLint v0, GLint v1)
 
void setUniform2i (const std::string name, GLint v0, GLint v1)
 
void setUniform3i (GLint pos, GLint v0, GLint v1, GLint v2)
 
void setUniform3i (const std::string name, GLint v0, GLint v1, GLint v2)
 
void setUniform4i (GLint pos, GLint v0, GLint v1, GLint v2, GLint v3)
 
void setUniform4i (const std::string name, GLint v0, GLint v1, GLint v2, GLint v3)
 
void setUniform1ui (GLint pos, GLuint v0)
 
void setUniform1ui (const std::string name, GLuint v0)
 
void setUniform2ui (GLint pos, GLuint v0, GLuint v1)
 
void setUniform2ui (const std::string name, GLuint v0, GLuint v1)
 
void setUniform3ui (GLint pos, GLuint v0, GLuint v1, GLuint v2)
 
void setUniform3ui (const std::string name, GLuint v0, GLuint v1, GLuint v2)
 
void setUniform4ui (GLint pos, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
 
void setUniform4ui (const std::string name, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
 
void setUniform1fv (GLint pos, GLsizei count, const GLfloat *value)
 
void setUniform1fv (const std::string name, GLsizei count, const GLfloat *value)
 
void setUniform2fv (GLint pos, GLsizei count, const GLfloat *value)
 
void setUniform2fv (const std::string name, GLsizei count, const GLfloat *value)
 
void setUniform3fv (GLint pos, GLsizei count, const GLfloat *value)
 
void setUniform3fv (const std::string name, GLsizei count, const GLfloat *value)
 
void setUniform4fv (GLint pos, GLsizei count, const GLfloat *value)
 
void setUniform4fv (const std::string name, GLsizei count, const GLfloat *value)
 
void setUniform1iv (GLint pos, GLsizei count, const GLint *value)
 
void setUniform1iv (const std::string name, GLsizei count, const GLint *value)
 
void setUniform2iv (GLint pos, GLsizei count, const GLint *value)
 
void setUniform2iv (const std::string name, GLsizei count, const GLint *value)
 
void setUniform3iv (GLint pos, GLsizei count, const GLint *value)
 
void setUniform3iv (const std::string name, GLsizei count, const GLint *value)
 
void setUniform4iv (GLint pos, GLsizei count, const GLint *value)
 
void setUniform4iv (const std::string name, GLsizei count, const GLint *value)
 
void setUniform1uiv (GLint pos, GLsizei count, const GLuint *value)
 
void setUniform1uiv (const std::string name, GLsizei count, const GLuint *value)
 
void setUniform2uiv (GLint pos, GLsizei count, const GLuint *value)
 
void setUniform2uiv (const std::string name, GLsizei count, const GLuint *value)
 
void setUniform3uiv (GLint pos, GLsizei count, const GLuint *value)
 
void setUniform3uiv (const std::string name, GLsizei count, const GLuint *value)
 
void setUniform4uiv (GLint pos, GLsizei count, const GLuint *value)
 
void setUniform4uiv (const std::string name, GLsizei count, const GLuint *value)
 
void setUniformMatrix2fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix2fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix3fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix3fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix4fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix4fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix2x3fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix2x3fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix3x2fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix3x2fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix2x4fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix2x4fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix4x2fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix4x2fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix3x4fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix3x4fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix4x3fv (GLint pos, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
void setUniformMatrix4x3fv (const std::string name, GLsizei count, const GLfloat *value, GLboolean tpose=false)
 
bool getUniformfv (GLint pos, GLsizei size, GLfloat *value) const
 
bool getUniformfv (const std::string name, GLsizei size, GLfloat *value) const
 
bool getUniformiv (GLint pos, GLsizei size, GLint *value) const
 
bool getUniformiv (const std::string name, GLsizei size, GLint *value) const
 
bool getUniformuiv (GLint pos, GLsizei size, GLuint *value) const
 
bool getUniformuiv (const std::string name, GLsizei size, GLuint *value) const
 

Static Public Member Functions

static std::shared_ptr< BillboardShaderalloc ()
 
static std::shared_ptr< BillboardShaderalloc (const std::string vsource, const std::string fsource)
 
- Static Public Member Functions inherited from cugl::graphics::Shader
static std::shared_ptr< Shaderalloc (const std::string vsource, const std::string fsource)
 

Additional Inherited Members

- Protected Attributes inherited from cugl::graphics::Shader
GLuint _program
 
GLuint _vertShader
 
GLuint _fragShader
 
std::string _vertSource
 
std::string _fragSource
 
std::unordered_map< std::string, GLenum > _attribtypes
 
std::unordered_map< GLint, std::string > _attribnames
 
std::unordered_map< std::string, GLint > _attribsizes
 
std::unordered_map< std::string, GLenum > _uniformtypes
 
std::unordered_map< GLint, std::string > _uniformnames
 
std::unordered_map< std::string, GLint > _uniformsizes
 
std::unordered_map< GLint, std::string > _uniblocknames
 
std::unordered_map< std::string, GLint > _uniblocksizes
 
std::unordered_map< GLint, GLint > _uniblockfields
 

Detailed Description

This class is a shader for rendering BillboardNode objects.

This class is a very lighweight subclass of Shader. It is exists mainly to verify the extistence of certain uniforms and cache their program locations.

Constructor & Destructor Documentation

◆ BillboardShader()

cugl::scene3::BillboardShader::BillboardShader ( )

Creates an uninitialized shader with no source.

You must initialize the shader for it to be compiled.

◆ ~BillboardShader()

cugl::scene3::BillboardShader::~BillboardShader ( )
inline

Deletes this shader, disposing all resources.

Member Function Documentation

◆ alloc() [1/2]

static std::shared_ptr< BillboardShader > cugl::scene3::BillboardShader::alloc ( )
inlinestatic

Returns a newly allocated shader with the standard vertex and fragment source.

The shader will compile the vertex and fragment sources and link them together. When compilation is complete, the shader will be bound and active. In addition, all uniforms will be validated.

Returns
a newly allocated shader with the standard vertex and fragment source.

◆ alloc() [2/2]

static std::shared_ptr< BillboardShader > cugl::scene3::BillboardShader::alloc ( const std::string  vsource,
const std::string  fsource 
)
inlinestatic

Returns a newly allocated shader with the given vertex and fragment source.

The shader will compile the vertex and fragment sources and link them together. When compilation is complete, the shader will be bound and active. In addition, all uniforms will be validated.

Parameters
vsourceThe source string for the vertex shader.
fsourceThe source string for the fragment shader.
Returns
a newly allocated shader with the given vertex and fragment source.

◆ dispose()

void cugl::scene3::BillboardShader::dispose ( )
overridevirtual

Deletes the shader program and resets all attributes.

You must reinitialize the shader to use it.

Reimplemented from cugl::graphics::Shader.

◆ init() [1/2]

bool cugl::scene3::BillboardShader::init ( )

Initializes this shader with the standard vertex and fragment source.

The shader will compile the vertex and fragment sources and link them together. When compilation is complete, the shader will be bound and active. In addition, all uniforms will be validated.

Returns
true if initialization was successful.

◆ init() [2/2]

bool cugl::scene3::BillboardShader::init ( const std::string  vsource,
const std::string  fsource 
)
overridevirtual

Initializes this shader with the given vertex and fragment source.

The shader will compile the vertex and fragment sources and link them together. When compilation is complete, the shader will be bound and active. In addition, all uniforms will be validated.

Parameters
vsourceThe source string for the vertex shader.
fsourceThe source string for the fragment shader.
Returns
true if initialization was successful.

Reimplemented from cugl::graphics::Shader.

◆ setCameraRight()

void cugl::scene3::BillboardShader::setCameraRight ( const Vec3  v)
inline

Sets the right direction of the camera for this shader.

This method will only succeed if the shader is actively bound.

Parameters
vThe camera right direction

◆ setCameraUp()

void cugl::scene3::BillboardShader::setCameraUp ( const Vec3  v)
inline

Sets the up direction of the camera for this shader.

This method will only succeed if the shader is actively bound.

Parameters
vThe camera up direction

◆ setGradient()

void cugl::scene3::BillboardShader::setGradient ( const std::shared_ptr< graphics::Gradient > &  grad)

Sets the gradient uniforms for this shader.

If the gradient is nullptr, this will 0 all gradient uniforms.

This method will only succeed if the shader is actively bound.

Parameters
gradThe gradient object

◆ setModelMatrix()

void cugl::scene3::BillboardShader::setModelMatrix ( const Mat4 matrix)
inline

Sets the model matrix for this shader.

This method will only succeed if the shader is actively bound.

Parameters
matrixThe model matrix

◆ setPerspective()

void cugl::scene3::BillboardShader::setPerspective ( const Mat4 matrix)
inline

Sets the perspective matrix for this shader.

This method will only succeed if the shader is actively bound.

Parameters
matrixThe perspective matrix

◆ setStyle()

void cugl::scene3::BillboardShader::setStyle ( Uint32  style)
inline

Sets the perspective matrix for this shader.

A value of 0 will omit the texture and/or gradient, and only use colors. A value of 1 or 3 will include the texture. A value of 2 or 3 will include the gradient.

This method will only succeed if the shader is actively bound.

Parameters
styleThe drawing style

◆ setTexture()

void cugl::scene3::BillboardShader::setTexture ( const std::shared_ptr< graphics::Texture > &  texture)
inline

Sets the texture for this shader.

This method will only succeed if the shader is actively bound. In addition, it does not actually bind the texture. That must be done separately.

Parameters
textureThe texture to bind

◆ setTextureOffset() [1/2]

void cugl::scene3::BillboardShader::setTextureOffset ( const Vec2  v)
inline

Sets the texture offset for this shader.

This value can be used for simple animations. It adjusts the texture coordinates of the sprite mesh by the given amount.

This method will only succeed if the shader is actively bound.

Parameters
vThe texture offset

◆ setTextureOffset() [2/2]

void cugl::scene3::BillboardShader::setTextureOffset ( float  x,
float  y 
)
inline

Sets the texture offset for this shader.

This value can be used for simple animations. It adjusts the texture coordinates of the sprite mesh by the given amount.

This method will only succeed if the shader is actively bound.

Parameters
xThe x-coordinate of the texture offset
yThe y-coordinate of the texture offset

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