annotate src/vertex-buffer.h @ 54:7fd43d272c93 good64bit

Ahh .. yup.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 06 Aug 2013 15:57:30 +0300
parents 785057719d9b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /* ============================================================================
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Freetype GL - A C OpenGL Freetype engine
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Platform: Any
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * WWW: http://code.google.com/p/freetype-gl/
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 * ----------------------------------------------------------------------------
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Copyright 2011,2012 Nicolas P. Rougier. All rights reserved.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 * Redistribution and use in source and binary forms, with or without
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 * modification, are permitted provided that the following conditions are met:
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 * 1. Redistributions of source code must retain the above copyright notice,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 * this list of conditions and the following disclaimer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 * 2. Redistributions in binary form must reproduce the above copyright
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 * notice, this list of conditions and the following disclaimer in the
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 * documentation and/or other materials provided with the distribution.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 * The views and conclusions contained in the software and documentation are
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 * those of the authors and should not be interpreted as representing official
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 * policies, either expressed or implied, of Nicolas P. Rougier.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 * ============================================================================
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 #ifndef __VERTEX_BUFFER_H__
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 #define __VERTEX_BUFFER_H__
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 #ifdef __cplusplus
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 extern "C" {
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #endif
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 #include "opengl.h"
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 #include "vector.h"
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 #include "vertex-attribute.h"
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 * @file vertex-buffer.h
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 * @author Nicolas Rougier (Nicolas.Rougier@inria.fr)
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 * @date April, 2012
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 * @defgroup vertex-buffer Vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 * @{
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 * Generic vertex buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 typedef struct
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 {
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 /** Format of the vertex buffer. */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 char * format;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 /** Vector of vertices. */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 vector_t * vertices;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 /** GL identity of the vertices buffer. */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 GLuint vertices_id;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 /** Vector of indices. */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 vector_t * indices;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 /** GL identity of the indices buffer. */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 GLuint indices_id;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 /** Current size of the vertices buffer in GPU */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 size_t GPU_vsize;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 /** Current size of the indices buffer in GPU*/
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 size_t GPU_isize;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 /** GL primitives to render. */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 GLenum mode;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 /** Whether the vertex buffer needs to be uploaded to GPU memory. */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 char state;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 /** Individual items */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 vector_t * items;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 /** Array of attributes. */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 vertex_attribute_t *attributes[MAX_VERTEX_ATTRIBUTE];
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 } vertex_buffer_t;
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 * Creates an empty vertex buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 * @param format a string describing vertex format.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 * @return an empty vertex buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 vertex_buffer_t *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 vertex_buffer_new( const char *format );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 * Deletes vertex buffer and releases GPU memory.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 vertex_buffer_delete( vertex_buffer_t * self );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 * Returns the number of items in the vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 * @return number of items
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 size_t
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 vertex_buffer_size( const vertex_buffer_t *self );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 * Returns vertex format
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 * @return vertex format
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 const char *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 vertex_buffer_format( const vertex_buffer_t *self );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 * Print information about a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 vertex_buffer_print( vertex_buffer_t * self );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 * Prepare vertex buffer for render.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 * @param mode render mode
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 vertex_buffer_render_setup ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 GLenum mode );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 * Finish rendering by setting back modified states
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 vertex_buffer_render_finish ( vertex_buffer_t *self );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 * Render vertex buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 * @param mode render mode
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 vertex_buffer_render ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 GLenum mode );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 * Render a specified item from the vertex buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 * @param index index of the item to be rendered
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 vertex_buffer_render_item ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 size_t index );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 * Upload buffer to GPU memory.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 vertex_buffer_upload( vertex_buffer_t *self );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 * Clear all items.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 vertex_buffer_clear( vertex_buffer_t *self );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 * Appends indices at the end of the buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 * @param indices indices to be appended
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 * @param icount number of indices to be appended
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 * @private
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 vertex_buffer_push_back_indices ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 const GLuint * indices,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 const size_t icount );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 * Appends vertices at the end of the buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 * @note Internal use
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 * @param vertices vertices to be appended
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 * @param vcount number of vertices to be appended
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 * @private
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 vertex_buffer_push_back_vertices ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 const void * vertices,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 const size_t vcount );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 * Insert indices in the buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 * @param index location before which to insert indices
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 * @param indices indices to be appended
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 * @param icount number of indices to be appended
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 * @private
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 vertex_buffer_insert_indices ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 const size_t index,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 const GLuint *indices,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 const size_t icount );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 * Insert vertices in the buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 * @param index location before which to insert vertices
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 * @param vertices vertices to be appended
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 * @param vcount number of vertices to be appended
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 * @private
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 vertex_buffer_insert_vertices ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 const size_t index,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 const void *vertices,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 const size_t vcount );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271 * Erase indices in the buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 * @param first the index of the first index to be erased
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 * @param last the index of the last index to be erased
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 * @private
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 vertex_buffer_erase_indices ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 const size_t first,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 const size_t last );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 * Erase vertices in the buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 * @param first the index of the first vertex to be erased
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 * @param last the index of the last vertex to be erased
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 * @private
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 vertex_buffer_erase_vertices ( vertex_buffer_t *self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 const size_t first,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 const size_t last );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 * Append a new item to the collection.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 * @param vcount number of vertices
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 * @param vertices raw vertices data
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 * @param icount number of indices
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 * @param indices raw indices data
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 size_t
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 vertex_buffer_push_back( vertex_buffer_t * self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 const void * vertices, const size_t vcount,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 const GLuint * indices, const size_t icount );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 * Insert a new item into the vertex buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 * @param index location before which to insert item
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 * @param vertices raw vertices data
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 * @param vcount number of vertices
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 * @param indices raw indices data
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 * @param icount number of indices
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324 size_t
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 vertex_buffer_insert( vertex_buffer_t * self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 size_t index,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 const void * vertices, const size_t vcount,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 const GLuint * indices, const size_t icount );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 /**
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 * Erase an item from the vertex buffer.
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 *
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 * @param self a vertex buffer
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 * @param index index of the item to be deleted
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 void
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 vertex_buffer_erase( vertex_buffer_t * self,
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 const size_t index );
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 /** @} */
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 #ifdef __cplusplus
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 }
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 #endif
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345
785057719d9b Import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 #endif /* __VERTEX_BUFFER_H__ */