ScummVM API documentation
OpenGL::Shader Class Reference

Public Member Functions

Shaderclone ()
 
void use (bool forceReload=false)
 
bool setUniform (const Common::String &uniform, const Math::Matrix4 &m)
 
bool setUniform (const Common::String &uniform, const Math::Matrix3 &m)
 
bool setUniform (const Common::String &uniform, const Math::Vector4d &v)
 
bool setUniform (const Common::String &uniform, const Math::Vector3d &v)
 
bool setUniform (const Common::String &uniform, const Math::Vector2d &v)
 
bool setUniform (const Common::String &uniform, unsigned int x)
 
bool setUniform (const Common::String &uniform, const int size, const int *array)
 
bool setUniform1f (const Common::String &uniform, float f)
 
GLint getUniformLocation (const Common::String &uniform) const
 
void enableVertexAttribute (const char *attrib, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer)
 
void enableVertexAttribute (const char *attrib, GLuint vbo, GLint size, GLenum type, GLboolean normalized, GLsizei stride, uint32 offset)
 
void disableVertexAttribute (const char *attrib, int size, const float *data)
 
template<int r>
void disableVertexAttribute (const char *attrib, const Math::Matrix< r, 1 > &m)
 
bool addAttribute (const char *attrib)
 
VertexAttribgetAttributeAt (uint32 idx)
 
VertexAttribgetAttribute (const char *attrib)
 
bool loadFromFiles (const char *vertex, const char *fragment, const char *const *attributes, int compatGLSLVersion=120)
 
bool loadFromStrings (const Common::String &name, const char *vertex, const char *fragment, const char *const *attributes, int compatGLSLVersion=0)
 
bool loadFromStringsArray (const Common::String &name, size_t vertexCount, const char *const *vertex, size_t fragmentCount, const char *const *fragment, const char *const *attributes)
 
void unbind ()
 
Common::StringgetError ()
 
bool hasError ()
 

Static Public Member Functions

static GLuint createBuffer (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage=GL_STATIC_DRAW)
 
static void freeBuffer (GLuint vbo)
 
static ShaderfromFiles (const char *vertex, const char *fragment, const char *const *attributes, int compatGLSLVersion=120)
 
static ShaderfromFiles (const char *shared, const char *const *attributes, int compatGLSLVersion=120)
 
static ShaderfromStrings (const Common::String &name, const char *vertex, const char *fragment, const char *const *attributes, int compatGLSLVersion=0)
 

Member Function Documentation

◆ fromFiles()

static Shader* OpenGL::Shader::fromFiles ( const char *  vertex,
const char *  fragment,
const char *const *  attributes,
int  compatGLSLVersion = 120 
)
static

Creates a shader object from files

For shader files (used by games), we used to require GLSL 1.20, this is the default for compatGLSLVersion. The GLSL version is converted to GLSL ES version if needed.

Parameters
nameThe name of the shader for errors messages
vertexThe vertex shader code
fragmentThe fragment shader code
attributesThe vertex attributes names for indexing
compatGLSLVersionThe GLSL version required: 0 for no preprocessing, 100 for GLSL 1.00 and so on
Returns
the shader object created

◆ fromStrings()

static Shader* OpenGL::Shader::fromStrings ( const Common::String name,
const char *  vertex,
const char *  fragment,
const char *const *  attributes,
int  compatGLSLVersion = 0 
)
static

Creates a shader object from strings

Shader strings are usually included in backends and don't need preprocessing, this is the default for compatGLSLVersion. The GLSL version is converted to GLSL ES version if needed.

Parameters
nameThe name of the shader for errors messages
vertexThe vertex shader code
fragmentThe fragment shader code
attributesThe vertex attributes names for indexing
compatGLSLVersionThe GLSL version required: 0 for no preprocessing, 100 for GLSL 1.00 and so on
Returns
the shader object created

◆ loadFromStringsArray()

bool OpenGL::Shader::loadFromStringsArray ( const Common::String name,
size_t  vertexCount,
const char *const *  vertex,
size_t  fragmentCount,
const char *const *  fragment,
const char *const *  attributes 
)

Creates a shader object from strings arrays

Everything is loaded directly without any preprocessing.

Parameters
nameThe name of the shader for errors messages
vertexCountThe number of vertex shader code parts
vertexThe vertex shader code parts
fragmentCountThe number of fragment shader code parts
fragmentThe fragment shader code parts
attributesThe vertex attributes names for indexing
Returns
the loading status

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