/************************************************************************ Since we don't want to have to rewrite rendering loops every time we want to draw a model, this module provides centralized drawing code. Copyright (C) 1998 Michael Garland. See "COPYING.txt" for details. $Id: MxStdRender.cxx,v 1.13 1998/10/26 21:09:30 garland Exp $ ************************************************************************/ #include "stdmix.h" #include "MxGL.h" #include "MxStdModel.h" //////////////////////////////////////////////////////////////////////// // // Globally visible variables. These exist for quasi-easy // customization. Eventually, we'll have a more flexible system. // float mx_mesh_color[3] = {0.05f, 0.05f, 0.05f}; float mx_alt_mesh_color[3] = {0.8f, 0.1f, 0.1f}; //////////////////////////////////////////////////////////////////////// // // Currently, we create custom routines for each possible combination // of normal and color bindings. This approach might eventually lead // to excessive code bloat. Be careful! // // Note that the whole point of this is to avoid conditional branching // in the rendering loop. Currently, we have 2: one for the loop // condition and one to test face validity. This is minimal. // #define _0(x) #define _V(x) glV(m.vertex(x)) #define _N(x) glN(m.normal(x)) #define _C(x) glC(m.color(x)) #define _CV(x) _C(x),_V(x) #define _NV(x) _N(x),_V(x) #define _NC(x) _N(x),_C(x) #define _NCV(x) _N(x),_C(x),_V(x) #define defdraw(fn, per_face, per_vert) \ static void fn(MxStdModel& m) \ { \ glBegin(GL_TRIANGLES); \ for(MxFaceID f=0; f= TABLE_SIZE ) draw_fallback(m); else { render_func fn = render_table[index]; if( fn ) (*fn)(m); else fatal_error("mx_render_model: Illegal model properties."); } } static inline void emit_faces_only(MxStdModel& m) { glBegin(GL_TRIANGLES); for(MxFaceID f=0; f