jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 3 | * Version: 7.6 |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 4 | * |
Brian Paul | 37c74af | 2008-09-04 14:58:02 -0600 | [diff] [blame] | 5 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 6 | * Copyright (C) 2009 VMware, Inc. All Rights Reserved. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 7 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the "Software"), |
| 10 | * to deal in the Software without restriction, including without limitation |
| 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 | * and/or sell copies of the Software, and to permit persons to whom the |
| 13 | * Software is furnished to do so, subject to the following conditions: |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 14 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 15 | * The above copyright notice and this permission notice shall be included |
| 16 | * in all copies or substantial portions of the Software. |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 17 | * |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 21 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 22 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 26 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 27 | #include "glheader.h" |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 28 | #include "imports.h" |
Brian Paul | 26895aa | 2004-03-03 15:35:08 +0000 | [diff] [blame] | 29 | #include "bufferobj.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 30 | #include "context.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 31 | #include "enable.h" |
| 32 | #include "enums.h" |
Brian Paul | 12cf98f | 2009-06-19 17:58:47 -0600 | [diff] [blame] | 33 | #include "hash.h" |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 34 | #include "mtypes.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 35 | #include "varray.h" |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 36 | #include "arrayobj.h" |
Brian | c223c6b | 2007-07-04 13:15:20 -0600 | [diff] [blame] | 37 | #include "glapi/dispatch.h" |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 38 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 39 | |
| 40 | /** |
Brian Paul | 54a5ffb | 2009-05-21 16:05:11 -0600 | [diff] [blame] | 41 | * Set the fields of a vertex array. |
Brian Paul | e2b7249 | 2009-06-22 16:56:35 -0600 | [diff] [blame] | 42 | * Also do an error check for GL_ARB_vertex_array_object: check that |
| 43 | * all arrays reside in VBOs when using a vertex array object. |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 44 | * |
| 45 | * \param array the array to update |
| 46 | * \param dirtyBit which bit to set in ctx->Array.NewState for this array |
| 47 | * \param elementSize size of each array element, in bytes |
| 48 | * \param size components per element (1, 2, 3 or 4) |
| 49 | * \param type datatype of each component (GL_FLOAT, GL_INT, etc) |
Brian Paul | 54a5ffb | 2009-05-21 16:05:11 -0600 | [diff] [blame] | 50 | * \param format either GL_RGBA or GL_BGRA |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 51 | * \param stride stride between elements, in elements |
| 52 | * \param normalized are integer types converted to floats in [-1, 1]? |
| 53 | * \param ptr the address (or offset inside VBO) of the array data |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 54 | */ |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 55 | static void |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 56 | update_array(GLcontext *ctx, struct gl_client_array *array, |
Brian Paul | f9d88c8 | 2006-06-13 17:24:36 +0000 | [diff] [blame] | 57 | GLbitfield dirtyBit, GLsizei elementSize, |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 58 | GLint size, GLenum type, GLenum format, |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 59 | GLsizei stride, GLboolean normalized, const GLvoid *ptr) |
| 60 | { |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 61 | ASSERT(format == GL_RGBA || format == GL_BGRA); |
Brian Paul | e2b7249 | 2009-06-22 16:56:35 -0600 | [diff] [blame] | 62 | |
| 63 | if (ctx->Array.ArrayObj->VBOonly && |
| 64 | ctx->Array.ArrayBufferObj->Name == 0) { |
| 65 | /* GL_ARB_vertex_array_object requires that all arrays reside in VBOs. |
| 66 | * Generate GL_INVALID_OPERATION if that's not true. |
| 67 | */ |
| 68 | _mesa_error(ctx, GL_INVALID_OPERATION, |
| 69 | "glVertex/Normal/EtcPointer(non-VBO array)"); |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 70 | return; |
Brian Paul | e2b7249 | 2009-06-22 16:56:35 -0600 | [diff] [blame] | 71 | } |
| 72 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 73 | array->Size = size; |
| 74 | array->Type = type; |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 75 | array->Format = format; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 76 | array->Stride = stride; |
| 77 | array->StrideB = stride ? stride : elementSize; |
| 78 | array->Normalized = normalized; |
| 79 | array->Ptr = (const GLubyte *) ptr; |
Brian Paul | 0077c87 | 2009-05-06 13:00:35 -0600 | [diff] [blame] | 80 | array->_ElementSize = elementSize; |
| 81 | |
Brian Paul | 37c74af | 2008-09-04 14:58:02 -0600 | [diff] [blame] | 82 | _mesa_reference_buffer_object(ctx, &array->BufferObj, |
| 83 | ctx->Array.ArrayBufferObj); |
| 84 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 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; |
Dave Airlie | cfe884e | 2010-01-18 16:29:31 +1000 | [diff] [blame] | 124 | case GL_HALF_FLOAT: |
| 125 | elementSize = size * sizeof(GLhalfARB); |
| 126 | break; |
Brian Paul | 394c1d1 | 2008-06-20 11:32:22 -0600 | [diff] [blame] | 127 | #if FEATURE_fixedpt |
| 128 | case GL_FIXED: |
| 129 | elementSize = size * sizeof(GLfixed); |
| 130 | break; |
| 131 | #endif |
Brian Paul | d17485f | 2008-06-20 11:49:25 -0600 | [diff] [blame] | 132 | #if FEATURE_vertex_array_byte |
| 133 | case GL_BYTE: |
| 134 | elementSize = size * sizeof(GLbyte); |
| 135 | break; |
| 136 | #endif |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 137 | default: |
Brian Paul | 2b82bc9 | 2009-08-04 14:53:24 -0600 | [diff] [blame] | 138 | _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type=%s)", |
| 139 | _mesa_lookup_enum_by_nr(type)); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 140 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 141 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 142 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 143 | update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX, |
| 144 | elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 148 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 149 | _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 150 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 151 | GLsizei elementSize; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 152 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 153 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 154 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 155 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 156 | _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 157 | return; |
| 158 | } |
| 159 | |
| 160 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 161 | _mesa_debug(ctx, "glNormalPointer( type %s stride %d )\n", |
| 162 | _mesa_lookup_enum_by_nr( type ), stride); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 163 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 164 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 165 | case GL_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 166 | elementSize = 3 * sizeof(GLbyte); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 167 | break; |
| 168 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 169 | elementSize = 3 * sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 170 | break; |
| 171 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 172 | elementSize = 3 * sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 173 | break; |
| 174 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 175 | elementSize = 3 * sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 176 | break; |
| 177 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 178 | elementSize = 3 * sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 179 | break; |
Dave Airlie | cfe884e | 2010-01-18 16:29:31 +1000 | [diff] [blame] | 180 | case GL_HALF_FLOAT: |
| 181 | elementSize = 3 * sizeof(GLhalfARB); |
| 182 | break; |
Brian Paul | 394c1d1 | 2008-06-20 11:32:22 -0600 | [diff] [blame] | 183 | #if FEATURE_fixedpt |
| 184 | case GL_FIXED: |
| 185 | elementSize = 3 * sizeof(GLfixed); |
| 186 | break; |
| 187 | #endif |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 188 | default: |
Brian Paul | 2b82bc9 | 2009-08-04 14:53:24 -0600 | [diff] [blame] | 189 | _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type=%s)", |
| 190 | _mesa_lookup_enum_by_nr(type)); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 191 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 192 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 193 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 194 | update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL, |
| 195 | elementSize, 3, type, GL_RGBA, stride, GL_TRUE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 199 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 200 | _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 201 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 202 | GLsizei elementSize; |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 203 | GLenum format; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 204 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 205 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 206 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 207 | if (size < 3 || size > 4) { |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 208 | if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { |
| 209 | _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(size)"); |
| 210 | return; |
| 211 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 212 | } |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 213 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 214 | _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 215 | return; |
| 216 | } |
| 217 | |
| 218 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 219 | _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size, |
| 220 | _mesa_lookup_enum_by_nr( type ), stride); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 221 | |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 222 | if (size == GL_BGRA) { |
| 223 | if (type != GL_UNSIGNED_BYTE) { |
| 224 | _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(GL_BGRA/GLubyte)"); |
| 225 | return; |
| 226 | } |
| 227 | format = GL_BGRA; |
| 228 | size = 4; |
| 229 | } |
| 230 | else { |
| 231 | format = GL_RGBA; |
| 232 | } |
| 233 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 234 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 235 | case GL_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 236 | elementSize = size * sizeof(GLbyte); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 237 | break; |
| 238 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 239 | elementSize = size * sizeof(GLubyte); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 240 | break; |
| 241 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 242 | elementSize = size * sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 243 | break; |
| 244 | case GL_UNSIGNED_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 245 | elementSize = size * sizeof(GLushort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 246 | break; |
| 247 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 248 | elementSize = size * sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 249 | break; |
| 250 | case GL_UNSIGNED_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 251 | elementSize = size * sizeof(GLuint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 252 | break; |
| 253 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 254 | elementSize = size * sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 255 | break; |
| 256 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 257 | elementSize = size * sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 258 | break; |
Dave Airlie | cfe884e | 2010-01-18 16:29:31 +1000 | [diff] [blame] | 259 | case GL_HALF_FLOAT: |
| 260 | elementSize = size * sizeof(GLhalfARB); |
| 261 | break; |
Brian Paul | 394c1d1 | 2008-06-20 11:32:22 -0600 | [diff] [blame] | 262 | #if FEATURE_fixedpt |
| 263 | case GL_FIXED: |
| 264 | elementSize = size * sizeof(GLfixed); |
| 265 | break; |
| 266 | #endif |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 267 | default: |
Brian Paul | 2b82bc9 | 2009-08-04 14:53:24 -0600 | [diff] [blame] | 268 | _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type=%s)", |
| 269 | _mesa_lookup_enum_by_nr(type)); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 270 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 271 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 272 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 273 | update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0, |
| 274 | elementSize, size, type, format, stride, GL_TRUE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 278 | void GLAPIENTRY |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 279 | _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) |
| 280 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 281 | GLint elementSize; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 282 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 283 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 284 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 285 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 286 | _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 287 | return; |
| 288 | } |
| 289 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 290 | switch (type) { |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 291 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 292 | elementSize = sizeof(GLfloat); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 293 | break; |
| 294 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 295 | elementSize = sizeof(GLdouble); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 296 | break; |
Dave Airlie | cfe884e | 2010-01-18 16:29:31 +1000 | [diff] [blame] | 297 | case GL_HALF_FLOAT: |
| 298 | elementSize = sizeof(GLhalfARB); |
| 299 | break; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 300 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 301 | _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 302 | return; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 303 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 304 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 305 | update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD, |
| 306 | elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 310 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 311 | _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 312 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 313 | GLsizei elementSize; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 314 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 315 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 316 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 317 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 318 | _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 319 | return; |
| 320 | } |
| 321 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 322 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 323 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 324 | elementSize = sizeof(GLubyte); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 325 | break; |
| 326 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 327 | elementSize = sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 328 | break; |
| 329 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 330 | elementSize = sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 331 | break; |
| 332 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 333 | elementSize = sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 334 | break; |
| 335 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 336 | elementSize = sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 337 | break; |
| 338 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 339 | _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 340 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 341 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 342 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 343 | update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX, |
| 344 | elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 348 | void GLAPIENTRY |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 349 | _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 350 | GLsizei stride, const GLvoid *ptr) |
| 351 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 352 | GLsizei elementSize; |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 353 | GLenum format; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 354 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 355 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 356 | |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 357 | if (size != 3 && size != 4) { |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 358 | if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { |
| 359 | _mesa_error(ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)"); |
| 360 | return; |
| 361 | } |
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 | if (stride < 0) { |
| 364 | _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" ); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 365 | return; |
| 366 | } |
| 367 | |
| 368 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 369 | _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n", |
Brian Paul | d09a1d8 | 2002-06-13 04:49:17 +0000 | [diff] [blame] | 370 | size, _mesa_lookup_enum_by_nr( type ), stride); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 371 | |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 372 | if (size == GL_BGRA) { |
| 373 | if (type != GL_UNSIGNED_BYTE) { |
| 374 | _mesa_error(ctx, GL_INVALID_VALUE, "glColorPointer(GL_BGRA/GLubyte)"); |
| 375 | return; |
| 376 | } |
| 377 | format = GL_BGRA; |
| 378 | size = 4; |
| 379 | } |
| 380 | else { |
| 381 | format = GL_RGBA; |
| 382 | } |
| 383 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 384 | switch (type) { |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 385 | case GL_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 386 | elementSize = size * sizeof(GLbyte); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 387 | break; |
| 388 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 389 | elementSize = size * sizeof(GLubyte); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 390 | break; |
| 391 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 392 | elementSize = size * sizeof(GLshort); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 393 | break; |
| 394 | case GL_UNSIGNED_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 395 | elementSize = size * sizeof(GLushort); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 396 | break; |
| 397 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 398 | elementSize = size * sizeof(GLint); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 399 | break; |
| 400 | case GL_UNSIGNED_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 401 | elementSize = size * sizeof(GLuint); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 402 | break; |
| 403 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 404 | elementSize = size * sizeof(GLfloat); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 405 | break; |
| 406 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 407 | elementSize = size * sizeof(GLdouble); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 408 | break; |
Dave Airlie | cfe884e | 2010-01-18 16:29:31 +1000 | [diff] [blame] | 409 | case GL_HALF_FLOAT: |
| 410 | elementSize = size * sizeof(GLhalfARB); |
| 411 | break; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 412 | default: |
Brian Paul | 2b82bc9 | 2009-08-04 14:53:24 -0600 | [diff] [blame] | 413 | _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type=%s)", |
| 414 | _mesa_lookup_enum_by_nr(type)); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 415 | return; |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 416 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 417 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 418 | update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1, |
| 419 | elementSize, size, type, format, stride, GL_TRUE, ptr); |
Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 423 | void GLAPIENTRY |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 424 | _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, |
| 425 | const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 426 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 427 | GLint elementSize; |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 428 | GET_CURRENT_CONTEXT(ctx); |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 429 | const GLuint unit = ctx->Array.ActiveTexture; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 430 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 431 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 432 | if (size < 1 || size > 4) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 433 | _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 434 | return; |
| 435 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 436 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 437 | _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 438 | return; |
| 439 | } |
| 440 | |
| 441 | if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 442 | _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] | 443 | unit, size, _mesa_lookup_enum_by_nr( type ), stride); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 444 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 445 | /* always need to check that <type> is legal */ |
| 446 | switch (type) { |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 447 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 448 | elementSize = size * sizeof(GLshort); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 449 | break; |
| 450 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 451 | elementSize = size * sizeof(GLint); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 452 | break; |
| 453 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 454 | elementSize = size * sizeof(GLfloat); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 455 | break; |
| 456 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 457 | elementSize = size * sizeof(GLdouble); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 458 | break; |
Dave Airlie | cfe884e | 2010-01-18 16:29:31 +1000 | [diff] [blame] | 459 | case GL_HALF_FLOAT: |
| 460 | elementSize = size * sizeof(GLhalfARB); |
| 461 | break; |
Brian Paul | 394c1d1 | 2008-06-20 11:32:22 -0600 | [diff] [blame] | 462 | #if FEATURE_fixedpt |
| 463 | case GL_FIXED: |
| 464 | elementSize = size * sizeof(GLfixed); |
| 465 | break; |
| 466 | #endif |
Brian Paul | d17485f | 2008-06-20 11:49:25 -0600 | [diff] [blame] | 467 | #if FEATURE_vertex_array_byte |
| 468 | case GL_BYTE: |
| 469 | elementSize = size * sizeof(GLbyte); |
| 470 | break; |
| 471 | #endif |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 472 | default: |
Brian Paul | 2b82bc9 | 2009-08-04 14:53:24 -0600 | [diff] [blame] | 473 | _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type=%s)", |
| 474 | _mesa_lookup_enum_by_nr(type)); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 475 | return; |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 476 | } |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 477 | |
Brian Paul | 89c8ff3 | 2010-02-03 13:24:43 -0700 | [diff] [blame^] | 478 | ASSERT(unit < Elements(ctx->Array.ArrayObj->TexCoord)); |
| 479 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 480 | update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit], |
| 481 | _NEW_ARRAY_TEXCOORD(unit), |
| 482 | elementSize, size, type, GL_RGBA, stride, GL_FALSE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 486 | void GLAPIENTRY |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 487 | _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 488 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 489 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 490 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 491 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 492 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 493 | _mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 494 | return; |
| 495 | } |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 496 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 497 | update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG, |
| 498 | sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, GL_RGBA, |
| 499 | stride, GL_FALSE, ptr); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | |
Brian Paul | 1cf2c8a | 2008-06-25 08:45:14 -0600 | [diff] [blame] | 503 | void GLAPIENTRY |
| 504 | _mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr) |
| 505 | { |
| 506 | GLsizei elementSize; |
| 507 | GET_CURRENT_CONTEXT(ctx); |
| 508 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 509 | |
| 510 | if (stride < 0) { |
| 511 | _mesa_error( ctx, GL_INVALID_VALUE, "glPointSizePointer(stride)" ); |
| 512 | return; |
| 513 | } |
| 514 | |
| 515 | switch (type) { |
| 516 | case GL_FLOAT: |
| 517 | elementSize = sizeof(GLfloat); |
| 518 | break; |
| 519 | #if FEATURE_fixedpt |
| 520 | case GL_FIXED: |
| 521 | elementSize = sizeof(GLfixed); |
| 522 | break; |
| 523 | #endif |
| 524 | default: |
| 525 | _mesa_error( ctx, GL_INVALID_ENUM, "glPointSizePointer(type)" ); |
| 526 | return; |
| 527 | } |
| 528 | |
| 529 | update_array(ctx, &ctx->Array.ArrayObj->PointSize, _NEW_ARRAY_POINT_SIZE, |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 530 | elementSize, 1, type, GL_RGBA, stride, GL_FALSE, ptr); |
Brian Paul | 1cf2c8a | 2008-06-25 08:45:14 -0600 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 534 | #if FEATURE_NV_vertex_program |
Brian Paul | a554d7c | 2009-05-21 15:55:33 -0600 | [diff] [blame] | 535 | /** |
| 536 | * Set a vertex attribute array. |
| 537 | * Note that these arrays DO alias the conventional GL vertex arrays |
| 538 | * (position, normal, color, fog, texcoord, etc). |
| 539 | * The generic attribute slots at #16 and above are not touched. |
| 540 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 541 | void GLAPIENTRY |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 542 | _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, |
| 543 | GLsizei stride, const GLvoid *ptr) |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 544 | { |
Markus Amsler | 29fbf72 | 2008-03-09 17:53:22 -0600 | [diff] [blame] | 545 | GLboolean normalized = GL_FALSE; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 546 | GLsizei elementSize; |
Maciej Cencora | 4adb190 | 2009-06-08 07:23:56 -0600 | [diff] [blame] | 547 | GLenum format; |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 548 | GET_CURRENT_CONTEXT(ctx); |
| 549 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 550 | |
Brian Paul | d2a74d7 | 2009-05-21 17:03:21 -0600 | [diff] [blame] | 551 | if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) { |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 552 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); |
| 553 | return; |
| 554 | } |
| 555 | |
| 556 | if (size < 1 || size > 4) { |
| 557 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size)"); |
| 558 | return; |
| 559 | } |
| 560 | |
| 561 | if (stride < 0) { |
| 562 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(stride)"); |
| 563 | return; |
| 564 | } |
| 565 | |
| 566 | if (type == GL_UNSIGNED_BYTE && size != 4) { |
| 567 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)"); |
| 568 | return; |
| 569 | } |
| 570 | |
Maciej Cencora | 4adb190 | 2009-06-08 07:23:56 -0600 | [diff] [blame] | 571 | if (size == GL_BGRA) { |
| 572 | if (type != GL_UNSIGNED_BYTE) { |
| 573 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 574 | "glVertexAttribPointerNV(GL_BGRA/type)"); |
| 575 | return; |
| 576 | } |
| 577 | |
| 578 | format = GL_BGRA; |
| 579 | size = 4; |
| 580 | normalized = GL_TRUE; |
| 581 | } |
| 582 | else { |
| 583 | format = GL_RGBA; |
| 584 | } |
| 585 | |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 586 | /* check for valid 'type' and compute StrideB right away */ |
| 587 | switch (type) { |
| 588 | case GL_UNSIGNED_BYTE: |
Markus Amsler | 29fbf72 | 2008-03-09 17:53:22 -0600 | [diff] [blame] | 589 | normalized = GL_TRUE; |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 590 | elementSize = size * sizeof(GLubyte); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 591 | break; |
| 592 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 593 | elementSize = size * sizeof(GLshort); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 594 | break; |
| 595 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 596 | elementSize = size * sizeof(GLfloat); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 597 | break; |
| 598 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 599 | elementSize = size * sizeof(GLdouble); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 600 | break; |
| 601 | default: |
Brian Paul | 2b82bc9 | 2009-08-04 14:53:24 -0600 | [diff] [blame] | 602 | _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type=%s)", |
| 603 | _mesa_lookup_enum_by_nr(type)); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 604 | return; |
| 605 | } |
| 606 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 607 | update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], |
| 608 | _NEW_ARRAY_ATTRIB(index), |
| 609 | elementSize, size, type, format, stride, normalized, ptr); |
Brian Paul | 2edd180 | 2002-01-11 17:25:35 +0000 | [diff] [blame] | 610 | } |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 611 | #endif |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 612 | |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 613 | |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 614 | #if FEATURE_ARB_vertex_program |
Brian Paul | a554d7c | 2009-05-21 15:55:33 -0600 | [diff] [blame] | 615 | /** |
| 616 | * Set a generic vertex attribute array. |
| 617 | * Note that these arrays DO NOT alias the conventional GL vertex arrays |
| 618 | * (position, normal, color, fog, texcoord, etc). |
| 619 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 620 | void GLAPIENTRY |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 621 | _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, |
| 622 | GLboolean normalized, |
| 623 | GLsizei stride, const GLvoid *ptr) |
| 624 | { |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 625 | GLsizei elementSize; |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 626 | GLenum format; |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 627 | GET_CURRENT_CONTEXT(ctx); |
| 628 | ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 629 | |
Brian Paul | 0505103 | 2005-11-01 04:36:33 +0000 | [diff] [blame] | 630 | if (index >= ctx->Const.VertexProgram.MaxAttribs) { |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 631 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); |
| 632 | return; |
| 633 | } |
| 634 | |
| 635 | if (size < 1 || size > 4) { |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 636 | if (!ctx->Extensions.EXT_vertex_array_bgra || size != GL_BGRA) { |
| 637 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)"); |
| 638 | return; |
| 639 | } |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | if (stride < 0) { |
| 643 | _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)"); |
| 644 | return; |
| 645 | } |
| 646 | |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 647 | if (size == GL_BGRA) { |
| 648 | if (type != GL_UNSIGNED_BYTE) { |
| 649 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 650 | "glVertexAttribPointerARB(GL_BGRA/type)"); |
| 651 | return; |
| 652 | } |
Maciej Cencora | 4adb190 | 2009-06-08 07:23:56 -0600 | [diff] [blame] | 653 | if (normalized != GL_TRUE) { |
| 654 | _mesa_error(ctx, GL_INVALID_VALUE, |
| 655 | "glVertexAttribPointerARB(GL_BGRA/normalized)"); |
| 656 | return; |
| 657 | } |
| 658 | |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 659 | format = GL_BGRA; |
| 660 | size = 4; |
Brian Paul | 76d27a6 | 2009-01-23 11:24:31 -0700 | [diff] [blame] | 661 | } |
| 662 | else { |
| 663 | format = GL_RGBA; |
| 664 | } |
| 665 | |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 666 | /* check for valid 'type' and compute StrideB right away */ |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 667 | /* NOTE: more types are supported here than in the NV extension */ |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 668 | switch (type) { |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 669 | case GL_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 670 | elementSize = size * sizeof(GLbyte); |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 671 | break; |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 672 | case GL_UNSIGNED_BYTE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 673 | elementSize = size * sizeof(GLubyte); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 674 | break; |
| 675 | case GL_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 676 | elementSize = size * sizeof(GLshort); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 677 | break; |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 678 | case GL_UNSIGNED_SHORT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 679 | elementSize = size * sizeof(GLushort); |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 680 | break; |
| 681 | case GL_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 682 | elementSize = size * sizeof(GLint); |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 683 | break; |
| 684 | case GL_UNSIGNED_INT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 685 | elementSize = size * sizeof(GLuint); |
Brian Paul | 196a90b | 2003-06-11 18:47:51 +0000 | [diff] [blame] | 686 | break; |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 687 | case GL_FLOAT: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 688 | elementSize = size * sizeof(GLfloat); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 689 | break; |
| 690 | case GL_DOUBLE: |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 691 | elementSize = size * sizeof(GLdouble); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 692 | break; |
Dave Airlie | cfe884e | 2010-01-18 16:29:31 +1000 | [diff] [blame] | 693 | case GL_HALF_FLOAT: |
| 694 | elementSize = size * sizeof(GLhalfARB); |
| 695 | break; |
Brian Paul | 48cba70 | 2008-07-03 14:12:27 -0600 | [diff] [blame] | 696 | #if FEATURE_fixedpt |
| 697 | case GL_FIXED: |
| 698 | elementSize = size * sizeof(GLfixed); |
| 699 | break; |
| 700 | #endif |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 701 | default: |
| 702 | _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" ); |
| 703 | return; |
| 704 | } |
| 705 | |
Brian Paul | f549f4c | 2009-11-12 23:04:26 -0700 | [diff] [blame] | 706 | update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], |
| 707 | _NEW_ARRAY_ATTRIB(index), |
| 708 | elementSize, size, type, format, stride, normalized, ptr); |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 709 | } |
Brian Paul | 148a284 | 2003-09-17 03:40:11 +0000 | [diff] [blame] | 710 | #endif |
Brian Paul | 92f9785 | 2003-05-01 22:44:02 +0000 | [diff] [blame] | 711 | |
| 712 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 713 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 714 | _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, |
| 715 | GLsizei count, const GLvoid *ptr) |
| 716 | { |
| 717 | (void) count; |
| 718 | _mesa_VertexPointer(size, type, stride, ptr); |
| 719 | } |
| 720 | |
| 721 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 722 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 723 | _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, |
| 724 | const GLvoid *ptr) |
| 725 | { |
| 726 | (void) count; |
| 727 | _mesa_NormalPointer(type, stride, ptr); |
| 728 | } |
| 729 | |
| 730 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 731 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 732 | _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, |
| 733 | const GLvoid *ptr) |
| 734 | { |
| 735 | (void) count; |
| 736 | _mesa_ColorPointer(size, type, stride, ptr); |
| 737 | } |
| 738 | |
| 739 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 740 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 741 | _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, |
| 742 | const GLvoid *ptr) |
| 743 | { |
| 744 | (void) count; |
| 745 | _mesa_IndexPointer(type, stride, ptr); |
| 746 | } |
| 747 | |
| 748 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 749 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 750 | _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, |
| 751 | GLsizei count, const GLvoid *ptr) |
| 752 | { |
| 753 | (void) count; |
| 754 | _mesa_TexCoordPointer(size, type, stride, ptr); |
| 755 | } |
| 756 | |
| 757 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 758 | void GLAPIENTRY |
Brian Paul | 1f0e213 | 2000-06-12 15:30:51 +0000 | [diff] [blame] | 759 | _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) |
| 760 | { |
| 761 | (void) count; |
| 762 | _mesa_EdgeFlagPointer(stride, ptr); |
| 763 | } |
| 764 | |
| 765 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 766 | void GLAPIENTRY |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 767 | _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 768 | { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 769 | GET_CURRENT_CONTEXT(ctx); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 770 | GLboolean tflag, cflag, nflag; /* enable/disable flags */ |
| 771 | GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ |
Keith Whitwell | f4b02d1 | 2001-01-05 05:31:42 +0000 | [diff] [blame] | 772 | GLenum ctype = 0; /* color type */ |
| 773 | GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 774 | const GLint toffset = 0; /* always zero */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 775 | GLint defstride; /* default stride */ |
| 776 | GLint c, f; |
Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 777 | |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 778 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 779 | |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 780 | f = sizeof(GLfloat); |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 781 | c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 782 | |
Brian Paul | c5b1e81 | 2003-10-22 22:59:07 +0000 | [diff] [blame] | 783 | if (stride < 0) { |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 784 | _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 785 | return; |
| 786 | } |
| 787 | |
| 788 | switch (format) { |
| 789 | case GL_V2F: |
| 790 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 791 | tcomps = 0; ccomps = 0; vcomps = 2; |
| 792 | voffset = 0; |
| 793 | defstride = 2*f; |
| 794 | break; |
| 795 | case GL_V3F: |
| 796 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 797 | tcomps = 0; ccomps = 0; vcomps = 3; |
| 798 | voffset = 0; |
| 799 | defstride = 3*f; |
| 800 | break; |
| 801 | case GL_C4UB_V2F: |
| 802 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 803 | tcomps = 0; ccomps = 4; vcomps = 2; |
| 804 | ctype = GL_UNSIGNED_BYTE; |
| 805 | coffset = 0; |
| 806 | voffset = c; |
| 807 | defstride = c + 2*f; |
| 808 | break; |
| 809 | case GL_C4UB_V3F: |
| 810 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 811 | tcomps = 0; ccomps = 4; vcomps = 3; |
| 812 | ctype = GL_UNSIGNED_BYTE; |
| 813 | coffset = 0; |
| 814 | voffset = c; |
| 815 | defstride = c + 3*f; |
| 816 | break; |
| 817 | case GL_C3F_V3F: |
| 818 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 819 | tcomps = 0; ccomps = 3; vcomps = 3; |
| 820 | ctype = GL_FLOAT; |
| 821 | coffset = 0; |
| 822 | voffset = 3*f; |
| 823 | defstride = 6*f; |
| 824 | break; |
| 825 | case GL_N3F_V3F: |
| 826 | tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; |
| 827 | tcomps = 0; ccomps = 0; vcomps = 3; |
| 828 | noffset = 0; |
| 829 | voffset = 3*f; |
| 830 | defstride = 6*f; |
| 831 | break; |
| 832 | case GL_C4F_N3F_V3F: |
| 833 | tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 834 | tcomps = 0; ccomps = 4; vcomps = 3; |
| 835 | ctype = GL_FLOAT; |
| 836 | coffset = 0; |
| 837 | noffset = 4*f; |
| 838 | voffset = 7*f; |
| 839 | defstride = 10*f; |
| 840 | break; |
| 841 | case GL_T2F_V3F: |
| 842 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 843 | tcomps = 2; ccomps = 0; vcomps = 3; |
| 844 | voffset = 2*f; |
| 845 | defstride = 5*f; |
| 846 | break; |
| 847 | case GL_T4F_V4F: |
| 848 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; |
| 849 | tcomps = 4; ccomps = 0; vcomps = 4; |
| 850 | voffset = 4*f; |
| 851 | defstride = 8*f; |
| 852 | break; |
| 853 | case GL_T2F_C4UB_V3F: |
| 854 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 855 | tcomps = 2; ccomps = 4; vcomps = 3; |
| 856 | ctype = GL_UNSIGNED_BYTE; |
| 857 | coffset = 2*f; |
| 858 | voffset = c+2*f; |
| 859 | defstride = c+5*f; |
| 860 | break; |
| 861 | case GL_T2F_C3F_V3F: |
| 862 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; |
| 863 | tcomps = 2; ccomps = 3; vcomps = 3; |
| 864 | ctype = GL_FLOAT; |
| 865 | coffset = 2*f; |
| 866 | voffset = 5*f; |
| 867 | defstride = 8*f; |
| 868 | break; |
| 869 | case GL_T2F_N3F_V3F: |
| 870 | tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; |
| 871 | tcomps = 2; ccomps = 0; vcomps = 3; |
| 872 | noffset = 2*f; |
| 873 | voffset = 5*f; |
| 874 | defstride = 8*f; |
| 875 | break; |
| 876 | case GL_T2F_C4F_N3F_V3F: |
| 877 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 878 | tcomps = 2; ccomps = 4; vcomps = 3; |
| 879 | ctype = GL_FLOAT; |
| 880 | coffset = 2*f; |
| 881 | noffset = 6*f; |
| 882 | voffset = 9*f; |
| 883 | defstride = 12*f; |
| 884 | break; |
| 885 | case GL_T4F_C4F_N3F_V4F: |
| 886 | tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; |
| 887 | tcomps = 4; ccomps = 4; vcomps = 4; |
| 888 | ctype = GL_FLOAT; |
| 889 | coffset = 4*f; |
| 890 | noffset = 8*f; |
| 891 | voffset = 11*f; |
| 892 | defstride = 15*f; |
| 893 | break; |
| 894 | default: |
Brian Paul | 0883634 | 2001-03-03 20:33:27 +0000 | [diff] [blame] | 895 | _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 896 | return; |
| 897 | } |
| 898 | |
| 899 | if (stride==0) { |
| 900 | stride = defstride; |
| 901 | } |
| 902 | |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 903 | _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); |
| 904 | _mesa_DisableClientState( GL_INDEX_ARRAY ); |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 905 | /* XXX also disable secondary color and generic arrays? */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 906 | |
| 907 | /* Texcoords */ |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 908 | if (tflag) { |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 909 | _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); |
| 910 | _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, |
Brian Paul | ab928e5 | 2004-03-10 16:17:35 +0000 | [diff] [blame] | 911 | (GLubyte *) pointer + toffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 912 | } |
| 913 | else { |
Brian Paul | ab928e5 | 2004-03-10 16:17:35 +0000 | [diff] [blame] | 914 | _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 915 | } |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 916 | |
| 917 | /* Color */ |
| 918 | if (cflag) { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 919 | _mesa_EnableClientState( GL_COLOR_ARRAY ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 920 | _mesa_ColorPointer( ccomps, ctype, stride, |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 921 | (GLubyte *) pointer + coffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 922 | } |
| 923 | else { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 924 | _mesa_DisableClientState( GL_COLOR_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | |
| 928 | /* Normals */ |
| 929 | if (nflag) { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 930 | _mesa_EnableClientState( GL_NORMAL_ARRAY ); |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 931 | _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 932 | } |
| 933 | else { |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 934 | _mesa_DisableClientState( GL_NORMAL_ARRAY ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 935 | } |
| 936 | |
Brian Paul | 4a3110f | 2003-12-12 18:40:02 +0000 | [diff] [blame] | 937 | /* Vertices */ |
Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 938 | _mesa_EnableClientState( GL_VERTEX_ARRAY ); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 939 | _mesa_VertexPointer( vcomps, GL_FLOAT, stride, |
| 940 | (GLubyte *) pointer + voffset ); |
jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 944 | void GLAPIENTRY |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 945 | _mesa_LockArraysEXT(GLint first, GLsizei count) |
| 946 | { |
| 947 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 948 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 949 | |
| 950 | if (MESA_VERBOSE & VERBOSE_API) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 951 | _mesa_debug(ctx, "glLockArrays %d %d\n", first, count); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 952 | |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 953 | if (first < 0) { |
| 954 | _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" ); |
| 955 | return; |
Gareth Hughes | 22144ab | 2001-03-12 00:48:37 +0000 | [diff] [blame] | 956 | } |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 957 | if (count <= 0) { |
| 958 | _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" ); |
| 959 | return; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 960 | } |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 961 | if (ctx->Array.LockCount != 0) { |
| 962 | _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" ); |
| 963 | return; |
| 964 | } |
| 965 | |
| 966 | ctx->Array.LockFirst = first; |
| 967 | ctx->Array.LockCount = count; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 968 | |
| 969 | ctx->NewState |= _NEW_ARRAY; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 970 | ctx->Array.NewState |= _NEW_ARRAY_ALL; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 974 | void GLAPIENTRY |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 975 | _mesa_UnlockArraysEXT( void ) |
| 976 | { |
| 977 | GET_CURRENT_CONTEXT(ctx); |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 978 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 979 | |
| 980 | if (MESA_VERBOSE & VERBOSE_API) |
Brian Paul | 4753d60 | 2002-06-15 02:38:15 +0000 | [diff] [blame] | 981 | _mesa_debug(ctx, "glUnlockArrays\n"); |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 982 | |
Eric Anholt | 5857e98 | 2008-02-02 02:54:13 -0800 | [diff] [blame] | 983 | if (ctx->Array.LockCount == 0) { |
| 984 | _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" ); |
| 985 | return; |
| 986 | } |
| 987 | |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 988 | ctx->Array.LockFirst = 0; |
| 989 | ctx->Array.LockCount = 0; |
| 990 | ctx->NewState |= _NEW_ARRAY; |
Keith Whitwell | cab974c | 2000-12-26 05:09:27 +0000 | [diff] [blame] | 991 | ctx->Array.NewState |= _NEW_ARRAY_ALL; |
Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 992 | } |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 993 | |
| 994 | |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 995 | /* GL_EXT_multi_draw_arrays */ |
| 996 | /* Somebody forgot to spec the first and count parameters as const! <sigh> */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 997 | void GLAPIENTRY |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 998 | _mesa_MultiDrawArraysEXT( GLenum mode, GLint *first, |
| 999 | GLsizei *count, GLsizei primcount ) |
| 1000 | { |
| 1001 | GET_CURRENT_CONTEXT(ctx); |
| 1002 | GLint i; |
| 1003 | |
| 1004 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1005 | |
| 1006 | for (i = 0; i < primcount; i++) { |
| 1007 | if (count[i] > 0) { |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 1008 | CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i])); |
Brian Paul | 2525bc7 | 2002-06-30 15:47:00 +0000 | [diff] [blame] | 1009 | } |
| 1010 | } |
| 1011 | } |
| 1012 | |
| 1013 | |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1014 | /* GL_IBM_multimode_draw_arrays */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1015 | void GLAPIENTRY |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1016 | _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, |
| 1017 | const GLsizei * count, |
| 1018 | GLsizei primcount, GLint modestride ) |
| 1019 | { |
| 1020 | GET_CURRENT_CONTEXT(ctx); |
| 1021 | GLint i; |
| 1022 | |
| 1023 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1024 | |
| 1025 | for ( i = 0 ; i < primcount ; i++ ) { |
| 1026 | if ( count[i] > 0 ) { |
Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 1027 | GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 1028 | CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] )); |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1029 | } |
| 1030 | } |
| 1031 | } |
| 1032 | |
| 1033 | |
| 1034 | /* GL_IBM_multimode_draw_arrays */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1035 | void GLAPIENTRY |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1036 | _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, |
| 1037 | GLenum type, const GLvoid * const * indices, |
| 1038 | GLsizei primcount, GLint modestride ) |
| 1039 | { |
| 1040 | GET_CURRENT_CONTEXT(ctx); |
| 1041 | GLint i; |
| 1042 | |
| 1043 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); |
| 1044 | |
Brian Paul | d2afb39 | 2003-09-17 18:15:13 +0000 | [diff] [blame] | 1045 | /* XXX not sure about ARB_vertex_buffer_object handling here */ |
| 1046 | |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1047 | for ( i = 0 ; i < primcount ; i++ ) { |
| 1048 | if ( count[i] > 0 ) { |
Brian Paul | 03e29a5 | 2003-12-04 03:16:27 +0000 | [diff] [blame] | 1049 | GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); |
Ian Romanick | 9bdfee3 | 2005-07-18 12:31:24 +0000 | [diff] [blame] | 1050 | CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] )); |
Ian Romanick | 3baefe6 | 2003-08-22 23:28:03 +0000 | [diff] [blame] | 1051 | } |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 1056 | /** |
Brian Paul | b288540 | 2009-08-06 13:53:06 -0600 | [diff] [blame] | 1057 | * Copy one client vertex array to another. |
| 1058 | */ |
| 1059 | void |
| 1060 | _mesa_copy_client_array(GLcontext *ctx, |
| 1061 | struct gl_client_array *dst, |
| 1062 | struct gl_client_array *src) |
| 1063 | { |
| 1064 | dst->Size = src->Size; |
| 1065 | dst->Type = src->Type; |
| 1066 | dst->Format = src->Format; |
| 1067 | dst->Stride = src->Stride; |
| 1068 | dst->StrideB = src->StrideB; |
| 1069 | dst->Ptr = src->Ptr; |
| 1070 | dst->Enabled = src->Enabled; |
| 1071 | dst->Normalized = src->Normalized; |
| 1072 | dst->_ElementSize = src->_ElementSize; |
| 1073 | _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); |
| 1074 | dst->_MaxElement = src->_MaxElement; |
| 1075 | } |
| 1076 | |
| 1077 | |
| 1078 | |
| 1079 | /** |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1080 | * Print vertex array's fields. |
| 1081 | */ |
| 1082 | static void |
| 1083 | print_array(const char *name, GLint index, const struct gl_client_array *array) |
| 1084 | { |
| 1085 | if (index >= 0) |
| 1086 | _mesa_printf(" %s[%d]: ", name, index); |
| 1087 | else |
| 1088 | _mesa_printf(" %s: ", name); |
| 1089 | _mesa_printf("Ptr=%p, Type=0x%x, Size=%d, ElemSize=%u, Stride=%d, Buffer=%u(Size %u), MaxElem=%u\n", |
| 1090 | array->Ptr, array->Type, array->Size, |
| 1091 | array->_ElementSize, array->StrideB, |
| 1092 | array->BufferObj->Name, array->BufferObj->Size, |
| 1093 | array->_MaxElement); |
| 1094 | } |
| 1095 | |
| 1096 | |
| 1097 | /** |
| 1098 | * Print current vertex object/array info. For debug. |
| 1099 | */ |
| 1100 | void |
| 1101 | _mesa_print_arrays(GLcontext *ctx) |
| 1102 | { |
Brian Paul | 6a2211f | 2009-05-21 15:55:50 -0600 | [diff] [blame] | 1103 | struct gl_array_object *arrayObj = ctx->Array.ArrayObj; |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1104 | GLuint i; |
| 1105 | |
Brian Paul | 8fe3134 | 2009-05-21 15:36:25 -0600 | [diff] [blame] | 1106 | _mesa_update_array_object_max_element(ctx, arrayObj); |
| 1107 | |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1108 | _mesa_printf("Array Object %u\n", arrayObj->Name); |
| 1109 | if (arrayObj->Vertex.Enabled) |
| 1110 | print_array("Vertex", -1, &arrayObj->Vertex); |
| 1111 | if (arrayObj->Normal.Enabled) |
| 1112 | print_array("Normal", -1, &arrayObj->Normal); |
| 1113 | if (arrayObj->Color.Enabled) |
| 1114 | print_array("Color", -1, &arrayObj->Color); |
Brian Paul | d30163a | 2009-05-22 14:23:02 -0600 | [diff] [blame] | 1115 | for (i = 0; i < Elements(arrayObj->TexCoord); i++) |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1116 | if (arrayObj->TexCoord[i].Enabled) |
| 1117 | print_array("TexCoord", i, &arrayObj->TexCoord[i]); |
Brian Paul | d30163a | 2009-05-22 14:23:02 -0600 | [diff] [blame] | 1118 | for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) |
Brian Paul | 39d7524 | 2009-05-14 16:25:32 -0600 | [diff] [blame] | 1119 | if (arrayObj->VertexAttrib[i].Enabled) |
| 1120 | print_array("Attrib", i, &arrayObj->VertexAttrib[i]); |
| 1121 | _mesa_printf(" _MaxElement = %u\n", arrayObj->_MaxElement); |
| 1122 | } |
| 1123 | |
| 1124 | |
| 1125 | /** |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 1126 | * Initialize vertex array state for given context. |
| 1127 | */ |
Kendall Bennett | c40d1dd | 2003-10-21 22:22:17 +0000 | [diff] [blame] | 1128 | void |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 1129 | _mesa_init_varray(GLcontext *ctx) |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1130 | { |
Ian Romanick | ee34e6e | 2006-06-12 16:26:29 +0000 | [diff] [blame] | 1131 | ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0); |
Brian Paul | 1030bf0 | 2009-05-07 13:52:26 -0600 | [diff] [blame] | 1132 | _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, |
| 1133 | ctx->Array.DefaultArrayObj); |
Brian Paul | 095c669 | 2006-04-25 00:21:32 +0000 | [diff] [blame] | 1134 | ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */ |
Brian Paul | 12cf98f | 2009-06-19 17:58:47 -0600 | [diff] [blame] | 1135 | |
| 1136 | ctx->Array.Objects = _mesa_NewHashTable(); |
| 1137 | } |
| 1138 | |
| 1139 | |
| 1140 | /** |
| 1141 | * Callback for deleting an array object. Called by _mesa_HashDeleteAll(). |
| 1142 | */ |
| 1143 | static void |
| 1144 | delete_arrayobj_cb(GLuint id, void *data, void *userData) |
| 1145 | { |
| 1146 | struct gl_array_object *arrayObj = (struct gl_array_object *) data; |
| 1147 | GLcontext *ctx = (GLcontext *) userData; |
| 1148 | _mesa_delete_array_object(ctx, arrayObj); |
| 1149 | } |
| 1150 | |
| 1151 | |
| 1152 | /** |
| 1153 | * Free vertex array state for given context. |
| 1154 | */ |
| 1155 | void |
| 1156 | _mesa_free_varray_data(GLcontext *ctx) |
| 1157 | { |
| 1158 | _mesa_HashDeleteAll(ctx->Array.Objects, delete_arrayobj_cb, ctx); |
| 1159 | _mesa_DeleteHashTable(ctx->Array.Objects); |
Keith Whitwell | 6dc8557 | 2003-07-17 13:43:59 +0000 | [diff] [blame] | 1160 | } |