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
, GLenum format
,
56 GLsizei stride
, GLboolean normalized
, const GLvoid
*ptr
)
58 ASSERT(format
== GL_RGBA
|| format
== GL_BGRA
);
61 array
->Format
= format
;
62 array
->Stride
= stride
;
63 array
->StrideB
= stride
? stride
: elementSize
;
64 array
->Normalized
= normalized
;
65 array
->Ptr
= (const GLubyte
*) ptr
;
66 array
->_ElementSize
= elementSize
;
68 #if FEATURE_ARB_vertex_buffer_object
69 _mesa_reference_buffer_object(ctx
, &array
->BufferObj
,
70 ctx
->Array
.ArrayBufferObj
);
72 /* Compute the index of the last array element that's inside the buffer.
73 * Later in glDrawArrays we'll check if start + count > _MaxElement to
74 * be sure we won't go out of bounds.
76 if (array
->BufferObj
->Name
)
77 array
->_MaxElement
= ((GLsizeiptrARB
) array
->BufferObj
->Size
78 - (GLsizeiptrARB
) array
->Ptr
+ array
->StrideB
79 - elementSize
) / array
->StrideB
;
82 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
84 ctx
->NewState
|= _NEW_ARRAY
;
85 ctx
->Array
.NewState
|= dirtyBit
;
90 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
93 GET_CURRENT_CONTEXT(ctx
);
94 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
96 if (size
< 2 || size
> 4) {
97 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(size)" );
101 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(stride)" );
105 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
106 _mesa_debug(ctx
, "glVertexPointer( sz %d type %s stride %d )\n", size
,
107 _mesa_lookup_enum_by_nr( type
), stride
);
109 /* always need to check that <type> is legal */
112 elementSize
= size
* sizeof(GLshort
);
115 elementSize
= size
* sizeof(GLint
);
118 elementSize
= size
* sizeof(GLfloat
);
121 elementSize
= size
* sizeof(GLdouble
);
125 elementSize
= size
* sizeof(GLfixed
);
128 #if FEATURE_vertex_array_byte
130 elementSize
= size
* sizeof(GLbyte
);
134 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
138 update_array(ctx
, &ctx
->Array
.ArrayObj
->Vertex
, _NEW_ARRAY_VERTEX
,
139 elementSize
, size
, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
141 if (ctx
->Driver
.VertexPointer
)
142 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
147 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
150 GET_CURRENT_CONTEXT(ctx
);
151 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
154 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
158 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
159 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
160 _mesa_lookup_enum_by_nr( type
), stride
);
164 elementSize
= 3 * sizeof(GLbyte
);
167 elementSize
= 3 * sizeof(GLshort
);
170 elementSize
= 3 * sizeof(GLint
);
173 elementSize
= 3 * sizeof(GLfloat
);
176 elementSize
= 3 * sizeof(GLdouble
);
180 elementSize
= 3 * sizeof(GLfixed
);
184 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
188 update_array(ctx
, &ctx
->Array
.ArrayObj
->Normal
, _NEW_ARRAY_NORMAL
,
189 elementSize
, 3, type
, GL_RGBA
, stride
, GL_TRUE
, ptr
);
191 if (ctx
->Driver
.NormalPointer
)
192 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
197 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
201 GET_CURRENT_CONTEXT(ctx
);
202 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
204 if (size
< 3 || size
> 4) {
205 if (!ctx
->Extensions
.EXT_vertex_array_bgra
|| size
!= GL_BGRA
) {
206 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorPointer(size)");
211 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
215 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
216 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
217 _mesa_lookup_enum_by_nr( type
), stride
);
219 if (size
== GL_BGRA
) {
220 if (type
!= GL_UNSIGNED_BYTE
) {
221 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorPointer(GL_BGRA/GLubyte)");
233 elementSize
= size
* sizeof(GLbyte
);
235 case GL_UNSIGNED_BYTE
:
236 elementSize
= size
* sizeof(GLubyte
);
239 elementSize
= size
* sizeof(GLshort
);
241 case GL_UNSIGNED_SHORT
:
242 elementSize
= size
* sizeof(GLushort
);
245 elementSize
= size
* sizeof(GLint
);
247 case GL_UNSIGNED_INT
:
248 elementSize
= size
* sizeof(GLuint
);
251 elementSize
= size
* sizeof(GLfloat
);
254 elementSize
= size
* sizeof(GLdouble
);
258 elementSize
= size
* sizeof(GLfixed
);
262 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
266 update_array(ctx
, &ctx
->Array
.ArrayObj
->Color
, _NEW_ARRAY_COLOR0
,
267 elementSize
, size
, type
, format
, stride
, GL_TRUE
, ptr
);
269 if (ctx
->Driver
.ColorPointer
)
270 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
275 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
278 GET_CURRENT_CONTEXT(ctx
);
279 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
282 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
288 elementSize
= sizeof(GLfloat
);
291 elementSize
= sizeof(GLdouble
);
294 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
298 update_array(ctx
, &ctx
->Array
.ArrayObj
->FogCoord
, _NEW_ARRAY_FOGCOORD
,
299 elementSize
, 1, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
301 if (ctx
->Driver
.FogCoordPointer
)
302 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
307 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
310 GET_CURRENT_CONTEXT(ctx
);
311 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
314 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
319 case GL_UNSIGNED_BYTE
:
320 elementSize
= sizeof(GLubyte
);
323 elementSize
= sizeof(GLshort
);
326 elementSize
= sizeof(GLint
);
329 elementSize
= sizeof(GLfloat
);
332 elementSize
= sizeof(GLdouble
);
335 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
339 update_array(ctx
, &ctx
->Array
.ArrayObj
->Index
, _NEW_ARRAY_INDEX
,
340 elementSize
, 1, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
342 if (ctx
->Driver
.IndexPointer
)
343 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
348 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
349 GLsizei stride
, const GLvoid
*ptr
)
353 GET_CURRENT_CONTEXT(ctx
);
354 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
356 if (size
!= 3 && size
!= 4) {
357 if (!ctx
->Extensions
.EXT_vertex_array_bgra
|| size
!= GL_BGRA
) {
358 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)");
363 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
367 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
368 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
369 size
, _mesa_lookup_enum_by_nr( type
), stride
);
371 if (size
== GL_BGRA
) {
372 if (type
!= GL_UNSIGNED_BYTE
) {
373 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorPointer(GL_BGRA/GLubyte)");
385 elementSize
= size
* sizeof(GLbyte
);
387 case GL_UNSIGNED_BYTE
:
388 elementSize
= size
* sizeof(GLubyte
);
391 elementSize
= size
* sizeof(GLshort
);
393 case GL_UNSIGNED_SHORT
:
394 elementSize
= size
* sizeof(GLushort
);
397 elementSize
= size
* sizeof(GLint
);
399 case GL_UNSIGNED_INT
:
400 elementSize
= size
* sizeof(GLuint
);
403 elementSize
= size
* sizeof(GLfloat
);
406 elementSize
= size
* sizeof(GLdouble
);
409 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
413 update_array(ctx
, &ctx
->Array
.ArrayObj
->SecondaryColor
, _NEW_ARRAY_COLOR1
,
414 elementSize
, size
, type
, format
, stride
, GL_TRUE
, ptr
);
416 if (ctx
->Driver
.SecondaryColorPointer
)
417 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
422 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
426 GET_CURRENT_CONTEXT(ctx
);
427 const GLuint unit
= ctx
->Array
.ActiveTexture
;
428 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
430 if (size
< 1 || size
> 4) {
431 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
435 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
439 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
440 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
441 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
443 /* always need to check that <type> is legal */
446 elementSize
= size
* sizeof(GLshort
);
449 elementSize
= size
* sizeof(GLint
);
452 elementSize
= size
* sizeof(GLfloat
);
455 elementSize
= size
* sizeof(GLdouble
);
459 elementSize
= size
* sizeof(GLfixed
);
462 #if FEATURE_vertex_array_byte
464 elementSize
= size
* sizeof(GLbyte
);
468 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
472 update_array(ctx
, &ctx
->Array
.ArrayObj
->TexCoord
[unit
],
473 _NEW_ARRAY_TEXCOORD(unit
),
474 elementSize
, size
, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
476 if (ctx
->Driver
.TexCoordPointer
)
477 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
482 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
484 GET_CURRENT_CONTEXT(ctx
);
485 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
488 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
492 update_array(ctx
, &ctx
->Array
.ArrayObj
->EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
493 sizeof(GLboolean
), 1, GL_UNSIGNED_BYTE
, GL_RGBA
,
494 stride
, GL_FALSE
, ptr
);
496 if (ctx
->Driver
.EdgeFlagPointer
)
497 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
502 _mesa_PointSizePointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
505 GET_CURRENT_CONTEXT(ctx
);
506 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
509 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSizePointer(stride)" );
515 elementSize
= sizeof(GLfloat
);
519 elementSize
= sizeof(GLfixed
);
523 _mesa_error( ctx
, GL_INVALID_ENUM
, "glPointSizePointer(type)" );
527 update_array(ctx
, &ctx
->Array
.ArrayObj
->PointSize
, _NEW_ARRAY_POINT_SIZE
,
528 elementSize
, 1, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
532 #if FEATURE_NV_vertex_program
534 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
535 GLsizei stride
, const GLvoid
*ptr
)
537 GLboolean normalized
= GL_FALSE
;
539 GET_CURRENT_CONTEXT(ctx
);
540 ASSERT_OUTSIDE_BEGIN_END(ctx
);
542 if (index
>= MAX_VERTEX_PROGRAM_ATTRIBS
) {
543 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
547 if (size
< 1 || size
> 4) {
548 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
553 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
557 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
558 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
562 /* check for valid 'type' and compute StrideB right away */
564 case GL_UNSIGNED_BYTE
:
565 normalized
= GL_TRUE
;
566 elementSize
= size
* sizeof(GLubyte
);
569 elementSize
= size
* sizeof(GLshort
);
572 elementSize
= size
* sizeof(GLfloat
);
575 elementSize
= size
* sizeof(GLdouble
);
578 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
582 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
583 _NEW_ARRAY_ATTRIB(index
),
584 elementSize
, size
, type
, GL_RGBA
, stride
, normalized
, ptr
);
586 if (ctx
->Driver
.VertexAttribPointer
)
587 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
592 #if FEATURE_ARB_vertex_program
594 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
595 GLboolean normalized
,
596 GLsizei stride
, const GLvoid
*ptr
)
600 GET_CURRENT_CONTEXT(ctx
);
601 ASSERT_OUTSIDE_BEGIN_END(ctx
);
603 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
604 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
608 if (size
< 1 || size
> 4) {
609 if (!ctx
->Extensions
.EXT_vertex_array_bgra
|| size
!= GL_BGRA
) {
610 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
616 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
620 if (size
== GL_BGRA
) {
621 if (type
!= GL_UNSIGNED_BYTE
) {
622 _mesa_error(ctx
, GL_INVALID_VALUE
,
623 "glVertexAttribPointerARB(GL_BGRA/type)");
628 normalized
= GL_TRUE
;
634 /* check for valid 'type' and compute StrideB right away */
635 /* NOTE: more types are supported here than in the NV extension */
638 elementSize
= size
* sizeof(GLbyte
);
640 case GL_UNSIGNED_BYTE
:
641 elementSize
= size
* sizeof(GLubyte
);
644 elementSize
= size
* sizeof(GLshort
);
646 case GL_UNSIGNED_SHORT
:
647 elementSize
= size
* sizeof(GLushort
);
650 elementSize
= size
* sizeof(GLint
);
652 case GL_UNSIGNED_INT
:
653 elementSize
= size
* sizeof(GLuint
);
656 elementSize
= size
* sizeof(GLfloat
);
659 elementSize
= size
* sizeof(GLdouble
);
663 elementSize
= size
* sizeof(GLfixed
);
667 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
671 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
672 _NEW_ARRAY_ATTRIB(index
),
673 elementSize
, size
, type
, GL_RGBA
, stride
, normalized
, ptr
);
675 if (ctx
->Driver
.VertexAttribPointer
)
676 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
682 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
683 GLsizei count
, const GLvoid
*ptr
)
686 _mesa_VertexPointer(size
, type
, stride
, ptr
);
691 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
695 _mesa_NormalPointer(type
, stride
, ptr
);
700 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
704 _mesa_ColorPointer(size
, type
, stride
, ptr
);
709 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
713 _mesa_IndexPointer(type
, stride
, ptr
);
718 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
719 GLsizei count
, const GLvoid
*ptr
)
722 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
727 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
730 _mesa_EdgeFlagPointer(stride
, ptr
);
735 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
737 GET_CURRENT_CONTEXT(ctx
);
738 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
739 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
740 GLenum ctype
= 0; /* color type */
741 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
742 const GLint toffset
= 0; /* always zero */
743 GLint defstride
; /* default stride */
746 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
749 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
752 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
758 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
759 tcomps
= 0; ccomps
= 0; vcomps
= 2;
764 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
765 tcomps
= 0; ccomps
= 0; vcomps
= 3;
770 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
771 tcomps
= 0; ccomps
= 4; vcomps
= 2;
772 ctype
= GL_UNSIGNED_BYTE
;
778 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
779 tcomps
= 0; ccomps
= 4; vcomps
= 3;
780 ctype
= GL_UNSIGNED_BYTE
;
786 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
787 tcomps
= 0; ccomps
= 3; vcomps
= 3;
794 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
795 tcomps
= 0; ccomps
= 0; vcomps
= 3;
801 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
802 tcomps
= 0; ccomps
= 4; vcomps
= 3;
810 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
811 tcomps
= 2; ccomps
= 0; vcomps
= 3;
816 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
817 tcomps
= 4; ccomps
= 0; vcomps
= 4;
821 case GL_T2F_C4UB_V3F
:
822 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
823 tcomps
= 2; ccomps
= 4; vcomps
= 3;
824 ctype
= GL_UNSIGNED_BYTE
;
830 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
831 tcomps
= 2; ccomps
= 3; vcomps
= 3;
838 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
839 tcomps
= 2; ccomps
= 0; vcomps
= 3;
844 case GL_T2F_C4F_N3F_V3F
:
845 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
846 tcomps
= 2; ccomps
= 4; vcomps
= 3;
853 case GL_T4F_C4F_N3F_V4F
:
854 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
855 tcomps
= 4; ccomps
= 4; vcomps
= 4;
863 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
871 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
872 _mesa_DisableClientState( GL_INDEX_ARRAY
);
873 /* XXX also disable secondary color and generic arrays? */
877 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
878 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
879 (GLubyte
*) pointer
+ toffset
);
882 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
887 _mesa_EnableClientState( GL_COLOR_ARRAY
);
888 _mesa_ColorPointer( ccomps
, ctype
, stride
,
889 (GLubyte
*) pointer
+ coffset
);
892 _mesa_DisableClientState( GL_COLOR_ARRAY
);
898 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
899 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
902 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
906 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
907 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
908 (GLubyte
*) pointer
+ voffset
);
913 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
915 GET_CURRENT_CONTEXT(ctx
);
916 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
918 if (MESA_VERBOSE
& VERBOSE_API
)
919 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
922 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
926 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
929 if (ctx
->Array
.LockCount
!= 0) {
930 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
934 ctx
->Array
.LockFirst
= first
;
935 ctx
->Array
.LockCount
= count
;
937 ctx
->NewState
|= _NEW_ARRAY
;
938 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
940 if (ctx
->Driver
.LockArraysEXT
)
941 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
946 _mesa_UnlockArraysEXT( void )
948 GET_CURRENT_CONTEXT(ctx
);
949 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
951 if (MESA_VERBOSE
& VERBOSE_API
)
952 _mesa_debug(ctx
, "glUnlockArrays\n");
954 if (ctx
->Array
.LockCount
== 0) {
955 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
959 ctx
->Array
.LockFirst
= 0;
960 ctx
->Array
.LockCount
= 0;
961 ctx
->NewState
|= _NEW_ARRAY
;
962 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
964 if (ctx
->Driver
.UnlockArraysEXT
)
965 ctx
->Driver
.UnlockArraysEXT( ctx
);
969 /* GL_EXT_multi_draw_arrays */
970 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
972 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
973 GLsizei
*count
, GLsizei primcount
)
975 GET_CURRENT_CONTEXT(ctx
);
978 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
980 for (i
= 0; i
< primcount
; i
++) {
982 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
988 /* GL_EXT_multi_draw_arrays */
990 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
991 const GLvoid
**indices
, GLsizei primcount
)
993 GET_CURRENT_CONTEXT(ctx
);
996 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
998 for (i
= 0; i
< primcount
; i
++) {
1000 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
1006 /* GL_IBM_multimode_draw_arrays */
1008 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
1009 const GLsizei
* count
,
1010 GLsizei primcount
, GLint modestride
)
1012 GET_CURRENT_CONTEXT(ctx
);
1015 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
1017 for ( i
= 0 ; i
< primcount
; i
++ ) {
1018 if ( count
[i
] > 0 ) {
1019 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
1020 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
1026 /* GL_IBM_multimode_draw_arrays */
1028 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
1029 GLenum type
, const GLvoid
* const * indices
,
1030 GLsizei primcount
, GLint modestride
)
1032 GET_CURRENT_CONTEXT(ctx
);
1035 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
1037 /* XXX not sure about ARB_vertex_buffer_object handling here */
1039 for ( i
= 0 ; i
< primcount
; i
++ ) {
1040 if ( count
[i
] > 0 ) {
1041 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
1042 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
1049 * Initialize vertex array state for given context.
1052 _mesa_init_varray(GLcontext
*ctx
)
1054 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
1055 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
1057 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */