mesa: Make bind_vertex_buffer avilable outside varray.c
[mesa.git] / src / mesa / main / varray.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 #ifndef VARRAY_H
28 #define VARRAY_H
29
30
31 #include "glheader.h"
32 #include "bufferobj.h"
33
34 struct gl_client_array;
35 struct gl_context;
36
37 /**
38 * Returns a pointer to the vertex attribute data in a client array,
39 * or the offset into the vertex buffer for an array that resides in
40 * a vertex buffer.
41 */
42 static inline const GLubyte *
43 _mesa_vertex_attrib_address(const struct gl_vertex_attrib_array *array,
44 const struct gl_vertex_buffer_binding *binding)
45 {
46 if (_mesa_is_bufferobj(binding->BufferObj))
47 return (const GLubyte *) (binding->Offset + array->RelativeOffset);
48 else
49 return array->Ptr;
50 }
51
52 /**
53 * Sets the fields in a gl_client_array to values derived from a
54 * gl_vertex_attrib_array and a gl_vertex_buffer_binding.
55 */
56 static inline void
57 _mesa_update_client_array(struct gl_context *ctx,
58 struct gl_client_array *dst,
59 const struct gl_vertex_attrib_array *src,
60 const struct gl_vertex_buffer_binding *binding)
61 {
62 dst->Size = src->Size;
63 dst->Type = src->Type;
64 dst->Format = src->Format;
65 dst->Stride = src->Stride;
66 dst->StrideB = binding->Stride;
67 dst->Ptr = _mesa_vertex_attrib_address(src, binding);
68 dst->Enabled = src->Enabled;
69 dst->Normalized = src->Normalized;
70 dst->Integer = src->Integer;
71 dst->Doubles = src->Doubles;
72 dst->InstanceDivisor = binding->InstanceDivisor;
73 dst->_ElementSize = src->_ElementSize;
74 _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
75 }
76
77 static inline bool
78 _mesa_attr_zero_aliases_vertex(struct gl_context *ctx)
79 {
80 const bool is_forward_compatible_context =
81 ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
82
83 /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
84 * 2.0. Note that we cannot just check for API_OPENGL_COMPAT here because
85 * that will erroneously allow this usage in a 3.0 forward-compatible
86 * context too.
87 */
88 return (ctx->API == API_OPENGLES
89 || (ctx->API == API_OPENGL_COMPAT
90 && !is_forward_compatible_context));
91 }
92
93 extern void
94 _mesa_bind_vertex_buffer(struct gl_context *ctx,
95 struct gl_vertex_array_object *vao,
96 GLuint index,
97 struct gl_buffer_object *vbo,
98 GLintptr offset, GLsizei stride);
99
100 extern void GLAPIENTRY
101 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride,
102 const GLvoid *ptr);
103
104
105 extern void GLAPIENTRY
106 _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
107
108
109 extern void GLAPIENTRY
110 _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
111
112
113 extern void GLAPIENTRY
114 _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
115
116
117 extern void GLAPIENTRY
118 _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
119 const GLvoid *ptr);
120
121
122 extern void GLAPIENTRY
123 _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr);
124
125
126 extern void GLAPIENTRY
127 _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
128 GLsizei count, const GLvoid *ptr);
129
130
131 extern void GLAPIENTRY
132 _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
133 const GLvoid *ptr);
134
135
136 extern void GLAPIENTRY
137 _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
138 const GLvoid *ptr);
139
140
141 extern void GLAPIENTRY
142 _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
143 const GLvoid *ptr);
144
145
146 extern void GLAPIENTRY
147 _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
148 GLsizei count, const GLvoid *ptr);
149
150
151 extern void GLAPIENTRY
152 _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr);
153
154
155 extern void GLAPIENTRY
156 _mesa_FogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
157
158
159 extern void GLAPIENTRY
160 _mesa_SecondaryColorPointer(GLint size, GLenum type,
161 GLsizei stride, const GLvoid *ptr);
162
163
164 extern void GLAPIENTRY
165 _mesa_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *ptr);
166
167
168 extern void GLAPIENTRY
169 _mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type,
170 GLboolean normalized, GLsizei stride,
171 const GLvoid *pointer);
172
173 void GLAPIENTRY
174 _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
175 GLsizei stride, const GLvoid *ptr);
176
177 extern void GLAPIENTRY
178 _mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type,
179 GLsizei stride, const GLvoid *pointer);
180
181 extern void GLAPIENTRY
182 _mesa_EnableVertexAttribArray(GLuint index);
183
184
185 extern void GLAPIENTRY
186 _mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index);
187
188
189 extern void GLAPIENTRY
190 _mesa_DisableVertexAttribArray(GLuint index);
191
192
193 extern void GLAPIENTRY
194 _mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index);
195
196
197 extern void GLAPIENTRY
198 _mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params);
199
200 extern void GLAPIENTRY
201 _mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params);
202
203 extern void GLAPIENTRY
204 _mesa_GetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params);
205
206 extern void GLAPIENTRY
207 _mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params);
208
209
210 extern void GLAPIENTRY
211 _mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params);
212
213
214 extern void GLAPIENTRY
215 _mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params);
216
217
218 extern void GLAPIENTRY
219 _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer);
220
221
222 void GLAPIENTRY
223 _mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index,
224 GLenum pname, GLint *param);
225
226
227 void GLAPIENTRY
228 _mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index,
229 GLenum pname, GLint64 *param);
230
231
232 extern void GLAPIENTRY
233 _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
234
235
236 extern void GLAPIENTRY
237 _mesa_MultiDrawArrays( GLenum mode, const GLint *first,
238 const GLsizei *count, GLsizei primcount );
239
240 extern void GLAPIENTRY
241 _mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
242 const GLvoid **indices, GLsizei primcount );
243
244 extern void GLAPIENTRY
245 _mesa_MultiDrawElementsBaseVertex( GLenum mode,
246 const GLsizei *count, GLenum type,
247 const GLvoid **indices, GLsizei primcount,
248 const GLint *basevertex);
249
250 extern void GLAPIENTRY
251 _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
252 const GLsizei * count,
253 GLsizei primcount, GLint modestride );
254
255
256 extern void GLAPIENTRY
257 _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
258 GLenum type, const GLvoid * const * indices,
259 GLsizei primcount, GLint modestride );
260
261 extern void GLAPIENTRY
262 _mesa_LockArraysEXT(GLint first, GLsizei count);
263
264 extern void GLAPIENTRY
265 _mesa_UnlockArraysEXT( void );
266
267
268 extern void GLAPIENTRY
269 _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count);
270
271 extern void GLAPIENTRY
272 _mesa_DrawArraysInstanced(GLenum mode, GLint first, GLsizei count,
273 GLsizei primcount);
274
275 extern void GLAPIENTRY
276 _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
277 const GLvoid *indices);
278
279 extern void GLAPIENTRY
280 _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
281 GLenum type, const GLvoid *indices);
282
283 extern void GLAPIENTRY
284 _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
285 const GLvoid *indices, GLint basevertex);
286
287 extern void GLAPIENTRY
288 _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
289 GLsizei count, GLenum type,
290 const GLvoid *indices,
291 GLint basevertex);
292
293 extern void GLAPIENTRY
294 _mesa_DrawTransformFeedback(GLenum mode, GLuint name);
295
296 extern void GLAPIENTRY
297 _mesa_PrimitiveRestartIndex(GLuint index);
298
299
300 extern void GLAPIENTRY
301 _mesa_VertexAttribDivisor(GLuint index, GLuint divisor);
302
303 extern unsigned
304 _mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type);
305
306 extern void GLAPIENTRY
307 _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
308 GLsizei stride);
309
310 extern void GLAPIENTRY
311 _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
312 GLintptr offset, GLsizei stride);
313
314 extern void GLAPIENTRY
315 _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
316 const GLintptr *offsets, const GLsizei *strides);
317
318 extern void GLAPIENTRY
319 _mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
320 const GLuint *buffers,
321 const GLintptr *offsets, const GLsizei *strides);
322
323 extern void GLAPIENTRY
324 _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
325 GLboolean normalized, GLuint relativeOffset);
326
327 extern void GLAPIENTRY
328 _mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size,
329 GLenum type, GLboolean normalized,
330 GLuint relativeOffset);
331
332 extern void GLAPIENTRY
333 _mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
334 GLuint relativeOffset);
335
336 extern void GLAPIENTRY
337 _mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex,
338 GLint size, GLenum type,
339 GLuint relativeOffset);
340
341 extern void GLAPIENTRY
342 _mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
343 GLuint relativeOffset);
344
345 extern void GLAPIENTRY
346 _mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
347 GLint size, GLenum type,
348 GLuint relativeOffset);
349
350 extern void GLAPIENTRY
351 _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);
352
353 extern void GLAPIENTRY
354 _mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex,
355 GLuint bindingIndex);
356
357 extern void GLAPIENTRY
358 _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor);
359
360 extern void GLAPIENTRY
361 _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint divisor);
362
363 extern void
364 _mesa_copy_client_array(struct gl_context *ctx,
365 struct gl_client_array *dst,
366 struct gl_client_array *src);
367
368 extern void
369 _mesa_copy_vertex_attrib_array(struct gl_context *ctx,
370 struct gl_vertex_attrib_array *dst,
371 const struct gl_vertex_attrib_array *src);
372
373 extern void
374 _mesa_copy_vertex_buffer_binding(struct gl_context *ctx,
375 struct gl_vertex_buffer_binding *dst,
376 const struct gl_vertex_buffer_binding *src);
377
378 extern void
379 _mesa_print_arrays(struct gl_context *ctx);
380
381 extern void
382 _mesa_init_varray( struct gl_context * ctx );
383
384 extern void
385 _mesa_free_varray_data(struct gl_context *ctx);
386
387 #endif