HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_ShaderHandle Class Reference

Simple interface to building a shader from a .prog file. More...

#include <RE_ShaderHandle.h>

+ Inheritance diagram for RE_ShaderHandle:

Public Member Functions

 RE_ShaderHandle (const char *program_file, bool register_shader=true, const char *defines=nullptr, RE_ShaderLanguage lang=RE_SHADER_LANGUAGE_GLSL)
 Create a shader handle using a .prog file. More...
 
 RE_ShaderHandle (const char *program_name, int code_version, const char *files, bool register_shader=true, const char *defines=nullptr, RE_ShaderLanguage lang=RE_SHADER_LANGUAGE_GLSL)
 
 RE_ShaderHandle (const RE_ShaderHandle &handle)
 
virtual ~RE_ShaderHandle ()
 
RE_Shaderoperator-> ()
 
void setProgramDefines (const char *defines)
 Set the defines for the program, overwriting existing ones. More...
 
void appendProgramDefines (const char *defines)
 Add more defines to the defines list. More...
 
void setShaderLanguage (RE_ShaderLanguage lang)
 Default language is GLSL. More...
 
bool isInitialized () const
 
bool isValid (RE_Render *r)
 
bool compile (RE_Render *r, UT_WorkBuffer *msg=nullptr)
 
int getCodeVersion () const
 Returns the GLSL or Cg version that the shader was compiled with. More...
 
RE_ShadergetShader () const
 
void printErrors (std::ostream &os) const
 Prints this shader's errors, warnings and messages. More...
 
const char * getErrors () const
 
const char * getName () const
 Name of the shader (if any) or the .prog pathname. More...
 
const char * getSourceFiles () const
 
const char * getDefines () const
 
UT_UniquePtr< RE_ShadercreateDetachedShader (RE_Render *r, UT_String *errors=nullptr) const
 

Static Public Member Functions

static const char * getSystemDefines (RE_Render *r)
 Returns a list of #defines for platform, vendor, driver version. More...
 

Protected Member Functions

virtual UT_UniquePtr< RE_ShadercompileImpl (RE_Render *r, UT_String *errors) const
 

Static Protected Member Functions

static void initializeDriverInformation (RE_Render *r)
 

Protected Attributes

UT_String myName
 
RE_ShaderLanguage myShaderLanguage
 
int myCodeVersion
 
UT_String mySourceFiles
 
UT_String myDefines
 
UT_UniquePtr< RE_ShadermyShader
 
bool myInitFlag
 
UT_String myErrors
 
UT_Lock myLock
 
bool myRegisterFlag
 

Static Protected Attributes

static UT_String theVendorDefines
 

Detailed Description

Simple interface to building a shader from a .prog file.

Examples:
tetprim/GR_PrimTetra.C.

Definition at line 77 of file RE_ShaderHandle.h.

Constructor & Destructor Documentation

RE_ShaderHandle::RE_ShaderHandle ( const char *  program_file,
bool  register_shader = true,
const char *  defines = nullptr,
RE_ShaderLanguage  lang = RE_SHADER_LANGUAGE_GLSL 
)

Create a shader handle using a .prog file.

RE_ShaderHandle::RE_ShaderHandle ( const char *  program_name,
int  code_version,
const char *  files,
bool  register_shader = true,
const char *  defines = nullptr,
RE_ShaderLanguage  lang = RE_SHADER_LANGUAGE_GLSL 
)

Create a shader handle with source files. All source files must share the same GLSL version (100,110,120,130,140,150,330,400,410...) and be whitespace separated in the string.

RE_ShaderHandle::RE_ShaderHandle ( const RE_ShaderHandle handle)
virtual RE_ShaderHandle::~RE_ShaderHandle ( )
virtual

Member Function Documentation

void RE_ShaderHandle::appendProgramDefines ( const char *  defines)
inline

Add more defines to the defines list.

Definition at line 109 of file RE_ShaderHandle.h.

bool RE_ShaderHandle::compile ( RE_Render r,
UT_WorkBuffer msg = nullptr 
)

Explicitly compile the shader. Has no effect if the shader is already compiled. Returns true if the shader compiled successfully or was already compiled, or false if the compile failed or previously failed.

virtual UT_UniquePtr<RE_Shader> RE_ShaderHandle::compileImpl ( RE_Render r,
UT_String errors 
) const
protectedvirtual
UT_UniquePtr<RE_Shader> RE_ShaderHandle::createDetachedShader ( RE_Render r,
UT_String errors = nullptr 
) const

Create a shader that is owner by the caller If the shader failed to compile, then an empty pointer is returned.

int RE_ShaderHandle::getCodeVersion ( ) const
inline

Returns the GLSL or Cg version that the shader was compiled with.

Definition at line 134 of file RE_ShaderHandle.h.

const char* RE_ShaderHandle::getDefines ( ) const
inline

Definition at line 151 of file RE_ShaderHandle.h.

const char* RE_ShaderHandle::getErrors ( ) const
inline

Returns a NUL-terminated string of errors. Empty string if no errors exist, or if the shader has not been compiled yet.

Definition at line 145 of file RE_ShaderHandle.h.

const char* RE_ShaderHandle::getName ( ) const

Name of the shader (if any) or the .prog pathname.

RE_Shader* RE_ShaderHandle::getShader ( ) const
inline

Returns the shader for this handle. Will return nullptr if the shader did not compile.

Definition at line 138 of file RE_ShaderHandle.h.

const char* RE_ShaderHandle::getSourceFiles ( ) const
inline

Definition at line 150 of file RE_ShaderHandle.h.

static const char* RE_ShaderHandle::getSystemDefines ( RE_Render r)
inlinestatic

Returns a list of #defines for platform, vendor, driver version.

Definition at line 160 of file RE_ShaderHandle.h.

static void RE_ShaderHandle::initializeDriverInformation ( RE_Render r)
staticprotected
bool RE_ShaderHandle::isInitialized ( ) const
inline

Returns true if the shader was initialized. The shader still may be invalid (compiled improperly).

Definition at line 117 of file RE_ShaderHandle.h.

bool RE_ShaderHandle::isValid ( RE_Render r)
inline

Returns true if the shader successfully compiled. This may force a compile.

Definition at line 121 of file RE_ShaderHandle.h.

RE_Shader* RE_ShaderHandle::operator-> ( )
inline

Definition at line 99 of file RE_ShaderHandle.h.

void RE_ShaderHandle::printErrors ( std::ostream &  os) const

Prints this shader's errors, warnings and messages.

void RE_ShaderHandle::setProgramDefines ( const char *  defines)
inline

Set the defines for the program, overwriting existing ones.

Definition at line 106 of file RE_ShaderHandle.h.

void RE_ShaderHandle::setShaderLanguage ( RE_ShaderLanguage  lang)

Default language is GLSL.

Member Data Documentation

int RE_ShaderHandle::myCodeVersion
protected

Definition at line 175 of file RE_ShaderHandle.h.

UT_String RE_ShaderHandle::myDefines
protected

Definition at line 177 of file RE_ShaderHandle.h.

UT_String RE_ShaderHandle::myErrors
protected

Definition at line 181 of file RE_ShaderHandle.h.

bool RE_ShaderHandle::myInitFlag
protected

Definition at line 180 of file RE_ShaderHandle.h.

UT_Lock RE_ShaderHandle::myLock
mutableprotected

Definition at line 182 of file RE_ShaderHandle.h.

UT_String RE_ShaderHandle::myName
protected

Definition at line 173 of file RE_ShaderHandle.h.

bool RE_ShaderHandle::myRegisterFlag
protected

Definition at line 183 of file RE_ShaderHandle.h.

UT_UniquePtr<RE_Shader> RE_ShaderHandle::myShader
protected

Definition at line 179 of file RE_ShaderHandle.h.

RE_ShaderLanguage RE_ShaderHandle::myShaderLanguage
protected

Definition at line 174 of file RE_ShaderHandle.h.

UT_String RE_ShaderHandle::mySourceFiles
protected

Definition at line 176 of file RE_ShaderHandle.h.

UT_String RE_ShaderHandle::theVendorDefines
staticprotected

Definition at line 184 of file RE_ShaderHandle.h.


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