Unofficial OpenGL Software Development Kit  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Namespaces
Shader.h File Reference

Includes functions to help load and validate shaders and programs. This header must be included after an OpenGL header. More...

#include <exception>
#include <string>
#include <vector>
#include "array_ref.h"
#include <boost/utility/string_ref.hpp>
#include <boost/noncopyable.hpp>

Go to the source code of this file.

Classes

class  glutil::ShaderException
 Base class for all exceptions thrown by shader and program creation functions. More...
 
class  glutil::SeparateShaderNotSupported
 Thrown if the user requests the creation of separate programs, but the implementation cannot do that. More...
 
class  glutil::CompileLinkException
 Thrown if the compilation or linking fails. The log will be stored in this exception. More...
 
class  glutil::UniqueShader
 RAII object for managing a shader object. More...
 
class  glutil::UniqueProgram
 RAII object for managing a program object. More...
 

Namespaces

namespace  glutil
 The main namespace for the GL Utility library. All GL Util functions are in this namespace.
 

Functions

Shader Compilation

These functions generate shaders from text strings. They will throw exceptions in the event of compilation failure.

GLuint glutil::CompileShader (GLenum shaderType, boost::string_ref shaderText)
 Creates a shader object and compiles it with the given text string. More...
 
GLuint glutil::CompileShader (GLenum shaderType, refs::array_ref< const char * > shaderList)
 As CompileShader(GLenum, const char *), but with a list of strings.
 
GLuint glutil::CompileShader (GLenum shaderType, const std::vector< std::string > &shaderList)
 As CompileShader(GLenum, const char *), but with a list of strings.
 
Program Linking

These functions take one or more shader objects and link them together into a program. In the event of a linker error, they will throw an exception.

All shader objects are detached from the program that is returned.

GLuint glutil::LinkProgram (GLuint shaderOne, GLuint shaderTwo)
 Links the two shader objects into a single program. More...
 
GLuint glutil::LinkProgram (GLuint program, GLuint shaderOne, GLuint shaderTwo)
 As LinkProgram(GLuint, GLuint), except that it is given a program to do the linking within.
 
GLuint glutil::LinkProgram (boost::string_ref vertexShader, boost::string_ref fragmentShader)
 Creates a program from two shader strings, one for a vertex shader and one for a fragment shader. More...
 
GLuint glutil::LinkProgram (GLuint program, boost::string_ref vertexShader, boost::string_ref fragmentShader)
 As LinkProgram(boost::string_ref, boost::string_ref), except that it is given a program to do the linking within.
 
GLuint glutil::LinkProgram (GLuint shader, bool isSeparable=false)
 Takes a single shader and links it into a program. More...
 
GLuint glutil::LinkProgram (refs::array_ref< GLuint > shaders, bool isSeparable=false)
 As LinkProgram(GLuint, bool), only with a list of shaders.
 
GLuint glutil::LinkProgram (GLuint program, refs::array_ref< GLuint > shaders)
 Takes a program and links a number of shaders to it. More...
 
Separable Program Creation

These functions generate separable programs from text strings. They will throw exceptions in the event that ARB_separate_shader_objects or GL 4.1+ are not available. Exceptions will also be thrown if the compiling/linking fails.

GLuint glutil::MakeSeparableProgram (GLenum shaderType, const char *shaderText)
 Creates a single-stage separable program from the given shader text. More...
 
GLuint glutil::MakeSeparableProgram (GLenum shaderType, const std::string &shaderText)
 Creates a single-stage separable program from the given shader text. More...
 
GLuint glutil::MakeSeparableProgram (GLenum shaderType, refs::array_ref< const char * > shaderList)
 As MakeSeparableProgram(GLenum, const char *), except with a list of strings.
 
GLuint glutil::MakeSeparableProgram (GLenum shaderType, const std::vector< std::string > &shaderList)
 As MakeSeparableProgram(GLenum, const char *), except with a list of strings.
 

Detailed Description

Includes functions to help load and validate shaders and programs. This header must be included after an OpenGL header.