Support Forum       Library Source       SourceForge Page       G3D Web Page     
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

G3D::VertexAndPixelShader::GPUShader Class Reference

List of all members.

Public Member Functions

 ~GPUShader ()
 Deletes the underlying glShaderObject.
const std::stringcode () 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::stringmessages () const
 Why compilation failed, or any compiler warnings if it succeeded.
bool ok () const
 Returns true if compilation and loading succeeded.
const std::stringshaderType () 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 GPUShaderinit (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

Constructor & Destructor Documentation

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.


Member Function Documentation

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 
)
Parameters:
samplerMappingsTable 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.

Parameters:
defineStringNew #defines to insert at the top of the program
codemodified in place
secondPassOn the scond pass, the samplerMappings must not be empty.
Returns:
True if there was one replacement, false otherwise
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.


Member Data Documentation

Referenced by code().

Set to true when name and code both == "".

Referenced by fixedFunction().

Referenced by glShaderObject().

Referenced by glShaderType().

Referenced by messages().

Referenced by ok().

Referenced by shaderType().

Filename if loaded from disk.

argument for output on subclasses

Referenced by usesG3DIndex().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

documentation generated on Mon Nov 14 2011 10:39:23 using doxygen 1.7.2