2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Keith Whitwell <keith@tungstengraphics.com>
30 #include "api_arrayelt.h"
33 #include "mfeatures.h"
38 #include "main/dispatch.h"
39 #include "vbo/vbo_context.h"
43 * Use the per-vertex functions found in <vfmt> to initialize the given
47 install_vtxfmt(struct gl_context
*ctx
, struct _glapi_table
*tab
,
48 const GLvertexformat
*vfmt
)
50 assert(ctx
->Version
> 0);
52 if (ctx
->API
!= API_OPENGL_CORE
&& ctx
->API
!= API_OPENGLES2
) {
53 SET_Color4f(tab
, vfmt
->Color4f
);
56 if (ctx
->API
== API_OPENGL_COMPAT
) {
57 _mesa_install_arrayelt_vtxfmt(tab
, vfmt
);
58 SET_Color3f(tab
, vfmt
->Color3f
);
59 SET_Color3fv(tab
, vfmt
->Color3fv
);
60 SET_Color4fv(tab
, vfmt
->Color4fv
);
61 SET_EdgeFlag(tab
, vfmt
->EdgeFlag
);
64 if (ctx
->API
== API_OPENGL_COMPAT
) {
65 _mesa_install_eval_vtxfmt(tab
, vfmt
);
68 if (ctx
->API
!= API_OPENGL_CORE
&& ctx
->API
!= API_OPENGLES2
) {
69 SET_Materialfv(tab
, vfmt
->Materialfv
);
70 SET_MultiTexCoord4fARB(tab
, vfmt
->MultiTexCoord4fARB
);
71 SET_Normal3f(tab
, vfmt
->Normal3f
);
74 if (ctx
->API
== API_OPENGL_COMPAT
) {
75 SET_FogCoordfEXT(tab
, vfmt
->FogCoordfEXT
);
76 SET_FogCoordfvEXT(tab
, vfmt
->FogCoordfvEXT
);
77 SET_Indexf(tab
, vfmt
->Indexf
);
78 SET_Indexfv(tab
, vfmt
->Indexfv
);
79 SET_MultiTexCoord1fARB(tab
, vfmt
->MultiTexCoord1fARB
);
80 SET_MultiTexCoord1fvARB(tab
, vfmt
->MultiTexCoord1fvARB
);
81 SET_MultiTexCoord2fARB(tab
, vfmt
->MultiTexCoord2fARB
);
82 SET_MultiTexCoord2fvARB(tab
, vfmt
->MultiTexCoord2fvARB
);
83 SET_MultiTexCoord3fARB(tab
, vfmt
->MultiTexCoord3fARB
);
84 SET_MultiTexCoord3fvARB(tab
, vfmt
->MultiTexCoord3fvARB
);
85 SET_MultiTexCoord4fvARB(tab
, vfmt
->MultiTexCoord4fvARB
);
86 SET_Normal3fv(tab
, vfmt
->Normal3fv
);
89 if (ctx
->API
== API_OPENGL_COMPAT
) {
90 SET_SecondaryColor3fEXT(tab
, vfmt
->SecondaryColor3fEXT
);
91 SET_SecondaryColor3fvEXT(tab
, vfmt
->SecondaryColor3fvEXT
);
92 SET_TexCoord1f(tab
, vfmt
->TexCoord1f
);
93 SET_TexCoord1fv(tab
, vfmt
->TexCoord1fv
);
94 SET_TexCoord2f(tab
, vfmt
->TexCoord2f
);
95 SET_TexCoord2fv(tab
, vfmt
->TexCoord2fv
);
96 SET_TexCoord3f(tab
, vfmt
->TexCoord3f
);
97 SET_TexCoord3fv(tab
, vfmt
->TexCoord3fv
);
98 SET_TexCoord4f(tab
, vfmt
->TexCoord4f
);
99 SET_TexCoord4fv(tab
, vfmt
->TexCoord4fv
);
100 SET_Vertex2f(tab
, vfmt
->Vertex2f
);
101 SET_Vertex2fv(tab
, vfmt
->Vertex2fv
);
102 SET_Vertex3f(tab
, vfmt
->Vertex3f
);
103 SET_Vertex3fv(tab
, vfmt
->Vertex3fv
);
104 SET_Vertex4f(tab
, vfmt
->Vertex4f
);
105 SET_Vertex4fv(tab
, vfmt
->Vertex4fv
);
108 if (ctx
->API
== API_OPENGL_COMPAT
) {
109 _mesa_install_dlist_vtxfmt(tab
, vfmt
); /* glCallList / glCallLists */
111 SET_Begin(tab
, vfmt
->Begin
);
112 SET_End(tab
, vfmt
->End
);
113 SET_PrimitiveRestartNV(tab
, vfmt
->PrimitiveRestartNV
);
115 SET_Rectf(tab
, vfmt
->Rectf
);
118 SET_DrawArrays(tab
, vfmt
->DrawArrays
);
119 SET_DrawElements(tab
, vfmt
->DrawElements
);
120 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles3(ctx
)) {
121 SET_DrawRangeElements(tab
, vfmt
->DrawRangeElements
);
124 SET_MultiDrawElementsEXT(tab
, vfmt
->MultiDrawElementsEXT
);
126 if (_mesa_is_desktop_gl(ctx
)) {
127 SET_DrawElementsBaseVertex(tab
, vfmt
->DrawElementsBaseVertex
);
128 SET_DrawRangeElementsBaseVertex(tab
, vfmt
->DrawRangeElementsBaseVertex
);
129 SET_MultiDrawElementsBaseVertex(tab
, vfmt
->MultiDrawElementsBaseVertex
);
130 SET_DrawArraysInstancedBaseInstance(tab
, vfmt
->DrawArraysInstancedBaseInstance
);
131 SET_DrawElementsInstancedBaseInstance(tab
, vfmt
->DrawElementsInstancedBaseInstance
);
132 SET_DrawElementsInstancedBaseVertex(tab
, vfmt
->DrawElementsInstancedBaseVertex
);
133 SET_DrawElementsInstancedBaseVertexBaseInstance(tab
, vfmt
->DrawElementsInstancedBaseVertexBaseInstance
);
136 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles3(ctx
)) {
137 SET_DrawArraysInstancedARB(tab
, vfmt
->DrawArraysInstanced
);
138 SET_DrawElementsInstancedARB(tab
, vfmt
->DrawElementsInstanced
);
141 if (_mesa_is_desktop_gl(ctx
)) {
142 SET_DrawTransformFeedback(tab
, vfmt
->DrawTransformFeedback
);
143 SET_DrawTransformFeedbackStream(tab
, vfmt
->DrawTransformFeedbackStream
);
144 SET_DrawTransformFeedbackInstanced(tab
,
145 vfmt
->DrawTransformFeedbackInstanced
);
146 SET_DrawTransformFeedbackStreamInstanced(tab
,
147 vfmt
->DrawTransformFeedbackStreamInstanced
);
150 /* Originally for GL_NV_vertex_program, this is also used by dlist.c */
151 if (ctx
->API
== API_OPENGL_COMPAT
) {
152 SET_VertexAttrib1fNV(tab
, vfmt
->VertexAttrib1fNV
);
153 SET_VertexAttrib1fvNV(tab
, vfmt
->VertexAttrib1fvNV
);
154 SET_VertexAttrib2fNV(tab
, vfmt
->VertexAttrib2fNV
);
155 SET_VertexAttrib2fvNV(tab
, vfmt
->VertexAttrib2fvNV
);
156 SET_VertexAttrib3fNV(tab
, vfmt
->VertexAttrib3fNV
);
157 SET_VertexAttrib3fvNV(tab
, vfmt
->VertexAttrib3fvNV
);
158 SET_VertexAttrib4fNV(tab
, vfmt
->VertexAttrib4fNV
);
159 SET_VertexAttrib4fvNV(tab
, vfmt
->VertexAttrib4fvNV
);
162 if (ctx
->API
!= API_OPENGLES
) {
163 SET_VertexAttrib1fARB(tab
, vfmt
->VertexAttrib1fARB
);
164 SET_VertexAttrib1fvARB(tab
, vfmt
->VertexAttrib1fvARB
);
165 SET_VertexAttrib2fARB(tab
, vfmt
->VertexAttrib2fARB
);
166 SET_VertexAttrib2fvARB(tab
, vfmt
->VertexAttrib2fvARB
);
167 SET_VertexAttrib3fARB(tab
, vfmt
->VertexAttrib3fARB
);
168 SET_VertexAttrib3fvARB(tab
, vfmt
->VertexAttrib3fvARB
);
169 SET_VertexAttrib4fARB(tab
, vfmt
->VertexAttrib4fARB
);
170 SET_VertexAttrib4fvARB(tab
, vfmt
->VertexAttrib4fvARB
);
173 /* GL_EXT_gpu_shader4 / OpenGL 3.0 */
174 if (_mesa_is_desktop_gl(ctx
)) {
175 SET_VertexAttribI1iEXT(tab
, vfmt
->VertexAttribI1i
);
176 SET_VertexAttribI2iEXT(tab
, vfmt
->VertexAttribI2i
);
177 SET_VertexAttribI3iEXT(tab
, vfmt
->VertexAttribI3i
);
178 SET_VertexAttribI2ivEXT(tab
, vfmt
->VertexAttribI2iv
);
179 SET_VertexAttribI3ivEXT(tab
, vfmt
->VertexAttribI3iv
);
181 SET_VertexAttribI1uiEXT(tab
, vfmt
->VertexAttribI1ui
);
182 SET_VertexAttribI2uiEXT(tab
, vfmt
->VertexAttribI2ui
);
183 SET_VertexAttribI3uiEXT(tab
, vfmt
->VertexAttribI3ui
);
184 SET_VertexAttribI2uivEXT(tab
, vfmt
->VertexAttribI2uiv
);
185 SET_VertexAttribI3uivEXT(tab
, vfmt
->VertexAttribI3uiv
);
188 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles3(ctx
)) {
189 SET_VertexAttribI4iEXT(tab
, vfmt
->VertexAttribI4i
);
190 SET_VertexAttribI4ivEXT(tab
, vfmt
->VertexAttribI4iv
);
191 SET_VertexAttribI4uiEXT(tab
, vfmt
->VertexAttribI4ui
);
192 SET_VertexAttribI4uivEXT(tab
, vfmt
->VertexAttribI4uiv
);
195 if (ctx
->API
== API_OPENGL_COMPAT
) {
196 /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */
197 SET_VertexP2ui(tab
, vfmt
->VertexP2ui
);
198 SET_VertexP2uiv(tab
, vfmt
->VertexP2uiv
);
199 SET_VertexP3ui(tab
, vfmt
->VertexP3ui
);
200 SET_VertexP3uiv(tab
, vfmt
->VertexP3uiv
);
201 SET_VertexP4ui(tab
, vfmt
->VertexP4ui
);
202 SET_VertexP4uiv(tab
, vfmt
->VertexP4uiv
);
204 SET_TexCoordP1ui(tab
, vfmt
->TexCoordP1ui
);
205 SET_TexCoordP1uiv(tab
, vfmt
->TexCoordP1uiv
);
206 SET_TexCoordP2ui(tab
, vfmt
->TexCoordP2ui
);
207 SET_TexCoordP2uiv(tab
, vfmt
->TexCoordP2uiv
);
208 SET_TexCoordP3ui(tab
, vfmt
->TexCoordP3ui
);
209 SET_TexCoordP3uiv(tab
, vfmt
->TexCoordP3uiv
);
210 SET_TexCoordP4ui(tab
, vfmt
->TexCoordP4ui
);
211 SET_TexCoordP4uiv(tab
, vfmt
->TexCoordP4uiv
);
213 SET_MultiTexCoordP1ui(tab
, vfmt
->MultiTexCoordP1ui
);
214 SET_MultiTexCoordP2ui(tab
, vfmt
->MultiTexCoordP2ui
);
215 SET_MultiTexCoordP3ui(tab
, vfmt
->MultiTexCoordP3ui
);
216 SET_MultiTexCoordP4ui(tab
, vfmt
->MultiTexCoordP4ui
);
217 SET_MultiTexCoordP1uiv(tab
, vfmt
->MultiTexCoordP1uiv
);
218 SET_MultiTexCoordP2uiv(tab
, vfmt
->MultiTexCoordP2uiv
);
219 SET_MultiTexCoordP3uiv(tab
, vfmt
->MultiTexCoordP3uiv
);
220 SET_MultiTexCoordP4uiv(tab
, vfmt
->MultiTexCoordP4uiv
);
222 SET_NormalP3ui(tab
, vfmt
->NormalP3ui
);
223 SET_NormalP3uiv(tab
, vfmt
->NormalP3uiv
);
225 SET_ColorP3ui(tab
, vfmt
->ColorP3ui
);
226 SET_ColorP4ui(tab
, vfmt
->ColorP4ui
);
227 SET_ColorP3uiv(tab
, vfmt
->ColorP3uiv
);
228 SET_ColorP4uiv(tab
, vfmt
->ColorP4uiv
);
230 SET_SecondaryColorP3ui(tab
, vfmt
->SecondaryColorP3ui
);
231 SET_SecondaryColorP3uiv(tab
, vfmt
->SecondaryColorP3uiv
);
234 if (_mesa_is_desktop_gl(ctx
)) {
235 SET_VertexAttribP1ui(tab
, vfmt
->VertexAttribP1ui
);
236 SET_VertexAttribP2ui(tab
, vfmt
->VertexAttribP2ui
);
237 SET_VertexAttribP3ui(tab
, vfmt
->VertexAttribP3ui
);
238 SET_VertexAttribP4ui(tab
, vfmt
->VertexAttribP4ui
);
240 SET_VertexAttribP1uiv(tab
, vfmt
->VertexAttribP1uiv
);
241 SET_VertexAttribP2uiv(tab
, vfmt
->VertexAttribP2uiv
);
242 SET_VertexAttribP3uiv(tab
, vfmt
->VertexAttribP3uiv
);
243 SET_VertexAttribP4uiv(tab
, vfmt
->VertexAttribP4uiv
);
249 * Install per-vertex functions into the API dispatch table for execution.
252 _mesa_install_exec_vtxfmt(struct gl_context
*ctx
, const GLvertexformat
*vfmt
)
254 install_vtxfmt( ctx
, ctx
->Exec
, vfmt
);
259 * Install per-vertex functions into the API dispatch table for display
263 _mesa_install_save_vtxfmt(struct gl_context
*ctx
, const GLvertexformat
*vfmt
)
265 if (_mesa_is_desktop_gl(ctx
))
266 install_vtxfmt( ctx
, ctx
->Save
, vfmt
);
271 * Install VBO vtxfmt functions.
273 * This function depends on ctx->Version.
276 _mesa_initialize_vbo_vtxfmt(struct gl_context
*ctx
)
278 struct vbo_exec_context
*exec
= &vbo_context(ctx
)->exec
;
279 _mesa_install_exec_vtxfmt(ctx
, &exec
->vtxfmt
);
280 if (ctx
->API
== API_OPENGL_COMPAT
) {
281 _mesa_install_save_vtxfmt(ctx
, &ctx
->ListState
.ListVtxfmt
);