clan::ShaderObject Class Reference - ClanLib SDK
Description: clan::ShaderObject Class Reference

Public Member Functions | Static Public Member Functions | List of all members
clan::ShaderObject Class Reference
clanDisplay Display

Shader Object. More...

`#include <shader_object.h>`

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

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

## 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

## ◆ ShaderObject() [1/6]

clan::ShaderObject::ShaderObject | ( |  | ) |

Constructs a null instance.

## ◆ ShaderObject() [2/6]

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

Constructs an OpenGL shader.

Parameters

  type | Shader type. Can be shadertype_vertex or shadertype_fragment.
  source | Shader source code, in OpenGL Shader Language (GLSL).
  gc | Graphics context in which to create the shader object

## ◆ ShaderObject() [3/6]

clan::ShaderObject::ShaderObject | ( | GraphicContext & | gc,
|  | ShaderType | type,
|  | const void * | source,
|  | int | source_size )

Constructs a ShaderObject.

## ◆ ShaderObject() [4/6]

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

## ◆ ShaderObject() [5/6]

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

## ◆ ShaderObject() [6/6]

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

## ◆ ~ShaderObject()

virtual clan::ShaderObject::~ShaderObject | ( |  | ) |
| virtual

## Member Function Documentation

## ◆ compile()

bool clan::ShaderObject::compile | ( |  | ) |

Compile program.

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

## ◆ get_handle()

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

Returns the OpenGL shader handle.

## ◆ get_info_log()

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

Get shader object's info log.

## ◆ get_provider()

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

Get Provider.

Returns
  provider

## ◆ get_shader_source()

std::string clan::ShaderObject::get_shader_source | ( |  | ) | const

Get shader source code.

## ◆ get_shader_type()

ShaderType clan::ShaderObject::get_shader_type | ( |  | ) | const

Gets the shader type.

## ◆ is_null()

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

Returns true if this object is invalid.

## ◆ load() [1/4]

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

## ◆ load() [2/4]

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

## ◆ load() [3/4]

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

## ◆ load() [4/4]

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

## ◆ load_and_compile() [1/3]

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

## ◆ load_and_compile() [2/3]

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

## ◆ load_and_compile() [3/3]

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

## ◆ operator bool()

clan::ShaderObject::operator bool | ( |  | ) | const
| inlineexplicit

## ◆ operator==()

bool clan::ShaderObject::operator== | ( | const ShaderObject & | other | ) | const

Handle comparison operator.

## ◆ throw_if_null()

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:

- shader_object.h