Molecule Viewer
 All Classes Functions Variables Enumerations Pages
Public Types | Public Member Functions | List of all members
Shader Class Reference

Represents a shader program. More...

#include <Shader.hpp>

Public Types

enum  Coordinates { Position = 1, Radius = 2, Color = 3, UVQuad = 4 }
 Enumerates the shader coordinates.
 
enum  Uniforms {
  ProjectionMatrix = 5, ModelViewMatrix = 6, OcclusionTexture = 8, LightPosition = 9,
  OcclusionDirections = 10, ShadowTex = 11, ShadowMVMatrix = 12, ShadowPMatrix = 13,
  ContourData = 14, ShadowActive = 15, OcclusionActive = 16, AmbientIntensity = 17,
  DirectIntensity = 18, Glossiness = 19, FarPlane = 20
}
 Enumerates the shader uniforms.
 

Public Member Functions

 Shader (const string &path)
 Loads shaders from files and compiles them. More...
 
 ~Shader ()
 destruct
 
GLuint GetAddress (int address)
 gets the shader address for the provided value (use Shader enumerations)
 
void bind () const
 Bind the shader to the OGL state-machine.
 
void unbind () const
 Unbind the shader.
 
GLint get_attrib_location (const std::string &name) const
 Query the location of a vertex attribute inside the shader.
 
GLint get_uniform_location (const std::string &name) const
 Query the location of a uniform variable inside the shader.
 
void bind_frag_data_location (const std::string &name)
 Define the name of the variable inside the shader which represents the final color for each fragment.
 
 operator bool ()
 A little cast helper. More...
 

Detailed Description

Represents a shader program.

One shader program contains a vertex, a geometry and a fragment shader. File endings: *.vert for vertex shader, *.frag for fragment shader and *.geom for geometry shader. The shader files have to be in the sub folder "Shaders", relative to this file.

Definition at line 14 of file Shader.hpp.

Constructor & Destructor Documentation

Shader::Shader ( const string &  path)

Loads shaders from files and compiles them.

When path is "hello", the files "hello.frag" & "hello.vert" will be loaded.

Definition at line 8 of file Shader.cpp.

Member Function Documentation

Shader::operator bool ( )
inline

A little cast helper.

With this you can simply do "if (shader) {...}" to test if a shader has been compiled successfully.

Definition at line 86 of file Shader.hpp.


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