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

sglInterleavedGeometry.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglInterleavedGeometry.hpp
00021  *  Created: 3 January 2000
00022  *  Summary: geometry primitives utilizing glInterleaveArray
00023  *****************************************************************************/
00024 
00025 #ifndef __SGL_INTERLEAVED_GEOMETRY_HPP
00026 #define __SGL_INTERLEAVED_GEOMETRY_HPP
00027 
00028 #include <sgl.h>
00029 #include <sglDrawable.hpp>
00030 
00031 //============================================================================
00032 
00149 class SGL_DLL_API sglInterleavedGeometry : public sglDrawable
00150 {
00151 public:
00153    sglInterleavedGeometry();
00155    virtual ~sglInterleavedGeometry();
00156 
00158    virtual AAEnum getAAType() const;
00159 
00163    void setGLPrimType(GLenum prim_type);
00165    GLenum getGLPrimType() const { return m_prim_type; }
00167    virtual sglStats::PrimEnum getPrimType() const;
00169    virtual unsigned int getPrimSize() const;
00170 
00176    unsigned int getNumPrims() const {return m_num_prims;}
00178    void setNumPrims(unsigned int num);
00179 
00181    unsigned int *getPrimLengths() const {return m_lengths;}
00183    void setPrimLengths(unsigned int *lengths);
00184 
00190    void setInterleavedArray(GLenum format,
00191                             void *array,
00192                             GLsizei stride = 0);
00193 
00195    void getInterleavedArray(GLenum *format,
00196                             void **array,
00197                             GLsizei *stride);
00198 
00200    virtual bool isValid() const;
00201 
00203    virtual void drawGeometry(const vector<sglTexCoords> &tex_coords) const;
00204 
00206    virtual void addStats(sglStats &stats) const;
00207 
00209    virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00210 
00211 protected:
00212    virtual bool computeBounds();
00213 
00214 private:   // not implemented
00215    sglInterleavedGeometry(const sglInterleavedGeometry &);
00216    sglInterleavedGeometry &operator=(const sglInterleavedGeometry &);
00217 
00218 private:
00219    GLenum        m_prim_type;
00220    unsigned int  m_num_prims;
00221    unsigned int *m_lengths;       // List of strip lengths
00222 
00223    void         *m_array;         // the packed data (see structs below).
00224    GLenum        m_array_format;  // one of the fourteen types
00225    GLsizei       m_array_stride;
00226 
00227    enum BoundsEnum {ePRIM_TYPE    = 0x01,
00228                     eNUMPRIMS     = 0x02,
00229                     eLENGTHS      = 0x04,
00230                     eARRAY        = 0x08,
00231                     eARRAY_FORMAT = 0x10};
00232    unsigned int  m_compute_bounds;
00233 };
00234 
00235 //----------------------------------------------------------------------------
00236 // structures to aid in packing the interleaved elements
00237 
00238 //struct sglV2fStruct
00239 
00240 //struct sglV3fStruct
00241 
00242 struct sglC4ubV2fStruct
00243 {
00244    unsigned char color[4];
00245    sglVec2f      vertex;
00246 };
00247 
00248 struct sglC4ubV3fStruct
00249 {
00250    unsigned char color[4];
00251    sglVec3f      vertex;
00252 };
00253 
00254 struct sglC3fV3fStruct
00255 {
00256    sglVec3f color;
00257    sglVec3f vertex;
00258 };
00259 
00260 struct sglN3fV3fStruct
00261 {
00262    sglVec3f normal;
00263    sglVec3f vertex;
00264 };
00265 
00266 struct sglC4fN3fV3fStruct
00267 {
00268    sglVec4f color;
00269    sglVec3f normal;
00270    sglVec3f vertex;
00271 };
00272 
00273 struct sglT2fV3fStruct
00274 {
00275    sglVec2f tex_coord;
00276    sglVec3f vertex;
00277 };
00278 
00279 struct sglT4fV4fStruct
00280 {
00281    sglVec4f tex_coord;
00282    sglVec4f vertex;
00283 };
00284 
00285 struct sglT2fC4ubV3fStruct
00286 {
00287    sglVec2f      tex_coord;
00288    unsigned char color[4];
00289    sglVec3f      vertex;
00290 };
00291 
00292 struct sglT2fC3fV3fStruct
00293 {
00294    sglVec2f tex_coord;
00295    sglVec3f color;
00296    sglVec3f vertex;
00297 };
00298 
00299 struct sglT2fN3fV3fStruct
00300 {
00301    sglVec2f tex_coord;
00302    sglVec3f normal;
00303    sglVec3f vertex;
00304 };
00305 
00306 struct sglT2fC4fN3fV3fStruct
00307 {
00308    sglVec2f tex_coord;
00309    sglVec4f color;
00310    sglVec3f normal;
00311    sglVec3f vertex;
00312 };
00313 
00314 struct sglT4fC4fN3fV4fStruct
00315 {
00316    sglVec4f tex_coord;
00317    sglVec4f color;
00318    sglVec3f normal;
00319    sglVec4f vertex;
00320 };
00321 
00322 //----------------------------------------------------------------------------
00323 
00324 #endif

Generated at Mon Jul 1 18:00:04 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001