DI-Guy Graphics API, diguyOglGraphicsShaderInstance

diguyOglGraphicsShaderInstance.cpp

DI-Guy API Version 12.5.1

This file was automatically generated from diguyOglGraphicsShaderInstance.cpp. Do not edit this file directly; the changes will be lost.
Introduction
Unlike shader programs, which are shared by many characters, shader instances allow non-shared, character-specific shader state to be maintained. An example is having different uniform variable values for different characters, such as a highlight color that is applied during shading.

See diguyOglGraphicsShaderProgram for information on shader programs.

The class diguyOglGraphicsShaderInstance is an example of a diguyGraphicsShaderInstance subclass for an immediate mode renderer using the DI-Guy Loader. The example subclass shows how to use the accessors of the diguyGraphicsShaderInstance class and which virtual functions should be overridden for an immediate mode renderer such as OpenGL.

Header files and forward declarations
#include <stdlib.h>
#include <stdio.h>

#include "diguyOglGraphicsShaderInstance.h"
#include "diguyOglGraphicsShaderProgram.h"
#include "diguyOglGraphicsShaderTechnique.h"

#include <libbdilog.h>
Constructor
Description:

Initialize data members of the class to a known state.

Most base class data will not be fully initialized until during the Build Stage, so most base class accessors should not be called here.

diguyOglGraphicsShaderInstance::diguyOglGraphicsShaderInstance(void* internal_data)
    :
    diguyGraphicsShaderInstance(internal_data)
{
    /*
     *  Get a pointer to the shader program this instance is associated with.
     *   The shader program will exist before this shader instance is
     *   created, so it is safe to call the get_shader_technique() accessor
     *   here in the constructor.
     */
    m_shader_technique = dynamic_cast<diguyOglGraphicsShaderTechnique*>(get_shader_technique());
    if (!m_shader_technique)
        return;

    /*
     *  Test code for diguyGraphicsShaderInstance variable functions.
     */
    //int num_variables = get_num_variables();
    //int i;
    //for (i=0; i<num_variables; i++)
    //{
    //	const char* variable_name = get_variable_name_at_index(i);
    //	const char* variable_type = get_variable_type(variable_name);
    //
    //	bdi_log_printf(BDI_LOG_WARN,
    //		"Variable %d of shader instance is '%s', with type '%s'.\n",
    //		i,
    //		variable_name,
    //		variable_type);
    //}
}
bind
Draw Stage

Description:

Override of diguyGraphicsShaderInstance::bind().

Before this bind() function is called the bind() function for the shader program this instance uses will have been called. In this example this means that the GLSL program object will be loaded.

The bind() function can set shader state such as instance level uniform values, etc., that will be used in the shader.

Note that link matrix data should not be set here, but rather in the bind_link_matrices() function. The same applies for the link color array and the apply matrices flag.

int
diguyOglGraphicsShaderInstance::bind()
{
    /*
     *  Nothing to be done in this example.  See
     *   diguyOglGraphicsShaderProgram::bind().
     */
    return 0;
}
unbind
Draw Stage

Description:

Override of diguyGraphicsShaderInstance::unbind().

int
diguyOglGraphicsShaderInstance::unbind()
{
    /*
     *  Nothing to be done in this example.  See
     *   diguyOglGraphicsShaderProgram::unbind().
     */
    return 0;
}
Create function definition
Create and return an object of a subclass of diguyGraphicsShaderInstance. This function will be called whenever DI-Guy requires a shader instance object.

diguyGraphicsShaderInstance*
diguyOglGraphicsShaderInstance_create_func(void* internal_data)
{
    return new diguyOglGraphicsShaderInstance(internal_data);
}



Copyright (C) 1992-2012 Boston Dynamics

ALL RIGHTS RESERVED.

These coded instructions, statements, and computer programs contain unpublished proprietary information of Boston Dynamics and are protected by Copyright Laws of the United States. They may not be used, duplicated, or disclosed in any form, in whole or in part, without the prior written consent from Boston Dynamics.

RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the government is subject to restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Sofware clause at DFARS 252.227-7013 and/or in similar or successor clauses in the FAR, or the DOD or NASA FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the Commercial Computer Software--Restricted Rights at 48 CFR 52.227-19, as applicable. Unpublished-rights reserved under the Copyright Laws of the United States.

Contractor/Manufacturer is:

Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.