jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 3 | * Version: 6.5.1 |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 4 | * |
Michal Krol | bb38cad | 2006-04-11 11:41:11 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 6 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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: |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 13 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 14 | * The above copyright notice and this permission notice shall be included |
| 15 | * in all copies or substantial portions of the Software. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 16 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 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. |
| 23 | */ |
| 24 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 25 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 26 | #include "glheader.h" |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 27 | #include "imports.h" |
Brian Paul | 26895aa | 2004-03-03 15:35:08 +0000 | [diff] [blame] | 28 | #include "bufferobj.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 29 | #include "context.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 30 | #include "enable.h" |
| 31 | #include "enums.h" |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 32 | #include "mtypes.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 33 | #include "varray.h" |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 34 | #include "arrayobj.h" |
Brian | c223c6b | 2007-07-04 13:15:20 -0600 | [diff] [blame] | 35 | #include "glapi/dispatch.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 36 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 37 | |
| 38 | /** |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 39 | * Update the fields of a vertex array object. |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 40 | * We need to do a few special things for arrays that live in |
| 41 | * vertex buffer objects. |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 42 | * |
| 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 |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 51 | */ |
| 52 | static void |
| 53 | update_array(GLcontext *ctx, struct gl_client_array *array, |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 54 | GLbitfield dirtyBit, GLsizei elementSize, |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 55 | GLint size, GLenum type, |
| 56 | GLsizei stride, GLboolean normalized, const GLvoid *ptr) |
| 57 | { |
| 58 | array->Size = size; |
| 59 | array->Type = type; |
| 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 | array->BufferObj->RefCount--; |
Brian Paul | 2020278 | 2004-02-11 22:06:05 +0000 | [diff] [blame] | 66 | if (array->BufferObj->RefCount <= 0) { |
Brian Paul | 293ad98 | 2004-09-27 16:19:17 +0000 | [diff] [blame] | 67 | ASSERT(array->BufferObj->Name); |
Brian Paul | 26895aa | 2004-03-03 15:35:08 +0000 | [diff] [blame] | 68 | _mesa_remove_buffer_object( ctx, array->BufferObj ); |
Brian Paul | 2020278 | 2004-02-11 22:06:05 +0000 | [diff] [blame] | 69 | (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj ); |
| 70 | } |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 71 | array->BufferObj = ctx->Array.ArrayBufferObj; |
| 72 | array->BufferObj->RefCount++; |
| 73 | /* Compute the index of the last array element that's inside the buffer. |
| 74 | * Later in glDrawArrays we'll check if start + count > _MaxElement to |
| 75 | * be sure we won't go out of bounds. |
| 76 | */ |
| 77 | if (ctx->Array.ArrayBufferObj->Name) |
| 78 | array->_MaxElement = ((GLsizeiptrARB) ctx->Array.ArrayBufferObj->Size |
Roland Scheidegger | cda3236 | 2007-03-27 21:03:32 +0200 | [diff] [blame] | 79 | - (GLsizeiptrARB) array->Ptr + array->StrideB |
| 80 | - elementSize) / array->StrideB; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 81 | else |
| 82 | #endif |
| 83 | array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ |
| 84 | |
| 85 | ctx->NewState |= _NEW_ARRAY; |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 86 | ctx->Array.NewState |= dirtyBit; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 90 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 91 | _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 92 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 93 | GLsizei elementSize; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 94 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 95 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 96 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 97 | if (size < 2 || size > 4) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 98 | _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 99 | return; |
| 100 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 101 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 102 | _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 103 | return; |
| 104 | } |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 105 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 106 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 107 | _mesa_debug(ctx, "glVertexPointer( sz %d type %s stride %d )\n", size, |
| 108 | _mesa_lookup_enum_by_nr( type ), stride); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 109 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 110 | /* always need to check that <type> is legal */ |
| 111 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 112 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 113 | elementSize = size * sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 114 | break; |
| 115 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 116 | elementSize = size * sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 117 | break; |
| 118 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 119 | elementSize = size * sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 120 | break; |
| 121 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 122 | elementSize = size * sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 123 | break; |
| 124 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 125 | _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 126 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 127 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 128 | |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 129 | update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX, |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 130 | elementSize, size, type, stride, GL_FALSE, ptr); |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 131 | |
| 132 | if (ctx->Driver.VertexPointer) |
| 133 | ctx->Driver.VertexPointer( ctx, size, type, stride, ptr ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 137 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 138 | _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 139 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 140 | GLsizei elementSize; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 141 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 142 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 143 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 144 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 145 | _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 146 | return; |
| 147 | } |
| 148 | |
| 149 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 150 | _mesa_debug(ctx, "glNormalPointer( type %s stride %d )\n", |
| 151 | _mesa_lookup_enum_by_nr( type ), stride); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 152 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 153 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 154 | case GL_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 155 | elementSize = 3 * sizeof(GLbyte); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 156 | break; |
| 157 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 158 | elementSize = 3 * sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 159 | break; |
| 160 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 161 | elementSize = 3 * sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 162 | break; |
| 163 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 164 | elementSize = 3 * sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 165 | break; |
| 166 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 167 | elementSize = 3 * sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 168 | break; |
| 169 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 170 | _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 171 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 172 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 173 | |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 174 | update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL, |
Brian Paul | ad38681 | 2006-04-13 15:57:29 +0000 | [diff] [blame] | 175 | elementSize, 3, type, stride, GL_TRUE, ptr); |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 176 | |
| 177 | if (ctx->Driver.NormalPointer) |
| 178 | ctx->Driver.NormalPointer( ctx, type, stride, ptr ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 182 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 183 | _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 184 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 185 | GLsizei elementSize; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 186 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 187 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 188 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 189 | if (size < 3 || size > 4) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 190 | _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 191 | return; |
| 192 | } |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 193 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 194 | _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 195 | return; |
| 196 | } |
| 197 | |
| 198 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 199 | _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size, |
| 200 | _mesa_lookup_enum_by_nr( type ), stride); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 201 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 202 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 203 | case GL_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 204 | elementSize = size * sizeof(GLbyte); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 205 | break; |
| 206 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 207 | elementSize = size * sizeof(GLubyte); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 208 | break; |
| 209 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 210 | elementSize = size * sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 211 | break; |
| 212 | case GL_UNSIGNED_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 213 | elementSize = size * sizeof(GLushort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 214 | break; |
| 215 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 216 | elementSize = size * sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 217 | break; |
| 218 | case GL_UNSIGNED_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 219 | elementSize = size * sizeof(GLuint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 220 | break; |
| 221 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 222 | elementSize = size * sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 223 | break; |
| 224 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 225 | elementSize = size * sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 226 | break; |
| 227 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 228 | _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 229 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 230 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 231 | |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 232 | update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0, |
Brian Paul | ad38681 | 2006-04-13 15:57:29 +0000 | [diff] [blame] | 233 | elementSize, size, type, stride, GL_TRUE, ptr); |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 234 | |
| 235 | if (ctx->Driver.ColorPointer) |
| 236 | ctx->Driver.ColorPointer( ctx, size, type, stride, ptr ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 240 | void GLAPIENTRY |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 241 | _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) |
| 242 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 243 | GLint elementSize; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 244 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 245 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 246 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 247 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 248 | _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 249 | return; |
| 250 | } |
| 251 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 252 | switch (type) { |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 253 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 254 | elementSize = sizeof(GLfloat); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 255 | break; |
| 256 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 257 | elementSize = sizeof(GLdouble); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 258 | break; |
| 259 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 260 | _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 261 | return; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 262 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 263 | |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 264 | update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD, |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 265 | elementSize, 1, type, stride, GL_FALSE, ptr); |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 266 | |
| 267 | if (ctx->Driver.FogCoordPointer) |
| 268 | ctx->Driver.FogCoordPointer( ctx, type, stride, ptr ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 272 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 273 | _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 274 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 275 | GLsizei elementSize; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 276 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 277 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 278 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 279 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 280 | _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 281 | return; |
| 282 | } |
| 283 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 284 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 285 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 286 | elementSize = sizeof(GLubyte); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 287 | break; |
| 288 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 289 | elementSize = sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 290 | break; |
| 291 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 292 | elementSize = sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 293 | break; |
| 294 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 295 | elementSize = sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 296 | break; |
| 297 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 298 | elementSize = sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 299 | break; |
| 300 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 301 | _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 302 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 303 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 304 | |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 305 | update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX, |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 306 | elementSize, 1, type, stride, GL_FALSE, ptr); |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 307 | |
| 308 | if (ctx->Driver.IndexPointer) |
| 309 | ctx->Driver.IndexPointer( ctx, type, stride, ptr ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 313 | void GLAPIENTRY |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 314 | _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 315 | GLsizei stride, const GLvoid *ptr) |
| 316 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 317 | GLsizei elementSize; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 318 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 319 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 320 | |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 321 | if (size != 3 && size != 4) { |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 322 | _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)" ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 323 | return; |
| 324 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 325 | if (stride < 0) { |
| 326 | _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 327 | return; |
| 328 | } |
| 329 | |
| 330 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 331 | _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n", |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 332 | size, _mesa_lookup_enum_by_nr( type ), stride); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 333 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 334 | switch (type) { |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 335 | case GL_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 336 | elementSize = size * sizeof(GLbyte); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 337 | break; |
| 338 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 339 | elementSize = size * sizeof(GLubyte); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 340 | break; |
| 341 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 342 | elementSize = size * sizeof(GLshort); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 343 | break; |
| 344 | case GL_UNSIGNED_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 345 | elementSize = size * sizeof(GLushort); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 346 | break; |
| 347 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 348 | elementSize = size * sizeof(GLint); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 349 | break; |
| 350 | case GL_UNSIGNED_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 351 | elementSize = size * sizeof(GLuint); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 352 | break; |
| 353 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 354 | elementSize = size * sizeof(GLfloat); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 355 | break; |
| 356 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 357 | elementSize = size * sizeof(GLdouble); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 358 | break; |
| 359 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 360 | _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 361 | return; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 362 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 363 | |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 364 | update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1, |
Brian Paul | ad38681 | 2006-04-13 15:57:29 +0000 | [diff] [blame] | 365 | elementSize, size, type, stride, GL_TRUE, ptr); |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 366 | |
| 367 | if (ctx->Driver.SecondaryColorPointer) |
| 368 | ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 372 | void GLAPIENTRY |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 373 | _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, |
| 374 | const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 375 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 376 | GLint elementSize; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 377 | GET_CURRENT_CONTEXT(ctx); |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 378 | const GLuint unit = ctx->Array.ActiveTexture; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 379 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 380 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 381 | if (size < 1 || size > 4) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 382 | _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 383 | return; |
| 384 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 385 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 386 | _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 387 | return; |
| 388 | } |
| 389 | |
| 390 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 391 | _mesa_debug(ctx, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n", |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 392 | unit, size, _mesa_lookup_enum_by_nr( type ), stride); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 393 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 394 | /* always need to check that <type> is legal */ |
| 395 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 396 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 397 | elementSize = size * sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 398 | break; |
| 399 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 400 | elementSize = size * sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 401 | break; |
| 402 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 403 | elementSize = size * sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 404 | break; |
| 405 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 406 | elementSize = size * sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 407 | break; |
| 408 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 409 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 410 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 411 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 412 | |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 413 | update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit], |
| 414 | _NEW_ARRAY_TEXCOORD(unit), |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 415 | elementSize, size, type, stride, GL_FALSE, ptr); |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 416 | |
| 417 | if (ctx->Driver.TexCoordPointer) |
| 418 | ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 422 | void GLAPIENTRY |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 423 | _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 424 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 425 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 426 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 427 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 428 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 429 | _mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 430 | return; |
| 431 | } |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 432 | |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 433 | update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG, |
Brian Paul | c78e895 | 2006-09-04 14:07:04 +0000 | [diff] [blame] | 434 | sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, ptr); |
Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 435 | |
| 436 | if (ctx->Driver.EdgeFlagPointer) |
| 437 | ctx->Driver.EdgeFlagPointer( ctx, stride, ptr ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 441 | #if FEATURE_NV_vertex_program |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 442 | void GLAPIENTRY |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 443 | _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, |
| 444 | GLsizei stride, const GLvoid *ptr) |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 445 | { |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 446 | const GLboolean normalized = GL_FALSE; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 447 | GLsizei elementSize; |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 448 | GET_CURRENT_CONTEXT(ctx); |
| 449 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 450 | |
Michal Krol | bb38cad | 2006-04-11 11:41:11 +0000 | [diff] [blame] | 451 | if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) { |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 452 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); |
| 453 | return; |
| 454 | } |
| 455 | |
| 456 | if (size < 1 || size > 4) { |
| 457 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size)"); |
| 458 | return; |
| 459 | } |
| 460 | |
| 461 | if (stride < 0) { |
| 462 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(stride)"); |
| 463 | return; |
| 464 | } |
| 465 | |
| 466 | if (type == GL_UNSIGNED_BYTE && size != 4) { |
| 467 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)"); |
| 468 | return; |
| 469 | } |
| 470 | |
| 471 | /* check for valid 'type' and compute StrideB right away */ |
| 472 | switch (type) { |
| 473 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 474 | elementSize = size * sizeof(GLubyte); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 475 | break; |
| 476 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 477 | elementSize = size * sizeof(GLshort); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 478 | break; |
| 479 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 480 | elementSize = size * sizeof(GLfloat); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 481 | break; |
| 482 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 483 | elementSize = size * sizeof(GLdouble); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 484 | break; |
| 485 | default: |
| 486 | _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type)" ); |
| 487 | return; |
| 488 | } |
| 489 | |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 490 | update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], |
| 491 | _NEW_ARRAY_ATTRIB(index), |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 492 | elementSize, size, type, stride, normalized, ptr); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 493 | |
Brian Paul | b775272 | 2002-04-21 18:49:18 +0000 | [diff] [blame] | 494 | if (ctx->Driver.VertexAttribPointer) |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 495 | ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr ); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 496 | } |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 497 | #endif |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 498 | |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 499 | |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 500 | #if FEATURE_ARB_vertex_program |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 501 | void GLAPIENTRY |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 502 | _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, |
| 503 | GLboolean normalized, |
| 504 | GLsizei stride, const GLvoid *ptr) |
| 505 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 506 | GLsizei elementSize; |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 507 | GET_CURRENT_CONTEXT(ctx); |
| 508 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 509 | |
Brian Paul | 0505103 | 2005-11-01 04:36:33 +0000 | [diff] [blame] | 510 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 511 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); |
| 512 | return; |
| 513 | } |
| 514 | |
| 515 | if (size < 1 || size > 4) { |
| 516 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)"); |
| 517 | return; |
| 518 | } |
| 519 | |
| 520 | if (stride < 0) { |
| 521 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)"); |
| 522 | return; |
| 523 | } |
| 524 | |
| 525 | if (type == GL_UNSIGNED_BYTE && size != 4) { |
| 526 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size!=4)"); |
| 527 | return; |
| 528 | } |
| 529 | |
| 530 | /* check for valid 'type' and compute StrideB right away */ |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 531 | /* NOTE: more types are supported here than in the NV extension */ |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 532 | switch (type) { |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 533 | case GL_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 534 | elementSize = size * sizeof(GLbyte); |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 535 | break; |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 536 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 537 | elementSize = size * sizeof(GLubyte); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 538 | break; |
| 539 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 540 | elementSize = size * sizeof(GLshort); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 541 | break; |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 542 | case GL_UNSIGNED_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 543 | elementSize = size * sizeof(GLushort); |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 544 | break; |
| 545 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 546 | elementSize = size * sizeof(GLint); |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 547 | break; |
| 548 | case GL_UNSIGNED_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 549 | elementSize = size * sizeof(GLuint); |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 550 | break; |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 551 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 552 | elementSize = size * sizeof(GLfloat); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 553 | break; |
| 554 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 555 | elementSize = size * sizeof(GLdouble); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 556 | break; |
| 557 | default: |
| 558 | _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" ); |
| 559 | return; |
| 560 | } |
| 561 | |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 562 | update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], |
| 563 | _NEW_ARRAY_ATTRIB(index), |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 564 | elementSize, size, type, stride, normalized, ptr); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 565 | |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 566 | if (ctx->Driver.VertexAttribPointer) |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 567 | ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 568 | } |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 569 | #endif |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 570 | |
| 571 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 572 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 573 | _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, |
| 574 | GLsizei count, const GLvoid *ptr) |
| 575 | { |
| 576 | (void) count; |
| 577 | _mesa_VertexPointer(size, type, stride, ptr); |
| 578 | } |
| 579 | |
| 580 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 581 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 582 | _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, |
| 583 | const GLvoid *ptr) |
| 584 | { |
| 585 | (void) count; |
| 586 | _mesa_NormalPointer(type, stride, ptr); |
| 587 | } |
| 588 | |
| 589 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 590 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 591 | _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, |
| 592 | const GLvoid *ptr) |
| 593 | { |
| 594 | (void) count; |
| 595 | _mesa_ColorPointer(size, type, stride, ptr); |
| 596 | } |
| 597 | |
| 598 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 599 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 600 | _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, |
| 601 | const GLvoid *ptr) |
| 602 | { |
| 603 | (void) count; |
| 604 | _mesa_IndexPointer(type, stride, ptr); |
| 605 | } |
| 606 | |
| 607 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 608 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 609 | _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, |
| 610 | GLsizei count, const GLvoid *ptr) |
| 611 | { |
| 612 | (void) count; |
| 613 | _mesa_TexCoordPointer(size, type, stride, ptr); |
| 614 | } |
| 615 | |
| 616 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 617 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 618 | _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) |
| 619 | { |
| 620 | (void) count; |
| 621 | _mesa_EdgeFlagPointer(stride, ptr); |
| 622 | } |
| 623 | |
| 624 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 625 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 626 | _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 627 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 628 | GET_CURRENT_CONTEXT(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 629 | GLboolean tflag, cflag, nflag; /* enable/disable flags */ |
| 630 | GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ |
Keith Whitwell | f4b02d1 | 2001-01-05 05:31:42 +0000 | [diff] [blame] | 631 | GLenum ctype = 0; /* color type */ |
| 632 | GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 633 | const GLint toffset = 0; /* always zero */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 634 | GLint defstride; /* default stride */ |
| 635 | GLint c, f; |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 636 | |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 637 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 638 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 639 | f = sizeof(GLfloat); |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 640 | c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 641 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 642 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 643 | _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 644 | return; |
| 645 | } |
| 646 | |
| 647 | switch (format) { |
| 648 | case GL_V2F: |
| 649 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 650 | tcomps = 0; ccomps = 0; vcomps = 2; |
| 651 | voffset = 0; |
| 652 | defstride = 2*f; |
| 653 | break; |
| 654 | case GL_V3F: |
| 655 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 656 | tcomps = 0; ccomps = 0; vcomps = 3; |
| 657 | voffset = 0; |
| 658 | defstride = 3*f; |
| 659 | break; |
| 660 | case GL_C4UB_V2F: |
| 661 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 662 | tcomps = 0; ccomps = 4; vcomps = 2; |
| 663 | ctype = GL_UNSIGNED_BYTE; |
| 664 | coffset = 0; |
| 665 | voffset = c; |
| 666 | defstride = c + 2*f; |
| 667 | break; |
| 668 | case GL_C4UB_V3F: |
| 669 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 670 | tcomps = 0; ccomps = 4; vcomps = 3; |
| 671 | ctype = GL_UNSIGNED_BYTE; |
| 672 | coffset = 0; |
| 673 | voffset = c; |
| 674 | defstride = c + 3*f; |
| 675 | break; |
| 676 | case GL_C3F_V3F: |
| 677 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 678 | tcomps = 0; ccomps = 3; vcomps = 3; |
| 679 | ctype = GL_FLOAT; |
| 680 | coffset = 0; |
| 681 | voffset = 3*f; |
| 682 | defstride = 6*f; |
| 683 | break; |
| 684 | case GL_N3F_V3F: |
| 685 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; |
| 686 | tcomps = 0; ccomps = 0; vcomps = 3; |
| 687 | noffset = 0; |
| 688 | voffset = 3*f; |
| 689 | defstride = 6*f; |
| 690 | break; |
| 691 | case GL_C4F_N3F_V3F: |
| 692 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 693 | tcomps = 0; ccomps = 4; vcomps = 3; |
| 694 | ctype = GL_FLOAT; |
| 695 | coffset = 0; |
| 696 | noffset = 4*f; |
| 697 | voffset = 7*f; |
| 698 | defstride = 10*f; |
| 699 | break; |
| 700 | case GL_T2F_V3F: |
| 701 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 702 | tcomps = 2; ccomps = 0; vcomps = 3; |
| 703 | voffset = 2*f; |
| 704 | defstride = 5*f; |
| 705 | break; |
| 706 | case GL_T4F_V4F: |
| 707 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 708 | tcomps = 4; ccomps = 0; vcomps = 4; |
| 709 | voffset = 4*f; |
| 710 | defstride = 8*f; |
| 711 | break; |
| 712 | case GL_T2F_C4UB_V3F: |
| 713 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 714 | tcomps = 2; ccomps = 4; vcomps = 3; |
| 715 | ctype = GL_UNSIGNED_BYTE; |
| 716 | coffset = 2*f; |
| 717 | voffset = c+2*f; |
| 718 | defstride = c+5*f; |
| 719 | break; |
| 720 | case GL_T2F_C3F_V3F: |
| 721 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 722 | tcomps = 2; ccomps = 3; vcomps = 3; |
| 723 | ctype = GL_FLOAT; |
| 724 | coffset = 2*f; |
| 725 | voffset = 5*f; |
| 726 | defstride = 8*f; |
| 727 | break; |
| 728 | case GL_T2F_N3F_V3F: |
| 729 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; |
| 730 | tcomps = 2; ccomps = 0; vcomps = 3; |
| 731 | noffset = 2*f; |
| 732 | voffset = 5*f; |
| 733 | defstride = 8*f; |
| 734 | break; |
| 735 | case GL_T2F_C4F_N3F_V3F: |
| 736 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 737 | tcomps = 2; ccomps = 4; vcomps = 3; |
| 738 | ctype = GL_FLOAT; |
| 739 | coffset = 2*f; |
| 740 | noffset = 6*f; |
| 741 | voffset = 9*f; |
| 742 | defstride = 12*f; |
| 743 | break; |
| 744 | case GL_T4F_C4F_N3F_V4F: |
| 745 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 746 | tcomps = 4; ccomps = 4; vcomps = 4; |
| 747 | ctype = GL_FLOAT; |
| 748 | coffset = 4*f; |
| 749 | noffset = 8*f; |
| 750 | voffset = 11*f; |
| 751 | defstride = 15*f; |
| 752 | break; |
| 753 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 754 | _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 755 | return; |
| 756 | } |
| 757 | |
| 758 | if (stride==0) { |
| 759 | stride = defstride; |
| 760 | } |
| 761 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 762 | _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); |
| 763 | _mesa_DisableClientState( GL_INDEX_ARRAY ); |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 764 | /* XXX also disable secondary color and generic arrays? */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 765 | |
| 766 | /* Texcoords */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 767 | if (tflag) { |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 768 | _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); |
| 769 | _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, |
Brian Paul | ab928e5 | 2004-03-10 16:17:35 +0000 | [diff] [blame] | 770 | (GLubyte *) pointer + toffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 771 | } |
| 772 | else { |
Brian Paul | ab928e5 | 2004-03-10 16:17:35 +0000 | [diff] [blame] | 773 | _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 774 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 775 | |
| 776 | /* Color */ |
| 777 | if (cflag) { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 778 | _mesa_EnableClientState( GL_COLOR_ARRAY ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 779 | _mesa_ColorPointer( ccomps, ctype, stride, |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 780 | (GLubyte *) pointer + coffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 781 | } |
| 782 | else { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 783 | _mesa_DisableClientState( GL_COLOR_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | |
| 787 | /* Normals */ |
| 788 | if (nflag) { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 789 | _mesa_EnableClientState( GL_NORMAL_ARRAY ); |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 790 | _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 791 | } |
| 792 | else { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 793 | _mesa_DisableClientState( GL_NORMAL_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 794 | } |
| 795 | |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 796 | /* Vertices */ |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 797 | _mesa_EnableClientState( GL_VERTEX_ARRAY ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 798 | _mesa_VertexPointer( vcomps, GL_FLOAT, stride, |
| 799 | (GLubyte *) pointer + voffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 800 | } |
| 801 | |
| 802 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 803 | void GLAPIENTRY |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 804 | _mesa_LockArraysEXT(GLint first, GLsizei count) |
| 805 | { |
| 806 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 807 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 808 | |
| 809 | if (MESA_VERBOSE & VERBOSE_API) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 810 | _mesa_debug(ctx, "glLockArrays %d %d\n", first, count); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 811 | |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 812 | if (first < 0) { |
| 813 | _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" ); |
| 814 | return; |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 815 | } |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 816 | if (count <= 0) { |
| 817 | _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" ); |
| 818 | return; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 819 | } |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 820 | if (ctx->Array.LockCount != 0) { |
| 821 | _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" ); |
| 822 | return; |
| 823 | } |
| 824 | |
| 825 | ctx->Array.LockFirst = first; |
| 826 | ctx->Array.LockCount = count; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 827 | |
| 828 | ctx->NewState |= _NEW_ARRAY; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 829 | ctx->Array.NewState |= _NEW_ARRAY_ALL; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 830 | |
| 831 | if (ctx->Driver.LockArraysEXT) |
| 832 | ctx->Driver.LockArraysEXT( ctx, first, count ); |
| 833 | } |
| 834 | |
| 835 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 836 | void GLAPIENTRY |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 837 | _mesa_UnlockArraysEXT( void ) |
| 838 | { |
| 839 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 840 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 841 | |
| 842 | if (MESA_VERBOSE & VERBOSE_API) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 843 | _mesa_debug(ctx, "glUnlockArrays\n"); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 844 | |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 845 | if (ctx->Array.LockCount == 0) { |
| 846 | _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" ); |
| 847 | return; |
| 848 | } |
| 849 | |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 850 | ctx->Array.LockFirst = 0; |
| 851 | ctx->Array.LockCount = 0; |
| 852 | ctx->NewState |= _NEW_ARRAY; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 853 | ctx->Array.NewState |= _NEW_ARRAY_ALL; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 854 | |
| 855 | if (ctx->Driver.UnlockArraysEXT) |
| 856 | ctx->Driver.UnlockArraysEXT( ctx ); |
| 857 | } |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 858 | |
| 859 | |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 860 | /* GL_EXT_multi_draw_arrays */ |
| 861 | /* Somebody forgot to spec the first and count parameters as const! <sigh> */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 862 | void GLAPIENTRY |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 863 | _mesa_MultiDrawArraysEXT( GLenum mode, GLint *first, |
| 864 | GLsizei *count, GLsizei primcount ) |
| 865 | { |
| 866 | GET_CURRENT_CONTEXT(ctx); |
| 867 | GLint i; |
| 868 | |
| 869 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 870 | |
| 871 | for (i = 0; i < primcount; i++) { |
| 872 | if (count[i] > 0) { |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 873 | CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i])); |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 874 | } |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | |
| 879 | /* GL_EXT_multi_draw_arrays */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 880 | void GLAPIENTRY |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 881 | _mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, |
| 882 | const GLvoid **indices, GLsizei primcount ) |
| 883 | { |
| 884 | GET_CURRENT_CONTEXT(ctx); |
| 885 | GLint i; |
| 886 | |
| 887 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 888 | |
| 889 | for (i = 0; i < primcount; i++) { |
| 890 | if (count[i] > 0) { |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 891 | CALL_DrawElements(ctx->Exec, (mode, count[i], type, indices[i])); |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 892 | } |
| 893 | } |
| 894 | } |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 895 | |
| 896 | |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 897 | /* GL_IBM_multimode_draw_arrays */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 898 | void GLAPIENTRY |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 899 | _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, |
| 900 | const GLsizei * count, |
| 901 | GLsizei primcount, GLint modestride ) |
| 902 | { |
| 903 | GET_CURRENT_CONTEXT(ctx); |
| 904 | GLint i; |
| 905 | |
| 906 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 907 | |
| 908 | for ( i = 0 ; i < primcount ; i++ ) { |
| 909 | if ( count[i] > 0 ) { |
Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 910 | GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 911 | CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] )); |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 912 | } |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | |
| 917 | /* GL_IBM_multimode_draw_arrays */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 918 | void GLAPIENTRY |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 919 | _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, |
| 920 | GLenum type, const GLvoid * const * indices, |
| 921 | GLsizei primcount, GLint modestride ) |
| 922 | { |
| 923 | GET_CURRENT_CONTEXT(ctx); |
| 924 | GLint i; |
| 925 | |
| 926 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 927 | |
Brian Paul | d2afb39 | 2003-09-17 18:15:13 +0000 | [diff] [blame] | 928 | /* XXX not sure about ARB_vertex_buffer_object handling here */ |
| 929 | |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 930 | for ( i = 0 ; i < primcount ; i++ ) { |
| 931 | if ( count[i] > 0 ) { |
Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 932 | GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 933 | CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] )); |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 934 | } |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 939 | /** |
| 940 | * Initialize vertex array state for given context. |
| 941 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 942 | void |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 943 | _mesa_init_varray(GLcontext *ctx) |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 944 | { |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 945 | ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0); |
| 946 | ctx->Array.ArrayObj = ctx->Array.DefaultArrayObj; |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 947 | |
| 948 | ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */ |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 949 | } |