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>

Public Member Functions

 RE_ShaderHandle (const char *program_file, bool register_shader=true, const char *defines=NULL)
 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=NULL)
 
 RE_ShaderHandle (const RE_ShaderHandle &handle)
 
 ~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)
 
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...
 

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 = NULL 
)

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 = NULL 
)

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)
RE_ShaderHandle::~RE_ShaderHandle ( )

Member Function Documentation

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

Add more defines to the defines list.

Definition at line 107 of file RE_ShaderHandle.h.

bool RE_ShaderHandle::compile ( RE_Render r)

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.

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 132 of file RE_ShaderHandle.h.

const char* RE_ShaderHandle::getDefines ( ) const
inline

Definition at line 149 of file RE_ShaderHandle.h.

const char* RE_ShaderHandle::getErrors ( ) const
inline

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

Definition at line 143 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 NULL if the shader did not compile.

Definition at line 136 of file RE_ShaderHandle.h.

const char* RE_ShaderHandle::getSourceFiles ( ) const
inline

Definition at line 148 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 158 of file RE_ShaderHandle.h.

bool RE_ShaderHandle::isInitialized ( ) const
inline

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

Definition at line 115 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 119 of file RE_ShaderHandle.h.

RE_Shader* RE_ShaderHandle::operator-> ( void  )
inline

Definition at line 97 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 104 of file RE_ShaderHandle.h.

void RE_ShaderHandle::setShaderLanguage ( RE_ShaderLanguage  lang)

Default language is GLSL.


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