2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
32 #include "bufferobj.h"
34 struct gl_client_array
;
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
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
)
46 if (_mesa_is_bufferobj(binding
->BufferObj
))
47 return (const GLubyte
*) (binding
->Offset
+ array
->RelativeOffset
);
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.
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
)
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
->InstanceDivisor
= binding
->InstanceDivisor
;
72 dst
->_ElementSize
= src
->_ElementSize
;
73 _mesa_reference_buffer_object(ctx
, &dst
->BufferObj
, binding
->BufferObj
);
77 _mesa_attr_zero_aliases_vertex(struct gl_context
*ctx
)
79 const bool is_forward_compatible_context
=
80 ctx
->Const
.ContextFlags
& GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT
;
82 /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
83 * 2.0. Note that we cannot just check for API_OPENGL_COMPAT here because
84 * that will erroneously allow this usage in a 3.0 forward-compatible
87 return (ctx
->API
== API_OPENGLES
88 || (ctx
->API
== API_OPENGL_COMPAT
89 && !is_forward_compatible_context
));
92 extern void GLAPIENTRY
93 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
,
97 extern void GLAPIENTRY
98 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
101 extern void GLAPIENTRY
102 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
105 extern void GLAPIENTRY
106 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
109 extern void GLAPIENTRY
110 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
114 extern void GLAPIENTRY
115 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
);
118 extern void GLAPIENTRY
119 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
120 GLsizei count
, const GLvoid
*ptr
);
123 extern void GLAPIENTRY
124 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
128 extern void GLAPIENTRY
129 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
133 extern void GLAPIENTRY
134 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
138 extern void GLAPIENTRY
139 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
140 GLsizei count
, const GLvoid
*ptr
);
143 extern void GLAPIENTRY
144 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
);
147 extern void GLAPIENTRY
148 _mesa_FogCoordPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
151 extern void GLAPIENTRY
152 _mesa_SecondaryColorPointer(GLint size
, GLenum type
,
153 GLsizei stride
, const GLvoid
*ptr
);
156 extern void GLAPIENTRY
157 _mesa_PointSizePointerOES(GLenum type
, GLsizei stride
, const GLvoid
*ptr
);
160 extern void GLAPIENTRY
161 _mesa_VertexAttribPointer(GLuint index
, GLint size
, GLenum type
,
162 GLboolean normalized
, GLsizei stride
,
163 const GLvoid
*pointer
);
166 _mesa_VertexAttribIPointer(GLuint index
, GLint size
, GLenum type
,
167 GLsizei stride
, const GLvoid
*ptr
);
169 extern void GLAPIENTRY
170 _mesa_VertexAttribLPointer(GLuint index
, GLint size
, GLenum type
,
171 GLsizei stride
, const GLvoid
*pointer
);
173 extern void GLAPIENTRY
174 _mesa_EnableVertexAttribArray(GLuint index
);
177 extern void GLAPIENTRY
178 _mesa_DisableVertexAttribArray(GLuint index
);
181 extern void GLAPIENTRY
182 _mesa_GetVertexAttribdv(GLuint index
, GLenum pname
, GLdouble
*params
);
184 extern void GLAPIENTRY
185 _mesa_GetVertexAttribfv(GLuint index
, GLenum pname
, GLfloat
*params
);
187 extern void GLAPIENTRY
188 _mesa_GetVertexAttribLdv(GLuint index
, GLenum pname
, GLdouble
*params
);
190 extern void GLAPIENTRY
191 _mesa_GetVertexAttribiv(GLuint index
, GLenum pname
, GLint
*params
);
194 extern void GLAPIENTRY
195 _mesa_GetVertexAttribIiv(GLuint index
, GLenum pname
, GLint
*params
);
198 extern void GLAPIENTRY
199 _mesa_GetVertexAttribIuiv(GLuint index
, GLenum pname
, GLuint
*params
);
202 extern void GLAPIENTRY
203 _mesa_GetVertexAttribPointerv(GLuint index
, GLenum pname
, GLvoid
**pointer
);
206 extern void GLAPIENTRY
207 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
);
210 extern void GLAPIENTRY
211 _mesa_MultiDrawArrays( GLenum mode
, const GLint
*first
,
212 const GLsizei
*count
, GLsizei primcount
);
214 extern void GLAPIENTRY
215 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
216 const GLvoid
**indices
, GLsizei primcount
);
218 extern void GLAPIENTRY
219 _mesa_MultiDrawElementsBaseVertex( GLenum mode
,
220 const GLsizei
*count
, GLenum type
,
221 const GLvoid
**indices
, GLsizei primcount
,
222 const GLint
*basevertex
);
224 extern void GLAPIENTRY
225 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
226 const GLsizei
* count
,
227 GLsizei primcount
, GLint modestride
);
230 extern void GLAPIENTRY
231 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
232 GLenum type
, const GLvoid
* const * indices
,
233 GLsizei primcount
, GLint modestride
);
235 extern void GLAPIENTRY
236 _mesa_LockArraysEXT(GLint first
, GLsizei count
);
238 extern void GLAPIENTRY
239 _mesa_UnlockArraysEXT( void );
242 extern void GLAPIENTRY
243 _mesa_DrawArrays(GLenum mode
, GLint first
, GLsizei count
);
245 extern void GLAPIENTRY
246 _mesa_DrawArraysInstanced(GLenum mode
, GLint first
, GLsizei count
,
249 extern void GLAPIENTRY
250 _mesa_DrawElements(GLenum mode
, GLsizei count
, GLenum type
,
251 const GLvoid
*indices
);
253 extern void GLAPIENTRY
254 _mesa_DrawRangeElements(GLenum mode
, GLuint start
, GLuint end
, GLsizei count
,
255 GLenum type
, const GLvoid
*indices
);
257 extern void GLAPIENTRY
258 _mesa_DrawElementsBaseVertex(GLenum mode
, GLsizei count
, GLenum type
,
259 const GLvoid
*indices
, GLint basevertex
);
261 extern void GLAPIENTRY
262 _mesa_DrawRangeElementsBaseVertex(GLenum mode
, GLuint start
, GLuint end
,
263 GLsizei count
, GLenum type
,
264 const GLvoid
*indices
,
267 extern void GLAPIENTRY
268 _mesa_DrawTransformFeedback(GLenum mode
, GLuint name
);
270 extern void GLAPIENTRY
271 _mesa_PrimitiveRestartIndex(GLuint index
);
274 extern void GLAPIENTRY
275 _mesa_VertexAttribDivisor(GLuint index
, GLuint divisor
);
278 _mesa_primitive_restart_index(const struct gl_context
*ctx
, GLenum ib_type
);
280 extern void GLAPIENTRY
281 _mesa_BindVertexBuffer(GLuint bindingIndex
, GLuint buffer
, GLintptr offset
,
284 extern void GLAPIENTRY
285 _mesa_BindVertexBuffers(GLuint first
, GLsizei count
, const GLuint
*buffers
,
286 const GLintptr
*offsets
, const GLsizei
*strides
);
288 extern void GLAPIENTRY
289 _mesa_VertexAttribFormat(GLuint attribIndex
, GLint size
, GLenum type
,
290 GLboolean normalized
, GLuint relativeOffset
);
292 extern void GLAPIENTRY
293 _mesa_VertexAttribIFormat(GLuint attribIndex
, GLint size
, GLenum type
,
294 GLuint relativeOffset
);
296 extern void GLAPIENTRY
297 _mesa_VertexAttribLFormat(GLuint attribIndex
, GLint size
, GLenum type
,
298 GLuint relativeOffset
);
300 extern void GLAPIENTRY
301 _mesa_VertexAttribBinding(GLuint attribIndex
, GLuint bindingIndex
);
303 extern void GLAPIENTRY
304 _mesa_VertexBindingDivisor(GLuint bindingIndex
, GLuint divisor
);
308 _mesa_copy_client_array(struct gl_context
*ctx
,
309 struct gl_client_array
*dst
,
310 struct gl_client_array
*src
);
313 _mesa_copy_vertex_attrib_array(struct gl_context
*ctx
,
314 struct gl_vertex_attrib_array
*dst
,
315 const struct gl_vertex_attrib_array
*src
);
318 _mesa_copy_vertex_buffer_binding(struct gl_context
*ctx
,
319 struct gl_vertex_buffer_binding
*dst
,
320 const struct gl_vertex_buffer_binding
*src
);
323 _mesa_print_arrays(struct gl_context
*ctx
);
326 _mesa_init_varray( struct gl_context
* ctx
);
329 _mesa_free_varray_data(struct gl_context
*ctx
);