Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | List of all members
vl::GLSLShader Class Reference

For internal use only. More...

#include <GLSL.hpp>

+ Inheritance diagram for vl::GLSLShader:

Public Member Functions

 GLSLShader ()
 
 GLSLShader (EShaderType type, const String &source_or_path)
 
 ~GLSLShader ()
 
void setType (EShaderType type)
 
EShaderType type () const
 
void setSource (const String &source_or_path)
 Sets the sources for this shader and schedules a recompilation for it. If the string passed is a file path the source is loaded from it. More...
 
const std::string & source () const
 Returns the sources for this shader. More...
 
void setPath (const String &path)
 The path from which the shader was loaded. More...
 
const Stringpath () const
 The path from which the shader was loaded. More...
 
bool reload ()
 Reloads the shader source and recompiles it. Returns true on success. More...
 
std::string getShaderSource () const
 Retrieves the shader source using glGetShaderSource() More...
 
bool compile ()
 Compiles the shader, see also http://www.opengl.org/sdk/docs/man/xhtml/glCompileShader.xml for more information. More...
 
bool compileStatus () const
 Returns true if the shader has been succesfully compiled. More...
 
String infoLog () const
 Returns a String object containing this shader's info log as returned by glGetShaderInfoLog(), see also http://www.opengl.org/sdk/docs/man/xhtml/glGetShaderInfoLog.xml for more information. More...
 
void createShader ()
 Creates the shader using the OpenGL function glCreateShader(), see also http://www.opengl.org/sdk/docs/man/xhtml/glCreateShader.xml for more information. More...
 
void deleteShader ()
 Deletes the shader using the OpenGL function glDeleteShader(), see also http://www.opengl.org/sdk/docs/man/xhtml/glDeleteShader.xml for more information. More...
 
unsigned int handle () const
 The handle of this OpenGL shader object as returned by glCreateShader() More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

EShaderType mType
 
std::string mSource
 
String mPath
 
unsigned int mHandle
 
bool mCompiled
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

For internal use only.

Base class for GLSLVertexShader, GLSLFragmentShader, GLSLGeometryShader, GLSLTessEvaluationShader and GLSLTessControlShader.

See also
GLSLVertexShader, GLSLFragmentShader, GLSLGeometryShader, GLSLTessControlShader, GLSLTessEvaluationShader, GLSLProgram, Effect

Definition at line 50 of file GLSL.hpp.

Constructor & Destructor Documentation

◆ GLSLShader() [1/2]

GLSLShader::GLSLShader ( )

Definition at line 45 of file GLSL.cpp.

References mCompiled, mHandle, mType, and vl::ST_VERTEX_SHADER.

◆ GLSLShader() [2/2]

GLSLShader::GLSLShader ( EShaderType  type,
const String source_or_path 
)

Definition at line 53 of file GLSL.cpp.

References mCompiled, mHandle, mType, setSource(), and type().

◆ ~GLSLShader()

GLSLShader::~GLSLShader ( )

Definition at line 62 of file GLSL.cpp.

References deleteShader().

Member Function Documentation

◆ compile()

bool GLSLShader::compile ( )

Compiles the shader, see also http://www.opengl.org/sdk/docs/man/xhtml/glCompileShader.xml for more information.

This function also create the shader if handle() == 0 using the OpenGL function glCreateShader(), see also http://www.opengl.org/sdk/docs/man/xhtml/glCreateShader.xml

Definition at line 159 of file GLSL.cpp.

References vl::Log::bug(), compileStatus(), createShader(), vl::String::empty(), vl::Log::error(), handle(), vl::Has_GLSL, infoLog(), vl::log(), mCompiled, mSource, NULL, vl::Object::objectName(), VL_CHECK, VL_CHECK_OGL, and vl::Log::warning().

Referenced by vl::GLSLProgram::attachShader(), and reload().

◆ compileStatus()

bool GLSLShader::compileStatus ( ) const

Returns true if the shader has been succesfully compiled.

The check is done using the OpenGL function glGetShaderiv(), see also http://www.opengl.org/sdk/docs/man/xhtml/glGetShader.xml for more information.

Definition at line 214 of file GLSL.cpp.

References handle(), vl::Has_GLSL, VL_CHECK, and VL_CHECK_OGL.

Referenced by compile().

◆ createShader()

void GLSLShader::createShader ( )

Creates the shader using the OpenGL function glCreateShader(), see also http://www.opengl.org/sdk/docs/man/xhtml/glCreateShader.xml for more information.

Definition at line 249 of file GLSL.cpp.

References handle(), vl::Has_GLSL, mCompiled, mHandle, mType, VL_CHECK, and VL_CHECK_OGL.

Referenced by vl::GLSLProgram::attachShader(), and compile().

◆ deleteShader()

void GLSLShader::deleteShader ( )

Deletes the shader using the OpenGL function glDeleteShader(), see also http://www.opengl.org/sdk/docs/man/xhtml/glDeleteShader.xml for more information.

Definition at line 264 of file GLSL.cpp.

References handle(), vl::Has_GLSL, mCompiled, mHandle, and VL_CHECK.

Referenced by ~GLSLShader().

◆ getShaderSource()

std::string GLSLShader::getShaderSource ( ) const

Retrieves the shader source using glGetShaderSource()

Definition at line 67 of file GLSL.cpp.

References handle(), vl::String::loadText(), vl::String::printf(), source(), and vl::String::splitLines().

Referenced by vlX::VLXClassWrapper_GLSLShader::exportGLSLShader().

◆ handle()

unsigned int vl::GLSLShader::handle ( ) const
inline

◆ infoLog()

String GLSLShader::infoLog ( ) const

Returns a String object containing this shader's info log as returned by glGetShaderInfoLog(), see also http://www.opengl.org/sdk/docs/man/xhtml/glGetShaderInfoLog.xml for more information.

Definition at line 227 of file GLSL.cpp.

References handle(), vl::Has_GLSL, NULL, VL_CHECK, and VL_CHECK_OGL.

Referenced by compile(), vl::GLSLProgram::linkProgram(), and vl::GLSLProgram::programBinary().

◆ path()

const String& vl::GLSLShader::path ( ) const
inline

The path from which the shader was loaded.

Definition at line 78 of file GLSL.hpp.

Referenced by vlX::VLXClassWrapper_GLSLShader::exportGLSLShader(), and reload().

◆ reload()

bool GLSLShader::reload ( )

Reloads the shader source and recompiles it. Returns true on success.

Definition at line 105 of file GLSL.cpp.

References compile(), vl::String::empty(), mPath, path(), and setSource().

◆ setPath()

void vl::GLSLShader::setPath ( const String path)
inline

The path from which the shader was loaded.

Definition at line 75 of file GLSL.hpp.

Referenced by setSource().

◆ setSource()

void GLSLShader::setSource ( const String source_or_path)

Sets the sources for this shader and schedules a recompilation for it. If the string passed is a file path the source is loaded from it.

Definition at line 115 of file GLSL.cpp.

References vl::String::clear(), vl::String::count(), vl::String::empty(), vl::Log::error(), vl::String::loadText(), vl::locateFile(), vl::max(), mCompiled, mPath, mSource, vl::Object::setObjectName(), setPath(), vl::String::toStdString(), and VL_CHECK.

Referenced by GLSLShader(), vlX::VLXClassWrapper_GLSLShader::importGLSLShader(), and reload().

◆ setType()

void vl::GLSLShader::setType ( EShaderType  type)
inline

Definition at line 64 of file GLSL.hpp.

◆ source()

const std::string& vl::GLSLShader::source ( ) const
inline

Returns the sources for this shader.

Definition at line 72 of file GLSL.hpp.

Referenced by vlX::VLXClassWrapper_GLSLShader::exportGLSLShader(), and getShaderSource().

◆ type()

EShaderType vl::GLSLShader::type ( ) const
inline

Definition at line 66 of file GLSL.hpp.

Referenced by GLSLShader().

Member Data Documentation

◆ mCompiled

bool vl::GLSLShader::mCompiled
protected

Definition at line 111 of file GLSL.hpp.

Referenced by compile(), createShader(), deleteShader(), GLSLShader(), and setSource().

◆ mHandle

unsigned int vl::GLSLShader::mHandle
protected

◆ mPath

String vl::GLSLShader::mPath
protected

Definition at line 109 of file GLSL.hpp.

Referenced by reload(), and setSource().

◆ mSource

std::string vl::GLSLShader::mSource
protected

Definition at line 108 of file GLSL.hpp.

Referenced by compile(), and setSource().

◆ mType

EShaderType vl::GLSLShader::mType
protected

Definition at line 107 of file GLSL.hpp.

Referenced by createShader(), and GLSLShader().


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