Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/gsgmisc/geomIssuer.cxx

Go to the documentation of this file.
00001 // Filename: geomIssuer.cxx
00002 // Created by:  drose (03Feb99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "geomIssuer.h"
00020 #include <geom.h>
00021 #include <graphicsStateGuardianBase.h>
00022 
00023 static void
00024 issue_vertex_noop(const Geom *, Geom::VertexIterator &,
00025                   GraphicsStateGuardianBase *) {
00026 }
00027 
00028 static void
00029 issue_normal_noop(const Geom *, Geom::NormalIterator &,
00030                   GraphicsStateGuardianBase *) {
00031 }
00032 
00033 static void
00034 issue_texcoord_noop(const Geom *, Geom::TexCoordIterator &,
00035                   GraphicsStateGuardianBase *) {
00036 }
00037 
00038 static void
00039 issue_color_noop(const Geom *, Geom::ColorIterator &, 
00040                  GraphicsStateGuardianBase *) {
00041 }
00042 
00043 static GeomIssuer noop_issuer;
00044 
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: GeomIssuer::Constructor
00048 //       Access: Public
00049 //  Description: The default constructor makes a no-op GeomIssuer.
00050 //               It's primarily intended to create the static
00051 //               _noop_issuer once and only once; normally, the real
00052 //               constructor, below, will be used.
00053 ////////////////////////////////////////////////////////////////////
00054 GeomIssuer::
00055 GeomIssuer() {
00056   for (int i = 0; i < num_GeomBindTypes; i++) {
00057     _vertex_command[i] = issue_vertex_noop;
00058     _normal_command[i] = issue_normal_noop;
00059     _texcoord_command[i] = issue_texcoord_noop;
00060     _color_command[i] = issue_color_noop;
00061   }
00062   _geom = NULL;
00063 }
00064 
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: GeomIssuer::Constructor
00068 //       Access: Public
00069 //  Description: This is the real constructor.  Given a Geom, the
00070 //               current gsg, and a series of functions that, when
00071 //               called, will actually issue the vertex/normal/whatnot
00072 //               to the rendering engine.  It will construct a
00073 //               GeomIssuer with these pointers in the appropriate
00074 //               places to either issue the component or do nothing,
00075 //               according to the requirements of the geom and of the
00076 //               current state of the gsg.
00077 ////////////////////////////////////////////////////////////////////
00078 GeomIssuer::
00079 GeomIssuer(const Geom *geom,
00080            GraphicsStateGuardianBase *gsg,
00081            IssueVertex *vertex,
00082            IssueNormal *normal,
00083            IssueTexCoord *texcoord,
00084            IssueColor *color) {
00085   memcpy(this, &noop_issuer, sizeof(GeomIssuer));
00086   _geom = geom;
00087   _gsg = gsg;
00088 
00089   // Issue vertices by default (we might not want to if we're doing
00090   // performance analysis)
00091   if (vertex != NULL) {
00092     _vertex_command[geom->get_binding(G_COORD)] = vertex;
00093   }
00094 
00095   // Issue normals only if we have them and the gsg says we should.
00096   if (normal != NULL && gsg->wants_normals()) {
00097     _normal_command[geom->get_binding(G_NORMAL)] = normal;
00098   }
00099 
00100   // Issue texcoords if we have them and the gsg wants them.
00101   if (texcoord != NULL && gsg->wants_texcoords()) {
00102     _texcoord_command[geom->get_binding(G_TEXCOORD)] = texcoord;
00103   }
00104 
00105   // And ditto for colors.
00106   if (color != NULL && gsg->wants_colors()) {
00107     _color_command[geom->get_binding(G_COLOR)] = color;
00108   }
00109 }

Generated on Fri May 2 00:39:47 2003 for Panda by doxygen1.3