DI-Guy SDK Documentation  13.5
diguyGraphicsMaterial Class Reference

A class that represents a shared material. More...

#include <diguyGraphicsMaterial.h>

Inheritance diagram for diguyGraphicsMaterial:
diguyDx11GraphicsMaterial diguyDx9GraphicsMaterial diguyOglGraphicsMaterial diguyOsgGraphicsMaterial

Public Member Functions

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 void build ()
 This function will be called by DI-Guy when it is time for a renderer-specific material object to be created. More...
 
virtual void unbuild ()
 This function will be called by DI-Guy when it is time for a renderer-specific material object to be destroyed. More...
 
virtual void bind_now ()
 This function will be called by DI-Guy when the material should be made active, or bound. More...
 

Accessor Functions

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

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

const char * get_name ()
 Returns the name of the texture. More...
 
void get_ambient (float *rgba) const
 This function returns the red, green, blue, and alpha components of the material's ambient setting. More...
 
void get_diffuse (float *rgba) const
 This function returns the red, green, blue, and alpha components of the material's diffuse setting. More...
 
void get_specular (float *rgba) const
 This function returns the red, green, blue, and alpha components of the material's specular setting. More...
 
void get_emission (float *rgba) const
 This function returns the red, green, blue, and alpha components of the material's emission setting. More...
 
void get_shininess (float *s) const
 This function returns the material's shininess setting. More...
 
int get_contains_alpha_component ()
 This function returns whether the material contains an alpha component. More...
 
static diguyGraphicsMaterialget_last_bound_material ()
 This function returns the last material that was bound. More...
 
static void clear_last_bound_material ()
 This function clears out the last bound material pointer. More...
 

Private Functions

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

No external access to them is expected or necessary.

bdiGeometryMtlm_scripted_object
 A pointer to internal data. More...
 
class bdiGeometryMtl
 
class bdiGeometryFactory
 
bdiGeometryMtlget_scripted_object ()
 
 diguyGraphicsMaterial (void *internal_data)
 A protected constructor. More...
 
virtual ~diguyGraphicsMaterial ()
 A protected destructor. More...
 

Detailed Description

A class that represents a shared material.

Can be subclassed by filling out the diguy_graphics_set_material_create_func(). Note this isn't needed in a modern renderer that will just copy the information into a uniform buffer, just implement diguyUniformBufferUpdater:set_material()

Constructor & Destructor Documentation

diguyGraphicsMaterial::diguyGraphicsMaterial ( void *  internal_data)
protected

A protected constructor.

Constructors are called automatically by DI-Guy.

virtual diguyGraphicsMaterial::~diguyGraphicsMaterial ( )
protectedvirtual

A protected destructor.

Destructors are called automatically by DI-Guy.

Member Function Documentation

const char* diguyGraphicsMaterial::get_name ( )

Returns the name of the texture.

This pointer will never be NULL.

Returns:

name of the texture

Callable From:

  • C++
  • Script
void diguyGraphicsMaterial::get_ambient ( float *  rgba) const

This function returns the red, green, blue, and alpha components of the material's ambient setting.

All returned values will be between 0 (least intensity) and 1 (highest intensity).

Parameters
rgbapointer to an array of four floats into which results should be copied

Callable From:

  • C++
void diguyGraphicsMaterial::get_diffuse ( float *  rgba) const

This function returns the red, green, blue, and alpha components of the material's diffuse setting.

All returned values will be between 0 (least intensity) and 1 (highest intensity).

Parameters
rgbapointer to an array of four floats into which results should be copied

Callable From:

  • C++
void diguyGraphicsMaterial::get_specular ( float *  rgba) const

This function returns the red, green, blue, and alpha components of the material's specular setting.

All returned values will be between 0 (least intensity) and 1 (highest intensity).

Parameters
rgbapointer to an array of four floats into which results should be copied

Callable From:

  • C++
void diguyGraphicsMaterial::get_emission ( float *  rgba) const

This function returns the red, green, blue, and alpha components of the material's emission setting.

All returned values will be between 0 (least intensity) and 1 (highest intensity).

Parameters
rgbapointer to an array of four floats into which results should be copied

Callable From:

  • C++
void diguyGraphicsMaterial::get_shininess ( float *  s) const

This function returns the material's shininess setting.

Parameters
spointer to float into which result should be copied

Callable From:

  • C++
int diguyGraphicsMaterial::get_contains_alpha_component ( )

This function returns whether the material contains an alpha component.

Materials that have an alpha component can make objects semi-transparent, which can affect when said objects should be drawn.

Returns:

1 if texture contains an alpha component, 0 if not; -1 on failure

Callable From:

  • C++
  • Script
static diguyGraphicsMaterial* diguyGraphicsMaterial::get_last_bound_material ( )
static

This function returns the last material that was bound.

In bind_now() the current material can be checked against the last bound material; if the values are the same the bind_now() function can most often immediately return. This is desirable because rendering state changes can have significant performance overhead.

Callable From:

  • C++
  • Script
static void diguyGraphicsMaterial::clear_last_bound_material ( )
static

This function clears out the last bound material pointer.

diguyScenario::draw() calls it automatically, but it's recommended that this function also be called when the drawing of a new character is beginning. This can be done in diguyGraphicsLink::begin_character_draw().

Callable From:

  • C++
  • Script
virtual void diguyGraphicsMaterial::build ( )
virtual

This function will be called by DI-Guy when it is time for a renderer-specific material object to be created.

At that point all material information has been read and is available via the Accessor Functions above.

Immediate Mode:

Immediate mode renderers may override this function, to create an object that may be invoked by bind_now() to set material attributes.

Scene Graph:

Scene graph renderers usually do override this function, to create a material object that will be associated with diguyGraphicsMesh objects.

Callable From:

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

Reimplemented in diguyOglGraphicsMaterial, diguyOsgGraphicsMaterial, diguyDx9GraphicsMaterial, and diguyDx11GraphicsMaterial.

virtual void diguyGraphicsMaterial::unbuild ( )
virtual

This function will be called by DI-Guy when it is time for a renderer-specific material object to be destroyed.

Immediate Mode:

Immediate mode renderers may override this function, to destroy any object that may have been created by build().

Scene Graph:

Scene graph renderers usually do override this function, to destroy any object that may have been created by build().

Callable From:

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

Reimplemented in diguyOglGraphicsMaterial, diguyOsgGraphicsMaterial, diguyDx9GraphicsMaterial, and diguyDx11GraphicsMaterial.

virtual void diguyGraphicsMaterial::bind_now ( )
virtual

This function will be called by DI-Guy when the material should be made active, or bound.

Note that this material should be checked against the material returned by get_last_bound_material(). If they're the same this function should return early.

Immediate Mode:

Immediate mode renderers usually do override this function, to invoke the object created by build(), or make calls to the renderer to set appropriate material state.

Scene Graph:

Scene graph renderers usually do not override this function.

Callable From:

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

Reimplemented in diguyOglGraphicsMaterial, diguyDx9GraphicsMaterial, and diguyDx11GraphicsMaterial.

bdiGeometryMtl* diguyGraphicsMaterial::get_scripted_object ( )
inline

Friends And Related Function Documentation

friend class bdiGeometryMtl
friend
friend class bdiGeometryFactory
friend

Member Data Documentation

bdiGeometryMtl* diguyGraphicsMaterial::m_scripted_object
private

A pointer to internal data.


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