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 #if FEATURE_ARB_vertex_buffer_object
67 _mesa_reference_buffer_object(ctx
, &array
->BufferObj
,
68 ctx
->Array
.ArrayBufferObj
);
70 /* Compute the index of the last array element that's inside the buffer.
71 * Later in glDrawArrays we'll check if start + count > _MaxElement to
72 * be sure we won't go out of bounds.
74 if (ctx
->Array
.ArrayBufferObj
->Name
)
75 array
->_MaxElement
= ((GLsizeiptrARB
) ctx
->Array
.ArrayBufferObj
->Size
76 - (GLsizeiptrARB
) array
->Ptr
+ array
->StrideB
77 - elementSize
) / array
->StrideB
;
80 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
82 ctx
->NewState
|= _NEW_ARRAY
;
83 ctx
->Array
.NewState
|= dirtyBit
;
88 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
91 GET_CURRENT_CONTEXT(ctx
);
92 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
94 if (size
< 2 || size
> 4) {
95 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(size)" );
99 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(stride)" );
103 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
104 _mesa_debug(ctx
, "glVertexPointer( sz %d type %s stride %d )\n", size
,
105 _mesa_lookup_enum_by_nr( type
), stride
);
107 /* always need to check that <type> is legal */
110 elementSize
= size
* sizeof(GLshort
);
113 elementSize
= size
* sizeof(GLint
);
116 elementSize
= size
* sizeof(GLfloat
);
119 elementSize
= size
* sizeof(GLdouble
);
123 elementSize
= size
* sizeof(GLfixed
);
126 #if FEATURE_vertex_array_byte
128 elementSize
= size
* sizeof(GLbyte
);
132 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
136 update_array(ctx
, &ctx
->Array
.ArrayObj
->Vertex
, _NEW_ARRAY_VERTEX
,
137 elementSize
, size
, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
139 if (ctx
->Driver
.VertexPointer
)
140 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
145 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
148 GET_CURRENT_CONTEXT(ctx
);
149 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
152 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
156 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
157 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
158 _mesa_lookup_enum_by_nr( type
), stride
);
162 elementSize
= 3 * sizeof(GLbyte
);
165 elementSize
= 3 * sizeof(GLshort
);
168 elementSize
= 3 * sizeof(GLint
);
171 elementSize
= 3 * sizeof(GLfloat
);
174 elementSize
= 3 * sizeof(GLdouble
);
178 elementSize
= 3 * sizeof(GLfixed
);
182 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
186 update_array(ctx
, &ctx
->Array
.ArrayObj
->Normal
, _NEW_ARRAY_NORMAL
,
187 elementSize
, 3, type
, GL_RGBA
, stride
, GL_TRUE
, ptr
);
189 if (ctx
->Driver
.NormalPointer
)
190 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
195 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
199 GET_CURRENT_CONTEXT(ctx
);
200 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
202 if (size
< 3 || size
> 4) {
203 if (!ctx
->Extensions
.EXT_vertex_array_bgra
|| size
!= GL_BGRA
) {
204 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorPointer(size)");
209 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
213 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
214 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
215 _mesa_lookup_enum_by_nr( type
), stride
);
217 if (size
== GL_BGRA
) {
218 if (type
!= GL_UNSIGNED_BYTE
) {
219 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorPointer(GL_BGRA/GLubyte)");
231 elementSize
= size
* sizeof(GLbyte
);
233 case GL_UNSIGNED_BYTE
:
234 elementSize
= size
* sizeof(GLubyte
);
237 elementSize
= size
* sizeof(GLshort
);
239 case GL_UNSIGNED_SHORT
:
240 elementSize
= size
* sizeof(GLushort
);
243 elementSize
= size
* sizeof(GLint
);
245 case GL_UNSIGNED_INT
:
246 elementSize
= size
* sizeof(GLuint
);
249 elementSize
= size
* sizeof(GLfloat
);
252 elementSize
= size
* sizeof(GLdouble
);
256 elementSize
= size
* sizeof(GLfixed
);
260 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
264 update_array(ctx
, &ctx
->Array
.ArrayObj
->Color
, _NEW_ARRAY_COLOR0
,
265 elementSize
, size
, type
, format
, stride
, GL_TRUE
, ptr
);
267 if (ctx
->Driver
.ColorPointer
)
268 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
273 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
276 GET_CURRENT_CONTEXT(ctx
);
277 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
280 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
286 elementSize
= sizeof(GLfloat
);
289 elementSize
= sizeof(GLdouble
);
292 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
296 update_array(ctx
, &ctx
->Array
.ArrayObj
->FogCoord
, _NEW_ARRAY_FOGCOORD
,
297 elementSize
, 1, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
299 if (ctx
->Driver
.FogCoordPointer
)
300 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
305 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
308 GET_CURRENT_CONTEXT(ctx
);
309 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
312 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
317 case GL_UNSIGNED_BYTE
:
318 elementSize
= sizeof(GLubyte
);
321 elementSize
= sizeof(GLshort
);
324 elementSize
= sizeof(GLint
);
327 elementSize
= sizeof(GLfloat
);
330 elementSize
= sizeof(GLdouble
);
333 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
337 update_array(ctx
, &ctx
->Array
.ArrayObj
->Index
, _NEW_ARRAY_INDEX
,
338 elementSize
, 1, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
340 if (ctx
->Driver
.IndexPointer
)
341 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
346 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
347 GLsizei stride
, const GLvoid
*ptr
)
351 GET_CURRENT_CONTEXT(ctx
);
352 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
354 if (size
!= 3 && size
!= 4) {
355 if (!ctx
->Extensions
.EXT_vertex_array_bgra
|| size
!= GL_BGRA
) {
356 _mesa_error(ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)");
361 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
365 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
366 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
367 size
, _mesa_lookup_enum_by_nr( type
), stride
);
369 if (size
== GL_BGRA
) {
370 if (type
!= GL_UNSIGNED_BYTE
) {
371 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorPointer(GL_BGRA/GLubyte)");
383 elementSize
= size
* sizeof(GLbyte
);
385 case GL_UNSIGNED_BYTE
:
386 elementSize
= size
* sizeof(GLubyte
);
389 elementSize
= size
* sizeof(GLshort
);
391 case GL_UNSIGNED_SHORT
:
392 elementSize
= size
* sizeof(GLushort
);
395 elementSize
= size
* sizeof(GLint
);
397 case GL_UNSIGNED_INT
:
398 elementSize
= size
* sizeof(GLuint
);
401 elementSize
= size
* sizeof(GLfloat
);
404 elementSize
= size
* sizeof(GLdouble
);
407 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
411 update_array(ctx
, &ctx
->Array
.ArrayObj
->SecondaryColor
, _NEW_ARRAY_COLOR1
,
412 elementSize
, size
, type
, format
, stride
, GL_TRUE
, ptr
);
414 if (ctx
->Driver
.SecondaryColorPointer
)
415 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
420 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
424 GET_CURRENT_CONTEXT(ctx
);
425 const GLuint unit
= ctx
->Array
.ActiveTexture
;
426 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
428 if (size
< 1 || size
> 4) {
429 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
433 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
437 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
438 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
439 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
441 /* always need to check that <type> is legal */
444 elementSize
= size
* sizeof(GLshort
);
447 elementSize
= size
* sizeof(GLint
);
450 elementSize
= size
* sizeof(GLfloat
);
453 elementSize
= size
* sizeof(GLdouble
);
457 elementSize
= size
* sizeof(GLfixed
);
460 #if FEATURE_vertex_array_byte
462 elementSize
= size
* sizeof(GLbyte
);
466 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
470 update_array(ctx
, &ctx
->Array
.ArrayObj
->TexCoord
[unit
],
471 _NEW_ARRAY_TEXCOORD(unit
),
472 elementSize
, size
, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
474 if (ctx
->Driver
.TexCoordPointer
)
475 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
480 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
482 GET_CURRENT_CONTEXT(ctx
);
483 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
486 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
490 update_array(ctx
, &ctx
->Array
.ArrayObj
->EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
491 sizeof(GLboolean
), 1, GL_UNSIGNED_BYTE
, GL_RGBA
,
492 stride
, GL_FALSE
, ptr
);
494 if (ctx
->Driver
.EdgeFlagPointer
)
495 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
500 _mesa_PointSizePointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
503 GET_CURRENT_CONTEXT(ctx
);
504 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
507 _mesa_error( ctx
, GL_INVALID_VALUE
, "glPointSizePointer(stride)" );
513 elementSize
= sizeof(GLfloat
);
517 elementSize
= sizeof(GLfixed
);
521 _mesa_error( ctx
, GL_INVALID_ENUM
, "glPointSizePointer(type)" );
525 update_array(ctx
, &ctx
->Array
.ArrayObj
->PointSize
, _NEW_ARRAY_POINT_SIZE
,
526 elementSize
, 1, type
, GL_RGBA
, stride
, GL_FALSE
, ptr
);
530 #if FEATURE_NV_vertex_program
532 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
533 GLsizei stride
, const GLvoid
*ptr
)
535 GLboolean normalized
= GL_FALSE
;
537 GET_CURRENT_CONTEXT(ctx
);
538 ASSERT_OUTSIDE_BEGIN_END(ctx
);
540 if (index
>= MAX_VERTEX_PROGRAM_ATTRIBS
) {
541 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
545 if (size
< 1 || size
> 4) {
546 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
551 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
555 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
556 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
560 /* check for valid 'type' and compute StrideB right away */
562 case GL_UNSIGNED_BYTE
:
563 normalized
= GL_TRUE
;
564 elementSize
= size
* sizeof(GLubyte
);
567 elementSize
= size
* sizeof(GLshort
);
570 elementSize
= size
* sizeof(GLfloat
);
573 elementSize
= size
* sizeof(GLdouble
);
576 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
580 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
581 _NEW_ARRAY_ATTRIB(index
),
582 elementSize
, size
, type
, GL_RGBA
, stride
, normalized
, ptr
);
584 if (ctx
->Driver
.VertexAttribPointer
)
585 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
590 #if FEATURE_ARB_vertex_program
592 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
593 GLboolean normalized
,
594 GLsizei stride
, const GLvoid
*ptr
)
598 GET_CURRENT_CONTEXT(ctx
);
599 ASSERT_OUTSIDE_BEGIN_END(ctx
);
601 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
602 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
606 if (size
< 1 || size
> 4) {
607 if (!ctx
->Extensions
.EXT_vertex_array_bgra
|| size
!= GL_BGRA
) {
608 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
614 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
618 if (size
== GL_BGRA
) {
619 if (type
!= GL_UNSIGNED_BYTE
) {
620 _mesa_error(ctx
, GL_INVALID_VALUE
,
621 "glVertexAttribPointerARB(GL_BGRA/type)");
626 normalized
= GL_TRUE
;
632 /* check for valid 'type' and compute StrideB right away */
633 /* NOTE: more types are supported here than in the NV extension */
636 elementSize
= size
* sizeof(GLbyte
);
638 case GL_UNSIGNED_BYTE
:
639 elementSize
= size
* sizeof(GLubyte
);
642 elementSize
= size
* sizeof(GLshort
);
644 case GL_UNSIGNED_SHORT
:
645 elementSize
= size
* sizeof(GLushort
);
648 elementSize
= size
* sizeof(GLint
);
650 case GL_UNSIGNED_INT
:
651 elementSize
= size
* sizeof(GLuint
);
654 elementSize
= size
* sizeof(GLfloat
);
657 elementSize
= size
* sizeof(GLdouble
);
661 elementSize
= size
* sizeof(GLfixed
);
665 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
669 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
670 _NEW_ARRAY_ATTRIB(index
),
671 elementSize
, size
, type
, GL_RGBA
, stride
, normalized
, ptr
);
673 if (ctx
->Driver
.VertexAttribPointer
)
674 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
680 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
681 GLsizei count
, const GLvoid
*ptr
)
684 _mesa_VertexPointer(size
, type
, stride
, ptr
);
689 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
693 _mesa_NormalPointer(type
, stride
, ptr
);
698 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
702 _mesa_ColorPointer(size
, type
, stride
, ptr
);
707 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
711 _mesa_IndexPointer(type
, stride
, ptr
);
716 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
717 GLsizei count
, const GLvoid
*ptr
)
720 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
725 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
728 _mesa_EdgeFlagPointer(stride
, ptr
);
733 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
735 GET_CURRENT_CONTEXT(ctx
);
736 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
737 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
738 GLenum ctype
= 0; /* color type */
739 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
740 const GLint toffset
= 0; /* always zero */
741 GLint defstride
; /* default stride */
744 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
747 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
750 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
756 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
757 tcomps
= 0; ccomps
= 0; vcomps
= 2;
762 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
763 tcomps
= 0; ccomps
= 0; vcomps
= 3;
768 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
769 tcomps
= 0; ccomps
= 4; vcomps
= 2;
770 ctype
= GL_UNSIGNED_BYTE
;
776 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
777 tcomps
= 0; ccomps
= 4; vcomps
= 3;
778 ctype
= GL_UNSIGNED_BYTE
;
784 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
785 tcomps
= 0; ccomps
= 3; vcomps
= 3;
792 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
793 tcomps
= 0; ccomps
= 0; vcomps
= 3;
799 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
800 tcomps
= 0; ccomps
= 4; vcomps
= 3;
808 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
809 tcomps
= 2; ccomps
= 0; vcomps
= 3;
814 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
815 tcomps
= 4; ccomps
= 0; vcomps
= 4;
819 case GL_T2F_C4UB_V3F
:
820 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
821 tcomps
= 2; ccomps
= 4; vcomps
= 3;
822 ctype
= GL_UNSIGNED_BYTE
;
828 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
829 tcomps
= 2; ccomps
= 3; vcomps
= 3;
836 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
837 tcomps
= 2; ccomps
= 0; vcomps
= 3;
842 case GL_T2F_C4F_N3F_V3F
:
843 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
844 tcomps
= 2; ccomps
= 4; vcomps
= 3;
851 case GL_T4F_C4F_N3F_V4F
:
852 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
853 tcomps
= 4; ccomps
= 4; vcomps
= 4;
861 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
869 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
870 _mesa_DisableClientState( GL_INDEX_ARRAY
);
871 /* XXX also disable secondary color and generic arrays? */
875 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
876 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
877 (GLubyte
*) pointer
+ toffset
);
880 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
885 _mesa_EnableClientState( GL_COLOR_ARRAY
);
886 _mesa_ColorPointer( ccomps
, ctype
, stride
,
887 (GLubyte
*) pointer
+ coffset
);
890 _mesa_DisableClientState( GL_COLOR_ARRAY
);
896 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
897 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
900 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
904 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
905 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
906 (GLubyte
*) pointer
+ voffset
);
911 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
913 GET_CURRENT_CONTEXT(ctx
);
914 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
916 if (MESA_VERBOSE
& VERBOSE_API
)
917 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
920 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
924 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
927 if (ctx
->Array
.LockCount
!= 0) {
928 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
932 ctx
->Array
.LockFirst
= first
;
933 ctx
->Array
.LockCount
= count
;
935 ctx
->NewState
|= _NEW_ARRAY
;
936 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
938 if (ctx
->Driver
.LockArraysEXT
)
939 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
944 _mesa_UnlockArraysEXT( void )
946 GET_CURRENT_CONTEXT(ctx
);
947 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
949 if (MESA_VERBOSE
& VERBOSE_API
)
950 _mesa_debug(ctx
, "glUnlockArrays\n");
952 if (ctx
->Array
.LockCount
== 0) {
953 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
957 ctx
->Array
.LockFirst
= 0;
958 ctx
->Array
.LockCount
= 0;
959 ctx
->NewState
|= _NEW_ARRAY
;
960 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
962 if (ctx
->Driver
.UnlockArraysEXT
)
963 ctx
->Driver
.UnlockArraysEXT( ctx
);
967 /* GL_EXT_multi_draw_arrays */
968 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
970 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
971 GLsizei
*count
, GLsizei primcount
)
973 GET_CURRENT_CONTEXT(ctx
);
976 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
978 for (i
= 0; i
< primcount
; i
++) {
980 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
986 /* GL_EXT_multi_draw_arrays */
988 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
989 const GLvoid
**indices
, GLsizei primcount
)
991 GET_CURRENT_CONTEXT(ctx
);
994 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
996 for (i
= 0; i
< primcount
; i
++) {
998 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
1004 /* GL_IBM_multimode_draw_arrays */
1006 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
1007 const GLsizei
* count
,
1008 GLsizei primcount
, GLint modestride
)
1010 GET_CURRENT_CONTEXT(ctx
);
1013 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
1015 for ( i
= 0 ; i
< primcount
; i
++ ) {
1016 if ( count
[i
] > 0 ) {
1017 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
1018 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
1024 /* GL_IBM_multimode_draw_arrays */
1026 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
1027 GLenum type
, const GLvoid
* const * indices
,
1028 GLsizei primcount
, GLint modestride
)
1030 GET_CURRENT_CONTEXT(ctx
);
1033 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
1035 /* XXX not sure about ARB_vertex_buffer_object handling here */
1037 for ( i
= 0 ; i
< primcount
; i
++ ) {
1038 if ( count
[i
] > 0 ) {
1039 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
1040 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
1047 * Initialize vertex array state for given context.
1050 _mesa_init_varray(GLcontext
*ctx
)
1052 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
1053 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
1055 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */