Krita Source Code Documentation
Loading...
Searching...
No Matches
KisShaderProgram Class Reference

#include <kis_opengl_shader_loader.h>

+ Inheritance diagram for KisShaderProgram:

Public Member Functions

int location (Uniform uniform)
 

Static Public Attributes

static std::map< Uniform, const char * > names
 

Private Attributes

std::map< Uniform, int > locationMap
 

Detailed Description

A wrapper class over Qt's QOpenGLShaderProgram to provide access to uniform locations without having to store them as constants next to the shader.

Definition at line 30 of file kis_opengl_shader_loader.h.

Member Function Documentation

◆ location()

int KisShaderProgram::location ( Uniform uniform)
inline

Stores uniform location in cache if it is called for the first time and retrieves the location from the map on subsequent calls.

Definition at line 42 of file kis_opengl_shader_loader.h.

42 {
43 std::map<Uniform, int>::const_iterator it = locationMap.find(uniform);
44 if (it != locationMap.end()) {
45 return it->second;
46 } else {
47 int location = uniformLocation(names[uniform]);
48 locationMap[uniform] = location;
49 return location;
50 }
51 }
int location(Uniform uniform)
std::map< Uniform, int > locationMap
static std::map< Uniform, const char * > names

References location(), locationMap, and names.

Member Data Documentation

◆ locationMap

std::map<Uniform, int> KisShaderProgram::locationMap
private

Definition at line 53 of file kis_opengl_shader_loader.h.

◆ names

std::map< Uniform, const char * > KisShaderProgram::names
static
Initial value:
= {
{ModelViewProjection, "modelViewProjection"},
{TextureMatrix, "textureMatrix"},
{ViewportScale, "viewportScale"},
{TexelSize, "texelSize"},
{Texture0, "texture0"},
{Texture1, "texture1"},
{FixedLodLevel, "fixedLodLevel"},
{FragmentColor, "fragColor"}
}
@ ModelViewProjection

Stores the mapping of uniform enums to actual shader uniform names. The actual shader names are necessary for calls to uniformLocation.

Definition at line 23 of file kis_opengl_shader_loader.h.

30 : public QOpenGLShaderProgram {
31public:

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