
This file was automatically generated from diguyOglGraphicsMaterial.cpp. Do not edit this file directly; the changes will be lost.
| Introduction |
Materials modify the color and lighting characteristics of meshes. They work in concert with textures to determine the final appearance of visible geometry.
The class diguyOglGraphicsMaterial is an example of a diguyGraphicsMaterial subclass for an immediate mode renderer using the DI-Guy Loader. The example subclass shows how to use the accessors of the diguyGraphicsMaterial class and which virtual functions should be overridden for an immediate mode renderer such as OpenGL.
| Header files and forward declarations |
#include "diguyOglGraphicsMaterial.h" #include <diguyApp.h>
| Constructor |
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.
diguyOglGraphicsMaterial::diguyOglGraphicsMaterial(void* internal_data) : diguyGraphicsMaterial(internal_data) { /* * Nothing else to do after calling base class constructor and * initializing data members. */ }
| build |
Build Stage
Description:
Override of diguyGraphicsMaterial::build().
The build() function should create renderer objects that will set the proper material state in bind() calls made during the Draw Stage.
Pre 11.0.2 this function stored the material state change calls in an OpenGL display list. Display lists, however, have been deprecated as part of the OpenGL spec and now have higher function overhead than just calling the material functions directly.
void diguyOglGraphicsMaterial::build() { /* * Nothing to do. */ }
| unbuild |
Unbuild Stage
Description:
Override of diguyGraphicsMaterial::unbuild().
The unbuild() function should destroy the objects created in the build() function.
void diguyOglGraphicsMaterial::unbuild() { /* * Nothing to do. */ }
| bind_now |
Draw Stage
Description:
Override of diguyGraphicsMaterial::bind_now().
The bind_now() function should do whatever is necessary to change the current state of the renderer to use this material's setting.
This implementation applies the display list created in build(), changing OpenGL material settings.
void diguyOglGraphicsMaterial::bind_now() { /* * Check to see if this material was the most recently bound material. * If so there isn't any need to make additional calls. */ if (diguyOglGraphicsMaterial::get_last_bound_material() == this) { return; } /* * If this is a render pass for checking for intersections, no need to * apply the material. */ if (diguyApp::get_app()->get_render_pass_flags() & DIGUY_RENDER_PASS_INTERSECTION) return; apply_material(); }
| apply_material |
Protected utility function that makes the appropriate OpenGL calls to add material properties to the OpenGL state.
void diguyOglGraphicsMaterial::apply_material() { float ambient[4]; float diffuse[4]; float specular[4]; float emission[4]; float shininess; /* * Call base class accessors to get material properties. */ get_ambient(ambient); get_diffuse(diffuse); get_specular(specular); get_emission(emission); get_shininess(&shininess); /* * Make OpenGL calls to apply material properties. */ glMaterialfv(GL_FRONT, GL_AMBIENT, ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, specular); glMaterialfv(GL_FRONT, GL_EMISSION, emission); glMaterialf(GL_FRONT, GL_SHININESS, shininess); }
| Create function definition |
Create and return an object of a subclass of diguyGraphicsMaterial.
diguyGraphicsMaterial* diguyOglGraphicsMaterial_create_func(void* internal_data) { return new diguyOglGraphicsMaterial(internal_data); }
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.