Skip to content

Vp::Shader ​

Base class for shaders. More...

#include "Viewport/shader/Shader.h"

Inherited by Vp::BoxBlurShader, Vp::ScreenOverlayShader, Vp::SelectionCompositeShader, Vp::WBOITCompositeShader, Vp::WorldShader

Public Functions ​

Name
Shader(GLuint id)
virtual~Shader() =default
voidbindTexture2D(GLuint textureUnit, GLuint textureID, GLint samplerLocation)
voidbindTexture2DArray(GLuint textureUnit, GLuint textureID, GLint samplerLocation)
voidbindTexture2DMS(GLuint textureUnit, GLuint textureID, GLint samplerLocation)
boolhasUniform(GLint location) const
virtual voidinit(bool initSuperclass)
virtual voidsetUniforms()<br>Set uniforms before rendering.
virtual voidsetUniformsPerMeshPart(Core::Mesh::MeshPart & meshPart)<br>Set uniforms before rendering individual mesh parts.
boolsupportsUserClipping() const
boolsupportsWboit() const
virtual voiduse() const

Public Attributes ​

Name
const std::array< glm::vec4, 6 > *m_clippingPlanes
std::stringm_fragSource
std::stringm_geoSource
GLuintm_id
std::stringm_injectedSource
std::stringm_vertSource
boolm_wboit <br>Whether to use weighted blended transparency for output if supported.
intm_wboitFunc

Protected Attributes ​

Name
std::array< GLint, 6 >m_clippingPlanesId
GLintm_wboitFlagId <br>Uniform id of the wboit enable/disable flag.
GLintm_wboitFuncId

Detailed Description ​

cpp
class Vp::Shader;

Base class for shaders.

Note that shader objects are just a facade/API for the glsl shaders. They shouldn't store state across frames and should have ALL their variables and uniforms set before each use. However sometimes it makes sense to store values in them. Just be aware that shaders are shared between many objects.

Public Functions Documentation ​

function Shader ​

cpp
explicit Shader(
    GLuint id
)

function ~Shader ​

cpp
virtual ~Shader() =default

function bindTexture2D ​

cpp
void bindTexture2D(
    GLuint textureUnit,
    GLuint textureID,
    GLint samplerLocation
)

function bindTexture2DArray ​

cpp
void bindTexture2DArray(
    GLuint textureUnit,
    GLuint textureID,
    GLint samplerLocation
)

function bindTexture2DMS ​

cpp
void bindTexture2DMS(
    GLuint textureUnit,
    GLuint textureID,
    GLint samplerLocation
)

function hasUniform ​

cpp
bool hasUniform(
    GLint location
) const

function init ​

cpp
virtual void init(
    bool initSuperclass
)

Reimplemented by: Vp::BoxBlurShader::init, Vp::ColorShader::init, Vp::FrustumShader::init, Vp::GridShader::init, Vp::GridShaderGeneric::init, Vp::ObjectShader::init, Vp::PhongShader::init, Vp::ScreenOverlayShader::init, Vp::SelectionCompositeShader::init, Vp::WBOITCompositeShader::init, Vp::WorldShader::init

function setUniforms ​

cpp
virtual void setUniforms()

Set uniforms before rendering.

Reimplemented by: Vp::BoxBlurShader::setUniforms, Vp::ColorShader::setUniforms, Vp::FrustumShader::setUniforms, Vp::GridShader::setUniforms, Vp::GridShaderGeneric::setUniforms, Vp::ObjectShader::setUniforms, Vp::PhongShader::setUniforms, Vp::ScreenOverlayShader::setUniforms, Vp::SelectionCompositeShader::setUniforms, Vp::WBOITCompositeShader::setUniforms, Vp::WorldShader::setUniforms

function setUniformsPerMeshPart ​

cpp
virtual void setUniformsPerMeshPart(
    Core::Mesh::MeshPart & meshPart
)

Set uniforms before rendering individual mesh parts.

Parameters:

  • meshPart MeshPart being rendered

Reimplemented by: Vp::PhongShader::setUniformsPerMeshPart

function supportsUserClipping ​

cpp
bool supportsUserClipping() const

function supportsWboit ​

cpp
bool supportsWboit() const

Return: Whether this shader supports output to wboit buffers

function use ​

cpp
virtual void use() const

Public Attributes Documentation ​

variable m_clippingPlanes ​

cpp
const std::array< glm::vec4, 6 > * m_clippingPlanes {nullptr};

variable m_fragSource ​

cpp
std::string m_fragSource;

variable m_geoSource ​

cpp
std::string m_geoSource;

variable m_id ​

cpp
GLuint m_id;

variable m_injectedSource ​

cpp
std::string m_injectedSource;

variable m_vertSource ​

cpp
std::string m_vertSource;

variable m_wboit ​

cpp
bool m_wboit = false;

Whether to use weighted blended transparency for output if supported.

See: supportsWboit()

variable m_wboitFunc ​

cpp
int m_wboitFunc = 0;

Protected Attributes Documentation ​

variable m_clippingPlanesId ​

cpp
std::array< GLint, 6 > m_clippingPlanesId;

variable m_wboitFlagId ​

cpp
GLint m_wboitFlagId {-1};

Uniform id of the wboit enable/disable flag.

variable m_wboitFuncId ​

cpp
GLint m_wboitFuncId {-1};

Updated on 2026-09-11 at 21:24:25 +0000