G3D::VertexAndPixelShader Class ReferenceA compatible vertex and pixel shader.
More...
#include <Shader.h>
Inherits G3D::ReferenceCountedObject.
List of all members.
|
Public Member Functions |
| const UniformDeclaration & | arg (int i) const |
| void | bindArgList (class RenderDevice *rd, const ArgList &args) const |
| GLhandleARB | glProgramObject () const |
| const std::string & | linkErrors () const |
| const std::string & | messages () const |
| int | numArgs () const |
| bool | ok () const |
| const std::string & | pixelErrors () const |
| void | ReferenceCountedObject_zeroWeakPointers () |
| void | validateArgList (const ArgList &args) const |
| const std::string & | vertexErrors () const |
| | ~VertexAndPixelShader () |
Static Public Member Functions |
| static VertexAndPixelShaderRef | fromFiles (const std::string &vertexShader, const std::string &pixelShader, UseG3DUniforms u=DO_NOT_DEFINE_G3D_UNIFORMS, bool debugErrors=true) |
| static VertexAndPixelShaderRef | fromStrings (const std::string &vertexShaderName, const std::string &vertexShader, const std::string &geometryShaderName, const std::string &geometryShader, const std::string &pixelShaderName, const std::string &pixelShader, UseG3DUniforms u=DO_NOT_DEFINE_G3D_UNIFORMS, bool debugErrors=true) |
| static VertexAndPixelShaderRef | fromStrings (const std::string &vertexShader, const std::string &pixelShader, UseG3DUniforms u=DO_NOT_DEFINE_G3D_UNIFORMS, bool debugErrors=true) |
| static bool | fullySupported () |
Public Attributes |
| AtomicInt32 | ReferenceCountedObject_refCount |
| _WeakPtrLinkedList * | ReferenceCountedObject_weakPointer |
Protected Member Functions |
| void | addUniformsFromCode (const std::string &code) |
| void | computeUniformArray () |
| | VertexAndPixelShader (const std::string &vsCode, const std::string &vsFilename, bool vsFromFile, const std::string &psCode, const std::string &psFilename, bool psFromFile, bool debug, UseG3DUniforms u) |
Static Protected Member Functions |
| static GLenum | canonicalType (GLenum e) |
| static bool | isSamplerType (GLenum e) |
Protected Attributes |
| std::string | _fragCompileMessages |
| GLhandleARB | _glProgramObject |
| std::string | _linkMessages |
| std::string | _messages |
| bool | _ok |
| std::string | _vertCompileMessages |
| GPUShader | geometryShader |
| int | lastTextureUnit |
| GPUShader | pixelShader |
| Array< UniformDeclaration > | uniformArray |
| Set< std::string > | uniformNames |
| GPUShader | vertexShader |
Static Protected Attributes |
| static std::string | ignore |
Friends |
| class | Shader |
Classes |
| class | ArgList |
| | Bindings of values to uniform variables for a VertexAndPixelShader. More...
|
| class | ArgumentError |
| | Thrown by validateArgList. More...
|
| class | GPUShader |
| class | UniformDeclaration |
Detailed Description
A compatible vertex and pixel shader.
Used internally by G3D::Shader; see that class for more information.
Only newer graphics cards with recent drivers (e.g. GeForceFX cards with driver version 57 or greater) support this API. Use the VertexAndPixelShader::fullySupported method to determine at run-time if your graphics card is compatible.
For purposes of shading, a "pixel" is technically a "fragment" in OpenGL terminology.
Pixel and vertex shaders are loaded as text strings written in GLSL, the high-level OpenGL shading language.
Typically, the G3D::Shader sets up constants like the object-space position of the light source and the object-to-world matrix. The vertex shader transforms input vertices to homogeneous clip space and computes values that are interpolated across the surface of a triangle (e.g. reflection vector). The pixel shader computes the final color of a pixel (it does not perform alpha-blending, however).
Multiple VertexAndPixelShaders may share object, vertex, and pixel shaders.
Uniform variables that begin with 'gl_' are ignored because they are assumed to be GL built-ins.
- Referenced Code:
- http://oss.sgi.com/projects/ogl-sample/registry/ARB/shader_objects.txt
- Referenced Code:
- http://oss.sgi.com/projects/ogl-sample/registry/ARB/vertex_shader.txt
BETA API This API is subject to change.
Constructor & Destructor Documentation
| G3D::VertexAndPixelShader::VertexAndPixelShader |
( |
const std::string & |
vsCode, |
|
|
const std::string & |
vsFilename, |
|
|
bool |
vsFromFile, |
|
|
const std::string & |
psCode, |
|
|
const std::string & |
psFilename, |
|
|
bool |
psFromFile, |
|
|
bool |
debug, |
|
|
UseG3DUniforms |
u | |
|
) |
| | [protected] |
| G3D::VertexAndPixelShader::~VertexAndPixelShader |
( |
|
) |
|
Member Function Documentation
| void G3D::VertexAndPixelShader::addUniformsFromCode |
( |
const std::string & |
code |
) |
[protected] |
Finds any uniform variables in the code that are not already in the uniform array that OpenGL returned and adds them to that array.
This causes VertexAndPixelShader to surpress warnings about setting variables that have been compiled away--those warnings are annoying when temporarily commenting out code.
| void G3D::VertexAndPixelShader::bindArgList |
( |
class RenderDevice * |
rd, |
|
|
const ArgList & |
args | |
|
) |
| | const |
Makes renderDevice calls to bind this argument list.
Calls validateArgList.
| static GLenum G3D::VertexAndPixelShader::canonicalType |
( |
GLenum |
e |
) |
[static, protected] |
Converts from int and bool types to float types (e.g.
GL_INT_VEC2_ARB -> GL_FLOAT_VEC2_ARB). Other types are left unmodified.
| void G3D::VertexAndPixelShader::computeUniformArray |
( |
|
) |
[protected] |
Computes the uniformArray from the current program object.
Called from the constructor
| static VertexAndPixelShaderRef G3D::VertexAndPixelShader::fromFiles |
( |
const std::string & |
vertexShader, |
|
|
const std::string & |
pixelShader, |
|
|
UseG3DUniforms |
u = DO_NOT_DEFINE_G3D_UNIFORMS, |
|
|
bool |
debugErrors = true | |
|
) |
| | [static] |
To use the fixed function pipeline for part of the shader, pass an empty string.
- Parameters:
-
| debugErrors | If true, a debugging dialog will appear when there are syntax errors in the shaders. If false, failures will occur silently; check VertexAndPixelShader::ok() to see if the files compiled correctly. |
| static VertexAndPixelShaderRef G3D::VertexAndPixelShader::fromStrings |
( |
const std::string & |
vertexShaderName, |
|
|
const std::string & |
vertexShader, |
|
|
const std::string & |
geometryShaderName, |
|
|
const std::string & |
geometryShader, |
|
|
const std::string & |
pixelShaderName, |
|
|
const std::string & |
pixelShader, |
|
|
UseG3DUniforms |
u = DO_NOT_DEFINE_G3D_UNIFORMS, |
|
|
bool |
debugErrors = true | |
|
) |
| | [static] |
To use the default/fixed-function pipeline for part of the shader, pass an empty string.
| static VertexAndPixelShaderRef G3D::VertexAndPixelShader::fromStrings |
( |
const std::string & |
vertexShader, |
|
|
const std::string & |
pixelShader, |
|
|
UseG3DUniforms |
u = DO_NOT_DEFINE_G3D_UNIFORMS, |
|
|
bool |
debugErrors = true | |
|
) |
| | [static] |
| static bool G3D::VertexAndPixelShader::fullySupported |
( |
|
) |
[static] |
| GLhandleARB G3D::VertexAndPixelShader::glProgramObject |
( |
|
) |
const [inline] |
The underlying OpenGL object for the vertex/pixel shader pair.
To bind a shader with RenderDevice, call renderDevice->setShader(s); To bind a shader without RenderDevice, call glUseProgramObjectARB(s->glProgramObject());
| static bool G3D::VertexAndPixelShader::isSamplerType |
( |
GLenum |
e |
) |
[static, protected] |
Returns true for types that are textures (e.g., GL_TEXTURE_2D).
| const std::string& G3D::VertexAndPixelShader::linkErrors |
( |
|
) |
const [inline] |
| const std::string& G3D::VertexAndPixelShader::messages |
( |
|
) |
const [inline] |
All compilation and linking messages, with additional formatting.
For details about a specific part of the process, see vertexErrors, pixelErrors, and linkErrors.
| int G3D::VertexAndPixelShader::numArgs |
( |
|
) |
const [inline] |
| bool G3D::VertexAndPixelShader::ok |
( |
|
) |
const [inline] |
| const std::string& G3D::VertexAndPixelShader::pixelErrors |
( |
|
) |
const [inline] |
| void G3D::ReferenceCountedObject::ReferenceCountedObject_zeroWeakPointers |
( |
|
) |
[inline, inherited] |
Automatically called immediately before the object is deleted.
This is not called from the destructor because it needs to be invoked before the subclass destructor.
| void G3D::VertexAndPixelShader::validateArgList |
( |
const ArgList & |
args |
) |
const |
Checks the actual values of uniform variables against those expected by the program.
If one of the arguments does not match, an ArgumentError exception is thrown.
| const std::string& G3D::VertexAndPixelShader::vertexErrors |
( |
|
) |
const [inline] |
Friends And Related Function Documentation
Member Data Documentation
The long name is to keep this from accidentally conflicting with a subclass's variable name.
Do not use or explicitly manipulate this value--its type may change in the future and is not part of the supported API.
Linked list of all weak pointers that reference this (some may be on the stack!).
Do not use or explicitly manipulate this value.
Does not contain g3d_ uniforms if they were compiled away.
Does not contain g3d_ uniforms if they were compiled away.
The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:48 2007 for G3D by
1.5.2
Hosted by
|