Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoVertexArrayIndexer.h
1 #ifndef COIN_VERTEXARRAYINDEXER_H
2 #define COIN_VERTEXARRAYINDEXER_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/lists/SbList.h>
41 #include <Inventor/system/gl.h>
42 #include <Inventor/C/glue/gl.h>
43 #include <stdlib.h>
44 
45 class SoVBO;
46 
48 public:
51 
52  void addTriangle(const int32_t v0,
53  const int32_t v1,
54  const int32_t v2);
55  void addLine(const int32_t v0,
56  const int32_t v1);
57  void addPoint(const int32_t v0);
58 
59 
60  void addQuad(const int32_t v0,
61  const int32_t v1,
62  const int32_t v2,
63  const int32_t v3);
64 
65  void beginTarget(GLenum target);
66  void targetVertex(GLenum target, const int32_t v);
67  void endTarget(GLenum target);
68 
69  void close(void);
70  void render(const cc_glglue * glue, const SbBool renderasvbo, const uint32_t vbocontextid);
71 
72  int getNumVertices(void);
73  int getNumIndices(void) const;
74  const GLint * getIndices(void) const;
75  GLint * getWriteableIndices(void);
76 
77 private:
78  void addIndex(int32_t i);
79  void sort_triangles(void);
80  void sort_lines(void);
81  SoVertexArrayIndexer * getNext(void);
82 
83  GLenum target;
84  SoVertexArrayIndexer * next;
85 
86  int targetcounter;
87  SbList <GLsizei> countarray;
88  SbList <const GLint *> ciarray;
89  SbList <GLint> indexarray;
90  SoVBO * vbo;
91  SbBool use_shorts;
92 };
93 
94 #endif // COIN_VERTEXARRAYINDEXER_H
void addQuad(const int32_t v0, const int32_t v1, const int32_t v2, const int32_t v3)
Definition: SoVertexArrayIndexer.cpp:140
const GLint * getIndices(void) const
Definition: SoVertexArrayIndexer.cpp:472
GLint * getWriteableIndices(void)
Definition: SoVertexArrayIndexer.cpp:483
int getNumIndices(void) const
Definition: SoVertexArrayIndexer.cpp:462
void addLine(const int32_t v0, const int32_t v1)
Definition: SoVertexArrayIndexer.cpp:89
void render(const cc_glglue *glue, const SbBool renderasvbo, const uint32_t vbocontextid)
Definition: SoVertexArrayIndexer.cpp:247
The SoVertexArrayIndexer class is used to simplify index handling for vertex array rendering...
Definition: SoVertexArrayIndexer.h:47
~SoVertexArrayIndexer()
Definition: SoVertexArrayIndexer.cpp:72
void beginTarget(GLenum target)
Definition: SoVertexArrayIndexer.cpp:166
void targetVertex(GLenum target, const int32_t v)
Definition: SoVertexArrayIndexer.cpp:184
int getNumVertices(void)
Definition: SoVertexArrayIndexer.cpp:317
void endTarget(GLenum target)
Definition: SoVertexArrayIndexer.cpp:203
void addTriangle(const int32_t v0, const int32_t v1, const int32_t v2)
Definition: SoVertexArrayIndexer.cpp:121
void addPoint(const int32_t v0)
Definition: SoVertexArrayIndexer.cpp:106
The SoVBO class is used to handle OpenGL vertex buffer objects.
Definition: SoVBO.h:47
SoVertexArrayIndexer(void)
Definition: SoVertexArrayIndexer.cpp:61
void close(void)
Definition: SoVertexArrayIndexer.cpp:220