Shader Object. More...

#include <shader_object.h>

Public Member Functions

 ShaderObject ()
 Constructs a null instance. More...
 
 ShaderObject (GraphicContext &gc, ShaderType type, const std::string &source)
 Constructs an OpenGL shader. More...
 
 ShaderObject (GraphicContext &gc, ShaderType type, const void *source, int source_size)
 Constructs a ShaderObject. More...
 
 ShaderObject (GraphicContext &gc, ShaderType type, const std::vector< std::string > &sources)
 Constructs a ShaderObject. More...
 
 ShaderObject (GraphicContextProvider *gc_provider, ShaderType type, const std::string &source)
 Constructs a ShaderObject. More...
 
 ShaderObject (GraphicContextProvider *gc_provider, ShaderType type, const std::vector< std::string > &sources)
 Constructs a ShaderObject. More...
 
virtual ~ShaderObject ()
 
bool compile ()
 Compile program. More...
 
unsigned int get_handle () const
 Returns the OpenGL shader handle. More...
 
std::string get_info_log () const
 Get shader object's info log. More...
 
ShaderObjectProviderget_provider () const
 Get Provider. More...
 
std::string get_shader_source () const
 Get shader source code. More...
 
ShaderType get_shader_type () const
 Gets the shader type. More...
 
bool is_null () const
 Returns true if this object is invalid. More...
 
 operator bool () const
 
bool operator== (const ShaderObject &other) const
 Handle comparison operator. More...
 
void throw_if_null () const
 Throw an exception if this object is invalid. More...
 

Static Public Member Functions

static ShaderObject load (GraphicContext &gc, const std::string &resource_id, const XMLResourceDocument &resources)
 Load. More...
 
static ShaderObject load (GraphicContext &gc, ShaderType type, const std::string &filename, const FileSystem &fs)
 Load. More...
 
static ShaderObject load (GraphicContext &gc, ShaderType type, const std::string &fullname)
 Load. More...
 
static ShaderObject load (GraphicContext &gc, ShaderType type, IODevice &file)
 Load. More...
 
static ShaderObject load_and_compile (GraphicContext &gc, ShaderType type, const std::string &filename, const FileSystem &fs)
 Load and compile. More...
 
static ShaderObject load_and_compile (GraphicContext &gc, ShaderType type, const std::string &filename)
 Load and compile. More...
 
static ShaderObject load_and_compile (GraphicContext &gc, ShaderType type, IODevice &file)
 Load and compile. More...
 

Detailed Description

Shader Object.

The source code that makes up a program that gets executed by one of the programmable stages is encapsulated in one or more shader objects. Shader objects are attached to a program objects to form a programmable setup. ShaderObject is ClanLib's C++ interface to OpenGL shader objects.

Constructor & Destructor Documentation

clan::ShaderObject::ShaderObject ( )

Constructs a null instance.

clan::ShaderObject::ShaderObject ( GraphicContext gc,
ShaderType  type,
const std::string source 
)

Constructs an OpenGL shader.

Parameters
typeShader type. Can be shadertype_vertex or shadertype_fragment.
sourceShader source code, in OpenGL Shader Language (GLSL).
gcGraphics context in which to create the shader object
clan::ShaderObject::ShaderObject ( GraphicContext gc,
ShaderType  type,
const void *  source,
int  source_size 
)

Constructs a ShaderObject.

clan::ShaderObject::ShaderObject ( GraphicContext gc,
ShaderType  type,
const std::vector< std::string > &  sources 
)

Constructs a ShaderObject.

Parameters
gc= Graphic Context
type= Shader Type
sources= sources
clan::ShaderObject::ShaderObject ( GraphicContextProvider gc_provider,
ShaderType  type,
const std::string source 
)

Constructs a ShaderObject.

Parameters
gc_provider= Graphic Context Provider
type= Shader Type
source= String Ref
clan::ShaderObject::ShaderObject ( GraphicContextProvider gc_provider,
ShaderType  type,
const std::vector< std::string > &  sources 
)

Constructs a ShaderObject.

Parameters
gc_provider= Graphic Context Provider
type= Shader Type
sources= sources
virtual clan::ShaderObject::~ShaderObject ( )
virtual

Member Function Documentation

bool clan::ShaderObject::compile ( )

Compile program.

If the compiling fails, get_info_log() will return the compile log.

unsigned int clan::ShaderObject::get_handle ( ) const

Returns the OpenGL shader handle.

std::string clan::ShaderObject::get_info_log ( ) const

Get shader object's info log.

ShaderObjectProvider* clan::ShaderObject::get_provider ( ) const

Get Provider.

Returns
provider
std::string clan::ShaderObject::get_shader_source ( ) const

Get shader source code.

ShaderType clan::ShaderObject::get_shader_type ( ) const

Gets the shader type.

bool clan::ShaderObject::is_null ( ) const
inline

Returns true if this object is invalid.

static ShaderObject clan::ShaderObject::load ( GraphicContext gc,
const std::string resource_id,
const XMLResourceDocument resources 
)
static

Load.

Parameters
gc= Graphic Context
resource_id= String Ref
resources= Resource Manager
Returns
Shader Object
static ShaderObject clan::ShaderObject::load ( GraphicContext gc,
ShaderType  type,
const std::string filename,
const FileSystem fs 
)
static

Load.

Parameters
gc= Graphic Context
type= Shader Type
filename= String Ref
directory= Virtual Directory
Returns
Shader Object
static ShaderObject clan::ShaderObject::load ( GraphicContext gc,
ShaderType  type,
const std::string fullname 
)
static

Load.

Parameters
gc= Graphic Context
type= Shader Type
fullname= String Ref
Returns
Shader Object
static ShaderObject clan::ShaderObject::load ( GraphicContext gc,
ShaderType  type,
IODevice file 
)
static

Load.

Parameters
gc= Graphic Context
type= Shader Type
file= IODevice
Returns
Shader Object
static ShaderObject clan::ShaderObject::load_and_compile ( GraphicContext gc,
ShaderType  type,
const std::string filename,
const FileSystem fs 
)
static

Load and compile.

Parameters
gc= Graphic Context
type= Shader Type
filename= String Ref
directory= Virtual Directory
Returns
Shader Object
static ShaderObject clan::ShaderObject::load_and_compile ( GraphicContext gc,
ShaderType  type,
const std::string filename 
)
static

Load and compile.

Parameters
gc= Graphic Context
type= Shader Type
filename= String Ref
Returns
Shader Object
static ShaderObject clan::ShaderObject::load_and_compile ( GraphicContext gc,
ShaderType  type,
IODevice file 
)
static

Load and compile.

Parameters
gc= Graphic Context
type= Shader Type
file= IODevice
Returns
Shader Object
clan::ShaderObject::operator bool ( ) const
inlineexplicit
bool clan::ShaderObject::operator== ( const ShaderObject other) const

Handle comparison operator.

void clan::ShaderObject::throw_if_null ( ) const

Throw an exception if this object is invalid.


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