/* Copyright 2005 Nicholas Bishop * * This file is part of SharpConstruct. * * SharpConstruct is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * SharpConstruct is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SharpConstruct; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Mesh.h" #include "Output3D.hh" #include #include using SharpConstruct::VAR; VAR::VAR() : triangle_count_( 0 ), quad_count_( 0 ) { glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); } bool VAR::IsSupported() { return true; } void VAR::Set( const Mesh& mesh, const bool vn, const bool c, const bool p ) { if( vn ) { glVertexPointer( 3, GL_FLOAT, sizeof( Optimized::Point3D ), &mesh.VertexLocations()[ 0 ] ); glNormalPointer( GL_FLOAT, sizeof( Optimized::Point3D ), &mesh.VertexNormals()[ 0 ] ); } if( c ) glColorPointer( 3, GL_FLOAT, 0, &mesh.VertexColors()[ 0 ] ); if( p ) { triangle_count_ = mesh.VisibleElements().Triangles * 3; triangle_data_ = &mesh.Triangles()[ 0 ]; quad_count_ = mesh.VisibleElements().Quads * 4; quad_data_ = &mesh.Quads()[ 0 ]; } } void VAR::Draw() const { glDrawElements( GL_TRIANGLES, triangle_count_, GL_UNSIGNED_INT, triangle_data_ ); glDrawElements( GL_QUADS, quad_count_, GL_UNSIGNED_INT, quad_data_ ); }