Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SoVBO.h
1#ifndef COIN_VBO_H
2#define COIN_VBO_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#ifndef COIN_INTERNAL
37#error this is a private header file
38#endif /* !COIN_INTERNAL */
39
40#include <Inventor/system/gl.h>
41#include <Inventor/C/glue/gl.h>
42
43#include "misc/SbHash.h"
44
45class SoState;
46
47class SoVBO {
48 public:
49 SoVBO(const GLenum target = GL_ARRAY_BUFFER,
50 const GLenum usage = GL_STATIC_DRAW);
51 ~SoVBO();
52
53 static void init(void);
54
55 void setBufferData(const GLvoid * data, intptr_t size, SbUniqueId dataid = 0);
56 void * allocBufferData(intptr_t size, SbUniqueId dataid = 0);
57 SbUniqueId getBufferDataId(void) const;
58 void getBufferData(const GLvoid *& data, intptr_t & size);
59 void bindBuffer(uint32_t contextid);
60
61 static void setVertexCountLimits(const int minlimit, const int maxlimit);
62 static int getVertexCountMinLimit(void);
63 static int getVertexCountMaxLimit(void);
64
65 static void testGLPerformance(const uint32_t contextid);
66 static SbBool shouldCreateVBO(SoState * state, const uint32_t contextid, const int numdata);
67 static SbBool shouldRenderAsVertexArrays(SoState * statea,
68 const uint32_t contextid,
69 const int numdata);
70
71 private:
72 static void context_created(const uint32_t contextid, void * closure);
73 static SbBool isVBOFast(const uint32_t contextid);
74 static void context_destruction_cb(uint32_t context, void * userdata);
75 friend struct vbo_schedule;
76 static void vbo_delete(void * closure, uint32_t contextid);
77
78 GLenum target;
79 GLenum usage;
80 const GLvoid * data;
81 intptr_t datasize;
82 SbUniqueId dataid;
83 SbBool didalloc;
84
85 SbHash<uint32_t, GLuint> vbohash;
86};
87
88#endif // COIN_VERTEXARRAYINDEXER_H
The SoState class manages the Coin scene graph traversal state data.
Definition SoState.h:44
The SoVBO class is used to handle OpenGL vertex buffer objects.
Definition SoVBO.h:47
void bindBuffer(uint32_t contextid)
Definition SoVBO.cpp:298
void * allocBufferData(intptr_t size, SbUniqueId dataid=0)
Definition SoVBO.cpp:205
~SoVBO()
Definition SoVBO.cpp:104
static void setVertexCountLimits(const int minlimit, const int maxlimit)
Definition SoVBO.cpp:364
void getBufferData(const GLvoid *&data, intptr_t &size)
Definition SoVBO.cpp:287
static int getVertexCountMinLimit(void)
Definition SoVBO.cpp:376
SoVBO(const GLenum target=0x8892, const GLenum usage=0x88E4)
Definition SoVBO.cpp:77
SbUniqueId getBufferDataId(void) const
Definition SoVBO.cpp:278
void setBufferData(const GLvoid *data, intptr_t size, SbUniqueId dataid=0)
Definition SoVBO.cpp:243
static int getVertexCountMaxLimit(void)
Definition SoVBO.cpp:387