DI-Guy SDK Documentation  13.7
diguyGraphicsShaderInstance Class Reference

A class that represents the unique per-character shader object. More...

#include <diguyGraphicsShaderInstance.h>

Inheritance diagram for diguyGraphicsShaderInstance:
diguyDx11GraphicsShaderInstance diguyDx9GraphicsShaderInstance diguyOglGraphicsShaderInstance diguyOsgGraphicsShaderInstance

Public Member Functions

Accessor Functions

The functions in this section provide access to data in this object.

They are designed to be called by DI-Guy programmers.

diguyGraphicsShaderTechniqueget_shader_technique ()
 This function returns the shader technique this shader instance is associated with. More...
 
diguyCharacterget_character ()
 This function returns a pointer to the character that this shader instance is associated with. More...
 
Virtual Functions

The functions in this section are all virtual functions that will be called by DI-Guy at various times during DI-Guy execution.

Because the functions are all virtual, DI-Guy programmers can create a subclass of this class and override them. Unless otherwise stated, the base class functions do not need to be called.

virtual int bind ()
 This function will be called by DI-Guy when it is time for the object that this shader instance is attached to to be rendered. More...
 
virtual int unbind ()
 This function will be called by DI-Guy when the object this shader is attached to is done being rendered. More...
 
Shader Variables

For GLSL shaders, these variables are represented internally as uniform variables.

DI-Guy reference shaders commonly use the prefix "ufrm_" for their uniform variables.

Instance shader variables are not shared between instances. Variables that should affect all instances of the program this instance is associated with should be set at the shader program level, using equivalent functions in diguyGraphicsShaderProgram.

int get_num_variables ()
 
const char * get_variable_name_at_index (int index)
 
int has_variable (const char *name)
 
const char * get_variable_type (const char *name)
 
void reset_variables_to_initial_values ()
 
void reset_variables_to_program_defaults ()
 
int set_variable_float (const char *name, float value, int set_current=1, int set_initial=0, float blend_time=0.0f)
 
int set_variable_vec2 (const char *name, float x, float y, int set_current=1, int set_initial=0, float blend_time=0.0f)
 
int set_variable_vec3 (const char *name, float x, float y, float z, int set_current=1, int set_initial=0, float blend_time=0.0f)
 
int set_variable_vec4 (const char *name, float x, float y, float z, float w, int set_current=1, int set_initial=0, float blend_time=0.0f)
 
int set_variable_int (const char *name, int value, int set_current=1, int set_initial=0)
 
int get_variable_float (const char *name, float *value, int get_current=1)
 
int get_variable_vec2 (const char *name, float *x, float *y, int get_current=1)
 
int get_variable_vec3 (const char *name, float *x, float *y, float *z, int get_current=1)
 
int get_variable_vec4 (const char *name, float *r, float *g, float *b, float *a, int get_current=1)
 
int get_variable_int (const char *name, int *value, int get_current=1)
 
Deprecated Functions

The following functions are deprecated.

As these functions may disappear in a future version of DI-Guy, it is recommended that you remove calls to these functions from your application.

diguyGraphicsShaderProgramget_shader_program ()
  Deprecated Functions: changed due to API restructuring More...
 

Private Functions

The functions and variables past this point are for internal use only.

No external access to them is expected or necessary.

bdiShaderProgramInstancem_internal_data
 A pointer to internal data. More...
 
class bdiShaderProgramInstance
 
class bdiGeometryFactory
 
bdiShaderProgramInstanceget_internal_data ()
 
 diguyGraphicsShaderInstance (void *internal_data)
 A protected constructor. More...
 
virtual ~diguyGraphicsShaderInstance ()
 A protected destructor. More...
 

Detailed Description

A class that represents the unique per-character shader object.

This class implements shader instances for use with shader programs. Shader programs are shared among all characters that use the shader program. Any variables used in a shader program should therefore apply to all characters using the shader.

Shader instances are not shared. Each character that has a shader program assigned to it will have a private shader instance in which variables specific to the character or its instance can be stored. A common case for this is current values of GLSL shader uniform variables.

Also see diguyGraphicsShaderProgram.

Constructor & Destructor Documentation

diguyGraphicsShaderInstance::diguyGraphicsShaderInstance ( void *  internal_data)
protected

A protected constructor.

Constructors are called automatically by DI-Guy.

virtual diguyGraphicsShaderInstance::~diguyGraphicsShaderInstance ( )
protectedvirtual

A protected destructor.

Destructors are called automatically by DI-Guy.

Member Function Documentation

diguyGraphicsShaderTechnique* diguyGraphicsShaderInstance::get_shader_technique ( )

This function returns the shader technique this shader instance is associated with.

Returns:

pointer to type diguyGraphicsShaderTechnique; should never be NULL

diguyCharacter* diguyGraphicsShaderInstance::get_character ( )

This function returns a pointer to the character that this shader instance is associated with.

Returns:

pointer to type diguyCharacter; may be NULL

virtual int diguyGraphicsShaderInstance::bind ( )
virtual

This function will be called by DI-Guy when it is time for the object that this shader instance is attached to to be rendered.

This happens during the Draw Stage, just before the geometry of a character or scene object is to be rendered.

Any instance level shader control variables should be set in this function. Instance level variables will affect only shader operations in which this instance is active. Variables that should affect the overall program of a shader should be set in diguyGraphicsShaderProgram::bind().

Immediate Mode:

Immediate mode renderers usually do override this function.

Scene Graph:

Scene graph renderers usually do not override this function; the renderer will typically do this internally. If shader variables need to be bound, however, this function should be overridden.

Callable From:

  • N/A (automatically called by DI-Guy Graphics API during the Draw Stage)

Reimplemented in diguyOglGraphicsShaderInstance, diguyDx9GraphicsShaderInstance, and diguyDx11GraphicsShaderInstance.

virtual int diguyGraphicsShaderInstance::unbind ( )
virtual

This function will be called by DI-Guy when the object this shader is attached to is done being rendered.

This happens during the Draw Stage, just after the geometry of a character has been rendered.

Any shader variables bound in bind() should be unbound here.

Immediate Mode:

Immediate mode renderers usually do override this function.

Scene Graph:

Scene graph renderers usually do not override this function; the renderer will typically do this internally. If the bind() function was overridden, however, this function probably should be, too.

Callable From:

  • N/A (automatically called by DI-Guy Graphics API during the Draw Stage)

Reimplemented in diguyOglGraphicsShaderInstance, diguyDx9GraphicsShaderInstance, and diguyDx11GraphicsShaderInstance.

int diguyGraphicsShaderInstance::get_num_variables ( )
const char* diguyGraphicsShaderInstance::get_variable_name_at_index ( int  index)
int diguyGraphicsShaderInstance::has_variable ( const char *  name)
const char* diguyGraphicsShaderInstance::get_variable_type ( const char *  name)
void diguyGraphicsShaderInstance::reset_variables_to_initial_values ( )
void diguyGraphicsShaderInstance::reset_variables_to_program_defaults ( )
int diguyGraphicsShaderInstance::set_variable_float ( const char *  name,
float  value,
int  set_current = 1,
int  set_initial = 0,
float  blend_time = 0.0f 
)
int diguyGraphicsShaderInstance::set_variable_vec2 ( const char *  name,
float  x,
float  y,
int  set_current = 1,
int  set_initial = 0,
float  blend_time = 0.0f 
)
int diguyGraphicsShaderInstance::set_variable_vec3 ( const char *  name,
float  x,
float  y,
float  z,
int  set_current = 1,
int  set_initial = 0,
float  blend_time = 0.0f 
)
int diguyGraphicsShaderInstance::set_variable_vec4 ( const char *  name,
float  x,
float  y,
float  z,
float  w,
int  set_current = 1,
int  set_initial = 0,
float  blend_time = 0.0f 
)
int diguyGraphicsShaderInstance::set_variable_int ( const char *  name,
int  value,
int  set_current = 1,
int  set_initial = 0 
)
int diguyGraphicsShaderInstance::get_variable_float ( const char *  name,
float *  value,
int  get_current = 1 
)
int diguyGraphicsShaderInstance::get_variable_vec2 ( const char *  name,
float *  x,
float *  y,
int  get_current = 1 
)
int diguyGraphicsShaderInstance::get_variable_vec3 ( const char *  name,
float *  x,
float *  y,
float *  z,
int  get_current = 1 
)
int diguyGraphicsShaderInstance::get_variable_vec4 ( const char *  name,
float *  r,
float *  g,
float *  b,
float *  a,
int  get_current = 1 
)
int diguyGraphicsShaderInstance::get_variable_int ( const char *  name,
int *  value,
int  get_current = 1 
)
diguyGraphicsShaderProgram* diguyGraphicsShaderInstance::get_shader_program ( )

Deprecated Functions: changed due to API restructuring

This function returns the shader program this shader instance is associated with.

Returns:

pointer to type diguyGraphicsShaderProgram; should never be NULL

bdiShaderProgramInstance* diguyGraphicsShaderInstance::get_internal_data ( )
inline

Friends And Related Function Documentation

friend class bdiShaderProgramInstance
friend
friend class bdiGeometryFactory
friend

Member Data Documentation

bdiShaderProgramInstance* diguyGraphicsShaderInstance::m_internal_data
private

A pointer to internal data.


The documentation for this class was generated from the following file: