|
Files
Class List
Class Members
Class Hierarchy
|
|
cyCgBaseProgram Class Reference#include <cyCg.h>
List of all members.
Detailed Description
Base class for Cg programs classes.
For basic shaders with few uniform parameters, you can use this class directly. If your shader has a lot of uniform parameters, you may want to derive a class from this class, and use OnCreate and OnBind events to initialize the custom parameters. See cyCodeBase solutions section for an example.
|
Protected variables |
|
CGprogram | program |
| | the CGprogram
|
|
CGparameter * | params |
| | registered parameters
|
|
int | numParam |
| | number of registered parameters
|
|
int | progType |
| | program type (0 = no program defined, CG_GL_VERTEX, or CG_GL_FRAGMENT)
|
Public Member Functions |
|
| void | CreateFromFile (int type, const char *program_file, const char *entry, const char *args=NULL) |
| | This method creates the program from a file.
|
|
void | Destroy () |
| | Destroys created program and deletes registered parameters.
|
|
CGbool | IsCreated () |
| | Returns true if the program is created and not destroyed.
|
|
void | Bind () |
| | Call this function to bind the Cg program. When Cg is enabled, the binded program will execute.
|
|
CGprogram | GetCgProgram () |
| | Returns the CGprogram.
|
|
int | GetProgType () |
| | returns program type (0 = no program defined, CG_GL_VERTEX, or CG_GL_FRAGMENT)
|
|
| void | SetNamedParameter1f (char *name, float x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter2f (char *name, float x, float y) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter3f (char *name, float x, float y, float z) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter4f (char *name, float x, float y, float z, float w) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter1fv (char *name, const float *x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter2fv (char *name, const float *x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter3fv (char *name, const float *x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter4fv (char *name, const float *x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter1d (char *name, double x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter2d (char *name, double x, double y) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter3d (char *name, double x, double y, double z) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter4d (char *name, double x, double y, double z, double w) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter1dv (char *name, const double *x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter2dv (char *name, const double *x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter3dv (char *name, const double *x) |
| | Assign value to the uniform parameter with the given name.
|
| void | SetNamedParameter4dv (char *name, const double *x) |
| | Assign value to the uniform parameter with the given name.
|
|
CGparameter | GetNamedParam (char *name) |
| | Returns the parameter with the given name.
|
|
| void | RegisterParameters (int num, char *names) |
| | Use this function to register the parameters that will be updated frequently.
|
|
void | DeleteRegisteredParams () |
| | Deletes the registered parameters.
|
|
int | GetNumRegisteredParameters () |
| | Returns the number of registered parameters.
|
| void | SetRegisteredParameter1f (unsigned int id, float x) |
| | Assigns value to the uniform parameter specified by id.
|
| void | SetRegisteredParameter2f (unsigned int id, float x, float y) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter3f (unsigned int id, float x, float y, float z) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter4f (unsigned int id, float x, float y, float z, float w) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter1fv (unsigned int id, const float *x) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter2fv (unsigned int id, const float *x) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter3fv (unsigned int id, const float *x) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter4fv (unsigned int id, const float *x) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter1d (unsigned int id, double x) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter2d (unsigned int id, double x, double y) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter3d (unsigned int id, double x, double y, double z) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter4d (unsigned int id, double x, double y, double z, double w) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter1dv (unsigned int id, const double *x) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter2dv (unsigned int id, const double *x) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter3dv (unsigned int id, const double *x) |
| | Use this function to register the parameters that will be updated frequently.
|
| void | SetRegisteredParameter4dv (unsigned int id, const double *x) |
| | Use this function to register the parameters that will be updated frequently.
|
Protected Member Functions |
|
| virtual void | OnCreate () |
| | This method is called when the program is created.
|
| virtual void | OnBind () |
| | This method is called whenever the program is binded.
|
Member Function Documentation
| void CreateFromFile |
( |
int |
type, |
|
|
const char * |
program_file, |
|
|
const char * |
entry, |
|
|
const char * |
args = NULL |
|
) |
[inline] |
|
|
|
This method creates the program from a file.
The argument type can be CG_GL_VERTEX or CG_GL_FRAGMENT, and it determines if this program is a vertex program or a fragment program. The argument program_file is the file name of the Cg shader, and the argument entry is the name of the shader program. If you would like to use compiler options, you can send a string using args argument, such that each option must be separated by '|' symbol. For example, the args string "-DLIMIT=0.02|-v" defines the macro LIMIT which is equal to 0.02 and -v option prints the computer's version to stdout. |
| virtual void OnBind |
( |
|
) |
[inline, protected, virtual] |
|
|
|
This method is called whenever the program is binded.
Overload this method to setup the program each time before you use it. See cyCodeBase solutions for an example. |
| virtual void OnCreate |
( |
|
) |
[inline, protected, virtual] |
|
|
|
This method is called when the program is created.
Overload this method to register custom parameters after creating the program. See cyCodeBase solutions for an example. |
| void RegisterParameters |
( |
int |
num, |
|
|
char * |
names |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetNamedParameter1d |
( |
char * |
name, |
|
|
double |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter1dv |
( |
char * |
name, |
|
|
const double * |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter1f |
( |
char * |
name, |
|
|
float |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter1fv |
( |
char * |
name, |
|
|
const float * |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter2d |
( |
char * |
name, |
|
|
double |
x, |
|
|
double |
y |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter2dv |
( |
char * |
name, |
|
|
const double * |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter2f |
( |
char * |
name, |
|
|
float |
x, |
|
|
float |
y |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter2fv |
( |
char * |
name, |
|
|
const float * |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter3d |
( |
char * |
name, |
|
|
double |
x, |
|
|
double |
y, |
|
|
double |
z |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter3dv |
( |
char * |
name, |
|
|
const double * |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter3f |
( |
char * |
name, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
z |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter3fv |
( |
char * |
name, |
|
|
const float * |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter4d |
( |
char * |
name, |
|
|
double |
x, |
|
|
double |
y, |
|
|
double |
z, |
|
|
double |
w |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter4dv |
( |
char * |
name, |
|
|
const double * |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter4f |
( |
char * |
name, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
z, |
|
|
float |
w |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetNamedParameter4fv |
( |
char * |
name, |
|
|
const float * |
x |
|
) |
[inline] |
|
|
|
Assign value to the uniform parameter with the given name.
These functions can be slow. If you need to change the parameter frequently, first register the parameter using RegisterParameters, and then use SetRegisteredParameter methods. |
| void SetRegisteredParameter1d |
( |
unsigned int |
id, |
|
|
double |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter1dv |
( |
unsigned int |
id, |
|
|
const double * |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter1f |
( |
unsigned int |
id, |
|
|
float |
x |
|
) |
[inline] |
|
|
|
Assigns value to the uniform parameter specified by id.
The parameter should be registered first using RegisterParameters method. The argument id should be smaller than the number of registered parameters. |
| void SetRegisteredParameter1fv |
( |
unsigned int |
id, |
|
|
const float * |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter2d |
( |
unsigned int |
id, |
|
|
double |
x, |
|
|
double |
y |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter2dv |
( |
unsigned int |
id, |
|
|
const double * |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter2f |
( |
unsigned int |
id, |
|
|
float |
x, |
|
|
float |
y |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter2fv |
( |
unsigned int |
id, |
|
|
const float * |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter3d |
( |
unsigned int |
id, |
|
|
double |
x, |
|
|
double |
y, |
|
|
double |
z |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter3dv |
( |
unsigned int |
id, |
|
|
const double * |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter3f |
( |
unsigned int |
id, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
z |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter3fv |
( |
unsigned int |
id, |
|
|
const float * |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter4d |
( |
unsigned int |
id, |
|
|
double |
x, |
|
|
double |
y, |
|
|
double |
z, |
|
|
double |
w |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter4dv |
( |
unsigned int |
id, |
|
|
const double * |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter4f |
( |
unsigned int |
id, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
z, |
|
|
float |
w |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
| void SetRegisteredParameter4fv |
( |
unsigned int |
id, |
|
|
const float * |
x |
|
) |
[inline] |
|
|
|
Use this function to register the parameters that will be updated frequently.
If you will not update the parameters frequently, you may use SetNamedParameter methods. Usage: RegisterParameters( 3, "scale|zoom|matrix" ); or RegisterParameters( 3, "scale zoom matrix" ); This overwrites previous registered parameters (if any). |
|