CUGL 4.0
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
cugl::graphics::ParticleShader Class Reference

#include <CUParticleShader.h>

Inheritance diagram for cugl::graphics::ParticleShader:
cugl::graphics::GraphicsShader

Public Member Functions

 ParticleShader ()
 
 ~ParticleShader ()
 
void dispose () override
 
bool init ()
 
bool init (const ShaderSource &vsource, const ShaderSource &fsource) override
 
void setPerspective (const Mat4 &matrix)
 
void setModelMatrix (const Mat4 &matrix)
 
void setCameraRight (const Vec3 &v)
 
void setCameraUp (const Vec3 &v)
 
void setTexture (const std::shared_ptr< Texture > &texture)
 
- Public Member Functions inherited from cugl::graphics::GraphicsShader
 GraphicsShader ()
 
 ~GraphicsShader ()
 
virtual void dispose ()
 
virtual bool init (const ShaderSource &vsource, const ShaderSource &fsource)
 
bool declareAttribute (const std::string name, const AttributeDef &def)
 
const AttributeDefgetAttributeDef (const std::string name) const
 
void setInstanced (Uint32 group, bool instanced)
 
void setAttributeStride (Uint32 group, size_t stride)
 
bool declareUniform (const std::string name, const UniformDef &def)
 
const UniformDefgetUniformDef (const std::string name) const
 
bool declareResource (const std::string name, const ResourceDef &def)
 
const ResourceDefgetResourceDef (const std::string name) const
 
void setRenderPass (const std::shared_ptr< RenderPass > &pass)
 
const std::shared_ptr< RenderPass > & getRenderPass () const
 
bool compile ()
 
bool isReady () const
 
void enableViewScissor (bool enable)
 
bool usesViewScissor () const
 
void setViewScissor (Uint32 x, Uint32 y, Uint32 w, Uint32 h)
 
void setViewScissor (const Rect &scissor)
 
Rect getViewScissor ()
 
void enableBlending (bool enable)
 
bool usesBlending () const
 
void enableDepthTest (bool enable)
 
bool usesDepthTest () const
 
void enableDepthWrite (bool enable)
 
bool usesDepthWrite () const
 
void enableStencilTest (bool enable)
 
bool usesStencilTest () const
 
void setDrawMode (DrawMode mode)
 
DrawMode getDrawMode () const
 
void setFrontFace (FrontFace face)
 
FrontFace getFrontFace () const
 
void setCullMode (CullMode mode)
 
CullMode getCullMode () const
 
void setDepthFunc (CompareOp func)
 
CompareOp getDepthFunc () const
 
void setStencilState (const StencilState &stencil)
 
void setFrontStencilState (const StencilState &stencil)
 
void setBackStencilState (const StencilState &stencil)
 
const StencilStategetFrontStencilState () const
 
const StencilStategetBackStencilState () const
 
void setColorMask (Uint8 mask)
 
Uint8 getColorMask () const
 
void setStencilMode (StencilMode mode)
 
void setBlendState (const BlendState &blend)
 
const BlendStategetBlendState () const
 
void setBlendMode (BlendMode mode)
 
void setLineWidth (float width)
 
float getLineWidth () const
 
void setVertices (Uint32 group, const std::shared_ptr< VertexBuffer > &vertices)
 
const std::shared_ptr< VertexBuffergetVertices (Uint32 group) const
 
void setIndices (const std::shared_ptr< IndexBuffer > &indices)
 
const std::shared_ptr< IndexBuffergetIndices () const
 
void setUniformBuffer (const std::string name, const std::shared_ptr< UniformBuffer > &buffer)
 
void setUniformBuffers (const std::string name, const std::vector< std::shared_ptr< UniformBuffer > > &buffers)
 
const std::shared_ptr< UniformBuffergetUniformBuffer (const std::string name) const
 
const std::vector< std::shared_ptr< UniformBuffer > > getUniformBuffers (const std::string name) const
 
void setStorageBuffer (const std::string name, const std::shared_ptr< StorageBuffer > &buffer)
 
void setStorageBuffers (const std::string name, const std::vector< std::shared_ptr< StorageBuffer > > &buffers)
 
const std::shared_ptr< StorageBuffergetStorageBuffer (const std::string name) const
 
const std::vector< std::shared_ptr< StorageBuffer > > getStorageBuffers (const std::string name) const
 
void setBlock (const std::string name, Uint32 block)
 
Uint32 getBlock (const std::string name)
 
void setTexture (const std::string name, const std::shared_ptr< Texture > &texture)
 
void setTextures (const std::string name, const std::vector< std::shared_ptr< Texture > > &textures)
 
const std::shared_ptr< TexturegetTexture (const std::string name) const
 
const std::vector< std::shared_ptr< Texture > > getTextures (const std::string name) const
 
void setTextureArray (const std::string name, const std::shared_ptr< TextureArray > &array)
 
void setTextureArrays (const std::string name, const std::vector< std::shared_ptr< TextureArray > > &arrays)
 
const std::shared_ptr< TextureArraygetTextureArray (const std::string name) const
 
const std::vector< std::shared_ptr< TextureArray > > getTextureArrays (const std::string name) const
 
void setImage (const std::string name, const std::shared_ptr< Image > &image)
 
void setImages (const std::string name, const std::vector< std::shared_ptr< Image > > &images)
 
const std::shared_ptr< ImagegetImage (const std::string name) const
 
const std::vector< std::shared_ptr< Image > > getImages (const std::string name) const
 
void setImageArray (const std::string name, const std::shared_ptr< ImageArray > &array)
 
void setImageArrays (const std::string name, const std::vector< std::shared_ptr< ImageArray > > &arrays)
 
const std::shared_ptr< ImageArraygetImageArray (const std::string name) const
 
const std::vector< std::shared_ptr< ImageArray > > getImageArrays (const std::string name) const
 
void setSampler (const std::string name, const std::shared_ptr< Sampler > &sampler)
 
void setSamplers (const std::string name, const std::vector< std::shared_ptr< Sampler > > &samplers)
 
const std::shared_ptr< SamplergetSampler (const std::string name) const
 
const std::vector< std::shared_ptr< Sampler > > getSamplers (const std::string name) const
 
void pushInt (const std::string name, Sint32 value)
 
void pushUInt (const std::string name, Uint32 value)
 
void pushFloat (const std::string name, float value)
 
void pushVec2 (const std::string name, const Vec2 &vec)
 
void pushVec2 (const std::string name, float x, float y)
 
void pushVec3 (const std::string name, const Vec3 &vec)
 
void pushVec3 (const std::string name, float x, float y, float z)
 
void pushVec4 (const std::string name, const Vec4 &vec)
 
void pushVec4 (const std::string name, const Quaternion &quat)
 
void pushVec4 (const std::string name, float x, float y, float z, float w)
 
void pushIVec2 (const std::string name, Sint32 x, Sint32 y)
 
void pushIVec3 (const std::string name, Sint32 x, Sint32 y, Sint32 z)
 
void pushIVec4 (const std::string name, Sint32 x, Sint32 y, Sint32 z, Sint32 w)
 
void pushUVec2 (const std::string name, Uint32 x, Uint32 y)
 
void pushUVec3 (const std::string name, Uint32 x, Uint32 y, Uint32 z)
 
void pushUVec4 (const std::string name, Uint32 x, Uint32 y, Uint32 z, Uint32 w)
 
void pushColor4f (const std::string name, const Color4f &color)
 
void pushColor4f (const std::string name, float red, float green, float blue, float alpha)
 
void pushColor4 (const std::string name, const Color4 color)
 
void pushColor4 (const std::string name, Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha)
 
void pushMat2 (const std::string name, const Affine2 &mat)
 
void pushMat2 (const std::string name, const float *array)
 
void pushMat3 (const std::string name, const Affine2 &mat)
 
void pushMat3 (const std::string name, const float *array)
 
void pushMat4 (const std::string name, const Mat4 &mat)
 
void pushMat4 (const std::string name, const float *array)
 
void push (const std::string name, Uint8 *data)
 
template<typename T >
void push (const std::string name, T value)
 
void begin ()
 
void begin (const std::shared_ptr< FrameBuffer > &framebuffer)
 
void end ()
 
void draw (Uint32 count, Uint32 offset=0)
 
void drawIndexed (Uint32 count, Uint32 offset=0)
 
void drawInstances (Uint32 count, Uint32 instances, Uint32 vtxoff=0, Uint32 insoff=0)
 
void drawInstancesIndexed (Uint32 count, Uint32 instances, Uint32 idxoff=0, Uint32 insoff=0)
 

Static Public Member Functions

static std::shared_ptr< ParticleShaderalloc ()
 
static std::shared_ptr< ParticleShaderalloc (const ShaderSource &vsource, const ShaderSource &fsource)
 
- Static Public Member Functions inherited from cugl::graphics::GraphicsShader
static std::shared_ptr< GraphicsShaderalloc (const ShaderSource &vsource, ShaderSource &fsource)
 

Additional Inherited Members

- Protected Member Functions inherited from cugl::graphics::GraphicsShader
bool validate ()
 
bool isCompatible (const std::shared_ptr< FrameBuffer > &framebuffer)
 
void flush ()
 
- Protected Attributes inherited from cugl::graphics::GraphicsShader
GraphicsShaderData * _data
 
ShaderSource _vertModule
 
ShaderSource _fragModule
 
size_t _attachments
 
std::unordered_map< std::string, AttributeDef_attributes
 
std::vector< Uint32 > _attrStride
 
std::unordered_map< std::string, UniformDef_uniforms
 
std::unordered_map< std::string, ResourceDef_resources
 
std::unordered_set< Uint32 > _instances
 
Uint32 _initialGroup
 
std::vector< std::shared_ptr< VertexBuffer > > _vertices
 
std::shared_ptr< IndexBuffer_indices
 
std::unordered_map< std::string, ResourceData * > _values
 
std::shared_ptr< RenderPass_renderpass
 
std::shared_ptr< FrameBuffer_framebuffer
 
- Static Protected Attributes inherited from cugl::graphics::GraphicsShader
static std::shared_ptr< GraphicsShaderg_shader
 

Detailed Description

This class is a shader for rendering ParticleSystem objects.

This class is a very lighweight subclass of GraphicsShader. It exists mainly to simplify the compilation stage for this shader.

This shader takes two vertex buffers. The template vertex buffer is at group 0, while the instance vertex buffer is at group 1.

Constructor & Destructor Documentation

◆ ParticleShader()

cugl::graphics::ParticleShader::ParticleShader ( )

Creates an uninitialized shader with no source.

You must initialize the shader for it to be compiled.

◆ ~ParticleShader()

cugl::graphics::ParticleShader::~ParticleShader ( )
inline

Deletes this shader, disposing all resources.

Member Function Documentation

◆ alloc() [1/2]

static std::shared_ptr< ParticleShader > cugl::graphics::ParticleShader::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< ParticleShader > cugl::graphics::ParticleShader::alloc ( const ShaderSource vsource,
const ShaderSource 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 for the vertex shader.
fsourceThe source for the fragment shader.
Returns
a newly allocated shader with the given vertex and fragment source.

◆ dispose()

void cugl::graphics::ParticleShader::dispose ( )
overridevirtual

Deletes the shader program and resets all attributes.

You must reinitialize the shader to use it.

Reimplemented from cugl::graphics::GraphicsShader.

◆ init() [1/2]

bool cugl::graphics::ParticleShader::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::graphics::ParticleShader::init ( const ShaderSource vsource,
const ShaderSource 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 for the vertex shader.
fsourceThe source for the fragment shader.
Returns
true if initialization was successful.

Reimplemented from cugl::graphics::GraphicsShader.

◆ setCameraRight()

void cugl::graphics::ParticleShader::setCameraRight ( const Vec3 v)
inline

Sets the right direction of the camera for this shader.

This method will only succeed if the shader is in an active draw pass;

Parameters
vThe camera right direction

◆ setCameraUp()

void cugl::graphics::ParticleShader::setCameraUp ( const Vec3 v)
inline

Sets the up direction of the camera for this shader.

This method will only succeed if the shader is in an active draw pass;

Parameters
vThe camera up direction

◆ setModelMatrix()

void cugl::graphics::ParticleShader::setModelMatrix ( const Mat4 matrix)
inline

Sets the model matrix for this shader.

This method will only succeed if the shader is in an active draw pass;

Parameters
matrixThe model matrix

◆ setPerspective()

void cugl::graphics::ParticleShader::setPerspective ( const Mat4 matrix)
inline

Sets the perspective matrix for this shader.

This method will only succeed if the shader is in an active draw pass;

Parameters
matrixThe perspective matrix

◆ setTexture()

void cugl::graphics::ParticleShader::setTexture ( const std::shared_ptr< Texture > &  texture)

Sets the texture for this shader.

This method will only succeed if the shader is in an active draw pass.

Parameters
textureThe texture to use

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