Open Inventor Reference
SoVBO.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2011 MeVis Medical Solutions AG All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: MeVis, Center for Medical Diagnostic Systems and
27 * Visualization GmbH, Universitätsallee 29, D-28359 Bremen, GERMANY, or:
28 *
29 * http://www.mevis.de
30 *
31 */
32
33/*
34 Author: Florian Link
35 Date: 09-2011
36*/
37
38#ifndef _SO_VBO_
39#define _SO_VBO_
40
41#include <Inventor/SbBasic.h>
43
44class SoState;
45class SoGLDisplayList;
46
52{
53public:
55 SoVBO(GLenum type);
57
59 static bool shouldUseVBO(SoState* state, int numData);
60
64
69 bool bind(SoState* state);
70
72 void unbind();
73
75 bool isValid(SoState* state);
76
78 void setData(int numBytes, const void* data, SbNodeIdType nodeId, SoState* state);
79
81 SbNodeIdType getDataId() const { return _nodeId; }
82
84 void clearData();
85
87 const void* getData() const { return _data; }
88
90 void freeGL(SoState* state = NULL);
91
93 bool hasSwappedRGBAData() const { return _hasSwappedRGBAData; }
94
98
100 static int getVboMinimumSizeLimit() { return _vboMinimumSizeLimit; }
101
103 void updateData(void* data);
104
105private:
107 void allocateData(int numBytes, SbNodeIdType nodeId, SoState* state);
108
111 void copyAndSwapPackedRGBA(int numValues, const uint32_t* values, SbNodeIdType nodeId, SoState* state);
112
113 GLenum _type;
114
115 const void* _data;
116 int _numBytes;
117 SbNodeIdType _nodeId;
118
119 SoGLDisplayList* _glBuffer;
120
121 bool _ownsData;
122 bool _hasSwappedRGBAData;
123 bool _hadGLError;
124
125 static int _vboMinimumSizeLimit;
126 static int _vboMaximumSizeLimit;
127};
128
129#endif
size_t SbNodeIdType
Type of unique ids of SoNode, used in the notification/change detection handling.
Definition SbBasic.h:90
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
unsigned int uint32_t
Definition SbTypeDefs.h:44
Class SoGLDisplayList:
An SoState collects and holds state while traversing a scene graph.
Definition SoState.h:82
SoVBO is used to manage OpenGL vertex buffer objects.
Definition SoVBO.h:52
bool bind(SoState *state)
bind the buffer to GL, transfer data if not already done.
void setData(int numBytes, const void *data, SbNodeIdType nodeId, SoState *state)
sets the client buffer data, ownership stays with the caller
static int getVboMinimumSizeLimit()
get the lower limit for VBO usage
Definition SoVBO.h:100
const void * getData() const
get the data pointer
Definition SoVBO.h:87
SoVBO(GLenum type)
create VBO of type GL_ARRAY_BUFFER (for vertex/normal/color etc. data) or GL_ELEMENT_ARRAY_BUFFER for...
void copyAndSwapPackedRGBA(SoState *state)
allocates new data buffer, copies the values set by setData() and swaps them bytewise,...
void updateData(void *data)
update the VBO data from the current data (bind() needs to be called before).
static bool shouldUseVBO(SoState *state, int numData)
returns if a VBO should be used depending on given state and the number of data elements (not bytes)
static bool isVertexArrayRenderingAllowed()
returns of vertex array rendering is allowed.
void freeGL(SoState *state=NULL)
free the GL part of the VBO (if state is passed, the VBO may be deleted immediately)
bool hasSwappedRGBAData() const
returns if the stored data has been swapped to be compatible to OpenGL on little endian machines
Definition SoVBO.h:93
void clearData()
clears the data, freeing it when it is owned by VBO
void unbind()
unbind the VBO in the GL state
SbNodeIdType getDataId() const
get the node id of the data
Definition SoVBO.h:81
bool isValid(SoState *state)
Returns if the VBO is valid and it's data is stored on the GPU.