2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul 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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "bufferobj.h"
35 #include "glapi/dispatch.h"
39 * Update the fields of a vertex array object.
40 * We need to do a few special things for arrays that live in
41 * vertex buffer objects.
43 * \param array the array to update
44 * \param dirtyBit which bit to set in ctx->Array.NewState for this array
45 * \param elementSize size of each array element, in bytes
46 * \param size components per element (1, 2, 3 or 4)
47 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
48 * \param stride stride between elements, in elements
49 * \param normalized are integer types converted to floats in [-1, 1]?
50 * \param ptr the address (or offset inside VBO) of the array data
53 update_array(GLcontext
*ctx
, struct gl_client_array
*array
,
54 GLbitfield dirtyBit
, GLsizei elementSize
,
55 GLint size
, GLenum type
,
56 GLsizei stride
, GLboolean normalized
, const GLvoid
*ptr
)
60 array
->Stride
= stride
;
61 array
->StrideB
= stride
? stride
: elementSize
;
62 array
->Normalized
= normalized
;
63 array
->Ptr
= (const GLubyte
*) ptr
;
64 #if FEATURE_ARB_vertex_buffer_object
65 _mesa_reference_buffer_object(ctx
, &array
->BufferObj
,
66 ctx
->Array
.ArrayBufferObj
);
68 /* Compute the index of the last array element that's inside the buffer.
69 * Later in glDrawArrays we'll check if start + count > _MaxElement to
70 * be sure we won't go out of bounds.
72 if (ctx
->Array
.ArrayBufferObj
->Name
)
73 array
->_MaxElement
= ((GLsizeiptrARB
) ctx
->Array
.ArrayBufferObj
->Size
74 - (GLsizeiptrARB
) array
->Ptr
+ array
->StrideB
75 - elementSize
) / array
->StrideB
;
78 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
80 ctx
->NewState
|= _NEW_ARRAY
;
81 ctx
->Array
.NewState
|= dirtyBit
;
86 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
89 GET_CURRENT_CONTEXT(ctx
);
90 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
92 if (size
< 2 || size
> 4) {
93 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(size)" );
97 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(stride)" );
101 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
102 _mesa_debug(ctx
, "glVertexPointer( sz %d type %s stride %d )\n", size
,
103 _mesa_lookup_enum_by_nr( type
), stride
);
105 /* always need to check that <type> is legal */
108 elementSize
= size
* sizeof(GLshort
);
111 elementSize
= size
* sizeof(GLint
);
114 elementSize
= size
* sizeof(GLfloat
);
117 elementSize
= size
* sizeof(GLdouble
);
121 elementSize
= size
* sizeof(GLfixed
);
124 #if FEATURE_vertex_array_byte
126 elementSize
= size
* sizeof(GLbyte
);
130 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
134 update_array(ctx
, &ctx
->Array
.ArrayObj
->Vertex
, _NEW_ARRAY_VERTEX
,
135 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
137 if (ctx
->Driver
.VertexPointer
)
138 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
143 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
146 GET_CURRENT_CONTEXT(ctx
);
147 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
150 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
154 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
155 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
156 _mesa_lookup_enum_by_nr( type
), stride
);
160 elementSize
= 3 * sizeof(GLbyte
);
163 elementSize
= 3 * sizeof(GLshort
);
166 elementSize
= 3 * sizeof(GLint
);
169 elementSize
= 3 * sizeof(GLfloat
);
172 elementSize
= 3 * sizeof(GLdouble
);
176 elementSize
= 3 * sizeof(GLfixed
);
180 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
184 update_array(ctx
, &ctx
->Array
.ArrayObj
->Normal
, _NEW_ARRAY_NORMAL
,
185 elementSize
, 3, type
, stride
, GL_TRUE
, ptr
);
187 if (ctx
->Driver
.NormalPointer
)
188 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
193 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
196 GET_CURRENT_CONTEXT(ctx
);
197 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
199 if (size
< 3 || size
> 4) {
200 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(size)" );
204 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
208 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
209 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
210 _mesa_lookup_enum_by_nr( type
), stride
);
214 elementSize
= size
* sizeof(GLbyte
);
216 case GL_UNSIGNED_BYTE
:
217 elementSize
= size
* sizeof(GLubyte
);
220 elementSize
= size
* sizeof(GLshort
);
222 case GL_UNSIGNED_SHORT
:
223 elementSize
= size
* sizeof(GLushort
);
226 elementSize
= size
* sizeof(GLint
);
228 case GL_UNSIGNED_INT
:
229 elementSize
= size
* sizeof(GLuint
);
232 elementSize
= size
* sizeof(GLfloat
);
235 elementSize
= size
* sizeof(GLdouble
);
239 elementSize
= size
* sizeof(GLfixed
);
243 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
247 update_array(ctx
, &ctx
->Array
.ArrayObj
->Color
, _NEW_ARRAY_COLOR0
,
248 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
250 if (ctx
->Driver
.ColorPointer
)
251 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
256 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
259 GET_CURRENT_CONTEXT(ctx
);
260 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
263 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
269 elementSize
= sizeof(GLfloat
);
272 elementSize
= sizeof(GLdouble
);
275 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
279 update_array(ctx
, &ctx
->Array
.ArrayObj
->FogCoord
, _NEW_ARRAY_FOGCOORD
,
280 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
282 if (ctx
->Driver
.FogCoordPointer
)
283 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
288 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
291 GET_CURRENT_CONTEXT(ctx
);
292 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
295 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
300 case GL_UNSIGNED_BYTE
:
301 elementSize
= sizeof(GLubyte
);
304 elementSize
= sizeof(GLshort
);
307 elementSize
= sizeof(GLint
);
310 elementSize
= sizeof(GLfloat
);
313 elementSize
= sizeof(GLdouble
);
316 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
320 update_array(ctx
, &ctx
->Array
.ArrayObj
->Index
, _NEW_ARRAY_INDEX
,
321 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
323 if (ctx
->Driver
.IndexPointer
)
324 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
329 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
330 GLsizei stride
, const GLvoid
*ptr
)
333 GET_CURRENT_CONTEXT(ctx
);
334 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
336 if (size
!= 3 && size
!= 4) {
337 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)" );
341 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
345 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
346 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
347 size
, _mesa_lookup_enum_by_nr( type
), stride
);
351 elementSize
= size
* sizeof(GLbyte
);
353 case GL_UNSIGNED_BYTE
:
354 elementSize
= size
* sizeof(GLubyte
);
357 elementSize
= size
* sizeof(GLshort
);
359 case GL_UNSIGNED_SHORT
:
360 elementSize
= size
* sizeof(GLushort
);
363 elementSize
= size
* sizeof(GLint
);
365 case GL_UNSIGNED_INT
:
366 elementSize
= size
* sizeof(GLuint
);
369 elementSize
= size
* sizeof(GLfloat
);
372 elementSize
= size
* sizeof(GLdouble
);
375 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
379 update_array(ctx
, &ctx
->Array
.ArrayObj
->SecondaryColor
, _NEW_ARRAY_COLOR1
,
380 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
382 if (ctx
->Driver
.SecondaryColorPointer
)
383 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
388 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
392 GET_CURRENT_CONTEXT(ctx
);
393 const GLuint unit
= ctx
->Array
.ActiveTexture
;
394 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
396 if (size
< 1 || size
> 4) {
397 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
401 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
405 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
406 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
407 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
409 /* always need to check that <type> is legal */
412 elementSize
= size
* sizeof(GLshort
);
415 elementSize
= size
* sizeof(GLint
);
418 elementSize
= size
* sizeof(GLfloat
);
421 elementSize
= size
* sizeof(GLdouble
);
425 elementSize
= size
* sizeof(GLfixed
);
428 #if FEATURE_vertex_array_byte
430 elementSize
= size
* sizeof(GLbyte
);
434 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
438 update_array(ctx
, &ctx
->Array
.ArrayObj
->TexCoord
[unit
],
439 _NEW_ARRAY_TEXCOORD(unit
),
440 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
442 if (ctx
->Driver
.TexCoordPointer
)
443 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
448 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
450 GET_CURRENT_CONTEXT(ctx
);
451 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
454 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
458 update_array(ctx
, &ctx
->Array
.ArrayObj
->EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
459 sizeof(GLboolean
), 1, GL_UNSIGNED_BYTE
, stride
, GL_FALSE
, ptr
);
461 if (ctx
->Driver
.EdgeFlagPointer
)
462 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
467 _mesa_PointSizePointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
470 GET_CURRENT_CONTEXT(ctx
);
471 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
474 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSizePointer(stride)" );
480 elementSize
= sizeof(GLfloat
);
484 elementSize
= sizeof(GLfixed
);
488 _mesa_error( ctx
, GL_INVALID_ENUM
, "glPointSizePointer(type)" );
492 update_array(ctx
, &ctx
->Array
.ArrayObj
->PointSize
, _NEW_ARRAY_POINT_SIZE
,
493 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
497 #if FEATURE_NV_vertex_program
499 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
500 GLsizei stride
, const GLvoid
*ptr
)
502 GLboolean normalized
= GL_FALSE
;
504 GET_CURRENT_CONTEXT(ctx
);
505 ASSERT_OUTSIDE_BEGIN_END(ctx
);
507 if (index
>= MAX_VERTEX_PROGRAM_ATTRIBS
) {
508 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
512 if (size
< 1 || size
> 4) {
513 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
518 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
522 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
523 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
527 /* check for valid 'type' and compute StrideB right away */
529 case GL_UNSIGNED_BYTE
:
530 normalized
= GL_TRUE
;
531 elementSize
= size
* sizeof(GLubyte
);
534 elementSize
= size
* sizeof(GLshort
);
537 elementSize
= size
* sizeof(GLfloat
);
540 elementSize
= size
* sizeof(GLdouble
);
543 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
547 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
548 _NEW_ARRAY_ATTRIB(index
),
549 elementSize
, size
, type
, stride
, normalized
, ptr
);
551 if (ctx
->Driver
.VertexAttribPointer
)
552 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
557 #if FEATURE_ARB_vertex_program
559 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
560 GLboolean normalized
,
561 GLsizei stride
, const GLvoid
*ptr
)
564 GET_CURRENT_CONTEXT(ctx
);
565 ASSERT_OUTSIDE_BEGIN_END(ctx
);
567 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
568 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
572 if (size
< 1 || size
> 4) {
573 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
578 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
582 /* check for valid 'type' and compute StrideB right away */
583 /* NOTE: more types are supported here than in the NV extension */
586 elementSize
= size
* sizeof(GLbyte
);
588 case GL_UNSIGNED_BYTE
:
589 elementSize
= size
* sizeof(GLubyte
);
592 elementSize
= size
* sizeof(GLshort
);
594 case GL_UNSIGNED_SHORT
:
595 elementSize
= size
* sizeof(GLushort
);
598 elementSize
= size
* sizeof(GLint
);
600 case GL_UNSIGNED_INT
:
601 elementSize
= size
* sizeof(GLuint
);
604 elementSize
= size
* sizeof(GLfloat
);
607 elementSize
= size
* sizeof(GLdouble
);
611 elementSize
= size
* sizeof(GLfixed
);
615 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
619 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
620 _NEW_ARRAY_ATTRIB(index
),
621 elementSize
, size
, type
, stride
, normalized
, ptr
);
623 if (ctx
->Driver
.VertexAttribPointer
)
624 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
630 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
631 GLsizei count
, const GLvoid
*ptr
)
634 _mesa_VertexPointer(size
, type
, stride
, ptr
);
639 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
643 _mesa_NormalPointer(type
, stride
, ptr
);
648 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
652 _mesa_ColorPointer(size
, type
, stride
, ptr
);
657 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
661 _mesa_IndexPointer(type
, stride
, ptr
);
666 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
667 GLsizei count
, const GLvoid
*ptr
)
670 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
675 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
678 _mesa_EdgeFlagPointer(stride
, ptr
);
683 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
685 GET_CURRENT_CONTEXT(ctx
);
686 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
687 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
688 GLenum ctype
= 0; /* color type */
689 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
690 const GLint toffset
= 0; /* always zero */
691 GLint defstride
; /* default stride */
694 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
697 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
700 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
706 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
707 tcomps
= 0; ccomps
= 0; vcomps
= 2;
712 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
713 tcomps
= 0; ccomps
= 0; vcomps
= 3;
718 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
719 tcomps
= 0; ccomps
= 4; vcomps
= 2;
720 ctype
= GL_UNSIGNED_BYTE
;
726 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
727 tcomps
= 0; ccomps
= 4; vcomps
= 3;
728 ctype
= GL_UNSIGNED_BYTE
;
734 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
735 tcomps
= 0; ccomps
= 3; vcomps
= 3;
742 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
743 tcomps
= 0; ccomps
= 0; vcomps
= 3;
749 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
750 tcomps
= 0; ccomps
= 4; vcomps
= 3;
758 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
759 tcomps
= 2; ccomps
= 0; vcomps
= 3;
764 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
765 tcomps
= 4; ccomps
= 0; vcomps
= 4;
769 case GL_T2F_C4UB_V3F
:
770 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
771 tcomps
= 2; ccomps
= 4; vcomps
= 3;
772 ctype
= GL_UNSIGNED_BYTE
;
778 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
779 tcomps
= 2; ccomps
= 3; vcomps
= 3;
786 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
787 tcomps
= 2; ccomps
= 0; vcomps
= 3;
792 case GL_T2F_C4F_N3F_V3F
:
793 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
794 tcomps
= 2; ccomps
= 4; vcomps
= 3;
801 case GL_T4F_C4F_N3F_V4F
:
802 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
803 tcomps
= 4; ccomps
= 4; vcomps
= 4;
811 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
819 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
820 _mesa_DisableClientState( GL_INDEX_ARRAY
);
821 /* XXX also disable secondary color and generic arrays? */
825 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
826 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
827 (GLubyte
*) pointer
+ toffset
);
830 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
835 _mesa_EnableClientState( GL_COLOR_ARRAY
);
836 _mesa_ColorPointer( ccomps
, ctype
, stride
,
837 (GLubyte
*) pointer
+ coffset
);
840 _mesa_DisableClientState( GL_COLOR_ARRAY
);
846 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
847 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
850 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
854 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
855 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
856 (GLubyte
*) pointer
+ voffset
);
861 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
863 GET_CURRENT_CONTEXT(ctx
);
864 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
866 if (MESA_VERBOSE
& VERBOSE_API
)
867 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
870 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
874 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
877 if (ctx
->Array
.LockCount
!= 0) {
878 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
882 ctx
->Array
.LockFirst
= first
;
883 ctx
->Array
.LockCount
= count
;
885 ctx
->NewState
|= _NEW_ARRAY
;
886 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
888 if (ctx
->Driver
.LockArraysEXT
)
889 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
894 _mesa_UnlockArraysEXT( void )
896 GET_CURRENT_CONTEXT(ctx
);
897 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
899 if (MESA_VERBOSE
& VERBOSE_API
)
900 _mesa_debug(ctx
, "glUnlockArrays\n");
902 if (ctx
->Array
.LockCount
== 0) {
903 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
907 ctx
->Array
.LockFirst
= 0;
908 ctx
->Array
.LockCount
= 0;
909 ctx
->NewState
|= _NEW_ARRAY
;
910 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
912 if (ctx
->Driver
.UnlockArraysEXT
)
913 ctx
->Driver
.UnlockArraysEXT( ctx
);
917 /* GL_EXT_multi_draw_arrays */
918 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
920 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
921 GLsizei
*count
, GLsizei primcount
)
923 GET_CURRENT_CONTEXT(ctx
);
926 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
928 for (i
= 0; i
< primcount
; i
++) {
930 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
936 /* GL_EXT_multi_draw_arrays */
938 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
939 const GLvoid
**indices
, GLsizei primcount
)
941 GET_CURRENT_CONTEXT(ctx
);
944 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
946 for (i
= 0; i
< primcount
; i
++) {
948 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
954 /* GL_IBM_multimode_draw_arrays */
956 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
957 const GLsizei
* count
,
958 GLsizei primcount
, GLint modestride
)
960 GET_CURRENT_CONTEXT(ctx
);
963 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
965 for ( i
= 0 ; i
< primcount
; i
++ ) {
966 if ( count
[i
] > 0 ) {
967 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
968 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
974 /* GL_IBM_multimode_draw_arrays */
976 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
977 GLenum type
, const GLvoid
* const * indices
,
978 GLsizei primcount
, GLint modestride
)
980 GET_CURRENT_CONTEXT(ctx
);
983 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
985 /* XXX not sure about ARB_vertex_buffer_object handling here */
987 for ( i
= 0 ; i
< primcount
; i
++ ) {
988 if ( count
[i
] > 0 ) {
989 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
990 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
997 * Initialize vertex array state for given context.
1000 _mesa_init_varray(GLcontext
*ctx
)
1002 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
1003 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
1005 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */