1 /* $Id: state.c,v 1.13 2000/05/23 20:10:50 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * This file initializes the immediate-mode dispatch table (which may
30 * be state-dependant) and manages internal Mesa state update.
96 gl_problem(NULL
, "undefined function dispatch");
103 _mesa_init_no_op_table(struct _glapi_table
*table
)
105 /* Check to be sure the dispatcher's table is at least as big as Mesa's. */
106 const GLuint size
= sizeof(struct _glapi_table
) / sizeof(void *);
107 assert(_glapi_get_dispatch_table_size() >= size
);
110 const GLuint n
= _glapi_get_dispatch_table_size();
112 void **dispatch
= (void **) table
;
113 for (i
= 0; i
< n
; i
++) {
114 dispatch
[i
] = (void *) generic_noop
;
121 * Initialize the given dispatch table with pointers to Mesa's
122 * immediate-mode commands.
125 _mesa_init_exec_table(struct _glapi_table
*exec
)
127 /* first initialize all dispatch slots to no-op */
128 _mesa_init_no_op_table(exec
);
130 /* load the dispatch slots we understand */
131 exec
->Accum
= _mesa_Accum
;
132 exec
->AlphaFunc
= _mesa_AlphaFunc
;
133 exec
->Begin
= _mesa_Begin
;
134 exec
->Bitmap
= _mesa_Bitmap
;
135 exec
->BlendFunc
= _mesa_BlendFunc
;
136 exec
->CallList
= _mesa_CallList
;
137 exec
->CallLists
= _mesa_CallLists
;
138 exec
->Clear
= _mesa_Clear
;
139 exec
->ClearAccum
= _mesa_ClearAccum
;
140 exec
->ClearColor
= _mesa_ClearColor
;
141 exec
->ClearDepth
= _mesa_ClearDepth
;
142 exec
->ClearIndex
= _mesa_ClearIndex
;
143 exec
->ClearStencil
= _mesa_ClearStencil
;
144 exec
->ClipPlane
= _mesa_ClipPlane
;
145 exec
->Color3b
= _mesa_Color3b
;
146 exec
->Color3bv
= _mesa_Color3bv
;
147 exec
->Color3d
= _mesa_Color3d
;
148 exec
->Color3dv
= _mesa_Color3dv
;
149 exec
->Color3f
= _mesa_Color3f
;
150 exec
->Color3fv
= _mesa_Color3fv
;
151 exec
->Color3i
= _mesa_Color3i
;
152 exec
->Color3iv
= _mesa_Color3iv
;
153 exec
->Color3s
= _mesa_Color3s
;
154 exec
->Color3sv
= _mesa_Color3sv
;
155 exec
->Color3ub
= _mesa_Color3ub
;
156 exec
->Color3ubv
= _mesa_Color3ubv
;
157 exec
->Color3ui
= _mesa_Color3ui
;
158 exec
->Color3uiv
= _mesa_Color3uiv
;
159 exec
->Color3us
= _mesa_Color3us
;
160 exec
->Color3usv
= _mesa_Color3usv
;
161 exec
->Color4b
= _mesa_Color4b
;
162 exec
->Color4bv
= _mesa_Color4bv
;
163 exec
->Color4d
= _mesa_Color4d
;
164 exec
->Color4dv
= _mesa_Color4dv
;
165 exec
->Color4f
= _mesa_Color4f
;
166 exec
->Color4fv
= _mesa_Color4fv
;
167 exec
->Color4i
= _mesa_Color4i
;
168 exec
->Color4iv
= _mesa_Color4iv
;
169 exec
->Color4s
= _mesa_Color4s
;
170 exec
->Color4sv
= _mesa_Color4sv
;
171 exec
->Color4ub
= _mesa_Color4ub
;
172 exec
->Color4ubv
= _mesa_Color4ubv
;
173 exec
->Color4ui
= _mesa_Color4ui
;
174 exec
->Color4uiv
= _mesa_Color4uiv
;
175 exec
->Color4us
= _mesa_Color4us
;
176 exec
->Color4usv
= _mesa_Color4usv
;
177 exec
->ColorMask
= _mesa_ColorMask
;
178 exec
->ColorMaterial
= _mesa_ColorMaterial
;
179 exec
->CopyPixels
= _mesa_CopyPixels
;
180 exec
->CullFace
= _mesa_CullFace
;
181 exec
->DeleteLists
= _mesa_DeleteLists
;
182 exec
->DepthFunc
= _mesa_DepthFunc
;
183 exec
->DepthMask
= _mesa_DepthMask
;
184 exec
->DepthRange
= _mesa_DepthRange
;
185 exec
->Disable
= _mesa_Disable
;
186 exec
->DrawBuffer
= _mesa_DrawBuffer
;
187 exec
->DrawPixels
= _mesa_DrawPixels
;
188 exec
->EdgeFlag
= _mesa_EdgeFlag
;
189 exec
->EdgeFlagv
= _mesa_EdgeFlagv
;
190 exec
->Enable
= _mesa_Enable
;
191 exec
->End
= _mesa_End
;
192 exec
->EndList
= _mesa_EndList
;
193 exec
->EvalCoord1d
= _mesa_EvalCoord1d
;
194 exec
->EvalCoord1dv
= _mesa_EvalCoord1dv
;
195 exec
->EvalCoord1f
= _mesa_EvalCoord1f
;
196 exec
->EvalCoord1fv
= _mesa_EvalCoord1fv
;
197 exec
->EvalCoord2d
= _mesa_EvalCoord2d
;
198 exec
->EvalCoord2dv
= _mesa_EvalCoord2dv
;
199 exec
->EvalCoord2f
= _mesa_EvalCoord2f
;
200 exec
->EvalCoord2fv
= _mesa_EvalCoord2fv
;
201 exec
->EvalMesh1
= _mesa_EvalMesh1
;
202 exec
->EvalMesh2
= _mesa_EvalMesh2
;
203 exec
->EvalPoint1
= _mesa_EvalPoint1
;
204 exec
->EvalPoint2
= _mesa_EvalPoint2
;
205 exec
->FeedbackBuffer
= _mesa_FeedbackBuffer
;
206 exec
->Finish
= _mesa_Finish
;
207 exec
->Flush
= _mesa_Flush
;
208 exec
->Fogf
= _mesa_Fogf
;
209 exec
->Fogfv
= _mesa_Fogfv
;
210 exec
->Fogi
= _mesa_Fogi
;
211 exec
->Fogiv
= _mesa_Fogiv
;
212 exec
->FrontFace
= _mesa_FrontFace
;
213 exec
->Frustum
= _mesa_Frustum
;
214 exec
->GenLists
= _mesa_GenLists
;
215 exec
->GetBooleanv
= _mesa_GetBooleanv
;
216 exec
->GetClipPlane
= _mesa_GetClipPlane
;
217 exec
->GetDoublev
= _mesa_GetDoublev
;
218 exec
->GetError
= _mesa_GetError
;
219 exec
->GetFloatv
= _mesa_GetFloatv
;
220 exec
->GetIntegerv
= _mesa_GetIntegerv
;
221 exec
->GetLightfv
= _mesa_GetLightfv
;
222 exec
->GetLightiv
= _mesa_GetLightiv
;
223 exec
->GetMapdv
= _mesa_GetMapdv
;
224 exec
->GetMapfv
= _mesa_GetMapfv
;
225 exec
->GetMapiv
= _mesa_GetMapiv
;
226 exec
->GetMaterialfv
= _mesa_GetMaterialfv
;
227 exec
->GetMaterialiv
= _mesa_GetMaterialiv
;
228 exec
->GetPixelMapfv
= _mesa_GetPixelMapfv
;
229 exec
->GetPixelMapuiv
= _mesa_GetPixelMapuiv
;
230 exec
->GetPixelMapusv
= _mesa_GetPixelMapusv
;
231 exec
->GetPolygonStipple
= _mesa_GetPolygonStipple
;
232 exec
->GetString
= _mesa_GetString
;
233 exec
->GetTexEnvfv
= _mesa_GetTexEnvfv
;
234 exec
->GetTexEnviv
= _mesa_GetTexEnviv
;
235 exec
->GetTexGendv
= _mesa_GetTexGendv
;
236 exec
->GetTexGenfv
= _mesa_GetTexGenfv
;
237 exec
->GetTexGeniv
= _mesa_GetTexGeniv
;
238 exec
->GetTexImage
= _mesa_GetTexImage
;
239 exec
->GetTexLevelParameterfv
= _mesa_GetTexLevelParameterfv
;
240 exec
->GetTexLevelParameteriv
= _mesa_GetTexLevelParameteriv
;
241 exec
->GetTexParameterfv
= _mesa_GetTexParameterfv
;
242 exec
->GetTexParameteriv
= _mesa_GetTexParameteriv
;
243 exec
->Hint
= _mesa_Hint
;
244 exec
->IndexMask
= _mesa_IndexMask
;
245 exec
->Indexd
= _mesa_Indexd
;
246 exec
->Indexdv
= _mesa_Indexdv
;
247 exec
->Indexf
= _mesa_Indexf
;
248 exec
->Indexfv
= _mesa_Indexfv
;
249 exec
->Indexi
= _mesa_Indexi
;
250 exec
->Indexiv
= _mesa_Indexiv
;
251 exec
->Indexs
= _mesa_Indexs
;
252 exec
->Indexsv
= _mesa_Indexsv
;
253 exec
->InitNames
= _mesa_InitNames
;
254 exec
->IsEnabled
= _mesa_IsEnabled
;
255 exec
->IsList
= _mesa_IsList
;
256 exec
->LightModelf
= _mesa_LightModelf
;
257 exec
->LightModelfv
= _mesa_LightModelfv
;
258 exec
->LightModeli
= _mesa_LightModeli
;
259 exec
->LightModeliv
= _mesa_LightModeliv
;
260 exec
->Lightf
= _mesa_Lightf
;
261 exec
->Lightfv
= _mesa_Lightfv
;
262 exec
->Lighti
= _mesa_Lighti
;
263 exec
->Lightiv
= _mesa_Lightiv
;
264 exec
->LineStipple
= _mesa_LineStipple
;
265 exec
->LineWidth
= _mesa_LineWidth
;
266 exec
->ListBase
= _mesa_ListBase
;
267 exec
->LoadIdentity
= _mesa_LoadIdentity
;
268 exec
->LoadMatrixd
= _mesa_LoadMatrixd
;
269 exec
->LoadMatrixf
= _mesa_LoadMatrixf
;
270 exec
->LoadName
= _mesa_LoadName
;
271 exec
->LogicOp
= _mesa_LogicOp
;
272 exec
->Map1d
= _mesa_Map1d
;
273 exec
->Map1f
= _mesa_Map1f
;
274 exec
->Map2d
= _mesa_Map2d
;
275 exec
->Map2f
= _mesa_Map2f
;
276 exec
->MapGrid1d
= _mesa_MapGrid1d
;
277 exec
->MapGrid1f
= _mesa_MapGrid1f
;
278 exec
->MapGrid2d
= _mesa_MapGrid2d
;
279 exec
->MapGrid2f
= _mesa_MapGrid2f
;
280 exec
->Materialf
= _mesa_Materialf
;
281 exec
->Materialfv
= _mesa_Materialfv
;
282 exec
->Materiali
= _mesa_Materiali
;
283 exec
->Materialiv
= _mesa_Materialiv
;
284 exec
->MatrixMode
= _mesa_MatrixMode
;
285 exec
->MultMatrixd
= _mesa_MultMatrixd
;
286 exec
->MultMatrixf
= _mesa_MultMatrixf
;
287 exec
->NewList
= _mesa_NewList
;
288 exec
->Normal3b
= _mesa_Normal3b
;
289 exec
->Normal3bv
= _mesa_Normal3bv
;
290 exec
->Normal3d
= _mesa_Normal3d
;
291 exec
->Normal3dv
= _mesa_Normal3dv
;
292 exec
->Normal3f
= _mesa_Normal3f
;
293 exec
->Normal3fv
= _mesa_Normal3fv
;
294 exec
->Normal3i
= _mesa_Normal3i
;
295 exec
->Normal3iv
= _mesa_Normal3iv
;
296 exec
->Normal3s
= _mesa_Normal3s
;
297 exec
->Normal3sv
= _mesa_Normal3sv
;
298 exec
->Ortho
= _mesa_Ortho
;
299 exec
->PassThrough
= _mesa_PassThrough
;
300 exec
->PixelMapfv
= _mesa_PixelMapfv
;
301 exec
->PixelMapuiv
= _mesa_PixelMapuiv
;
302 exec
->PixelMapusv
= _mesa_PixelMapusv
;
303 exec
->PixelStoref
= _mesa_PixelStoref
;
304 exec
->PixelStorei
= _mesa_PixelStorei
;
305 exec
->PixelTransferf
= _mesa_PixelTransferf
;
306 exec
->PixelTransferi
= _mesa_PixelTransferi
;
307 exec
->PixelZoom
= _mesa_PixelZoom
;
308 exec
->PointSize
= _mesa_PointSize
;
309 exec
->PolygonMode
= _mesa_PolygonMode
;
310 exec
->PolygonOffset
= _mesa_PolygonOffset
;
311 exec
->PolygonStipple
= _mesa_PolygonStipple
;
312 exec
->PopAttrib
= _mesa_PopAttrib
;
313 exec
->PopMatrix
= _mesa_PopMatrix
;
314 exec
->PopName
= _mesa_PopName
;
315 exec
->PushAttrib
= _mesa_PushAttrib
;
316 exec
->PushMatrix
= _mesa_PushMatrix
;
317 exec
->PushName
= _mesa_PushName
;
318 exec
->RasterPos2d
= _mesa_RasterPos2d
;
319 exec
->RasterPos2dv
= _mesa_RasterPos2dv
;
320 exec
->RasterPos2f
= _mesa_RasterPos2f
;
321 exec
->RasterPos2fv
= _mesa_RasterPos2fv
;
322 exec
->RasterPos2i
= _mesa_RasterPos2i
;
323 exec
->RasterPos2iv
= _mesa_RasterPos2iv
;
324 exec
->RasterPos2s
= _mesa_RasterPos2s
;
325 exec
->RasterPos2sv
= _mesa_RasterPos2sv
;
326 exec
->RasterPos3d
= _mesa_RasterPos3d
;
327 exec
->RasterPos3dv
= _mesa_RasterPos3dv
;
328 exec
->RasterPos3f
= _mesa_RasterPos3f
;
329 exec
->RasterPos3fv
= _mesa_RasterPos3fv
;
330 exec
->RasterPos3i
= _mesa_RasterPos3i
;
331 exec
->RasterPos3iv
= _mesa_RasterPos3iv
;
332 exec
->RasterPos3s
= _mesa_RasterPos3s
;
333 exec
->RasterPos3sv
= _mesa_RasterPos3sv
;
334 exec
->RasterPos4d
= _mesa_RasterPos4d
;
335 exec
->RasterPos4dv
= _mesa_RasterPos4dv
;
336 exec
->RasterPos4f
= _mesa_RasterPos4f
;
337 exec
->RasterPos4fv
= _mesa_RasterPos4fv
;
338 exec
->RasterPos4i
= _mesa_RasterPos4i
;
339 exec
->RasterPos4iv
= _mesa_RasterPos4iv
;
340 exec
->RasterPos4s
= _mesa_RasterPos4s
;
341 exec
->RasterPos4sv
= _mesa_RasterPos4sv
;
342 exec
->ReadBuffer
= _mesa_ReadBuffer
;
343 exec
->ReadPixels
= _mesa_ReadPixels
;
344 exec
->Rectd
= _mesa_Rectd
;
345 exec
->Rectdv
= _mesa_Rectdv
;
346 exec
->Rectf
= _mesa_Rectf
;
347 exec
->Rectfv
= _mesa_Rectfv
;
348 exec
->Recti
= _mesa_Recti
;
349 exec
->Rectiv
= _mesa_Rectiv
;
350 exec
->Rects
= _mesa_Rects
;
351 exec
->Rectsv
= _mesa_Rectsv
;
352 exec
->RenderMode
= _mesa_RenderMode
;
353 exec
->Rotated
= _mesa_Rotated
;
354 exec
->Rotatef
= _mesa_Rotatef
;
355 exec
->Scaled
= _mesa_Scaled
;
356 exec
->Scalef
= _mesa_Scalef
;
357 exec
->Scissor
= _mesa_Scissor
;
358 exec
->SelectBuffer
= _mesa_SelectBuffer
;
359 exec
->ShadeModel
= _mesa_ShadeModel
;
360 exec
->StencilFunc
= _mesa_StencilFunc
;
361 exec
->StencilMask
= _mesa_StencilMask
;
362 exec
->StencilOp
= _mesa_StencilOp
;
363 exec
->TexCoord1d
= _mesa_TexCoord1d
;
364 exec
->TexCoord1dv
= _mesa_TexCoord1dv
;
365 exec
->TexCoord1f
= _mesa_TexCoord1f
;
366 exec
->TexCoord1fv
= _mesa_TexCoord1fv
;
367 exec
->TexCoord1i
= _mesa_TexCoord1i
;
368 exec
->TexCoord1iv
= _mesa_TexCoord1iv
;
369 exec
->TexCoord1s
= _mesa_TexCoord1s
;
370 exec
->TexCoord1sv
= _mesa_TexCoord1sv
;
371 exec
->TexCoord2d
= _mesa_TexCoord2d
;
372 exec
->TexCoord2dv
= _mesa_TexCoord2dv
;
373 exec
->TexCoord2f
= _mesa_TexCoord2f
;
374 exec
->TexCoord2fv
= _mesa_TexCoord2fv
;
375 exec
->TexCoord2i
= _mesa_TexCoord2i
;
376 exec
->TexCoord2iv
= _mesa_TexCoord2iv
;
377 exec
->TexCoord2s
= _mesa_TexCoord2s
;
378 exec
->TexCoord2sv
= _mesa_TexCoord2sv
;
379 exec
->TexCoord3d
= _mesa_TexCoord3d
;
380 exec
->TexCoord3dv
= _mesa_TexCoord3dv
;
381 exec
->TexCoord3f
= _mesa_TexCoord3f
;
382 exec
->TexCoord3fv
= _mesa_TexCoord3fv
;
383 exec
->TexCoord3i
= _mesa_TexCoord3i
;
384 exec
->TexCoord3iv
= _mesa_TexCoord3iv
;
385 exec
->TexCoord3s
= _mesa_TexCoord3s
;
386 exec
->TexCoord3sv
= _mesa_TexCoord3sv
;
387 exec
->TexCoord4d
= _mesa_TexCoord4d
;
388 exec
->TexCoord4dv
= _mesa_TexCoord4dv
;
389 exec
->TexCoord4f
= _mesa_TexCoord4f
;
390 exec
->TexCoord4fv
= _mesa_TexCoord4fv
;
391 exec
->TexCoord4i
= _mesa_TexCoord4i
;
392 exec
->TexCoord4iv
= _mesa_TexCoord4iv
;
393 exec
->TexCoord4s
= _mesa_TexCoord4s
;
394 exec
->TexCoord4sv
= _mesa_TexCoord4sv
;
395 exec
->TexEnvf
= _mesa_TexEnvf
;
396 exec
->TexEnvfv
= _mesa_TexEnvfv
;
397 exec
->TexEnvi
= _mesa_TexEnvi
;
398 exec
->TexEnviv
= _mesa_TexEnviv
;
399 exec
->TexGend
= _mesa_TexGend
;
400 exec
->TexGendv
= _mesa_TexGendv
;
401 exec
->TexGenf
= _mesa_TexGenf
;
402 exec
->TexGenfv
= _mesa_TexGenfv
;
403 exec
->TexGeni
= _mesa_TexGeni
;
404 exec
->TexGeniv
= _mesa_TexGeniv
;
405 exec
->TexImage1D
= _mesa_TexImage1D
;
406 exec
->TexImage2D
= _mesa_TexImage2D
;
407 exec
->TexParameterf
= _mesa_TexParameterf
;
408 exec
->TexParameterfv
= _mesa_TexParameterfv
;
409 exec
->TexParameteri
= _mesa_TexParameteri
;
410 exec
->TexParameteriv
= _mesa_TexParameteriv
;
411 exec
->Translated
= _mesa_Translated
;
412 exec
->Translatef
= _mesa_Translatef
;
413 exec
->Vertex2d
= _mesa_Vertex2d
;
414 exec
->Vertex2dv
= _mesa_Vertex2dv
;
415 exec
->Vertex2f
= _mesa_Vertex2f
;
416 exec
->Vertex2fv
= _mesa_Vertex2fv
;
417 exec
->Vertex2i
= _mesa_Vertex2i
;
418 exec
->Vertex2iv
= _mesa_Vertex2iv
;
419 exec
->Vertex2s
= _mesa_Vertex2s
;
420 exec
->Vertex2sv
= _mesa_Vertex2sv
;
421 exec
->Vertex3d
= _mesa_Vertex3d
;
422 exec
->Vertex3dv
= _mesa_Vertex3dv
;
423 exec
->Vertex3f
= _mesa_Vertex3f
;
424 exec
->Vertex3fv
= _mesa_Vertex3fv
;
425 exec
->Vertex3i
= _mesa_Vertex3i
;
426 exec
->Vertex3iv
= _mesa_Vertex3iv
;
427 exec
->Vertex3s
= _mesa_Vertex3s
;
428 exec
->Vertex3sv
= _mesa_Vertex3sv
;
429 exec
->Vertex4d
= _mesa_Vertex4d
;
430 exec
->Vertex4dv
= _mesa_Vertex4dv
;
431 exec
->Vertex4f
= _mesa_Vertex4f
;
432 exec
->Vertex4fv
= _mesa_Vertex4fv
;
433 exec
->Vertex4i
= _mesa_Vertex4i
;
434 exec
->Vertex4iv
= _mesa_Vertex4iv
;
435 exec
->Vertex4s
= _mesa_Vertex4s
;
436 exec
->Vertex4sv
= _mesa_Vertex4sv
;
437 exec
->Viewport
= _mesa_Viewport
;
440 exec
->AreTexturesResident
= _mesa_AreTexturesResident
;
441 exec
->ArrayElement
= _mesa_ArrayElement
;
442 exec
->BindTexture
= _mesa_BindTexture
;
443 exec
->ColorPointer
= _mesa_ColorPointer
;
444 exec
->CopyTexImage1D
= _mesa_CopyTexImage1D
;
445 exec
->CopyTexImage2D
= _mesa_CopyTexImage2D
;
446 exec
->CopyTexSubImage1D
= _mesa_CopyTexSubImage1D
;
447 exec
->CopyTexSubImage2D
= _mesa_CopyTexSubImage2D
;
448 exec
->DeleteTextures
= _mesa_DeleteTextures
;
449 exec
->DisableClientState
= _mesa_DisableClientState
;
450 exec
->DrawArrays
= _mesa_DrawArrays
;
451 exec
->DrawElements
= _mesa_DrawElements
;
452 exec
->EdgeFlagPointer
= _mesa_EdgeFlagPointer
;
453 exec
->EnableClientState
= _mesa_EnableClientState
;
454 exec
->GenTextures
= _mesa_GenTextures
;
455 exec
->GetPointerv
= _mesa_GetPointerv
;
456 exec
->IndexPointer
= _mesa_IndexPointer
;
457 exec
->Indexub
= _mesa_Indexub
;
458 exec
->Indexubv
= _mesa_Indexubv
;
459 exec
->InterleavedArrays
= _mesa_InterleavedArrays
;
460 exec
->IsTexture
= _mesa_IsTexture
;
461 exec
->NormalPointer
= _mesa_NormalPointer
;
462 exec
->PopClientAttrib
= _mesa_PopClientAttrib
;
463 exec
->PrioritizeTextures
= _mesa_PrioritizeTextures
;
464 exec
->PushClientAttrib
= _mesa_PushClientAttrib
;
465 exec
->TexCoordPointer
= _mesa_TexCoordPointer
;
466 exec
->TexSubImage1D
= _mesa_TexSubImage1D
;
467 exec
->TexSubImage2D
= _mesa_TexSubImage2D
;
468 exec
->VertexPointer
= _mesa_VertexPointer
;
471 exec
->CopyTexSubImage3D
= _mesa_CopyTexSubImage3D
;
472 exec
->DrawRangeElements
= _mesa_DrawRangeElements
;
473 exec
->TexImage3D
= _mesa_TexImage3D
;
474 exec
->TexSubImage3D
= _mesa_TexSubImage3D
;
476 /* OpenGL 1.2 GL_ARB_imaging */
477 exec
->BlendColor
= _mesa_BlendColor
;
478 exec
->BlendEquation
= _mesa_BlendEquation
;
479 exec
->ColorSubTable
= _mesa_ColorSubTable
;
480 exec
->ColorTable
= _mesa_ColorTable
;
481 exec
->ColorTableParameterfv
= _mesa_ColorTableParameterfv
;
482 exec
->ColorTableParameteriv
= _mesa_ColorTableParameteriv
;
483 exec
->ConvolutionFilter1D
= _mesa_ConvolutionFilter1D
;
484 exec
->ConvolutionFilter2D
= _mesa_ConvolutionFilter2D
;
485 exec
->ConvolutionParameterf
= _mesa_ConvolutionParameterf
;
486 exec
->ConvolutionParameterfv
= _mesa_ConvolutionParameterfv
;
487 exec
->ConvolutionParameteri
= _mesa_ConvolutionParameteri
;
488 exec
->ConvolutionParameteriv
= _mesa_ConvolutionParameteriv
;
489 exec
->CopyColorSubTable
= _mesa_CopyColorSubTable
;
490 exec
->CopyColorTable
= _mesa_CopyColorTable
;
491 exec
->CopyConvolutionFilter1D
= _mesa_CopyConvolutionFilter1D
;
492 exec
->CopyConvolutionFilter2D
= _mesa_CopyConvolutionFilter2D
;
493 exec
->GetColorTable
= _mesa_GetColorTable
;
494 exec
->GetColorTableParameterfv
= _mesa_GetColorTableParameterfv
;
495 exec
->GetColorTableParameteriv
= _mesa_GetColorTableParameteriv
;
496 exec
->GetConvolutionFilter
= _mesa_GetConvolutionFilter
;
497 exec
->GetConvolutionParameterfv
= _mesa_GetConvolutionParameterfv
;
498 exec
->GetConvolutionParameteriv
= _mesa_GetConvolutionParameteriv
;
499 exec
->GetHistogram
= _mesa_GetHistogram
;
500 exec
->GetHistogramParameterfv
= _mesa_GetHistogramParameterfv
;
501 exec
->GetHistogramParameteriv
= _mesa_GetHistogramParameteriv
;
502 exec
->GetMinmax
= _mesa_GetMinmax
;
503 exec
->GetMinmaxParameterfv
= _mesa_GetMinmaxParameterfv
;
504 exec
->GetMinmaxParameteriv
= _mesa_GetMinmaxParameteriv
;
505 exec
->GetSeparableFilter
= _mesa_GetSeparableFilter
;
506 exec
->Histogram
= _mesa_Histogram
;
507 exec
->Minmax
= _mesa_Minmax
;
508 exec
->ResetHistogram
= _mesa_ResetHistogram
;
509 exec
->ResetMinmax
= _mesa_ResetMinmax
;
510 exec
->SeparableFilter2D
= _mesa_SeparableFilter2D
;
512 /* 2. GL_EXT_blend_color */
514 exec
->BlendColorEXT
= _mesa_BlendColorEXT
;
517 /* 3. GL_EXT_polygon_offset */
518 exec
->PolygonOffsetEXT
= _mesa_PolygonOffsetEXT
;
520 /* 6. GL_EXT_texture3d */
522 exec
->CopyTexSubImage3DEXT
= _mesa_CopyTexSubImage3D
;
523 exec
->TexImage3DEXT
= _mesa_TexImage3DEXT
;
524 exec
->TexSubImage3DEXT
= _mesa_TexSubImage3D
;
527 /* 11. GL_EXT_histogram */
528 exec
->GetHistogramEXT
= _mesa_GetHistogram
;
529 exec
->GetHistogramParameterfvEXT
= _mesa_GetHistogramParameterfv
;
530 exec
->GetHistogramParameterivEXT
= _mesa_GetHistogramParameteriv
;
531 exec
->GetMinmaxEXT
= _mesa_GetMinmax
;
532 exec
->GetMinmaxParameterfvEXT
= _mesa_GetMinmaxParameterfv
;
533 exec
->GetMinmaxParameterivEXT
= _mesa_GetMinmaxParameteriv
;
535 /* ?. GL_SGIX_pixel_texture */
536 exec
->PixelTexGenSGIX
= _mesa_PixelTexGenSGIX
;
538 /* 15. GL_SGIS_pixel_texture */
539 exec
->PixelTexGenParameteriSGIS
= _mesa_PixelTexGenParameteriSGIS
;
540 exec
->PixelTexGenParameterivSGIS
= _mesa_PixelTexGenParameterivSGIS
;
541 exec
->PixelTexGenParameterfSGIS
= _mesa_PixelTexGenParameterfSGIS
;
542 exec
->PixelTexGenParameterfvSGIS
= _mesa_PixelTexGenParameterfvSGIS
;
543 exec
->GetPixelTexGenParameterivSGIS
= _mesa_GetPixelTexGenParameterivSGIS
;
544 exec
->GetPixelTexGenParameterfvSGIS
= _mesa_GetPixelTexGenParameterfvSGIS
;
546 /* 37. GL_EXT_blend_minmax */
548 exec
->BlendEquationEXT
= _mesa_BlendEquationEXT
;
551 /* 54. GL_EXT_point_parameters */
552 exec
->PointParameterfEXT
= _mesa_PointParameterfEXT
;
553 exec
->PointParameterfvEXT
= _mesa_PointParameterfvEXT
;
555 /* 77. GL_PGI_misc_hints */
556 exec
->HintPGI
= _mesa_HintPGI
;
558 /* 78. GL_EXT_paletted_texture */
560 exec
->ColorTableEXT
= _mesa_ColorTableEXT
;
561 exec
->ColorSubTableEXT
= _mesa_ColorSubTableEXT
;
563 exec
->GetColorTableEXT
= _mesa_GetColorTable
;
564 exec
->GetColorTableParameterfvEXT
= _mesa_GetColorTableParameterfv
;
565 exec
->GetColorTableParameterivEXT
= _mesa_GetColorTableParameteriv
;
567 /* 97. GL_EXT_compiled_vertex_array */
568 exec
->LockArraysEXT
= _mesa_LockArraysEXT
;
569 exec
->UnlockArraysEXT
= _mesa_UnlockArraysEXT
;
571 /* 173. GL_INGR_blend_func_separate */
572 exec
->BlendFuncSeparateEXT
= _mesa_BlendFuncSeparateEXT
;
574 /* 196. GL_MESA_resize_buffers */
575 exec
->ResizeBuffersMESA
= _mesa_ResizeBuffersMESA
;
577 /* 197. GL_MESA_window_pos */
578 exec
->WindowPos2dMESA
= _mesa_WindowPos2dMESA
;
579 exec
->WindowPos2dvMESA
= _mesa_WindowPos2dvMESA
;
580 exec
->WindowPos2fMESA
= _mesa_WindowPos2fMESA
;
581 exec
->WindowPos2fvMESA
= _mesa_WindowPos2fvMESA
;
582 exec
->WindowPos2iMESA
= _mesa_WindowPos2iMESA
;
583 exec
->WindowPos2ivMESA
= _mesa_WindowPos2ivMESA
;
584 exec
->WindowPos2sMESA
= _mesa_WindowPos2sMESA
;
585 exec
->WindowPos2svMESA
= _mesa_WindowPos2svMESA
;
586 exec
->WindowPos3dMESA
= _mesa_WindowPos3dMESA
;
587 exec
->WindowPos3dvMESA
= _mesa_WindowPos3dvMESA
;
588 exec
->WindowPos3fMESA
= _mesa_WindowPos3fMESA
;
589 exec
->WindowPos3fvMESA
= _mesa_WindowPos3fvMESA
;
590 exec
->WindowPos3iMESA
= _mesa_WindowPos3iMESA
;
591 exec
->WindowPos3ivMESA
= _mesa_WindowPos3ivMESA
;
592 exec
->WindowPos3sMESA
= _mesa_WindowPos3sMESA
;
593 exec
->WindowPos3svMESA
= _mesa_WindowPos3svMESA
;
594 exec
->WindowPos4dMESA
= _mesa_WindowPos4dMESA
;
595 exec
->WindowPos4dvMESA
= _mesa_WindowPos4dvMESA
;
596 exec
->WindowPos4fMESA
= _mesa_WindowPos4fMESA
;
597 exec
->WindowPos4fvMESA
= _mesa_WindowPos4fvMESA
;
598 exec
->WindowPos4iMESA
= _mesa_WindowPos4iMESA
;
599 exec
->WindowPos4ivMESA
= _mesa_WindowPos4ivMESA
;
600 exec
->WindowPos4sMESA
= _mesa_WindowPos4sMESA
;
601 exec
->WindowPos4svMESA
= _mesa_WindowPos4svMESA
;
603 /* ARB 1. GL_ARB_multitexture */
604 exec
->ActiveTextureARB
= _mesa_ActiveTextureARB
;
605 exec
->ClientActiveTextureARB
= _mesa_ClientActiveTextureARB
;
606 exec
->MultiTexCoord1dARB
= _mesa_MultiTexCoord1dARB
;
607 exec
->MultiTexCoord1dvARB
= _mesa_MultiTexCoord1dvARB
;
608 exec
->MultiTexCoord1fARB
= _mesa_MultiTexCoord1fARB
;
609 exec
->MultiTexCoord1fvARB
= _mesa_MultiTexCoord1fvARB
;
610 exec
->MultiTexCoord1iARB
= _mesa_MultiTexCoord1iARB
;
611 exec
->MultiTexCoord1ivARB
= _mesa_MultiTexCoord1ivARB
;
612 exec
->MultiTexCoord1sARB
= _mesa_MultiTexCoord1sARB
;
613 exec
->MultiTexCoord1svARB
= _mesa_MultiTexCoord1svARB
;
614 exec
->MultiTexCoord2dARB
= _mesa_MultiTexCoord2dARB
;
615 exec
->MultiTexCoord2dvARB
= _mesa_MultiTexCoord2dvARB
;
616 exec
->MultiTexCoord2fARB
= _mesa_MultiTexCoord2fARB
;
617 exec
->MultiTexCoord2fvARB
= _mesa_MultiTexCoord2fvARB
;
618 exec
->MultiTexCoord2iARB
= _mesa_MultiTexCoord2iARB
;
619 exec
->MultiTexCoord2ivARB
= _mesa_MultiTexCoord2ivARB
;
620 exec
->MultiTexCoord2sARB
= _mesa_MultiTexCoord2sARB
;
621 exec
->MultiTexCoord2svARB
= _mesa_MultiTexCoord2svARB
;
622 exec
->MultiTexCoord3dARB
= _mesa_MultiTexCoord3dARB
;
623 exec
->MultiTexCoord3dvARB
= _mesa_MultiTexCoord3dvARB
;
624 exec
->MultiTexCoord3fARB
= _mesa_MultiTexCoord3fARB
;
625 exec
->MultiTexCoord3fvARB
= _mesa_MultiTexCoord3fvARB
;
626 exec
->MultiTexCoord3iARB
= _mesa_MultiTexCoord3iARB
;
627 exec
->MultiTexCoord3ivARB
= _mesa_MultiTexCoord3ivARB
;
628 exec
->MultiTexCoord3sARB
= _mesa_MultiTexCoord3sARB
;
629 exec
->MultiTexCoord3svARB
= _mesa_MultiTexCoord3svARB
;
630 exec
->MultiTexCoord4dARB
= _mesa_MultiTexCoord4dARB
;
631 exec
->MultiTexCoord4dvARB
= _mesa_MultiTexCoord4dvARB
;
632 exec
->MultiTexCoord4fARB
= _mesa_MultiTexCoord4fARB
;
633 exec
->MultiTexCoord4fvARB
= _mesa_MultiTexCoord4fvARB
;
634 exec
->MultiTexCoord4iARB
= _mesa_MultiTexCoord4iARB
;
635 exec
->MultiTexCoord4ivARB
= _mesa_MultiTexCoord4ivARB
;
636 exec
->MultiTexCoord4sARB
= _mesa_MultiTexCoord4sARB
;
637 exec
->MultiTexCoord4svARB
= _mesa_MultiTexCoord4svARB
;
639 /* ARB 3. GL_ARB_transpose_matrix */
640 exec
->LoadTransposeMatrixdARB
= _mesa_LoadTransposeMatrixdARB
;
641 exec
->LoadTransposeMatrixfARB
= _mesa_LoadTransposeMatrixfARB
;
642 exec
->MultTransposeMatrixdARB
= _mesa_MultTransposeMatrixdARB
;
643 exec
->MultTransposeMatrixfARB
= _mesa_MultTransposeMatrixfARB
;
645 /* ARB 12. GL_ARB_texture_compression */
646 exec
->CompressedTexImage3DARB
= _mesa_CompressedTexImage3DARB
;
647 exec
->CompressedTexImage2DARB
= _mesa_CompressedTexImage2DARB
;
648 exec
->CompressedTexImage1DARB
= _mesa_CompressedTexImage1DARB
;
649 exec
->CompressedTexSubImage3DARB
= _mesa_CompressedTexSubImage3DARB
;
650 exec
->CompressedTexSubImage2DARB
= _mesa_CompressedTexSubImage2DARB
;
651 exec
->CompressedTexSubImage1DARB
= _mesa_CompressedTexSubImage1DARB
;
652 exec
->GetCompressedTexImageARB
= _mesa_GetCompressedTexImageARB
;
658 /**********************************************************************/
659 /***** State update logic *****/
660 /**********************************************************************/
664 * Since the device driver may or may not support pixel logic ops we
665 * have to make some extensive tests to determine whether or not
666 * software-implemented logic operations have to be used.
668 static void update_pixel_logic( GLcontext
*ctx
)
670 if (ctx
->Visual
->RGBAflag
) {
671 /* RGBA mode blending w/ Logic Op */
672 if (ctx
->Color
.ColorLogicOpEnabled
) {
673 if (ctx
->Driver
.LogicOp
674 && (*ctx
->Driver
.LogicOp
)( ctx
, ctx
->Color
.LogicOp
)) {
675 /* Device driver can do logic, don't have to do it in software */
676 ctx
->Color
.SWLogicOpEnabled
= GL_FALSE
;
679 /* Device driver can't do logic op so we do it in software */
680 ctx
->Color
.SWLogicOpEnabled
= GL_TRUE
;
685 if (ctx
->Driver
.LogicOp
) {
686 (void) (*ctx
->Driver
.LogicOp
)( ctx
, GL_COPY
);
688 ctx
->Color
.SWLogicOpEnabled
= GL_FALSE
;
692 /* CI mode Logic Op */
693 if (ctx
->Color
.IndexLogicOpEnabled
) {
694 if (ctx
->Driver
.LogicOp
695 && (*ctx
->Driver
.LogicOp
)( ctx
, ctx
->Color
.LogicOp
)) {
696 /* Device driver can do logic, don't have to do it in software */
697 ctx
->Color
.SWLogicOpEnabled
= GL_FALSE
;
700 /* Device driver can't do logic op so we do it in software */
701 ctx
->Color
.SWLogicOpEnabled
= GL_TRUE
;
706 if (ctx
->Driver
.LogicOp
) {
707 (void) (*ctx
->Driver
.LogicOp
)( ctx
, GL_COPY
);
709 ctx
->Color
.SWLogicOpEnabled
= GL_FALSE
;
717 * Check if software implemented RGBA or Color Index masking is needed.
719 static void update_pixel_masking( GLcontext
*ctx
)
721 if (ctx
->Visual
->RGBAflag
) {
722 GLuint
*colorMask
= (GLuint
*) ctx
->Color
.ColorMask
;
723 if (*colorMask
== 0xffffffff) {
724 /* disable masking */
725 if (ctx
->Driver
.ColorMask
) {
726 (void) (*ctx
->Driver
.ColorMask
)( ctx
, GL_TRUE
, GL_TRUE
, GL_TRUE
, GL_TRUE
);
728 ctx
->Color
.SWmasking
= GL_FALSE
;
731 /* Ask driver to do color masking, if it can't then
734 GLboolean red
= ctx
->Color
.ColorMask
[RCOMP
] ? GL_TRUE
: GL_FALSE
;
735 GLboolean green
= ctx
->Color
.ColorMask
[GCOMP
] ? GL_TRUE
: GL_FALSE
;
736 GLboolean blue
= ctx
->Color
.ColorMask
[BCOMP
] ? GL_TRUE
: GL_FALSE
;
737 GLboolean alpha
= ctx
->Color
.ColorMask
[ACOMP
] ? GL_TRUE
: GL_FALSE
;
738 if (ctx
->Driver
.ColorMask
739 && (*ctx
->Driver
.ColorMask
)( ctx
, red
, green
, blue
, alpha
)) {
740 ctx
->Color
.SWmasking
= GL_FALSE
;
743 ctx
->Color
.SWmasking
= GL_TRUE
;
748 if (ctx
->Color
.IndexMask
==0xffffffff) {
749 /* disable masking */
750 if (ctx
->Driver
.IndexMask
) {
751 (void) (*ctx
->Driver
.IndexMask
)( ctx
, 0xffffffff );
753 ctx
->Color
.SWmasking
= GL_FALSE
;
756 /* Ask driver to do index masking, if it can't then
759 if (ctx
->Driver
.IndexMask
760 && (*ctx
->Driver
.IndexMask
)( ctx
, ctx
->Color
.IndexMask
)) {
761 ctx
->Color
.SWmasking
= GL_FALSE
;
764 ctx
->Color
.SWmasking
= GL_TRUE
;
771 static void update_fog_mode( GLcontext
*ctx
)
773 int old_mode
= ctx
->FogMode
;
775 if (ctx
->Fog
.Enabled
) {
776 if (ctx
->Texture
.Enabled
)
777 ctx
->FogMode
= FOG_FRAGMENT
;
778 else if (ctx
->Hint
.Fog
== GL_NICEST
)
779 ctx
->FogMode
= FOG_FRAGMENT
;
781 ctx
->FogMode
= FOG_VERTEX
;
783 if (ctx
->Driver
.GetParameteri
)
784 if ((ctx
->Driver
.GetParameteri
)( ctx
, DD_HAVE_HARDWARE_FOG
))
785 ctx
->FogMode
= FOG_FRAGMENT
;
788 ctx
->FogMode
= FOG_NONE
;
791 if (old_mode
!= ctx
->FogMode
)
792 ctx
->NewState
|= NEW_FOG
;
797 * Recompute the value of ctx->RasterMask, etc. according to
798 * the current context.
800 static void update_rasterflags( GLcontext
*ctx
)
804 if (ctx
->Color
.AlphaEnabled
) ctx
->RasterMask
|= ALPHATEST_BIT
;
805 if (ctx
->Color
.BlendEnabled
) ctx
->RasterMask
|= BLEND_BIT
;
806 if (ctx
->Depth
.Test
) ctx
->RasterMask
|= DEPTH_BIT
;
807 if (ctx
->FogMode
==FOG_FRAGMENT
) ctx
->RasterMask
|= FOG_BIT
;
808 if (ctx
->Color
.SWLogicOpEnabled
) ctx
->RasterMask
|= LOGIC_OP_BIT
;
809 if (ctx
->Scissor
.Enabled
) ctx
->RasterMask
|= SCISSOR_BIT
;
810 if (ctx
->Stencil
.Enabled
) ctx
->RasterMask
|= STENCIL_BIT
;
811 if (ctx
->Color
.SWmasking
) ctx
->RasterMask
|= MASKING_BIT
;
812 if (ctx
->Texture
.ReallyEnabled
) ctx
->RasterMask
|= TEXTURE_BIT
;
814 if (ctx
->DrawBuffer
->UseSoftwareAlphaBuffers
815 && ctx
->Color
.ColorMask
[ACOMP
]
816 && ctx
->Color
.DrawBuffer
!= GL_NONE
)
817 ctx
->RasterMask
|= ALPHABUF_BIT
;
819 if ( ctx
->Viewport
.X
<0
820 || ctx
->Viewport
.X
+ ctx
->Viewport
.Width
> ctx
->DrawBuffer
->Width
822 || ctx
->Viewport
.Y
+ ctx
->Viewport
.Height
> ctx
->DrawBuffer
->Height
) {
823 ctx
->RasterMask
|= WINCLIP_BIT
;
826 if (ctx
->Depth
.OcclusionTest
)
827 ctx
->RasterMask
|= OCCLUSION_BIT
;
830 /* If we're not drawing to exactly one color buffer set the
831 * MULTI_DRAW_BIT flag. Also set it if we're drawing to no
832 * buffers or the RGBA or CI mask disables all writes.
834 ctx
->TriangleCaps
&= ~DD_MULTIDRAW
;
836 if (ctx
->Color
.MultiDrawBuffer
) {
837 ctx
->RasterMask
|= MULTI_DRAW_BIT
;
838 ctx
->TriangleCaps
|= DD_MULTIDRAW
;
840 else if (ctx
->Color
.DrawBuffer
==GL_NONE
) {
841 ctx
->RasterMask
|= MULTI_DRAW_BIT
;
842 ctx
->TriangleCaps
|= DD_MULTIDRAW
;
844 else if (ctx
->Visual
->RGBAflag
&& ctx
->Color
.ColorMask
==0) {
845 /* all RGBA channels disabled */
846 ctx
->RasterMask
|= MULTI_DRAW_BIT
;
847 ctx
->TriangleCaps
|= DD_MULTIDRAW
;
848 ctx
->Color
.DrawDestMask
= 0;
850 else if (!ctx
->Visual
->RGBAflag
&& ctx
->Color
.IndexMask
==0) {
851 /* all color index bits disabled */
852 ctx
->RasterMask
|= MULTI_DRAW_BIT
;
853 ctx
->TriangleCaps
|= DD_MULTIDRAW
;
854 ctx
->Color
.DrawDestMask
= 0;
859 void gl_print_state( const char *msg
, GLuint state
)
862 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
865 (state
& NEW_LIGHTING
) ? "lighting, " : "",
866 (state
& NEW_RASTER_OPS
) ? "raster-ops, " : "",
867 (state
& NEW_TEXTURING
) ? "texturing, " : "",
868 (state
& NEW_POLYGON
) ? "polygon, " : "",
869 (state
& NEW_DRVSTATE0
) ? "driver-0, " : "",
870 (state
& NEW_DRVSTATE1
) ? "driver-1, " : "",
871 (state
& NEW_DRVSTATE2
) ? "driver-2, " : "",
872 (state
& NEW_DRVSTATE3
) ? "driver-3, " : "",
873 (state
& NEW_MODELVIEW
) ? "modelview, " : "",
874 (state
& NEW_PROJECTION
) ? "projection, " : "",
875 (state
& NEW_TEXTURE_MATRIX
) ? "texture-matrix, " : "",
876 (state
& NEW_USER_CLIP
) ? "user-clip, " : "",
877 (state
& NEW_TEXTURE_ENV
) ? "texture-env, " : "",
878 (state
& NEW_CLIENT_STATE
) ? "client-state, " : "",
879 (state
& NEW_FOG
) ? "fog, " : "",
880 (state
& NEW_NORMAL_TRANSFORM
) ? "normal-transform, " : "",
881 (state
& NEW_VIEWPORT
) ? "viewport, " : "",
882 (state
& NEW_TEXTURE_ENABLE
) ? "texture-enable, " : "");
886 void gl_print_enable_flags( const char *msg
, GLuint flags
)
889 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s\n",
892 (flags
& ENABLE_TEX0
) ? "tex-0, " : "",
893 (flags
& ENABLE_TEX1
) ? "tex-1, " : "",
894 (flags
& ENABLE_LIGHT
) ? "light, " : "",
895 (flags
& ENABLE_FOG
) ? "fog, " : "",
896 (flags
& ENABLE_USERCLIP
) ? "userclip, " : "",
897 (flags
& ENABLE_TEXGEN0
) ? "tex-gen-0, " : "",
898 (flags
& ENABLE_TEXGEN1
) ? "tex-gen-1, " : "",
899 (flags
& ENABLE_TEXMAT0
) ? "tex-mat-0, " : "",
900 (flags
& ENABLE_TEXMAT1
) ? "tex-mat-1, " : "",
901 (flags
& ENABLE_NORMALIZE
) ? "normalize, " : "",
902 (flags
& ENABLE_RESCALE
) ? "rescale, " : "");
907 * If ctx->NewState is non-zero then this function MUST be called before
908 * rendering any primitive. Basically, function pointers and miscellaneous
909 * flags are updated to reflect the current state of the state machine.
911 void gl_update_state( GLcontext
*ctx
)
915 if (MESA_VERBOSE
& VERBOSE_STATE
)
916 gl_print_state("", ctx
->NewState
);
918 if (ctx
->NewState
& NEW_CLIENT_STATE
)
919 gl_update_client_state( ctx
);
921 if ((ctx
->NewState
& NEW_TEXTURE_ENABLE
) &&
922 (ctx
->Enabled
& ENABLE_TEX_ANY
) != ctx
->Texture
.Enabled
)
923 ctx
->NewState
|= NEW_TEXTURING
| NEW_RASTER_OPS
;
925 if (ctx
->NewState
& NEW_TEXTURE_ENV
) {
926 if (ctx
->Texture
.Unit
[0].EnvMode
== ctx
->Texture
.Unit
[0].LastEnvMode
&&
927 ctx
->Texture
.Unit
[1].EnvMode
== ctx
->Texture
.Unit
[1].LastEnvMode
)
928 ctx
->NewState
&= ~NEW_TEXTURE_ENV
;
929 ctx
->Texture
.Unit
[0].LastEnvMode
= ctx
->Texture
.Unit
[0].EnvMode
;
930 ctx
->Texture
.Unit
[1].LastEnvMode
= ctx
->Texture
.Unit
[1].EnvMode
;
933 if (ctx
->NewState
& NEW_TEXTURE_MATRIX
) {
934 ctx
->Enabled
&= ~(ENABLE_TEXMAT0
|ENABLE_TEXMAT1
);
936 for (i
=0; i
< MAX_TEXTURE_UNITS
; i
++) {
937 if (ctx
->TextureMatrix
[i
].flags
& MAT_DIRTY_ALL_OVER
)
939 gl_matrix_analyze( &ctx
->TextureMatrix
[i
] );
940 ctx
->TextureMatrix
[i
].flags
&= ~MAT_DIRTY_DEPENDENTS
;
942 if (ctx
->Texture
.Unit
[i
].Enabled
&&
943 ctx
->TextureMatrix
[i
].type
!= MATRIX_IDENTITY
)
944 ctx
->Enabled
|= ENABLE_TEXMAT0
<< i
;
949 if (ctx
->NewState
& (NEW_TEXTURING
| NEW_TEXTURE_ENABLE
)) {
950 ctx
->Texture
.NeedNormals
= GL_FALSE
;
951 gl_update_dirty_texobjs(ctx
);
952 ctx
->Enabled
&= ~(ENABLE_TEXGEN0
|ENABLE_TEXGEN1
);
953 ctx
->Texture
.ReallyEnabled
= 0;
955 for (i
=0; i
< MAX_TEXTURE_UNITS
; i
++) {
956 if (ctx
->Texture
.Unit
[i
].Enabled
) {
957 gl_update_texture_unit( ctx
, &ctx
->Texture
.Unit
[i
] );
959 ctx
->Texture
.ReallyEnabled
|=
960 ctx
->Texture
.Unit
[i
].ReallyEnabled
<<(i
*4);
962 if (ctx
->Texture
.Unit
[i
].GenFlags
!= 0) {
963 ctx
->Enabled
|= ENABLE_TEXGEN0
<< i
;
965 if (ctx
->Texture
.Unit
[i
].GenFlags
& TEXGEN_NEED_NORMALS
)
967 ctx
->Texture
.NeedNormals
= GL_TRUE
;
968 ctx
->Texture
.NeedEyeCoords
= GL_TRUE
;
971 if (ctx
->Texture
.Unit
[i
].GenFlags
& TEXGEN_NEED_EYE_COORD
)
973 ctx
->Texture
.NeedEyeCoords
= GL_TRUE
;
979 ctx
->Texture
.Enabled
= ctx
->Enabled
& ENABLE_TEX_ANY
;
980 ctx
->NeedNormals
= (ctx
->Light
.Enabled
|| ctx
->Texture
.NeedNormals
);
983 if (ctx
->NewState
& (NEW_RASTER_OPS
| NEW_LIGHTING
| NEW_FOG
| NEW_TEXTURE_ENABLE
)) {
985 if (ctx
->NewState
& (NEW_RASTER_OPS
| NEW_TEXTURE_ENABLE
)) {
986 update_pixel_logic(ctx
);
987 update_pixel_masking(ctx
);
988 update_fog_mode(ctx
);
989 update_rasterflags(ctx
);
990 if (ctx
->Driver
.Dither
) {
991 (*ctx
->Driver
.Dither
)( ctx
, ctx
->Color
.DitherFlag
);
994 /* update scissor region */
995 ctx
->DrawBuffer
->Xmin
= 0;
996 ctx
->DrawBuffer
->Ymin
= 0;
997 ctx
->DrawBuffer
->Xmax
= ctx
->DrawBuffer
->Width
-1;
998 ctx
->DrawBuffer
->Ymax
= ctx
->DrawBuffer
->Height
-1;
999 if (ctx
->Scissor
.Enabled
) {
1000 if (ctx
->Scissor
.X
> ctx
->DrawBuffer
->Xmin
) {
1001 ctx
->DrawBuffer
->Xmin
= ctx
->Scissor
.X
;
1003 if (ctx
->Scissor
.Y
> ctx
->DrawBuffer
->Ymin
) {
1004 ctx
->DrawBuffer
->Ymin
= ctx
->Scissor
.Y
;
1006 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < ctx
->DrawBuffer
->Xmax
) {
1007 ctx
->DrawBuffer
->Xmax
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
1009 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1 < ctx
->DrawBuffer
->Ymax
) {
1010 ctx
->DrawBuffer
->Ymax
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1;
1015 if (ctx
->NewState
& NEW_LIGHTING
) {
1016 ctx
->TriangleCaps
&= ~(DD_TRI_LIGHT_TWOSIDE
|DD_LIGHTING_CULL
);
1017 if (ctx
->Light
.Enabled
) {
1018 if (ctx
->Light
.Model
.TwoSide
)
1019 ctx
->TriangleCaps
|= (DD_TRI_LIGHT_TWOSIDE
|DD_LIGHTING_CULL
);
1020 gl_update_lighting(ctx
);
1025 if (ctx
->NewState
& (NEW_POLYGON
| NEW_LIGHTING
)) {
1027 ctx
->TriangleCaps
&= ~DD_TRI_CULL_FRONT_BACK
;
1029 if (ctx
->NewState
& NEW_POLYGON
) {
1030 /* Setup CullBits bitmask */
1031 if (ctx
->Polygon
.CullFlag
) {
1032 ctx
->backface_sign
= 1;
1033 switch(ctx
->Polygon
.CullFaceMode
) {
1035 if(ctx
->Polygon
.FrontFace
==GL_CCW
)
1036 ctx
->backface_sign
= -1;
1037 ctx
->Polygon
.CullBits
= 1;
1040 if(ctx
->Polygon
.FrontFace
!=GL_CCW
)
1041 ctx
->backface_sign
= -1;
1042 ctx
->Polygon
.CullBits
= 2;
1045 case GL_FRONT_AND_BACK
:
1046 ctx
->backface_sign
= 0;
1047 ctx
->Polygon
.CullBits
= 0;
1048 ctx
->TriangleCaps
|= DD_TRI_CULL_FRONT_BACK
;
1053 ctx
->Polygon
.CullBits
= 3;
1054 ctx
->backface_sign
= 0;
1057 /* Any Polygon offsets enabled? */
1058 ctx
->TriangleCaps
&= ~DD_TRI_OFFSET
;
1060 if (ctx
->Polygon
.OffsetPoint
||
1061 ctx
->Polygon
.OffsetLine
||
1062 ctx
->Polygon
.OffsetFill
)
1063 ctx
->TriangleCaps
|= DD_TRI_OFFSET
;
1065 /* reset Z offsets now */
1066 ctx
->PointZoffset
= 0.0;
1067 ctx
->LineZoffset
= 0.0;
1068 ctx
->PolygonZoffset
= 0.0;
1072 if (ctx
->NewState
& ~(NEW_CLIENT_STATE
|
1073 NEW_DRIVER_STATE
|NEW_USER_CLIP
|
1075 gl_update_clipmask(ctx
);
1077 if (ctx
->NewState
& (NEW_LIGHTING
|
1089 ctx
->IndirectTriangles
= ctx
->TriangleCaps
& ~ctx
->Driver
.TriangleCaps
;
1090 ctx
->IndirectTriangles
|= DD_SW_RASTERIZE
;
1092 if (MESA_VERBOSE
&VERBOSE_CULL
)
1093 gl_print_tri_caps("initial indirect tris", ctx
->IndirectTriangles
);
1095 ctx
->Driver
.PointsFunc
= NULL
;
1096 ctx
->Driver
.LineFunc
= NULL
;
1097 ctx
->Driver
.TriangleFunc
= NULL
;
1098 ctx
->Driver
.QuadFunc
= NULL
;
1099 ctx
->Driver
.RectFunc
= NULL
;
1100 ctx
->Driver
.RenderVBClippedTab
= NULL
;
1101 ctx
->Driver
.RenderVBCulledTab
= NULL
;
1102 ctx
->Driver
.RenderVBRawTab
= NULL
;
1105 * Here the driver sets up all the ctx->Driver function pointers to
1106 * it's specific, private functions.
1108 ctx
->Driver
.UpdateState(ctx
);
1110 if (MESA_VERBOSE
&VERBOSE_CULL
)
1111 gl_print_tri_caps("indirect tris", ctx
->IndirectTriangles
);
1114 * In case the driver didn't hook in an optimized point, line or
1115 * triangle function we'll now select "core/fallback" point, line
1116 * and triangle functions.
1118 if (ctx
->IndirectTriangles
& DD_SW_RASTERIZE
) {
1119 gl_set_point_function(ctx
);
1120 gl_set_line_function(ctx
);
1121 gl_set_triangle_function(ctx
);
1122 gl_set_quad_function(ctx
);
1124 if ((ctx
->IndirectTriangles
&
1125 (DD_TRI_SW_RASTERIZE
|DD_QUAD_SW_RASTERIZE
|DD_TRI_CULL
)) ==
1126 (DD_TRI_SW_RASTERIZE
|DD_QUAD_SW_RASTERIZE
|DD_TRI_CULL
))
1127 ctx
->IndirectTriangles
&= ~DD_TRI_CULL
;
1130 if (MESA_VERBOSE
&VERBOSE_CULL
)
1131 gl_print_tri_caps("indirect tris 2", ctx
->IndirectTriangles
);
1133 gl_set_render_vb_function(ctx
);
1136 /* Should only be calc'd when !need_eye_coords and not culling.
1138 if (ctx
->NewState
& (NEW_MODELVIEW
|NEW_PROJECTION
)) {
1139 if (ctx
->NewState
& NEW_MODELVIEW
) {
1140 gl_matrix_analyze( &ctx
->ModelView
);
1141 ctx
->ProjectionMatrix
.flags
&= ~MAT_DIRTY_DEPENDENTS
;
1144 if (ctx
->NewState
& NEW_PROJECTION
) {
1145 gl_matrix_analyze( &ctx
->ProjectionMatrix
);
1146 ctx
->ProjectionMatrix
.flags
&= ~MAT_DIRTY_DEPENDENTS
;
1148 if (ctx
->Transform
.AnyClip
) {
1149 gl_update_userclip( ctx
);
1153 gl_calculate_model_project_matrix( ctx
);
1154 ctx
->ModelProjectWinMatrixUptodate
= 0;
1157 if (ctx
->NewState
& NEW_COLOR_MATRIX
) {
1158 gl_matrix_analyze( &ctx
->ColorMatrix
);
1161 /* Figure out whether we can light in object space or not. If we
1162 * can, find the current positions of the lights in object space
1164 if ((ctx
->Enabled
& (ENABLE_POINT_ATTEN
| ENABLE_LIGHT
| ENABLE_FOG
|
1165 ENABLE_TEXGEN0
| ENABLE_TEXGEN1
)) &&
1166 (ctx
->NewState
& (NEW_LIGHTING
|
1174 GLboolean oldcoord
, oldnorm
;
1176 oldcoord
= ctx
->NeedEyeCoords
;
1177 oldnorm
= ctx
->NeedEyeNormals
;
1179 ctx
->NeedNormals
= (ctx
->Light
.Enabled
|| ctx
->Texture
.NeedNormals
);
1180 ctx
->NeedEyeCoords
= ((ctx
->Fog
.Enabled
&& ctx
->Hint
.Fog
!= GL_NICEST
) ||
1181 ctx
->Point
.Attenuated
);
1182 ctx
->NeedEyeNormals
= GL_FALSE
;
1184 if (ctx
->Light
.Enabled
) {
1185 if (ctx
->Light
.Flags
& LIGHT_POSITIONAL
) {
1186 /* Need length for attenuation */
1187 if (!TEST_MAT_FLAGS( &ctx
->ModelView
, MAT_FLAGS_LENGTH_PRESERVING
))
1188 ctx
->NeedEyeCoords
= GL_TRUE
;
1189 } else if (ctx
->Light
.NeedVertices
) {
1190 /* Need angle for spot calculations */
1191 if (!TEST_MAT_FLAGS( &ctx
->ModelView
, MAT_FLAGS_ANGLE_PRESERVING
))
1192 ctx
->NeedEyeCoords
= GL_TRUE
;
1194 ctx
->NeedEyeNormals
= ctx
->NeedEyeCoords
;
1196 if (ctx
->Texture
.Enabled
|| ctx
->RenderMode
==GL_FEEDBACK
) {
1197 if (ctx
->Texture
.NeedEyeCoords
) ctx
->NeedEyeCoords
= GL_TRUE
;
1198 if (ctx
->Texture
.NeedNormals
)
1199 ctx
->NeedNormals
= ctx
->NeedEyeNormals
= GL_TRUE
;
1202 ctx
->vb_proj_matrix
= &ctx
->ModelProjectMatrix
;
1204 if (ctx
->NeedEyeCoords
)
1205 ctx
->vb_proj_matrix
= &ctx
->ProjectionMatrix
;
1207 if (ctx
->Light
.Enabled
) {
1208 gl_update_lighting_function(ctx
);
1210 if ( (ctx
->NewState
& NEW_LIGHTING
) ||
1211 ((ctx
->NewState
& (NEW_MODELVIEW
| NEW_PROJECTION
)) &&
1212 !ctx
->NeedEyeCoords
) ||
1213 oldcoord
!= ctx
->NeedEyeCoords
||
1214 oldnorm
!= ctx
->NeedEyeNormals
) {
1215 gl_compute_light_positions(ctx
);
1218 ctx
->rescale_factor
= 1.0F
;
1220 if (ctx
->ModelView
.flags
& (MAT_FLAG_UNIFORM_SCALE
|
1221 MAT_FLAG_GENERAL_SCALE
|
1222 MAT_FLAG_GENERAL_3D
|
1226 GLfloat
*m
= ctx
->ModelView
.inv
;
1227 GLfloat f
= m
[2]*m
[2] + m
[6]*m
[6] + m
[10]*m
[10];
1228 if (f
> 1e-12 && (f
-1)*(f
-1) > 1e-12)
1229 ctx
->rescale_factor
= 1.0/GL_SQRT(f
);
1233 gl_update_normal_transform( ctx
);
1236 gl_update_pipelines(ctx
);