#include <cgbinding.h>
Public Methods | |
CgBinding (void) | |
Constructor for CgBinding interface. | |
~CgBinding (void) | |
Destructor for the CgBinding class. | |
virtual bool | ValidateVertexBindingType (VertexBindingType type)=0 |
virtual void * | GetVertexBindingType (VertexBindingType type, void *context1, void *context2)=0 |
virtual bool | ValidatePixelBindingType (VertexBindingType type)=0 |
virtual void * | GetPixelBindingType (PixelBindingType type, void *context1, void *context2)=0 |
VertexBindingType | AsciiToVertexBindingType (const char *bind_name) |
Convert ascii string into VertexBindingType. | |
PixelBindingType | AsciiToPixelBindingType (const char *bind_name) |
Convert ascii string into PixelBindingType. | |
CgVertexShader * | CreateVertexShader (const char *program, VertexBindingFormat type, unsigned int device) |
Create a vertex shader program by compiling a Cg source file. | |
CgPixelShader * | CreatePixelShader (const char *program, unsigned int device) |
Create a pixel shader program by compiling a Cg source file. | |
bool | ReleaseVertexShader (CgVertexShader *shader) |
Release a previously loaded VertexShader program. | |
bool | ReleasePixelShader (CgPixelShader *shader) |
Release a previously loaded VertexShader program. | |
void * | GetVertexAttributes (VertexBindingFormat type) |
Converts the enumerated vertex type into a valid vertex attributes pointer. | |
const char * | GetLastListing (void) const |
const char * | GetLastError (void) const |
The application needs to only provide two services to run vertex shader programs. First it must be able to validate whether or not it knows how to manage a particular VertexBindingType and be able to provide real-time data for those binding types it says it can support. The same thing is true to bind pixel shader programs as well.
|
Constructor for CgBinding interface.
Simply initializes member variables to their default state.
|
|
Destructor for the CgBinding class.
Free's up all previously allocated shader programs.
|
|
Convert ascii string into PixelBindingType.
This method is the key routine that allows for the ability to run-time dynamically bind a Cg program to your application. Because Cg is a general purpose programming language you can name your variables anything you want. However, each one of these variables must be bound to your application so they can be updated int real-time. Therefore each variable must be mapped to a specific application operation. If you create new variable name that must be bound to your application you should add it to the VertexBindingType enumeration and provide the ASCII mapping for it here. First make sure it doesn't map to an existing type, and if it does simply make it an alias. Realize that every single PixelBindingType is going to require application code on your part to provide that service. The only reason that PixelBindings and VertexBindings are seperated out is because they are such distinctly different operations I felt it would create less confusion than if they were all mixed up into a single enumeration.
|
|
Convert ascii string into VertexBindingType.
This method is the key routine that allows for the ability to run-time dynamically bind a Cg program to your application. Because Cg is a general purpose programming language you can name your variables anything you want. However, each one of these variables must be bound to your application so they can be updated int real-time. Therefore each variable must be mapped to a specific application operation. If you create new variable name that must be bound to your application you should add it to the VertexBindingType enumeration and provide the ASCII mapping for it here. First make sure it doesn't map to an existing type, and if it does simply make it an alias. Realize that every single VertexBindingType is going to require application code on your part to provide that service.
|
|
Create a pixel shader program by compiling a Cg source file.
This method creates a pixel shader on the current device by loading the Cg source code specified. If there are any errors it will return a null pointer and you can find out why it failed by calling the method GetLastError. You can get the Cg compiler listing output by calling GetLastListing
|
|
Create a vertex shader program by compiling a Cg source file.
This method creates a vertex shader on the current device by loading the Cg source code specified. The Cg source file will be compiled and bound to the vertex format specified by the application. If there are any errors it will return a null pointer and you can find out why it failed by calling the method GetLastError. You can get the Cg compiler listing output by calling GetLastListing
|
|
|
|
|
|
|
|
Converts the enumerated vertex type into a valid vertex attributes pointer.
Again, this is just a convenience method so that all of our supported vertex formats can reside in one centralized piece of code. This routine accepts the enumerated vertex format type and converts it into a proper vertex definition pointer to be passed down into the Cg program loader routine.
|
|
|
|
Release a previously loaded VertexShader program.
|
|
Release a previously loaded VertexShader program.
|
|
|
|
|