Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/mevis/include/Inventor/misc/SoVBO.h
Go to the documentation of this file.
00001 /*
00002  *
00003  *  Copyright (C) 2011 MeVis Medical Solutions AG  All Rights Reserved.
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  Further, this software is distributed without any warranty that it is
00016  *  free of the rightful claim of any third person regarding infringement
00017  *  or the like.  Any license provided herein, whether implied or
00018  *  otherwise, applies only to this software file.  Patent licenses, if
00019  *  any, provided herein do not apply to combinations of this program with
00020  *  other software, or any other product whatsoever.
00021  *
00022  *  You should have received a copy of the GNU Lesser General Public
00023  *  License along with this library; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  *  Contact information: MeVis, Center for Medical Diagnostic Systems and
00027  *  Visualization GmbH, Universitätsallee 29, D-28359 Bremen, GERMANY, or:
00028  *
00029  *  http://www.mevis.de
00030  *
00031  */
00032 
00033 /*
00034  Author: Florian Link
00035  Date:   09-2011
00036 */
00037 
00038 #ifndef _SO_VBO_
00039 #define _SO_VBO_
00040 
00041 #include <Inventor/SbBasic.h>
00042 #include <Inventor/system/SbOpenGL.h>
00043 
00044 class SoState;
00045 class SoGLDisplayList;
00046 
00051 class INVENTOR_API SoVBO
00052 {
00053 public:
00055   SoVBO(GLenum type);
00056   ~SoVBO();
00057 
00059   static bool shouldUseVBO(SoState* state, int numData);
00060 
00063   static bool isVertexArrayRenderingAllowed();
00064 
00069   bool bind(SoState* state);
00070 
00072   void unbind();
00073 
00075   void setData(int numBytes, const void* data, int nodeId, SoState* state);
00076 
00078   uint32_t getDataId() const { return _nodeId; }
00079 
00081   void clearData();
00082 
00084   const void* getData() const { return _data; }
00085 
00087   void freeGL(SoState* state = NULL);
00088 
00090   bool hasSwappedRGBAData() const { return _hasSwappedRGBAData; }
00091 
00094   void copyAndSwapPackedRGBA(SoState* state);
00095 
00096 private:
00098   void allocateData(int numBytes, int nodeId, SoState* state);
00099 
00102   void copyAndSwapPackedRGBA(int numValues, const uint32_t* values, int nodeId, SoState* state);
00103 
00104   GLenum _type;
00105 
00106   const void* _data;
00107   int      _numBytes;
00108   uint32_t _nodeId;
00109 
00110   SoGLDisplayList* _glBuffer;
00111 
00112   bool _ownsData;
00113   bool _hasSwappedRGBAData;
00114   bool _hadGLError;
00115 
00116   static int _vboMinimumSizeLimit;
00117   static int _vboMaximumSizeLimit;
00118 };
00119 
00120 #endif