G3D::ObjectShader Class Reference#include <Shader.h>
Inherits G3D::ReferenceCountedObject.
List of all members.
Detailed Description
- Deprecated:
- Use G3D::Shader instead, which provides a superset of functionality.
An ObjectShader is run once per primitive group. A primitive group is defined by either the pair of calls RenderDevice::beginPrimitive...RenderDevice::endPrimitive or the single call RenderDevice::sendIndices.
To create an ObjectShader, subclass it and override the ObjectShader::run method to set up the RenderDevice state as you wish. Commonly, the ObjectShader is used to compute certain world-space constants (e.g. lighting), set the VertexAndPixelShader and
Do not make a public constructor for your subclass. Instead, write static "create" method that calls a private constructor and then returns an ObjectShaderRef (or your own subclass).
Example:
typedef ReferenceCountedPointer<class BumpShader> BumpShaderRef;
class BumpShader : ObjectShader {
private:
VertexAndPixelShaderRef vps;
VertexAndPixelShader::ArgList args;
Vector3 lightVector;
BumpShader() {
vps = VertexAndPixelShader::fromFiles("bump_vertex.glsl", "bump_pixel.glsl");
}
public:
void setBumpMap(TextureRef b) {
args.set("bumpMap", b);
}
void setLight(const Vector3& L) {
lightVector = L;
}
static BumpShaderRef create() {
return new BumpShader();
}
void run(RenderDevice* rd) {
args.set("osLightDirection",
rd->objectToWorldMatrix().vectorToObjectSpace(lightVector));
rd->setVertexAndPixelShader(vps, args);
}
};
Constructor & Destructor Documentation
| G3D::ObjectShader::ObjectShader |
( |
|
) |
[inline, protected] |
|
Member Function Documentation
| const std::string& G3D::ObjectShader::messages |
( |
|
) |
const [inline] |
|
| bool G3D::ObjectShader::ok |
( |
|
) |
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. |
| virtual void G3D::ObjectShader::run |
( |
class RenderDevice * |
renderDevice |
) |
[pure virtual] |
|
|
|
Invoked by RenderDevice immediately before a primitive group. Use this to set state on the render device. Do not call pushState from inside this method. |
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. |
The documentation for this class was generated from the following file:
Generated on Mon Jul 17 11:50:48 2006 for G3D by
1.4.5
Hosted by
|