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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
26 * Keith Whitwell <keith@tungstengraphics.com> Gareth Hughes
30 #include "api_arrayelt.h"
37 #include "main/dispatch.h"
38 #include "vbo/vbo_context.h"
42 * Copy the functions found in the GLvertexformat object into the
46 install_vtxfmt(struct gl_context
*ctx
, struct _glapi_table
*tab
,
47 const GLvertexformat
*vfmt
)
49 assert(ctx
->Version
> 0);
51 if (ctx
->API
!= API_OPENGL_CORE
&& ctx
->API
!= API_OPENGLES2
) {
52 SET_Color4f(tab
, vfmt
->Color4f
);
55 if (ctx
->API
== API_OPENGL_COMPAT
) {
56 _mesa_install_arrayelt_vtxfmt(tab
, vfmt
);
57 SET_Color3f(tab
, vfmt
->Color3f
);
58 SET_Color3fv(tab
, vfmt
->Color3fv
);
59 SET_Color4fv(tab
, vfmt
->Color4fv
);
60 SET_EdgeFlag(tab
, vfmt
->EdgeFlag
);
63 if (ctx
->API
== API_OPENGL_COMPAT
) {
64 _mesa_install_eval_vtxfmt(tab
, vfmt
);
67 if (ctx
->API
!= API_OPENGL_CORE
&& ctx
->API
!= API_OPENGLES2
) {
68 SET_Materialfv(tab
, vfmt
->Materialfv
);
69 SET_MultiTexCoord4fARB(tab
, vfmt
->MultiTexCoord4fARB
);
70 SET_Normal3f(tab
, vfmt
->Normal3f
);
73 if (ctx
->API
== API_OPENGL_COMPAT
) {
74 SET_FogCoordfEXT(tab
, vfmt
->FogCoordfEXT
);
75 SET_FogCoordfvEXT(tab
, vfmt
->FogCoordfvEXT
);
76 SET_Indexf(tab
, vfmt
->Indexf
);
77 SET_Indexfv(tab
, vfmt
->Indexfv
);
78 SET_MultiTexCoord1fARB(tab
, vfmt
->MultiTexCoord1fARB
);
79 SET_MultiTexCoord1fvARB(tab
, vfmt
->MultiTexCoord1fvARB
);
80 SET_MultiTexCoord2fARB(tab
, vfmt
->MultiTexCoord2fARB
);
81 SET_MultiTexCoord2fvARB(tab
, vfmt
->MultiTexCoord2fvARB
);
82 SET_MultiTexCoord3fARB(tab
, vfmt
->MultiTexCoord3fARB
);
83 SET_MultiTexCoord3fvARB(tab
, vfmt
->MultiTexCoord3fvARB
);
84 SET_MultiTexCoord4fvARB(tab
, vfmt
->MultiTexCoord4fvARB
);
85 SET_Normal3fv(tab
, vfmt
->Normal3fv
);
88 if (ctx
->API
== API_OPENGL_COMPAT
) {
89 SET_SecondaryColor3fEXT(tab
, vfmt
->SecondaryColor3fEXT
);
90 SET_SecondaryColor3fvEXT(tab
, vfmt
->SecondaryColor3fvEXT
);
91 SET_TexCoord1f(tab
, vfmt
->TexCoord1f
);
92 SET_TexCoord1fv(tab
, vfmt
->TexCoord1fv
);
93 SET_TexCoord2f(tab
, vfmt
->TexCoord2f
);
94 SET_TexCoord2fv(tab
, vfmt
->TexCoord2fv
);
95 SET_TexCoord3f(tab
, vfmt
->TexCoord3f
);
96 SET_TexCoord3fv(tab
, vfmt
->TexCoord3fv
);
97 SET_TexCoord4f(tab
, vfmt
->TexCoord4f
);
98 SET_TexCoord4fv(tab
, vfmt
->TexCoord4fv
);
99 SET_Vertex2f(tab
, vfmt
->Vertex2f
);
100 SET_Vertex2fv(tab
, vfmt
->Vertex2fv
);
101 SET_Vertex3f(tab
, vfmt
->Vertex3f
);
102 SET_Vertex3fv(tab
, vfmt
->Vertex3fv
);
103 SET_Vertex4f(tab
, vfmt
->Vertex4f
);
104 SET_Vertex4fv(tab
, vfmt
->Vertex4fv
);
107 if (ctx
->API
== API_OPENGL_COMPAT
) {
108 _mesa_install_dlist_vtxfmt(tab
, vfmt
); /* glCallList / glCallLists */
110 SET_Begin(tab
, vfmt
->Begin
);
111 SET_End(tab
, vfmt
->End
);
112 SET_PrimitiveRestartNV(tab
, vfmt
->PrimitiveRestartNV
);
115 /* Originally for GL_NV_vertex_program, this is also used by dlist.c */
116 if (ctx
->API
== API_OPENGL_COMPAT
) {
117 SET_VertexAttrib1fNV(tab
, vfmt
->VertexAttrib1fNV
);
118 SET_VertexAttrib1fvNV(tab
, vfmt
->VertexAttrib1fvNV
);
119 SET_VertexAttrib2fNV(tab
, vfmt
->VertexAttrib2fNV
);
120 SET_VertexAttrib2fvNV(tab
, vfmt
->VertexAttrib2fvNV
);
121 SET_VertexAttrib3fNV(tab
, vfmt
->VertexAttrib3fNV
);
122 SET_VertexAttrib3fvNV(tab
, vfmt
->VertexAttrib3fvNV
);
123 SET_VertexAttrib4fNV(tab
, vfmt
->VertexAttrib4fNV
);
124 SET_VertexAttrib4fvNV(tab
, vfmt
->VertexAttrib4fvNV
);
127 if (ctx
->API
!= API_OPENGLES
) {
128 SET_VertexAttrib1fARB(tab
, vfmt
->VertexAttrib1fARB
);
129 SET_VertexAttrib1fvARB(tab
, vfmt
->VertexAttrib1fvARB
);
130 SET_VertexAttrib2fARB(tab
, vfmt
->VertexAttrib2fARB
);
131 SET_VertexAttrib2fvARB(tab
, vfmt
->VertexAttrib2fvARB
);
132 SET_VertexAttrib3fARB(tab
, vfmt
->VertexAttrib3fARB
);
133 SET_VertexAttrib3fvARB(tab
, vfmt
->VertexAttrib3fvARB
);
134 SET_VertexAttrib4fARB(tab
, vfmt
->VertexAttrib4fARB
);
135 SET_VertexAttrib4fvARB(tab
, vfmt
->VertexAttrib4fvARB
);
138 /* GL_EXT_gpu_shader4 / OpenGL 3.0 */
139 if (_mesa_is_desktop_gl(ctx
)) {
140 SET_VertexAttribI1iEXT(tab
, vfmt
->VertexAttribI1i
);
141 SET_VertexAttribI2iEXT(tab
, vfmt
->VertexAttribI2i
);
142 SET_VertexAttribI3iEXT(tab
, vfmt
->VertexAttribI3i
);
143 SET_VertexAttribI2ivEXT(tab
, vfmt
->VertexAttribI2iv
);
144 SET_VertexAttribI3ivEXT(tab
, vfmt
->VertexAttribI3iv
);
146 SET_VertexAttribI1uiEXT(tab
, vfmt
->VertexAttribI1ui
);
147 SET_VertexAttribI2uiEXT(tab
, vfmt
->VertexAttribI2ui
);
148 SET_VertexAttribI3uiEXT(tab
, vfmt
->VertexAttribI3ui
);
149 SET_VertexAttribI2uivEXT(tab
, vfmt
->VertexAttribI2uiv
);
150 SET_VertexAttribI3uivEXT(tab
, vfmt
->VertexAttribI3uiv
);
153 if (_mesa_is_desktop_gl(ctx
) || _mesa_is_gles3(ctx
)) {
154 SET_VertexAttribI4iEXT(tab
, vfmt
->VertexAttribI4i
);
155 SET_VertexAttribI4ivEXT(tab
, vfmt
->VertexAttribI4iv
);
156 SET_VertexAttribI4uiEXT(tab
, vfmt
->VertexAttribI4ui
);
157 SET_VertexAttribI4uivEXT(tab
, vfmt
->VertexAttribI4uiv
);
160 if (ctx
->API
== API_OPENGL_COMPAT
) {
161 /* GL_ARB_vertex_type_10_10_10_2_rev / GL 3.3 */
162 SET_VertexP2ui(tab
, vfmt
->VertexP2ui
);
163 SET_VertexP2uiv(tab
, vfmt
->VertexP2uiv
);
164 SET_VertexP3ui(tab
, vfmt
->VertexP3ui
);
165 SET_VertexP3uiv(tab
, vfmt
->VertexP3uiv
);
166 SET_VertexP4ui(tab
, vfmt
->VertexP4ui
);
167 SET_VertexP4uiv(tab
, vfmt
->VertexP4uiv
);
169 SET_TexCoordP1ui(tab
, vfmt
->TexCoordP1ui
);
170 SET_TexCoordP1uiv(tab
, vfmt
->TexCoordP1uiv
);
171 SET_TexCoordP2ui(tab
, vfmt
->TexCoordP2ui
);
172 SET_TexCoordP2uiv(tab
, vfmt
->TexCoordP2uiv
);
173 SET_TexCoordP3ui(tab
, vfmt
->TexCoordP3ui
);
174 SET_TexCoordP3uiv(tab
, vfmt
->TexCoordP3uiv
);
175 SET_TexCoordP4ui(tab
, vfmt
->TexCoordP4ui
);
176 SET_TexCoordP4uiv(tab
, vfmt
->TexCoordP4uiv
);
178 SET_MultiTexCoordP1ui(tab
, vfmt
->MultiTexCoordP1ui
);
179 SET_MultiTexCoordP2ui(tab
, vfmt
->MultiTexCoordP2ui
);
180 SET_MultiTexCoordP3ui(tab
, vfmt
->MultiTexCoordP3ui
);
181 SET_MultiTexCoordP4ui(tab
, vfmt
->MultiTexCoordP4ui
);
182 SET_MultiTexCoordP1uiv(tab
, vfmt
->MultiTexCoordP1uiv
);
183 SET_MultiTexCoordP2uiv(tab
, vfmt
->MultiTexCoordP2uiv
);
184 SET_MultiTexCoordP3uiv(tab
, vfmt
->MultiTexCoordP3uiv
);
185 SET_MultiTexCoordP4uiv(tab
, vfmt
->MultiTexCoordP4uiv
);
187 SET_NormalP3ui(tab
, vfmt
->NormalP3ui
);
188 SET_NormalP3uiv(tab
, vfmt
->NormalP3uiv
);
190 SET_ColorP3ui(tab
, vfmt
->ColorP3ui
);
191 SET_ColorP4ui(tab
, vfmt
->ColorP4ui
);
192 SET_ColorP3uiv(tab
, vfmt
->ColorP3uiv
);
193 SET_ColorP4uiv(tab
, vfmt
->ColorP4uiv
);
195 SET_SecondaryColorP3ui(tab
, vfmt
->SecondaryColorP3ui
);
196 SET_SecondaryColorP3uiv(tab
, vfmt
->SecondaryColorP3uiv
);
199 if (_mesa_is_desktop_gl(ctx
)) {
200 SET_VertexAttribP1ui(tab
, vfmt
->VertexAttribP1ui
);
201 SET_VertexAttribP2ui(tab
, vfmt
->VertexAttribP2ui
);
202 SET_VertexAttribP3ui(tab
, vfmt
->VertexAttribP3ui
);
203 SET_VertexAttribP4ui(tab
, vfmt
->VertexAttribP4ui
);
205 SET_VertexAttribP1uiv(tab
, vfmt
->VertexAttribP1uiv
);
206 SET_VertexAttribP2uiv(tab
, vfmt
->VertexAttribP2uiv
);
207 SET_VertexAttribP3uiv(tab
, vfmt
->VertexAttribP3uiv
);
208 SET_VertexAttribP4uiv(tab
, vfmt
->VertexAttribP4uiv
);
214 * Install per-vertex functions into the API dispatch table for execution.
217 _mesa_install_exec_vtxfmt(struct gl_context
*ctx
, const GLvertexformat
*vfmt
)
219 install_vtxfmt(ctx
, ctx
->Exec
, vfmt
);
221 install_vtxfmt(ctx
, ctx
->BeginEnd
, vfmt
);
226 * Install per-vertex functions into the API dispatch table for display
230 _mesa_install_save_vtxfmt(struct gl_context
*ctx
, const GLvertexformat
*vfmt
)
232 if (_mesa_is_desktop_gl(ctx
))
233 install_vtxfmt(ctx
, ctx
->Save
, vfmt
);
238 * Install VBO vtxfmt functions.
240 * This function depends on ctx->Version.
243 _mesa_initialize_vbo_vtxfmt(struct gl_context
*ctx
)
245 struct vbo_exec_context
*exec
= &vbo_context(ctx
)->exec
;
246 _mesa_install_exec_vtxfmt(ctx
, &exec
->vtxfmt
);
247 if (ctx
->API
== API_OPENGL_COMPAT
) {
248 _mesa_install_save_vtxfmt(ctx
, &ctx
->ListState
.ListVtxfmt
);