OSGGeoProperty.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *               Copyright (C) 2000-2002 by the OpenSG Forum                 *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _OSGGEOPROPERTY_H_
00040 #define _OSGGEOPROPERTY_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include "OSGGeoPropertyBase.h"
00046 #include "OSGWindow.h"
00047 
00048 #ifdef OSG_WINCE
00049 #define GL_STATIC_DRAW_ARB 0x88E4
00050 #endif
00051 
00052 OSG_BEGIN_NAMESPACE
00053 
00054 class Window;
00055 
00060 class OSG_DRAWABLE_DLLMAPPING GeoProperty : public GeoPropertyBase
00061 {
00062   private:
00063 
00064     /*==========================  PUBLIC  =================================*/
00065 
00066   public:
00067 
00068     typedef GeoPropertyBase                             Inherited;
00069 
00070     /*---------------------------------------------------------------------*/
00074     virtual       UInt32  getFormat    (void) const = 0;
00075     virtual       UInt32  getFormatSize(void) const = 0;
00076     virtual       UInt32  getStride    (void) const = 0;
00077     virtual       UInt32  getDimension (void) const = 0;
00078     virtual       UInt32  getSize      (void) const;
00079     virtual       UInt32  size         (void) const = 0;
00080     virtual const UInt8  *getData      (void) const
00081     { return NULL;  }
00082 
00084     /*---------------------------------------------------------------------*/
00088     virtual void changed(ConstFieldMaskArg whichField,
00089                          UInt32            origin,
00090                          BitVector         detail);
00091 
00093     /*---------------------------------------------------------------------*/
00097     virtual void dump(      UInt32     uiIndent = 0,
00098                       const BitVector  bvFlags  = 0) const;
00099 
00101     /*---------------------------------------------------------------------*/
00105     virtual const StateChunkClass * getClass         (void) const;
00106 
00108     /*---------------------------------------------------------------------*/
00112     inline static        UInt32            getStaticClassId (void);
00113     inline static  const StateChunkClass * getStaticClass   (void);
00114 
00116     /*---------------------------------------------------------------------*/
00120     virtual void activate      (DrawEnv *pEnv, UInt32 index = 0) = 0;
00121 
00122     virtual void changeFrom    (DrawEnv    *pEnv,
00123                                 StateChunk *old,
00124                                 UInt32      index = 0)  = 0;
00125 
00126     virtual void deactivate    (DrawEnv *pEnv, UInt32 index = 0) = 0;
00127 
00128     virtual bool isTransparent (void) const;
00129 
00131     /*---------------------------------------------------------------------*/
00135     virtual Real32 switchCost  ( StateChunk * chunk );
00136 
00137     virtual bool   operator <  (const StateChunk &other) const;
00138 
00139     virtual bool   operator == (const StateChunk &other) const;
00140     virtual bool   operator != (const StateChunk &other) const;
00141 
00143     /*---------------------------------------------------------------------*/
00147     inline static UInt32 MapFormatToSize(GLenum format);
00148 
00150     /*=========================  PROTECTED  ===============================*/
00151 
00152   protected:
00153 
00154     // Variables should all be in GeoPropertyBase.
00155 
00156     /*---------------------------------------------------------------------*/
00160     GeoProperty(void);
00161     GeoProperty(const GeoProperty &source);
00162 
00163     void onCreate(const GeoProperty *p = NULL);
00164     void onDestroy(UInt32 uiContainerId);
00165 
00167     /*---------------------------------------------------------------------*/
00171     virtual ~GeoProperty(void);
00172 
00175     virtual GLenum getBufferType(void) = 0; // buffer type for VBOs
00176 
00177     static StateChunkClass _class;
00178 
00179     /*---------------------------------------------------------------------*/
00183     static UInt32 _extVertexBufferObject;
00184     static UInt32 _extMultitexture;
00185     static UInt32 _arbVertexProgram;
00186     static UInt32 _extSecondaryColor;
00187     static UInt32 _funcBindBuffer;
00188     static UInt32 _funcBufferData;
00189     static UInt32 _funcDeleteBuffers;
00190     static UInt32 _glClientActiveTextureARB;
00191     static UInt32 _funcglVertexAttribPointerARB;
00192     static UInt32 _funcglEnableVertexAttribArrayARB;
00193     static UInt32 _funcglDisableVertexAttribArrayARB;
00194     static UInt32 _glSecondaryColorPointerEXT;
00196     /*---------------------------------------------------------------------*/
00200     static void initMethod(InitPhase ePhase);
00201 
00203     /*==========================  PRIVATE  ================================*/
00204 
00205   private:
00206 
00207     friend class FieldContainer;
00208     friend class GeoPropertyBase;
00209 
00210     /*---------------------------------------------------------------------*/
00214     void handleGL(DrawEnv *pEnv, UInt32 id, Window::GLObjectStatusE mode);
00215     static void handleDestroyGL(DrawEnv *pEnv, UInt32 id, Window::GLObjectStatusE mode);
00216 
00219     // prohibit default functions (move to 'public' if you need one)
00220     void operator =(const GeoProperty &source);
00221 };
00222 
00223 typedef GeoProperty *GeoPropertyP;
00224 
00225 OSG_END_NAMESPACE
00226 
00227 #include "OSGGeoPropertyBase.inl"
00228 #include "OSGGeoProperty.inl"
00229 
00230 #endif /* _OSGGEOPROPERTY_H_ */