| Support Forum Library Source SourceForge Page G3D Web Page |
Public Member Functions | |
| ~GPUShader () | |
| Deletes the underlying glShaderObject. | |
| const std::string & | code () const |
| bool | fixedFunction () const |
| GLhandleARB | glShaderObject () const |
| Returns the underlying OpenGL shader object for this shader. | |
| GLenum | glShaderType () const |
| Shader type, e.g. | |
| void | init (const std::string &name, const std::string &code, bool fromFile, bool debug, GLenum glType, const std::string &type, PreprocessorStatus u, const Table< std::string, int > &samplerMappings, bool secondPass) |
| const std::string & | messages () const |
| Why compilation failed, or any compiler warnings if it succeeded. | |
| bool | ok () const |
| Returns true if compilation and loading succeeded. | |
| const std::string & | shaderType () const |
| bool | usesG3DIndex () const |
| True if this shader uses the g3d_Index extension and therefore needs double-compilation to resolve dependencies. | |
Protected Member Functions | |
| void | checkForSupport () |
| Checks to ensure that this profile is supported on this card. | |
| void | compile () |
| Returns true on success. | |
| bool | replaceG3DIndex (std::string &code, std::string &defineString, const Table< std::string, int > &samplerMappings, bool secondPass) |
Replaces all instances of g3d_Index[samplername] with (g3d_Indx_samplername) Called from init. | |
| void | replaceG3DSize (std::string &code, std::string &uniformString) |
Replaces all instances of "g3d_sampler2DSize(<i>name</i>)" with " (g3d_sz2D_<i>name</i>.xy)" and. | |
Static Protected Member Functions | |
| static GPUShader * | init (GPUShader *shader, bool debug) |
| Initialize a shader object and returns object. | |
Protected Attributes | |
| std::string | _code |
| bool | _fixedFunction |
| Set to true when name and code both == "". | |
| GLhandleARB | _glShaderObject |
| GLenum | _glShaderType |
| std::string | _messages |
| std::string | _name |
| bool | _ok |
| std::string | _shaderType |
| std::string | filename |
| Filename if loaded from disk. | |
| bool | fromFile |
| bool | m_usesG3DIndex |
Static Protected Attributes | |
| static std::string | ignore |
| argument for output on subclasses | |
| G3D::VertexAndPixelShader::GPUShader::~GPUShader | ( | ) |
Deletes the underlying glShaderObject.
Between GL's reference counting and G3D's reference counting, an underlying object can never be deleted while in use.
| void G3D::VertexAndPixelShader::GPUShader::checkForSupport | ( | ) | [protected] |
Checks to ensure that this profile is supported on this card.
Called from init().
| const std::string& G3D::VertexAndPixelShader::GPUShader::code | ( | ) | const [inline] |
| void G3D::VertexAndPixelShader::GPUShader::compile | ( | ) | [protected] |
Returns true on success.
Called from init.
| bool G3D::VertexAndPixelShader::GPUShader::fixedFunction | ( | ) | const [inline] |
| GLhandleARB G3D::VertexAndPixelShader::GPUShader::glShaderObject | ( | ) | const [inline] |
Returns the underlying OpenGL shader object for this shader.
| GLenum G3D::VertexAndPixelShader::GPUShader::glShaderType | ( | ) | const [inline] |
Shader type, e.g.
GL_VERTEX_SHADER_ARB
| static GPUShader* G3D::VertexAndPixelShader::GPUShader::init | ( | GPUShader * | shader, |
| bool | debug | ||
| ) | [static, protected] |
Initialize a shader object and returns object.
Called from subclass create methods.
| void G3D::VertexAndPixelShader::GPUShader::init | ( | const std::string & | name, |
| const std::string & | code, | ||
| bool | fromFile, | ||
| bool | debug, | ||
| GLenum | glType, | ||
| const std::string & | type, | ||
| PreprocessorStatus | u, | ||
| const Table< std::string, int > & | samplerMappings, | ||
| bool | secondPass | ||
| ) |
| samplerMappings | Table mapping sampler names to their gl_TexCoord indices. This may be empty if the mappings are not yet known. |
| const std::string& G3D::VertexAndPixelShader::GPUShader::messages | ( | ) | const [inline] |
Why compilation failed, or any compiler warnings if it succeeded.
| bool G3D::VertexAndPixelShader::GPUShader::ok | ( | ) | const [inline] |
Returns true if compilation and loading succeeded.
If they failed, check the message string.
| bool G3D::VertexAndPixelShader::GPUShader::replaceG3DIndex | ( | std::string & | code, |
| std::string & | defineString, | ||
| const Table< std::string, int > & | samplerMappings, | ||
| bool | secondPass | ||
| ) | [protected] |
Replaces all instances of g3d_Index[samplername] with (g3d_Indx_samplername) Called from init.
The first time a file is compiled, samplerMappings is empty. It must then compiled again with correct mappings, which are assigned elsewhere.
| defineString | New #defines to insert at the top of the program |
| code | modified in place |
| secondPass | On the scond pass, the samplerMappings must not be empty. |
| void G3D::VertexAndPixelShader::GPUShader::replaceG3DSize | ( | std::string & | code, |
| std::string & | uniformString | ||
| ) | [protected] |
Replaces all instances of "g3d_sampler2DSize(<i>name</i>)" with " (g3d_sz2D_<i>name</i>.xy)" and.
"g3d_sampler2DInvSize(<i>name</i>)" with " (g3d_sz2D_<i>name</i>.zw)"
Note that both replacements will leave column numbers the same in error messages. The () wrapper ensures that .xy fields are accessible using normal syntax off the result; it is the same as the standard practice of wrapping macros in parentheses.
and adds "<code>uniform vec4 g3d_sz2D_<i>name</i>;</code>" to the uniform string.
Called from init.
| const std::string& G3D::VertexAndPixelShader::GPUShader::shaderType | ( | ) | const [inline] |
| bool G3D::VertexAndPixelShader::GPUShader::usesG3DIndex | ( | ) | const [inline] |
True if this shader uses the g3d_Index extension and therefore needs double-compilation to resolve dependencies.
Referenced by code().
bool G3D::VertexAndPixelShader::GPUShader::_fixedFunction [protected] |
Set to true when name and code both == "".
Referenced by fixedFunction().
Referenced by glShaderObject().
Referenced by glShaderType().
Referenced by messages().
bool G3D::VertexAndPixelShader::GPUShader::_ok [protected] |
Referenced by ok().
Referenced by shaderType().
Filename if loaded from disk.
bool G3D::VertexAndPixelShader::GPUShader::fromFile [protected] |
std::string G3D::VertexAndPixelShader::GPUShader::ignore [static, protected] |
argument for output on subclasses
bool G3D::VertexAndPixelShader::GPUShader::m_usesG3DIndex [protected] |
Referenced by usesG3DIndex().
1.7.2