Stellarium  0.90.0
List of all members | Public Types | Public Member Functions
ShaderMgr Class Reference

A simple shader cache class that gives us the correct shader depending on desired configuration. More...

#include <ShaderManager.hpp>

Public Types

enum  UNIFORM {
  UNIFORM_MAT_MODELVIEW, UNIFORM_MAT_PROJECTION, UNIFORM_MAT_MVP, UNIFORM_MAT_NORMAL,
  UNIFORM_MAT_SHADOW0, UNIFORM_MAT_SHADOW1, UNIFORM_MAT_SHADOW2, UNIFORM_MAT_SHADOW3,
  UNIFORM_MAT_CUBEMVP, UNIFORM_TEX_DIFFUSE, UNIFORM_TEX_EMISSIVE, UNIFORM_TEX_BUMP,
  UNIFORM_TEX_HEIGHT, UNIFORM_TEX_SHADOW0, UNIFORM_TEX_SHADOW1, UNIFORM_TEX_SHADOW2,
  UNIFORM_TEX_SHADOW3, UNIFORM_MTL_SHININESS, UNIFORM_MTL_ALPHA, UNIFORM_MIX_AMBIENT,
  UNIFORM_MIX_DIFFUSE, UNIFORM_MIX_SPECULAR, UNIFORM_MIX_TORCHDIFFUSE, UNIFORM_MIX_EMISSIVE,
  UNIFORM_LIGHT_DIRECTION_VIEW, UNIFORM_TORCH_ATTENUATION, UNIFORM_VEC_COLOR, UNIFORM_VEC_SPLITDATA,
  UNIFORM_VEC_LIGHTORTHOSCALE, UNIFORM_FLOAT_ALPHA_THRESH
}
 Enum for OpenGL shader uniform locations (faster than accessing by string each time) More...
 

Public Member Functions

QOpenGLShaderProgram * getShader (const GlobalShaderParameters &globals, const S3DScene::Material *mat=Q_NULLPTR)
 Returns a shader that supports the specified operations. Must be called within a GL context. More...
 
QOpenGLShaderProgram * getDebugShader ()
 Returns the Frustum/Boundingbox Debug shader. More...
 
QOpenGLShaderProgram * getCubeShader ()
 Returns the cubemapping shader. More...
 
QOpenGLShaderProgram * getTextureShader ()
 Returns the basic texturing shader. More...
 
GLint uniformLocation (const QOpenGLShaderProgram *shad, UNIFORM uni)
 Returns the location of this uniform for this shader, or -1 if this uniform does not exist. More...
 
void clearCache ()
 Clears the shaders that have been created by this manager. Must be called within a GL context. More...
 

Detailed Description

A simple shader cache class that gives us the correct shader depending on desired configuration.

It also contains a uniform cache to avoid unnecessary glUniformLocation calls

Definition at line 52 of file ShaderManager.hpp.

Member Enumeration Documentation

Enum for OpenGL shader uniform locations (faster than accessing by string each time)

Enumerator
UNIFORM_MAT_MODELVIEW 

Defines the ModelView matrix.

UNIFORM_MAT_PROJECTION 

Defines the Projection matrix.

UNIFORM_MAT_MVP 

Defines the combined ModelViewProjection matrix, used if shader needs no separation of the 2 for a bit of a speedup.

UNIFORM_MAT_NORMAL 

Defines the 3x3 Normal matrix (transpose of the inverse MV matrix)

UNIFORM_MAT_SHADOW0 

The shadow matrices (4x 4x4 Matrices)

UNIFORM_MAT_CUBEMVP 

The first cube MVP (array mat4, total 6)

UNIFORM_TEX_DIFFUSE 

Defines the Diffuse texture slot.

UNIFORM_TEX_EMISSIVE 

Defines the emissive texture slot.

UNIFORM_TEX_BUMP 

Defines the Bump texture slot.

UNIFORM_TEX_HEIGHT 

Defines the Height texture slot.

UNIFORM_TEX_SHADOW0 

Shadow maps, 4x.

UNIFORM_MTL_SHININESS 

Material specular shininess (exponent)

UNIFORM_MTL_ALPHA 

Material global transparency.

UNIFORM_MIX_AMBIENT 

(Light ambient + const factor) * Material ambient or diffuse, depending on Illum model

UNIFORM_MIX_DIFFUSE 

Light directional * Material diffuse.

UNIFORM_MIX_SPECULAR 

Light specular * Material specular color.

UNIFORM_MIX_TORCHDIFFUSE 

Torch color * mat diffuse.

UNIFORM_MIX_EMISSIVE 

Material emissive color * light emissive.

UNIFORM_LIGHT_DIRECTION_VIEW 

Light direction vector (view space)

UNIFORM_TORCH_ATTENUATION 

Torchlight attenuation factor (1 float, like in the second model at http://framebunker.com/blog/lighting-2-attenuation/)

UNIFORM_VEC_COLOR 

simple color vec4

UNIFORM_VEC_SPLITDATA 

Squared frustum splits (vec4)

UNIFORM_VEC_LIGHTORTHOSCALE 

Scaling of each frustum's light ortho projection (4xvec2)

UNIFORM_FLOAT_ALPHA_THRESH 

Alpha test threshold.

Definition at line 59 of file ShaderManager.hpp.

Member Function Documentation

void ShaderMgr::clearCache ( )

Clears the shaders that have been created by this manager. Must be called within a GL context.

QOpenGLShaderProgram * ShaderMgr::getCubeShader ( )
inline

Returns the cubemapping shader.

Definition at line 268 of file ShaderManager.hpp.

QOpenGLShaderProgram * ShaderMgr::getDebugShader ( )
inline

Returns the Frustum/Boundingbox Debug shader.

Definition at line 263 of file ShaderManager.hpp.

QOpenGLShaderProgram * ShaderMgr::getShader ( const GlobalShaderParameters globals,
const S3DScene::Material mat = Q_NULLPTR 
)
inline

Returns a shader that supports the specified operations. Must be called within a GL context.

Definition at line 218 of file ShaderManager.hpp.

QOpenGLShaderProgram * ShaderMgr::getTextureShader ( )
inline

Returns the basic texturing shader.

Definition at line 273 of file ShaderManager.hpp.

GLint ShaderMgr::uniformLocation ( const QOpenGLShaderProgram *  shad,
UNIFORM  uni 
)
inline

Returns the location of this uniform for this shader, or -1 if this uniform does not exist.

This is cached to elimate the overhead of the glGet calls

Definition at line 278 of file ShaderManager.hpp.


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