blob: 8624cb62e79aebe3dd2c1b8fbef45adaf5ba829b [file] [log] [blame]
Keith Whitwellf4b02d12001-01-05 05:31:42 +00001/* $Id: context.c,v 1.115 2001/01/05 05:31:42 keithw Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paule4b684c2000-09-12 21:07:40 +00005 * Version: 3.5
jtgafb833d1999-08-19 00:55:39 +00006 *
Brian Paul54287052000-01-17 20:00:15 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
jtgafb833d1999-08-19 00:55:39 +00008 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
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.
25 */
26
27
jtgafb833d1999-08-19 00:55:39 +000028#ifdef PC_HEADER
29#include "all.h"
30#else
Brian Paulfbd8f211999-11-11 01:22:25 +000031#include "glheader.h"
Brian Paulb1394fa2000-09-26 20:53:53 +000032#include "buffers.h"
jtgafb833d1999-08-19 00:55:39 +000033#include "clip.h"
Brian Paul4bdcfe52000-04-17 17:57:04 +000034#include "colortab.h"
jtgafb833d1999-08-19 00:55:39 +000035#include "context.h"
jtgafb833d1999-08-19 00:55:39 +000036#include "dlist.h"
37#include "eval.h"
38#include "enums.h"
Brian Paul585a68c1999-09-11 11:31:34 +000039#include "extensions.h"
jtgafb833d1999-08-19 00:55:39 +000040#include "fog.h"
Brian Paulb7a43041999-11-30 20:34:51 +000041#include "get.h"
Brian Paulf9b97d92000-01-28 20:17:42 +000042#include "glapinoop.h"
Brian Paul9560f052000-01-31 23:11:39 +000043#include "glthread.h"
jtgafb833d1999-08-19 00:55:39 +000044#include "hash.h"
Brian Paulb1394fa2000-09-26 20:53:53 +000045#include "imports.h"
jtgafb833d1999-08-19 00:55:39 +000046#include "light.h"
jtgafb833d1999-08-19 00:55:39 +000047#include "macros.h"
Brian Paulfbd8f211999-11-11 01:22:25 +000048#include "mem.h"
jtgafb833d1999-08-19 00:55:39 +000049#include "mmath.h"
jtgafb833d1999-08-19 00:55:39 +000050#include "simple_list.h"
Brian Paulfa9df402000-02-02 19:16:46 +000051#include "state.h"
jtgafb833d1999-08-19 00:55:39 +000052#include "teximage.h"
53#include "texobj.h"
jtgafb833d1999-08-19 00:55:39 +000054#include "texture.h"
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000055#include "mtypes.h"
jtgafb833d1999-08-19 00:55:39 +000056#include "varray.h"
Keith Whitwell23caf202000-11-16 21:05:34 +000057
58#include "math/m_translate.h"
59#include "math/m_vertices.h"
60#include "math/m_matrix.h"
61#include "math/m_xform.h"
Keith Whitwellf4b02d12001-01-05 05:31:42 +000062#include "math/mathmod.h"
jtgafb833d1999-08-19 00:55:39 +000063#endif
64
Brian Paul3b18a362000-09-26 15:27:20 +000065#if defined(MESA_TRACE)
Brian Paul45f36342000-09-05 20:28:06 +000066#include "Trace/tr_context.h"
67#include "Trace/tr_wrapper.h"
68#endif
69
jtgafb833d1999-08-19 00:55:39 +000070
Keith Whitwell23caf202000-11-16 21:05:34 +000071#ifndef MESA_VERBOSE
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000072int MESA_VERBOSE = 0
Keith Whitwell23caf202000-11-16 21:05:34 +000073/* | VERBOSE_PIPELINE */
74/* | VERBOSE_IMMEDIATE */
75/* | VERBOSE_VARRAY */
76/* | VERBOSE_TEXTURE */
77/* | VERBOSE_API */
78/* | VERBOSE_DRIVER */
79/* | VERBOSE_STATE */
Keith Whitwell23caf202000-11-16 21:05:34 +000080/* | VERBOSE_DISPLAY_LIST */
81;
82#endif
83
84#ifndef MESA_DEBUG_FLAGS
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000085int MESA_DEBUG_FLAGS = 0
Keith Whitwell23caf202000-11-16 21:05:34 +000086/* | DEBUG_ALWAYS_FLUSH */
87;
88#endif
Brian Paulb1394fa2000-09-26 20:53:53 +000089
90/**********************************************************************/
91/***** OpenGL SI-style interface (new in Mesa 3.5) *****/
92/**********************************************************************/
93
94static GLboolean
95_mesa_DestroyContext(__GLcontext *gc)
96{
97 if (gc) {
98 _mesa_free_context_data(gc);
99 (*gc->imports.free)(gc, gc);
100 }
101 return GL_TRUE;
102}
103
104
105/* exported OpenGL SI interface */
106__GLcontext *
107__glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes)
108{
109 GLcontext *ctx;
110
111 ctx = (GLcontext *) (*imports->calloc)(0, 1, sizeof(GLcontext));
112 if (ctx == NULL) {
113 return NULL;
114 }
115 ctx->imports = *imports;
116
117 _mesa_initialize_visual(&ctx->Visual,
118 modes->rgbMode,
119 modes->doubleBufferMode,
120 modes->stereoMode,
121 modes->redBits,
122 modes->greenBits,
123 modes->blueBits,
124 modes->alphaBits,
125 modes->indexBits,
126 modes->depthBits,
127 modes->stencilBits,
128 modes->accumRedBits,
129 modes->accumGreenBits,
130 modes->accumBlueBits,
131 modes->accumAlphaBits,
132 0);
133
134 _mesa_initialize_context(ctx, &ctx->Visual, NULL, imports->wscx, GL_FALSE);
135
136 ctx->exports.destroyContext = _mesa_DestroyContext;
137
138 return ctx;
139}
140
141
142/* exported OpenGL SI interface */
143void
144__glCoreNopDispatch(void)
145{
146#if 0
147 /* SI */
148 __gl_dispatch = __glNopDispatchState;
149#else
150 /* Mesa */
151 _glapi_set_dispatch(NULL);
152#endif
153}
154
155
jtgafb833d1999-08-19 00:55:39 +0000156/**********************************************************************/
157/***** Context and Thread management *****/
158/**********************************************************************/
159
160
jtgafb833d1999-08-19 00:55:39 +0000161
jtgafb833d1999-08-19 00:55:39 +0000162/**********************************************************************/
Brian Paul4d053dd2000-01-14 04:45:47 +0000163/***** GL Visual allocation/destruction *****/
164/**********************************************************************/
165
166
167/*
168 * Allocate a new GLvisual object.
169 * Input: rgbFlag - GL_TRUE=RGB(A) mode, GL_FALSE=Color Index mode
Brian Paul4d053dd2000-01-14 04:45:47 +0000170 * dbFlag - double buffering?
171 * stereoFlag - stereo buffer?
Brian Pauled30dfa2000-03-03 17:47:39 +0000172 * depthBits - requested bits per depth buffer value
173 * Any value in [0, 32] is acceptable but the actual
174 * depth type will be GLushort or GLuint as needed.
175 * stencilBits - requested minimum bits per stencil buffer value
176 * accumBits - requested minimum bits per accum buffer component
177 * indexBits - number of bits per pixel if rgbFlag==GL_FALSE
178 * red/green/blue/alphaBits - number of bits per color component
179 * in frame buffer for RGB(A) mode.
180 * We always use 8 in core Mesa though.
Brian Paul4d053dd2000-01-14 04:45:47 +0000181 * Return: pointer to new GLvisual or NULL if requested parameters can't
182 * be met.
183 */
Brian Paulb371e0d2000-03-31 01:05:51 +0000184GLvisual *
185_mesa_create_visual( GLboolean rgbFlag,
Brian Paulb371e0d2000-03-31 01:05:51 +0000186 GLboolean dbFlag,
187 GLboolean stereoFlag,
188 GLint redBits,
189 GLint greenBits,
190 GLint blueBits,
191 GLint alphaBits,
192 GLint indexBits,
193 GLint depthBits,
194 GLint stencilBits,
195 GLint accumRedBits,
196 GLint accumGreenBits,
197 GLint accumBlueBits,
198 GLint accumAlphaBits,
199 GLint numSamples )
Brian Paul4d053dd2000-01-14 04:45:47 +0000200{
Brian Paul178a1c52000-04-22 01:05:00 +0000201 GLvisual *vis = (GLvisual *) CALLOC( sizeof(GLvisual) );
202 if (vis) {
Brian Paule70c6232000-05-04 13:53:55 +0000203 if (!_mesa_initialize_visual(vis, rgbFlag, dbFlag, stereoFlag,
Brian Paul178a1c52000-04-22 01:05:00 +0000204 redBits, greenBits, blueBits, alphaBits,
205 indexBits, depthBits, stencilBits,
206 accumRedBits, accumGreenBits,
207 accumBlueBits, accumAlphaBits,
Brian Paulb1394fa2000-09-26 20:53:53 +0000208 numSamples)) {
Brian Paul178a1c52000-04-22 01:05:00 +0000209 FREE(vis);
210 return NULL;
211 }
212 }
213 return vis;
214}
215
216
217/*
218 * Initialize the fields of the given GLvisual.
219 * Input: see _mesa_create_visual() above.
220 * Return: GL_TRUE = success
221 * GL_FALSE = failure.
222 */
223GLboolean
224_mesa_initialize_visual( GLvisual *vis,
225 GLboolean rgbFlag,
Brian Paul178a1c52000-04-22 01:05:00 +0000226 GLboolean dbFlag,
227 GLboolean stereoFlag,
228 GLint redBits,
229 GLint greenBits,
230 GLint blueBits,
231 GLint alphaBits,
232 GLint indexBits,
233 GLint depthBits,
234 GLint stencilBits,
235 GLint accumRedBits,
236 GLint accumGreenBits,
237 GLint accumBlueBits,
238 GLint accumAlphaBits,
239 GLint numSamples )
240{
241 assert(vis);
Brian Paul4d053dd2000-01-14 04:45:47 +0000242
Brian Pauled30dfa2000-03-03 17:47:39 +0000243 /* This is to catch bad values from device drivers not updated for
244 * Mesa 3.3. Some device drivers just passed 1. That's a REALLY
245 * bad value now (a 1-bit depth buffer!?!).
246 */
247 assert(depthBits == 0 || depthBits > 1);
248
249 if (depthBits < 0 || depthBits > 32) {
Brian Paul178a1c52000-04-22 01:05:00 +0000250 return GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000251 }
Brian Pauled30dfa2000-03-03 17:47:39 +0000252 if (stencilBits < 0 || stencilBits > (GLint) (8 * sizeof(GLstencil))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000253 return GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000254 }
Brian Paulb371e0d2000-03-31 01:05:51 +0000255 if (accumRedBits < 0 || accumRedBits > (GLint) (8 * sizeof(GLaccum))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000256 return GL_FALSE;
Brian Paulb371e0d2000-03-31 01:05:51 +0000257 }
258 if (accumGreenBits < 0 || accumGreenBits > (GLint) (8 * sizeof(GLaccum))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000259 return GL_FALSE;
Brian Paulb371e0d2000-03-31 01:05:51 +0000260 }
261 if (accumBlueBits < 0 || accumBlueBits > (GLint) (8 * sizeof(GLaccum))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000262 return GL_FALSE;
Brian Paulb371e0d2000-03-31 01:05:51 +0000263 }
264 if (accumAlphaBits < 0 || accumAlphaBits > (GLint) (8 * sizeof(GLaccum))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000265 return GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000266 }
267
268 vis->RGBAflag = rgbFlag;
269 vis->DBflag = dbFlag;
270 vis->StereoFlag = stereoFlag;
271 vis->RedBits = redBits;
272 vis->GreenBits = greenBits;
273 vis->BlueBits = blueBits;
Brian Paule70c6232000-05-04 13:53:55 +0000274 vis->AlphaBits = alphaBits;
Brian Paul4d053dd2000-01-14 04:45:47 +0000275
Brian Paulb371e0d2000-03-31 01:05:51 +0000276 vis->IndexBits = indexBits;
277 vis->DepthBits = depthBits;
278 vis->AccumRedBits = (accumRedBits > 0) ? (8 * sizeof(GLaccum)) : 0;
279 vis->AccumGreenBits = (accumGreenBits > 0) ? (8 * sizeof(GLaccum)) : 0;
280 vis->AccumBlueBits = (accumBlueBits > 0) ? (8 * sizeof(GLaccum)) : 0;
281 vis->AccumAlphaBits = (accumAlphaBits > 0) ? (8 * sizeof(GLaccum)) : 0;
282 vis->StencilBits = (stencilBits > 0) ? (8 * sizeof(GLstencil)) : 0;
Brian Paul4d053dd2000-01-14 04:45:47 +0000283
Brian Pauled30dfa2000-03-03 17:47:39 +0000284 if (depthBits == 0) {
285 /* Special case. Even if we don't have a depth buffer we need
Brian Paul35324a62000-10-09 22:42:40 +0000286 * good values for DepthMax for Z vertex transformation purposes
287 * and for per-fragment fog computation.
Brian Pauled30dfa2000-03-03 17:47:39 +0000288 */
Brian Paul35324a62000-10-09 22:42:40 +0000289 vis->DepthMax = 1 << 16;
290 vis->DepthMaxF = (GLfloat) vis->DepthMax;
Brian Pauled30dfa2000-03-03 17:47:39 +0000291 }
Brian Paul3a94f5c2000-05-18 18:12:36 +0000292 else if (depthBits < 32) {
Brian Pauled30dfa2000-03-03 17:47:39 +0000293 vis->DepthMax = (1 << depthBits) - 1;
294 vis->DepthMaxF = (GLfloat) vis->DepthMax;
295 }
Brian Paul3a94f5c2000-05-18 18:12:36 +0000296 else {
297 /* Special case since shift values greater than or equal to the
298 * number of bits in the left hand expression's type are
299 * undefined.
300 */
301 vis->DepthMax = 0xffffffff;
302 vis->DepthMaxF = (GLfloat) vis->DepthMax;
303 }
Brian Paul9da422c2000-12-16 00:21:28 +0000304 vis->MRD = 2.0; /* XXX temporary value */
Brian Pauled30dfa2000-03-03 17:47:39 +0000305
Brian Paul178a1c52000-04-22 01:05:00 +0000306 return GL_TRUE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000307}
308
309
Brian Paulb371e0d2000-03-31 01:05:51 +0000310void
311_mesa_destroy_visual( GLvisual *vis )
312{
313 FREE(vis);
314}
315
316
Brian Paul4d053dd2000-01-14 04:45:47 +0000317/**********************************************************************/
318/***** GL Framebuffer allocation/destruction *****/
319/**********************************************************************/
320
321
322/*
323 * Create a new framebuffer. A GLframebuffer is a struct which
324 * encapsulates the depth, stencil and accum buffers and related
325 * parameters.
326 * Input: visual - a GLvisual pointer
327 * softwareDepth - create/use a software depth buffer?
328 * softwareStencil - create/use a software stencil buffer?
329 * softwareAccum - create/use a software accum buffer?
330 * softwareAlpha - create/use a software alpha buffer?
331
332 * Return: pointer to new GLframebuffer struct or NULL if error.
333 */
Brian Paul178a1c52000-04-22 01:05:00 +0000334GLframebuffer *
Brian Paulb1394fa2000-09-26 20:53:53 +0000335_mesa_create_framebuffer( GLvisual *visual,
336 GLboolean softwareDepth,
337 GLboolean softwareStencil,
338 GLboolean softwareAccum,
339 GLboolean softwareAlpha )
Brian Paul4d053dd2000-01-14 04:45:47 +0000340{
Brian Paul178a1c52000-04-22 01:05:00 +0000341 GLframebuffer *buffer = CALLOC_STRUCT(gl_frame_buffer);
342 assert(visual);
343 if (buffer) {
344 _mesa_initialize_framebuffer(buffer, visual,
345 softwareDepth, softwareStencil,
346 softwareAccum, softwareAlpha );
Brian Paul4d053dd2000-01-14 04:45:47 +0000347 }
Brian Paul178a1c52000-04-22 01:05:00 +0000348 return buffer;
349}
350
351
352/*
353 * Initialize a GLframebuffer object.
Brian Paulb1394fa2000-09-26 20:53:53 +0000354 * Input: See _mesa_create_framebuffer() above.
Brian Paul178a1c52000-04-22 01:05:00 +0000355 */
356void
357_mesa_initialize_framebuffer( GLframebuffer *buffer,
358 GLvisual *visual,
359 GLboolean softwareDepth,
360 GLboolean softwareStencil,
361 GLboolean softwareAccum,
362 GLboolean softwareAlpha )
363{
364 assert(buffer);
365 assert(visual);
Brian Paul4d053dd2000-01-14 04:45:47 +0000366
367 /* sanity checks */
368 if (softwareDepth ) {
369 assert(visual->DepthBits > 0);
370 }
371 if (softwareStencil) {
372 assert(visual->StencilBits > 0);
373 }
374 if (softwareAccum) {
375 assert(visual->RGBAflag);
Brian Paulb371e0d2000-03-31 01:05:51 +0000376 assert(visual->AccumRedBits > 0);
377 assert(visual->AccumGreenBits > 0);
378 assert(visual->AccumBlueBits > 0);
Brian Paul4d053dd2000-01-14 04:45:47 +0000379 }
380 if (softwareAlpha) {
381 assert(visual->RGBAflag);
382 assert(visual->AlphaBits > 0);
383 }
384
385 buffer->Visual = visual;
386 buffer->UseSoftwareDepthBuffer = softwareDepth;
387 buffer->UseSoftwareStencilBuffer = softwareStencil;
388 buffer->UseSoftwareAccumBuffer = softwareAccum;
389 buffer->UseSoftwareAlphaBuffers = softwareAlpha;
Brian Paul4d053dd2000-01-14 04:45:47 +0000390}
391
392
Brian Paul4d053dd2000-01-14 04:45:47 +0000393/*
394 * Free a framebuffer struct and its buffers.
395 */
Brian Paul178a1c52000-04-22 01:05:00 +0000396void
Brian Paulb1394fa2000-09-26 20:53:53 +0000397_mesa_destroy_framebuffer( GLframebuffer *buffer )
Brian Paul4d053dd2000-01-14 04:45:47 +0000398{
399 if (buffer) {
Brian Paul650cb742000-03-17 15:31:52 +0000400 if (buffer->DepthBuffer) {
401 FREE( buffer->DepthBuffer );
Brian Paul4d053dd2000-01-14 04:45:47 +0000402 }
403 if (buffer->Accum) {
404 FREE( buffer->Accum );
405 }
406 if (buffer->Stencil) {
407 FREE( buffer->Stencil );
408 }
409 if (buffer->FrontLeftAlpha) {
410 FREE( buffer->FrontLeftAlpha );
411 }
412 if (buffer->BackLeftAlpha) {
413 FREE( buffer->BackLeftAlpha );
414 }
415 if (buffer->FrontRightAlpha) {
416 FREE( buffer->FrontRightAlpha );
417 }
418 if (buffer->BackRightAlpha) {
419 FREE( buffer->BackRightAlpha );
420 }
421 FREE(buffer);
422 }
423}
424
425
426
427/**********************************************************************/
jtgafb833d1999-08-19 00:55:39 +0000428/***** Context allocation, initialization, destroying *****/
429/**********************************************************************/
430
431
Brian Paul9560f052000-01-31 23:11:39 +0000432_glthread_DECLARE_STATIC_MUTEX(OneTimeLock);
433
434
jtgafb833d1999-08-19 00:55:39 +0000435/*
436 * This function just calls all the various one-time-init functions in Mesa.
437 */
Brian Paul178a1c52000-04-22 01:05:00 +0000438static void
439one_time_init( void )
jtgafb833d1999-08-19 00:55:39 +0000440{
441 static GLboolean alreadyCalled = GL_FALSE;
Brian Paul9560f052000-01-31 23:11:39 +0000442 _glthread_LOCK_MUTEX(OneTimeLock);
jtgafb833d1999-08-19 00:55:39 +0000443 if (!alreadyCalled) {
Brian Paul4d053dd2000-01-14 04:45:47 +0000444 /* do some implementation tests */
445 assert( sizeof(GLbyte) == 1 );
446 assert( sizeof(GLshort) >= 2 );
447 assert( sizeof(GLint) >= 4 );
448 assert( sizeof(GLubyte) == 1 );
449 assert( sizeof(GLushort) >= 2 );
450 assert( sizeof(GLuint) >= 4 );
451
jtgafb833d1999-08-19 00:55:39 +0000452 gl_init_lists();
Keith Whitwell23caf202000-11-16 21:05:34 +0000453
454 _mesa_init_math();
455 _math_init();
Brian Paul68ee4bc2000-01-28 19:02:22 +0000456
457 if (getenv("MESA_DEBUG")) {
458 _glapi_noop_enable_warnings(GL_TRUE);
459 }
460 else {
461 _glapi_noop_enable_warnings(GL_FALSE);
462 }
463
jtgafb833d1999-08-19 00:55:39 +0000464#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
465 fprintf(stderr, "Mesa DEBUG build %s %s\n", __DATE__, __TIME__);
466#endif
Brian Paul68ee4bc2000-01-28 19:02:22 +0000467
468 alreadyCalled = GL_TRUE;
469 }
Brian Paul9560f052000-01-31 23:11:39 +0000470 _glthread_UNLOCK_MUTEX(OneTimeLock);
jtgafb833d1999-08-19 00:55:39 +0000471}
472
473
Brian Paul4d053dd2000-01-14 04:45:47 +0000474
jtgafb833d1999-08-19 00:55:39 +0000475/*
476 * Allocate and initialize a shared context state structure.
477 */
Brian Paul178a1c52000-04-22 01:05:00 +0000478static struct gl_shared_state *
479alloc_shared_state( void )
jtgafb833d1999-08-19 00:55:39 +0000480{
jtgafb833d1999-08-19 00:55:39 +0000481 struct gl_shared_state *ss;
482 GLboolean outOfMemory;
483
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000484 ss = CALLOC_STRUCT(gl_shared_state);
jtgafb833d1999-08-19 00:55:39 +0000485 if (!ss)
486 return NULL;
487
Brian Paule4b684c2000-09-12 21:07:40 +0000488 _glthread_INIT_MUTEX(ss->Mutex);
jtgafb833d1999-08-19 00:55:39 +0000489
Brian Paule4b684c2000-09-12 21:07:40 +0000490 ss->DisplayList = _mesa_NewHashTable();
Brian Paulbb797902000-01-24 16:19:54 +0000491 ss->TexObjects = _mesa_NewHashTable();
jtgafb833d1999-08-19 00:55:39 +0000492
493 /* Default Texture objects */
494 outOfMemory = GL_FALSE;
Brian Paula8523782000-11-19 23:10:25 +0000495
496 ss->Default1D = _mesa_alloc_texture_object(ss, 0, 1);
497 if (!ss->Default1D) {
498 outOfMemory = GL_TRUE;
499 }
500 else {
501 ss->Default1D->RefCount++;
jtgafb833d1999-08-19 00:55:39 +0000502 }
503
Brian Paula8523782000-11-19 23:10:25 +0000504 ss->Default2D = _mesa_alloc_texture_object(ss, 0, 2);
505 if (!ss->Default2D) {
506 outOfMemory = GL_TRUE;
507 }
508 else {
509 ss->Default2D->RefCount++;
510 }
511
512 ss->Default3D = _mesa_alloc_texture_object(ss, 0, 3);
513 if (!ss->Default3D) {
514 outOfMemory = GL_TRUE;
515 }
516 else {
517 ss->Default1D->RefCount++;
518 }
519
520 ss->DefaultCubeMap = _mesa_alloc_texture_object(ss, 0, 6);
Brian Paul413d6a22000-05-26 14:44:59 +0000521 if (!ss->DefaultCubeMap) {
522 outOfMemory = GL_TRUE;
523 }
524 else {
525 ss->DefaultCubeMap->RefCount++;
526 }
527
jtgafb833d1999-08-19 00:55:39 +0000528 if (!ss->DisplayList || !ss->TexObjects || outOfMemory) {
529 /* Ran out of memory at some point. Free everything and return NULL */
530 if (ss->DisplayList)
Brian Paulbb797902000-01-24 16:19:54 +0000531 _mesa_DeleteHashTable(ss->DisplayList);
jtgafb833d1999-08-19 00:55:39 +0000532 if (ss->TexObjects)
Brian Paulbb797902000-01-24 16:19:54 +0000533 _mesa_DeleteHashTable(ss->TexObjects);
Brian Paula8523782000-11-19 23:10:25 +0000534 if (ss->Default1D)
535 _mesa_free_texture_object(ss, ss->Default1D);
536 if (ss->Default2D)
537 _mesa_free_texture_object(ss, ss->Default2D);
538 if (ss->Default3D)
539 _mesa_free_texture_object(ss, ss->Default3D);
Brian Paul413d6a22000-05-26 14:44:59 +0000540 if (ss->DefaultCubeMap)
Brian Paula8523782000-11-19 23:10:25 +0000541 _mesa_free_texture_object(ss, ss->DefaultCubeMap);
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000542 FREE(ss);
jtgafb833d1999-08-19 00:55:39 +0000543 return NULL;
544 }
545 else {
546 return ss;
547 }
548}
549
550
551/*
552 * Deallocate a shared state context and all children structures.
553 */
Brian Paul178a1c52000-04-22 01:05:00 +0000554static void
555free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
jtgafb833d1999-08-19 00:55:39 +0000556{
557 /* Free display lists */
558 while (1) {
Brian Paulbb797902000-01-24 16:19:54 +0000559 GLuint list = _mesa_HashFirstEntry(ss->DisplayList);
jtgafb833d1999-08-19 00:55:39 +0000560 if (list) {
561 gl_destroy_list(ctx, list);
562 }
563 else {
564 break;
565 }
566 }
Brian Paulbb797902000-01-24 16:19:54 +0000567 _mesa_DeleteHashTable(ss->DisplayList);
jtgafb833d1999-08-19 00:55:39 +0000568
569 /* Free texture objects */
570 while (ss->TexObjectList)
571 {
572 if (ctx->Driver.DeleteTexture)
573 (*ctx->Driver.DeleteTexture)( ctx, ss->TexObjectList );
574 /* this function removes from linked list too! */
Brian Paula8523782000-11-19 23:10:25 +0000575 _mesa_free_texture_object(ss, ss->TexObjectList);
jtgafb833d1999-08-19 00:55:39 +0000576 }
Brian Paulbb797902000-01-24 16:19:54 +0000577 _mesa_DeleteHashTable(ss->TexObjects);
jtgafb833d1999-08-19 00:55:39 +0000578
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000579 FREE(ss);
jtgafb833d1999-08-19 00:55:39 +0000580}
581
582
583
jtgafb833d1999-08-19 00:55:39 +0000584/*
585 * Initialize the nth light. Note that the defaults for light 0 are
586 * different than the other lights.
587 */
Brian Paul178a1c52000-04-22 01:05:00 +0000588static void
589init_light( struct gl_light *l, GLuint n )
jtgafb833d1999-08-19 00:55:39 +0000590{
591 make_empty_list( l );
592
593 ASSIGN_4V( l->Ambient, 0.0, 0.0, 0.0, 1.0 );
594 if (n==0) {
595 ASSIGN_4V( l->Diffuse, 1.0, 1.0, 1.0, 1.0 );
596 ASSIGN_4V( l->Specular, 1.0, 1.0, 1.0, 1.0 );
597 }
598 else {
599 ASSIGN_4V( l->Diffuse, 0.0, 0.0, 0.0, 1.0 );
600 ASSIGN_4V( l->Specular, 0.0, 0.0, 0.0, 1.0 );
601 }
602 ASSIGN_4V( l->EyePosition, 0.0, 0.0, 1.0, 0.0 );
603 ASSIGN_3V( l->EyeDirection, 0.0, 0.0, -1.0 );
604 l->SpotExponent = 0.0;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000605 gl_invalidate_spot_exp_table( l );
jtgafb833d1999-08-19 00:55:39 +0000606 l->SpotCutoff = 180.0;
Keith Whitwell14940c42000-11-05 18:40:57 +0000607 l->_CosCutoff = 0.0; /* KW: -ve values not admitted */
jtgafb833d1999-08-19 00:55:39 +0000608 l->ConstantAttenuation = 1.0;
609 l->LinearAttenuation = 0.0;
610 l->QuadraticAttenuation = 0.0;
611 l->Enabled = GL_FALSE;
612}
613
614
615
Brian Paul178a1c52000-04-22 01:05:00 +0000616static void
617init_lightmodel( struct gl_lightmodel *lm )
jtgafb833d1999-08-19 00:55:39 +0000618{
619 ASSIGN_4V( lm->Ambient, 0.2, 0.2, 0.2, 1.0 );
620 lm->LocalViewer = GL_FALSE;
621 lm->TwoSide = GL_FALSE;
622 lm->ColorControl = GL_SINGLE_COLOR;
623}
624
625
Brian Paul178a1c52000-04-22 01:05:00 +0000626static void
627init_material( struct gl_material *m )
jtgafb833d1999-08-19 00:55:39 +0000628{
629 ASSIGN_4V( m->Ambient, 0.2, 0.2, 0.2, 1.0 );
630 ASSIGN_4V( m->Diffuse, 0.8, 0.8, 0.8, 1.0 );
631 ASSIGN_4V( m->Specular, 0.0, 0.0, 0.0, 1.0 );
632 ASSIGN_4V( m->Emission, 0.0, 0.0, 0.0, 1.0 );
633 m->Shininess = 0.0;
634 m->AmbientIndex = 0;
635 m->DiffuseIndex = 1;
636 m->SpecularIndex = 1;
637}
638
639
640
Brian Paul178a1c52000-04-22 01:05:00 +0000641static void
642init_texture_unit( GLcontext *ctx, GLuint unit )
jtgafb833d1999-08-19 00:55:39 +0000643{
644 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
645
646 texUnit->EnvMode = GL_MODULATE;
Brian Paul24507ff2000-06-27 21:42:13 +0000647 texUnit->CombineModeRGB = GL_MODULATE;
648 texUnit->CombineModeA = GL_MODULATE;
649 texUnit->CombineSourceRGB[0] = GL_TEXTURE;
650 texUnit->CombineSourceRGB[1] = GL_PREVIOUS_EXT;
651 texUnit->CombineSourceRGB[2] = GL_CONSTANT_EXT;
652 texUnit->CombineSourceA[0] = GL_TEXTURE;
653 texUnit->CombineSourceA[1] = GL_PREVIOUS_EXT;
654 texUnit->CombineSourceA[2] = GL_CONSTANT_EXT;
655 texUnit->CombineOperandRGB[0] = GL_SRC_COLOR;
656 texUnit->CombineOperandRGB[1] = GL_SRC_COLOR;
657 texUnit->CombineOperandRGB[2] = GL_SRC_ALPHA;
658 texUnit->CombineOperandA[0] = GL_SRC_ALPHA;
659 texUnit->CombineOperandA[1] = GL_SRC_ALPHA;
660 texUnit->CombineOperandA[2] = GL_SRC_ALPHA;
661 texUnit->CombineScaleShiftRGB = 0;
662 texUnit->CombineScaleShiftA = 0;
663
jtgafb833d1999-08-19 00:55:39 +0000664 ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
665 texUnit->TexGenEnabled = 0;
666 texUnit->GenModeS = GL_EYE_LINEAR;
667 texUnit->GenModeT = GL_EYE_LINEAR;
668 texUnit->GenModeR = GL_EYE_LINEAR;
669 texUnit->GenModeQ = GL_EYE_LINEAR;
Keith Whitwell14940c42000-11-05 18:40:57 +0000670 texUnit->_GenBitS = TEXGEN_EYE_LINEAR;
671 texUnit->_GenBitT = TEXGEN_EYE_LINEAR;
672 texUnit->_GenBitR = TEXGEN_EYE_LINEAR;
673 texUnit->_GenBitQ = TEXGEN_EYE_LINEAR;
Brian Paul26f3b052000-07-19 20:58:59 +0000674
jtgafb833d1999-08-19 00:55:39 +0000675 /* Yes, these plane coefficients are correct! */
676 ASSIGN_4V( texUnit->ObjectPlaneS, 1.0, 0.0, 0.0, 0.0 );
677 ASSIGN_4V( texUnit->ObjectPlaneT, 0.0, 1.0, 0.0, 0.0 );
678 ASSIGN_4V( texUnit->ObjectPlaneR, 0.0, 0.0, 0.0, 0.0 );
679 ASSIGN_4V( texUnit->ObjectPlaneQ, 0.0, 0.0, 0.0, 0.0 );
680 ASSIGN_4V( texUnit->EyePlaneS, 1.0, 0.0, 0.0, 0.0 );
681 ASSIGN_4V( texUnit->EyePlaneT, 0.0, 1.0, 0.0, 0.0 );
682 ASSIGN_4V( texUnit->EyePlaneR, 0.0, 0.0, 0.0, 0.0 );
683 ASSIGN_4V( texUnit->EyePlaneQ, 0.0, 0.0, 0.0, 0.0 );
684
Brian Paula8523782000-11-19 23:10:25 +0000685 texUnit->Current1D = ctx->Shared->Default1D;
686 texUnit->Current2D = ctx->Shared->Default2D;
687 texUnit->Current3D = ctx->Shared->Default3D;
Brian Paul413d6a22000-05-26 14:44:59 +0000688 texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
jtgafb833d1999-08-19 00:55:39 +0000689}
690
691
jtgafb833d1999-08-19 00:55:39 +0000692
Brian Paul4d053dd2000-01-14 04:45:47 +0000693
jtgafb833d1999-08-19 00:55:39 +0000694/* Initialize a 1-D evaluator map */
Brian Paul178a1c52000-04-22 01:05:00 +0000695static void
696init_1d_map( struct gl_1d_map *map, int n, const float *initial )
jtgafb833d1999-08-19 00:55:39 +0000697{
698 map->Order = 1;
699 map->u1 = 0.0;
700 map->u2 = 1.0;
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000701 map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000702 if (map->Points) {
703 GLint i;
704 for (i=0;i<n;i++)
705 map->Points[i] = initial[i];
706 }
jtgafb833d1999-08-19 00:55:39 +0000707}
708
709
710/* Initialize a 2-D evaluator map */
Brian Paul178a1c52000-04-22 01:05:00 +0000711static void
712init_2d_map( struct gl_2d_map *map, int n, const float *initial )
jtgafb833d1999-08-19 00:55:39 +0000713{
714 map->Uorder = 1;
715 map->Vorder = 1;
716 map->u1 = 0.0;
717 map->u2 = 1.0;
718 map->v1 = 0.0;
719 map->v2 = 1.0;
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000720 map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000721 if (map->Points) {
722 GLint i;
723 for (i=0;i<n;i++)
724 map->Points[i] = initial[i];
725 }
jtgafb833d1999-08-19 00:55:39 +0000726}
727
728
jtgafb833d1999-08-19 00:55:39 +0000729/*
Brian Paul4d053dd2000-01-14 04:45:47 +0000730 * Initialize the attribute groups in a GLcontext.
jtgafb833d1999-08-19 00:55:39 +0000731 */
Brian Paul178a1c52000-04-22 01:05:00 +0000732static void
733init_attrib_groups( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +0000734{
735 GLuint i, j;
736
Brian Paul4d053dd2000-01-14 04:45:47 +0000737 assert(ctx);
jtgafb833d1999-08-19 00:55:39 +0000738
Brian Paul539cce52000-02-03 19:40:07 +0000739 /* Constants, may be overriden by device drivers */
Brian Paul4d053dd2000-01-14 04:45:47 +0000740 ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
741 ctx->Const.MaxTextureSize = 1 << (MAX_TEXTURE_LEVELS - 1);
Brian Paul86fc3702000-05-22 16:33:20 +0000742 ctx->Const.MaxCubeTextureSize = ctx->Const.MaxTextureSize;
Brian Paul4d053dd2000-01-14 04:45:47 +0000743 ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS;
744 ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
Brian Paul539cce52000-02-03 19:40:07 +0000745 ctx->Const.SubPixelBits = SUB_PIXEL_BITS;
746 ctx->Const.MinPointSize = MIN_POINT_SIZE;
747 ctx->Const.MaxPointSize = MAX_POINT_SIZE;
748 ctx->Const.MinPointSizeAA = MIN_POINT_SIZE;
749 ctx->Const.MaxPointSizeAA = MAX_POINT_SIZE;
750 ctx->Const.PointSizeGranularity = POINT_SIZE_GRANULARITY;
751 ctx->Const.MinLineWidth = MIN_LINE_WIDTH;
752 ctx->Const.MaxLineWidth = MAX_LINE_WIDTH;
753 ctx->Const.MinLineWidthAA = MIN_LINE_WIDTH;
754 ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH;
755 ctx->Const.LineWidthGranularity = LINE_WIDTH_GRANULARITY;
756 ctx->Const.NumAuxBuffers = NUM_AUX_BUFFERS;
Brian Paul4bdcfe52000-04-17 17:57:04 +0000757 ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE;
Brian Paul82b02f02000-05-07 20:37:40 +0000758 ctx->Const.MaxConvolutionWidth = MAX_CONVOLUTION_WIDTH;
759 ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT;
Brian Paul1207bf02000-05-23 20:10:49 +0000760 ctx->Const.NumCompressedTextureFormats = 0;
Brian Paula8644322000-11-27 18:22:13 +0000761 ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES;
762 ctx->Const.MaxLights = MAX_LIGHTS;
jtgafb833d1999-08-19 00:55:39 +0000763
Brian Paul4d053dd2000-01-14 04:45:47 +0000764 /* Modelview matrix */
Keith Whitwell23caf202000-11-16 21:05:34 +0000765 _math_matrix_ctr( &ctx->ModelView );
766 _math_matrix_alloc_inv( &ctx->ModelView );
Brian Paul4d053dd2000-01-14 04:45:47 +0000767
768 ctx->ModelViewStackDepth = 0;
Brian Paul7fc29c52000-03-06 17:03:03 +0000769 for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000770 _math_matrix_ctr( &ctx->ModelViewStack[i] );
771 _math_matrix_alloc_inv( &ctx->ModelViewStack[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +0000772 }
773
774 /* Projection matrix - need inv for user clipping in clip space*/
Keith Whitwell23caf202000-11-16 21:05:34 +0000775 _math_matrix_ctr( &ctx->ProjectionMatrix );
776 _math_matrix_alloc_inv( &ctx->ProjectionMatrix );
Brian Paul4d053dd2000-01-14 04:45:47 +0000777
778 ctx->ProjectionStackDepth = 0;
Brian Paul7fc29c52000-03-06 17:03:03 +0000779 for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000780 _math_matrix_ctr( &ctx->ProjectionStack[i] );
781 _math_matrix_alloc_inv( &ctx->ProjectionStack[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +0000782 }
783
Keith Whitwell23caf202000-11-16 21:05:34 +0000784 /* Derived ModelProject matrix */
785 _math_matrix_ctr( &ctx->_ModelProjectMatrix );
786
Brian Paul4d053dd2000-01-14 04:45:47 +0000787 /* Texture matrix */
Brian Paul904ecb22000-06-27 23:38:45 +0000788 for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000789 _math_matrix_ctr( &ctx->TextureMatrix[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +0000790 ctx->TextureStackDepth[i] = 0;
Brian Paul7fc29c52000-03-06 17:03:03 +0000791 for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000792 _math_matrix_ctr( &ctx->TextureStack[i][j] );
Brian Paul4d053dd2000-01-14 04:45:47 +0000793 ctx->TextureStack[i][j].inv = 0;
jtgafb833d1999-08-19 00:55:39 +0000794 }
Brian Paul4d053dd2000-01-14 04:45:47 +0000795 }
jtgafb833d1999-08-19 00:55:39 +0000796
Brian Paul250069d2000-04-08 18:57:45 +0000797 /* Color matrix */
Keith Whitwell23caf202000-11-16 21:05:34 +0000798 _math_matrix_ctr(&ctx->ColorMatrix);
Brian Paul250069d2000-04-08 18:57:45 +0000799 ctx->ColorStackDepth = 0;
800 for (j = 0; j < MAX_COLOR_STACK_DEPTH - 1; j++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000801 _math_matrix_ctr(&ctx->ColorStack[j]);
Brian Paul250069d2000-04-08 18:57:45 +0000802 }
803
Brian Paul4d053dd2000-01-14 04:45:47 +0000804 /* Accumulate buffer group */
805 ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 );
jtgafb833d1999-08-19 00:55:39 +0000806
Brian Paul4d053dd2000-01-14 04:45:47 +0000807 /* Color buffer group */
808 ctx->Color.IndexMask = 0xffffffff;
809 ctx->Color.ColorMask[0] = 0xff;
810 ctx->Color.ColorMask[1] = 0xff;
811 ctx->Color.ColorMask[2] = 0xff;
812 ctx->Color.ColorMask[3] = 0xff;
Brian Paul4d053dd2000-01-14 04:45:47 +0000813 ctx->Color.ClearIndex = 0;
814 ASSIGN_4V( ctx->Color.ClearColor, 0.0, 0.0, 0.0, 0.0 );
815 ctx->Color.DrawBuffer = GL_FRONT;
816 ctx->Color.AlphaEnabled = GL_FALSE;
817 ctx->Color.AlphaFunc = GL_ALWAYS;
818 ctx->Color.AlphaRef = 0;
819 ctx->Color.BlendEnabled = GL_FALSE;
820 ctx->Color.BlendSrcRGB = GL_ONE;
821 ctx->Color.BlendDstRGB = GL_ZERO;
822 ctx->Color.BlendSrcA = GL_ONE;
823 ctx->Color.BlendDstA = GL_ZERO;
824 ctx->Color.BlendEquation = GL_FUNC_ADD_EXT;
Brian Paul4d053dd2000-01-14 04:45:47 +0000825 ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
826 ctx->Color.IndexLogicOpEnabled = GL_FALSE;
827 ctx->Color.ColorLogicOpEnabled = GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000828 ctx->Color.LogicOp = GL_COPY;
829 ctx->Color.DitherFlag = GL_TRUE;
830 ctx->Color.MultiDrawBuffer = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000831
Brian Paul4d053dd2000-01-14 04:45:47 +0000832 /* Current group */
Brian Paul19300532000-10-29 19:02:23 +0000833 ASSIGN_4V( ctx->Current.Color, CHAN_MAX, CHAN_MAX, CHAN_MAX, CHAN_MAX );
Brian Paul4d053dd2000-01-14 04:45:47 +0000834 ctx->Current.Index = 1;
835 for (i=0; i<MAX_TEXTURE_UNITS; i++)
836 ASSIGN_4V( ctx->Current.Texcoord[i], 0.0, 0.0, 0.0, 1.0 );
837 ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 );
838 ctx->Current.RasterDistance = 0.0;
839 ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 );
840 ctx->Current.RasterIndex = 1;
841 for (i=0; i<MAX_TEXTURE_UNITS; i++)
842 ASSIGN_4V( ctx->Current.RasterMultiTexCoord[i], 0.0, 0.0, 0.0, 1.0 );
843 ctx->Current.RasterTexCoord = ctx->Current.RasterMultiTexCoord[0];
844 ctx->Current.RasterPosValid = GL_TRUE;
845 ctx->Current.EdgeFlag = GL_TRUE;
846 ASSIGN_3V( ctx->Current.Normal, 0.0, 0.0, 1.0 );
jtgafb833d1999-08-19 00:55:39 +0000847
jtgafb833d1999-08-19 00:55:39 +0000848
Brian Paul4d053dd2000-01-14 04:45:47 +0000849 /* Depth buffer group */
850 ctx->Depth.Test = GL_FALSE;
851 ctx->Depth.Clear = 1.0;
852 ctx->Depth.Func = GL_LESS;
853 ctx->Depth.Mask = GL_TRUE;
Brian Paul1b2ff692000-03-11 23:23:26 +0000854 ctx->Depth.OcclusionTest = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000855
Brian Paul4d053dd2000-01-14 04:45:47 +0000856 /* Evaluators group */
857 ctx->Eval.Map1Color4 = GL_FALSE;
858 ctx->Eval.Map1Index = GL_FALSE;
859 ctx->Eval.Map1Normal = GL_FALSE;
860 ctx->Eval.Map1TextureCoord1 = GL_FALSE;
861 ctx->Eval.Map1TextureCoord2 = GL_FALSE;
862 ctx->Eval.Map1TextureCoord3 = GL_FALSE;
863 ctx->Eval.Map1TextureCoord4 = GL_FALSE;
864 ctx->Eval.Map1Vertex3 = GL_FALSE;
865 ctx->Eval.Map1Vertex4 = GL_FALSE;
866 ctx->Eval.Map2Color4 = GL_FALSE;
867 ctx->Eval.Map2Index = GL_FALSE;
868 ctx->Eval.Map2Normal = GL_FALSE;
869 ctx->Eval.Map2TextureCoord1 = GL_FALSE;
870 ctx->Eval.Map2TextureCoord2 = GL_FALSE;
871 ctx->Eval.Map2TextureCoord3 = GL_FALSE;
872 ctx->Eval.Map2TextureCoord4 = GL_FALSE;
873 ctx->Eval.Map2Vertex3 = GL_FALSE;
874 ctx->Eval.Map2Vertex4 = GL_FALSE;
875 ctx->Eval.AutoNormal = GL_FALSE;
876 ctx->Eval.MapGrid1un = 1;
877 ctx->Eval.MapGrid1u1 = 0.0;
878 ctx->Eval.MapGrid1u2 = 1.0;
879 ctx->Eval.MapGrid2un = 1;
880 ctx->Eval.MapGrid2vn = 1;
881 ctx->Eval.MapGrid2u1 = 0.0;
882 ctx->Eval.MapGrid2u2 = 1.0;
883 ctx->Eval.MapGrid2v1 = 0.0;
884 ctx->Eval.MapGrid2v2 = 1.0;
jtgafb833d1999-08-19 00:55:39 +0000885
Brian Paul4d053dd2000-01-14 04:45:47 +0000886 /* Evaluator data */
887 {
888 static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 };
889 static GLfloat normal[3] = { 0.0, 0.0, 1.0 };
890 static GLfloat index[1] = { 1.0 };
891 static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 };
892 static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 };
jtgafb833d1999-08-19 00:55:39 +0000893
Brian Paul4d053dd2000-01-14 04:45:47 +0000894 init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex );
895 init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex );
896 init_1d_map( &ctx->EvalMap.Map1Index, 1, index );
897 init_1d_map( &ctx->EvalMap.Map1Color4, 4, color );
898 init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal );
899 init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord );
900 init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord );
901 init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord );
902 init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord );
jtgafb833d1999-08-19 00:55:39 +0000903
Brian Paul4d053dd2000-01-14 04:45:47 +0000904 init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex );
905 init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex );
906 init_2d_map( &ctx->EvalMap.Map2Index, 1, index );
907 init_2d_map( &ctx->EvalMap.Map2Color4, 4, color );
908 init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal );
909 init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord );
910 init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord );
911 init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord );
912 init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord );
913 }
jtgafb833d1999-08-19 00:55:39 +0000914
Brian Paul4d053dd2000-01-14 04:45:47 +0000915 /* Fog group */
916 ctx->Fog.Enabled = GL_FALSE;
917 ctx->Fog.Mode = GL_EXP;
918 ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 );
919 ctx->Fog.Index = 0.0;
920 ctx->Fog.Density = 1.0;
921 ctx->Fog.Start = 0.0;
922 ctx->Fog.End = 1.0;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000923 ctx->Fog.ColorSumEnabled = GL_FALSE;
924 ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
jtgafb833d1999-08-19 00:55:39 +0000925
Brian Paul4d053dd2000-01-14 04:45:47 +0000926 /* Hint group */
927 ctx->Hint.PerspectiveCorrection = GL_DONT_CARE;
928 ctx->Hint.PointSmooth = GL_DONT_CARE;
929 ctx->Hint.LineSmooth = GL_DONT_CARE;
930 ctx->Hint.PolygonSmooth = GL_DONT_CARE;
931 ctx->Hint.Fog = GL_DONT_CARE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000932 ctx->Hint.AllowDrawWin = GL_TRUE;
Brian Paul8cce3142000-04-10 15:52:25 +0000933 ctx->Hint.AllowDrawFrg = GL_TRUE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000934 ctx->Hint.AllowDrawMem = GL_TRUE;
935 ctx->Hint.StrictLighting = GL_TRUE;
Brian Paul1207bf02000-05-23 20:10:49 +0000936 ctx->Hint.ClipVolumeClipping = GL_DONT_CARE;
937 ctx->Hint.TextureCompression = GL_DONT_CARE;
jtgafb833d1999-08-19 00:55:39 +0000938
Brian Paul0771d152000-04-07 00:19:41 +0000939 /* Histogram group */
940 ctx->Histogram.Width = 0;
941 ctx->Histogram.Format = GL_RGBA;
942 ctx->Histogram.Sink = GL_FALSE;
943 ctx->Histogram.RedSize = 0xffffffff;
944 ctx->Histogram.GreenSize = 0xffffffff;
945 ctx->Histogram.BlueSize = 0xffffffff;
946 ctx->Histogram.AlphaSize = 0xffffffff;
947 ctx->Histogram.LuminanceSize = 0xffffffff;
948 for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) {
949 ctx->Histogram.Count[i][0] = 0;
950 ctx->Histogram.Count[i][1] = 0;
951 ctx->Histogram.Count[i][2] = 0;
952 ctx->Histogram.Count[i][3] = 0;
953 }
954
955 /* Min/Max group */
956 ctx->MinMax.Format = GL_RGBA;
957 ctx->MinMax.Sink = GL_FALSE;
958 ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000;
959 ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000;
960 ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000;
961 ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000;
962
Brian Paul4d053dd2000-01-14 04:45:47 +0000963 /* Extensions */
964 gl_extensions_ctr( ctx );
jtgafb833d1999-08-19 00:55:39 +0000965
Brian Paul4d053dd2000-01-14 04:45:47 +0000966 /* Lighting group */
967 for (i=0;i<MAX_LIGHTS;i++) {
968 init_light( &ctx->Light.Light[i], i );
969 }
970 make_empty_list( &ctx->Light.EnabledList );
jtgafb833d1999-08-19 00:55:39 +0000971
Brian Paul4d053dd2000-01-14 04:45:47 +0000972 init_lightmodel( &ctx->Light.Model );
973 init_material( &ctx->Light.Material[0] );
974 init_material( &ctx->Light.Material[1] );
975 ctx->Light.ShadeModel = GL_SMOOTH;
976 ctx->Light.Enabled = GL_FALSE;
977 ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK;
978 ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE;
979 ctx->Light.ColorMaterialBitmask
980 = gl_material_bitmask( ctx,
981 GL_FRONT_AND_BACK,
982 GL_AMBIENT_AND_DIFFUSE, ~0, 0 );
jtgafb833d1999-08-19 00:55:39 +0000983
Brian Paul4d053dd2000-01-14 04:45:47 +0000984 ctx->Light.ColorMaterialEnabled = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000985
Brian Paul4d053dd2000-01-14 04:45:47 +0000986 /* Lighting miscellaneous */
Keith Whitwell14940c42000-11-05 18:40:57 +0000987 ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab );
988 make_empty_list( ctx->_ShineTabList );
Brian Paul4d053dd2000-01-14 04:45:47 +0000989 for (i = 0 ; i < 10 ; i++) {
990 struct gl_shine_tab *s = MALLOC_STRUCT( gl_shine_tab );
991 s->shininess = -1;
992 s->refcount = 0;
Keith Whitwell14940c42000-11-05 18:40:57 +0000993 insert_at_tail( ctx->_ShineTabList, s );
Brian Paul4d053dd2000-01-14 04:45:47 +0000994 }
Brian Paul77d61af2000-06-28 04:20:21 +0000995
jtgafb833d1999-08-19 00:55:39 +0000996
Brian Paul4d053dd2000-01-14 04:45:47 +0000997 /* Line group */
998 ctx->Line.SmoothFlag = GL_FALSE;
999 ctx->Line.StippleFlag = GL_FALSE;
1000 ctx->Line.Width = 1.0;
1001 ctx->Line.StipplePattern = 0xffff;
1002 ctx->Line.StippleFactor = 1;
jtgafb833d1999-08-19 00:55:39 +00001003
Brian Paul4d053dd2000-01-14 04:45:47 +00001004 /* Display List group */
1005 ctx->List.ListBase = 0;
jtgafb833d1999-08-19 00:55:39 +00001006
Brian Paul4d053dd2000-01-14 04:45:47 +00001007 /* Pixel group */
1008 ctx->Pixel.RedBias = 0.0;
1009 ctx->Pixel.RedScale = 1.0;
1010 ctx->Pixel.GreenBias = 0.0;
1011 ctx->Pixel.GreenScale = 1.0;
1012 ctx->Pixel.BlueBias = 0.0;
1013 ctx->Pixel.BlueScale = 1.0;
1014 ctx->Pixel.AlphaBias = 0.0;
1015 ctx->Pixel.AlphaScale = 1.0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001016 ctx->Pixel.DepthBias = 0.0;
1017 ctx->Pixel.DepthScale = 1.0;
1018 ctx->Pixel.IndexOffset = 0;
1019 ctx->Pixel.IndexShift = 0;
1020 ctx->Pixel.ZoomX = 1.0;
1021 ctx->Pixel.ZoomY = 1.0;
1022 ctx->Pixel.MapColorFlag = GL_FALSE;
1023 ctx->Pixel.MapStencilFlag = GL_FALSE;
1024 ctx->Pixel.MapStoSsize = 1;
1025 ctx->Pixel.MapItoIsize = 1;
1026 ctx->Pixel.MapItoRsize = 1;
1027 ctx->Pixel.MapItoGsize = 1;
1028 ctx->Pixel.MapItoBsize = 1;
1029 ctx->Pixel.MapItoAsize = 1;
1030 ctx->Pixel.MapRtoRsize = 1;
1031 ctx->Pixel.MapGtoGsize = 1;
1032 ctx->Pixel.MapBtoBsize = 1;
1033 ctx->Pixel.MapAtoAsize = 1;
1034 ctx->Pixel.MapStoS[0] = 0;
1035 ctx->Pixel.MapItoI[0] = 0;
1036 ctx->Pixel.MapItoR[0] = 0.0;
1037 ctx->Pixel.MapItoG[0] = 0.0;
1038 ctx->Pixel.MapItoB[0] = 0.0;
1039 ctx->Pixel.MapItoA[0] = 0.0;
1040 ctx->Pixel.MapItoR8[0] = 0;
1041 ctx->Pixel.MapItoG8[0] = 0;
1042 ctx->Pixel.MapItoB8[0] = 0;
1043 ctx->Pixel.MapItoA8[0] = 0;
1044 ctx->Pixel.MapRtoR[0] = 0.0;
1045 ctx->Pixel.MapGtoG[0] = 0.0;
1046 ctx->Pixel.MapBtoB[0] = 0.0;
1047 ctx->Pixel.MapAtoA[0] = 0.0;
Brian Paul2b2e9252000-04-07 16:27:26 +00001048 ctx->Pixel.HistogramEnabled = GL_FALSE;
1049 ctx->Pixel.MinMaxEnabled = GL_FALSE;
1050 ctx->Pixel.PixelTextureEnabled = GL_FALSE;
1051 ctx->Pixel.FragmentRgbSource = GL_PIXEL_GROUP_COLOR_SGIS;
1052 ctx->Pixel.FragmentAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS;
Brian Paul82b02f02000-05-07 20:37:40 +00001053 ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0);
1054 ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0);
1055 ASSIGN_4V(ctx->Pixel.ColorTableScale, 1.0, 1.0, 1.0, 1.0);
1056 ASSIGN_4V(ctx->Pixel.ColorTableBias, 0.0, 0.0, 0.0, 0.0);
Brian Paul6c50e162000-06-30 22:11:04 +00001057 ASSIGN_4V(ctx->Pixel.PCCTscale, 1.0, 1.0, 1.0, 1.0);
1058 ASSIGN_4V(ctx->Pixel.PCCTbias, 0.0, 0.0, 0.0, 0.0);
1059 ASSIGN_4V(ctx->Pixel.PCMCTscale, 1.0, 1.0, 1.0, 1.0);
1060 ASSIGN_4V(ctx->Pixel.PCMCTbias, 0.0, 0.0, 0.0, 0.0);
Brian Paul4fe34b22000-04-11 15:07:48 +00001061 ctx->Pixel.ColorTableEnabled = GL_FALSE;
1062 ctx->Pixel.PostConvolutionColorTableEnabled = GL_FALSE;
1063 ctx->Pixel.PostColorMatrixColorTableEnabled = GL_FALSE;
Brian Paul82b02f02000-05-07 20:37:40 +00001064 ctx->Pixel.Convolution1DEnabled = GL_FALSE;
1065 ctx->Pixel.Convolution2DEnabled = GL_FALSE;
1066 ctx->Pixel.Separable2DEnabled = GL_FALSE;
1067 for (i = 0; i < 3; i++) {
1068 ASSIGN_4V(ctx->Pixel.ConvolutionBorderColor[i], 0.0, 0.0, 0.0, 0.0);
1069 ctx->Pixel.ConvolutionBorderMode[i] = GL_REDUCE;
1070 ASSIGN_4V(ctx->Pixel.ConvolutionFilterScale[i], 1.0, 1.0, 1.0, 1.0);
1071 ASSIGN_4V(ctx->Pixel.ConvolutionFilterBias[i], 0.0, 0.0, 0.0, 0.0);
1072 }
Brian Paul67adba12000-12-09 20:35:54 +00001073 for (i = 0; i < MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_WIDTH * 4; i++) {
1074 ctx->Convolution1D.Filter[i] = 0.0;
1075 ctx->Convolution2D.Filter[i] = 0.0;
1076 ctx->Separable2D.Filter[i] = 0.0;
1077 }
Brian Paul82b02f02000-05-07 20:37:40 +00001078 ASSIGN_4V(ctx->Pixel.PostConvolutionScale, 1.0, 1.0, 1.0, 1.0);
1079 ASSIGN_4V(ctx->Pixel.PostConvolutionBias, 0.0, 0.0, 0.0, 0.0);
jtgafb833d1999-08-19 00:55:39 +00001080
Brian Paul4d053dd2000-01-14 04:45:47 +00001081 /* Point group */
1082 ctx->Point.SmoothFlag = GL_FALSE;
1083 ctx->Point.Size = 1.0;
Brian Paul24a32622000-11-15 16:38:40 +00001084 ctx->Point._Size = 1.0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001085 ctx->Point.Params[0] = 1.0;
1086 ctx->Point.Params[1] = 0.0;
1087 ctx->Point.Params[2] = 0.0;
Keith Whitwell14940c42000-11-05 18:40:57 +00001088 ctx->Point._Attenuated = GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +00001089 ctx->Point.MinSize = 0.0;
Brian Paul24a32622000-11-15 16:38:40 +00001090 ctx->Point.MaxSize = ctx->Const.MaxPointSize;
Brian Paul4d053dd2000-01-14 04:45:47 +00001091 ctx->Point.Threshold = 1.0;
Brian Paul06d05af2000-12-08 00:20:15 +00001092 ctx->Point.SpriteMode = GL_FALSE; /* GL_MESA_sprite_point */
jtgafb833d1999-08-19 00:55:39 +00001093
Brian Paul4d053dd2000-01-14 04:45:47 +00001094 /* Polygon group */
1095 ctx->Polygon.CullFlag = GL_FALSE;
1096 ctx->Polygon.CullFaceMode = GL_BACK;
1097 ctx->Polygon.FrontFace = GL_CCW;
Keith Whitwellcab974c2000-12-26 05:09:27 +00001098 ctx->Polygon._FrontBit = 0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001099 ctx->Polygon.FrontMode = GL_FILL;
1100 ctx->Polygon.BackMode = GL_FILL;
Brian Paul4d053dd2000-01-14 04:45:47 +00001101 ctx->Polygon.SmoothFlag = GL_FALSE;
1102 ctx->Polygon.StippleFlag = GL_FALSE;
1103 ctx->Polygon.OffsetFactor = 0.0F;
1104 ctx->Polygon.OffsetUnits = 0.0F;
Brian Pauld0d7d622000-10-21 00:02:47 +00001105 ctx->Polygon.OffsetMRD = 0.0F;
Brian Paul4d053dd2000-01-14 04:45:47 +00001106 ctx->Polygon.OffsetPoint = GL_FALSE;
1107 ctx->Polygon.OffsetLine = GL_FALSE;
1108 ctx->Polygon.OffsetFill = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001109
Brian Paul4d053dd2000-01-14 04:45:47 +00001110 /* Polygon Stipple group */
1111 MEMSET( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) );
jtgafb833d1999-08-19 00:55:39 +00001112
Brian Paul4d053dd2000-01-14 04:45:47 +00001113 /* Scissor group */
1114 ctx->Scissor.Enabled = GL_FALSE;
1115 ctx->Scissor.X = 0;
1116 ctx->Scissor.Y = 0;
1117 ctx->Scissor.Width = 0;
1118 ctx->Scissor.Height = 0;
jtgafb833d1999-08-19 00:55:39 +00001119
Brian Paul4d053dd2000-01-14 04:45:47 +00001120 /* Stencil group */
1121 ctx->Stencil.Enabled = GL_FALSE;
1122 ctx->Stencil.Function = GL_ALWAYS;
1123 ctx->Stencil.FailFunc = GL_KEEP;
1124 ctx->Stencil.ZPassFunc = GL_KEEP;
1125 ctx->Stencil.ZFailFunc = GL_KEEP;
1126 ctx->Stencil.Ref = 0;
1127 ctx->Stencil.ValueMask = STENCIL_MAX;
1128 ctx->Stencil.Clear = 0;
1129 ctx->Stencil.WriteMask = STENCIL_MAX;
jtgafb833d1999-08-19 00:55:39 +00001130
Brian Paul4d053dd2000-01-14 04:45:47 +00001131 /* Texture group */
1132 ctx->Texture.CurrentUnit = 0; /* multitexture */
1133 ctx->Texture.CurrentTransformUnit = 0; /* multitexture */
Keith Whitwell14940c42000-11-05 18:40:57 +00001134 ctx->Texture._ReallyEnabled = 0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001135 for (i=0; i<MAX_TEXTURE_UNITS; i++)
1136 init_texture_unit( ctx, i );
Brian Paul23316032000-09-14 23:13:23 +00001137 ctx->Texture.SharedPalette = GL_FALSE;
Brian Paul4bdcfe52000-04-17 17:57:04 +00001138 _mesa_init_colortable(&ctx->Texture.Palette);
jtgafb833d1999-08-19 00:55:39 +00001139
Brian Paul4d053dd2000-01-14 04:45:47 +00001140 /* Transformation group */
1141 ctx->Transform.MatrixMode = GL_MODELVIEW;
1142 ctx->Transform.Normalize = GL_FALSE;
1143 ctx->Transform.RescaleNormals = GL_FALSE;
1144 for (i=0;i<MAX_CLIP_PLANES;i++) {
1145 ctx->Transform.ClipEnabled[i] = GL_FALSE;
1146 ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 );
1147 }
Keith Whitwell14940c42000-11-05 18:40:57 +00001148 ctx->Transform._AnyClip = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001149
Brian Paul4d053dd2000-01-14 04:45:47 +00001150 /* Viewport group */
1151 ctx->Viewport.X = 0;
1152 ctx->Viewport.Y = 0;
1153 ctx->Viewport.Width = 0;
1154 ctx->Viewport.Height = 0;
1155 ctx->Viewport.Near = 0.0;
1156 ctx->Viewport.Far = 1.0;
Keith Whitwell23caf202000-11-16 21:05:34 +00001157 _math_matrix_ctr(&ctx->Viewport._WindowMap);
jtgafb833d1999-08-19 00:55:39 +00001158
1159#define Sz 10
1160#define Tz 14
Keith Whitwell14940c42000-11-05 18:40:57 +00001161 ctx->Viewport._WindowMap.m[Sz] = 0.5 * ctx->Visual.DepthMaxF;
1162 ctx->Viewport._WindowMap.m[Tz] = 0.5 * ctx->Visual.DepthMaxF;
jtgafb833d1999-08-19 00:55:39 +00001163#undef Sz
1164#undef Tz
1165
Keith Whitwell14940c42000-11-05 18:40:57 +00001166 ctx->Viewport._WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION;
1167 ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
jtgafb833d1999-08-19 00:55:39 +00001168
Brian Paul4d053dd2000-01-14 04:45:47 +00001169 /* Vertex arrays */
1170 ctx->Array.Vertex.Size = 4;
1171 ctx->Array.Vertex.Type = GL_FLOAT;
1172 ctx->Array.Vertex.Stride = 0;
1173 ctx->Array.Vertex.StrideB = 0;
1174 ctx->Array.Vertex.Ptr = NULL;
1175 ctx->Array.Vertex.Enabled = GL_FALSE;
1176 ctx->Array.Normal.Type = GL_FLOAT;
1177 ctx->Array.Normal.Stride = 0;
1178 ctx->Array.Normal.StrideB = 0;
1179 ctx->Array.Normal.Ptr = NULL;
1180 ctx->Array.Normal.Enabled = GL_FALSE;
1181 ctx->Array.Color.Size = 4;
1182 ctx->Array.Color.Type = GL_FLOAT;
1183 ctx->Array.Color.Stride = 0;
1184 ctx->Array.Color.StrideB = 0;
1185 ctx->Array.Color.Ptr = NULL;
1186 ctx->Array.Color.Enabled = GL_FALSE;
1187 ctx->Array.Index.Type = GL_FLOAT;
1188 ctx->Array.Index.Stride = 0;
1189 ctx->Array.Index.StrideB = 0;
1190 ctx->Array.Index.Ptr = NULL;
1191 ctx->Array.Index.Enabled = GL_FALSE;
1192 for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
1193 ctx->Array.TexCoord[i].Size = 4;
1194 ctx->Array.TexCoord[i].Type = GL_FLOAT;
1195 ctx->Array.TexCoord[i].Stride = 0;
1196 ctx->Array.TexCoord[i].StrideB = 0;
1197 ctx->Array.TexCoord[i].Ptr = NULL;
1198 ctx->Array.TexCoord[i].Enabled = GL_FALSE;
1199 }
1200 ctx->Array.TexCoordInterleaveFactor = 1;
1201 ctx->Array.EdgeFlag.Stride = 0;
1202 ctx->Array.EdgeFlag.StrideB = 0;
1203 ctx->Array.EdgeFlag.Ptr = NULL;
1204 ctx->Array.EdgeFlag.Enabled = GL_FALSE;
1205 ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
1206
1207 /* Pixel transfer */
1208 ctx->Pack.Alignment = 4;
1209 ctx->Pack.RowLength = 0;
1210 ctx->Pack.ImageHeight = 0;
1211 ctx->Pack.SkipPixels = 0;
1212 ctx->Pack.SkipRows = 0;
1213 ctx->Pack.SkipImages = 0;
1214 ctx->Pack.SwapBytes = GL_FALSE;
1215 ctx->Pack.LsbFirst = GL_FALSE;
1216 ctx->Unpack.Alignment = 4;
1217 ctx->Unpack.RowLength = 0;
1218 ctx->Unpack.ImageHeight = 0;
1219 ctx->Unpack.SkipPixels = 0;
1220 ctx->Unpack.SkipRows = 0;
1221 ctx->Unpack.SkipImages = 0;
1222 ctx->Unpack.SwapBytes = GL_FALSE;
1223 ctx->Unpack.LsbFirst = GL_FALSE;
1224
1225 /* Feedback */
1226 ctx->Feedback.Type = GL_2D; /* TODO: verify */
1227 ctx->Feedback.Buffer = NULL;
1228 ctx->Feedback.BufferSize = 0;
1229 ctx->Feedback.Count = 0;
1230
1231 /* Selection/picking */
1232 ctx->Select.Buffer = NULL;
1233 ctx->Select.BufferSize = 0;
1234 ctx->Select.BufferCount = 0;
1235 ctx->Select.Hits = 0;
1236 ctx->Select.NameStackDepth = 0;
1237
Brian Paul4d053dd2000-01-14 04:45:47 +00001238 /* Renderer and client attribute stacks */
1239 ctx->AttribStackDepth = 0;
1240 ctx->ClientAttribStackDepth = 0;
1241
Brian Paul13811372000-04-12 00:27:37 +00001242 /* Display list */
1243 ctx->CallDepth = 0;
1244 ctx->ExecuteFlag = GL_TRUE;
1245 ctx->CompileFlag = GL_FALSE;
1246 ctx->CurrentListPtr = NULL;
1247 ctx->CurrentBlock = NULL;
1248 ctx->CurrentListNum = 0;
1249 ctx->CurrentPos = 0;
1250
1251 /* Color tables */
Brian Paul4bdcfe52000-04-17 17:57:04 +00001252 _mesa_init_colortable(&ctx->ColorTable);
1253 _mesa_init_colortable(&ctx->ProxyColorTable);
1254 _mesa_init_colortable(&ctx->PostConvolutionColorTable);
1255 _mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable);
1256 _mesa_init_colortable(&ctx->PostColorMatrixColorTable);
1257 _mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable);
Brian Paul13811372000-04-12 00:27:37 +00001258
Brian Paul4d053dd2000-01-14 04:45:47 +00001259 /* Miscellaneous */
Keith Whitwella96308c2000-10-30 13:31:59 +00001260 ctx->NewState = _NEW_ALL;
Brian Paul4d053dd2000-01-14 04:45:47 +00001261 ctx->RenderMode = GL_RENDER;
Keith Whitwell14940c42000-11-05 18:40:57 +00001262 ctx->_ImageTransferState = 0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001263
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001264 ctx->_NeedNormals = 0;
1265 ctx->_NeedEyeCoords = 0;
1266 ctx->_ModelViewInvScale = 1.0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001267
Brian Paul4d053dd2000-01-14 04:45:47 +00001268 ctx->ErrorValue = (GLenum) GL_NO_ERROR;
1269
1270 ctx->CatchSignals = GL_TRUE;
Brian Paul1b2ff692000-03-11 23:23:26 +00001271 ctx->OcclusionResult = GL_FALSE;
Brian Paul7e67fb42000-04-04 15:14:10 +00001272 ctx->OcclusionResultSaved = GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +00001273
1274 /* For debug/development only */
1275 ctx->NoRaster = getenv("MESA_NO_RASTER") ? GL_TRUE : GL_FALSE;
1276 ctx->FirstTimeCurrent = GL_TRUE;
1277
1278 /* Dither disable */
1279 ctx->NoDither = getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
1280 if (ctx->NoDither) {
1281 if (getenv("MESA_DEBUG")) {
1282 fprintf(stderr, "MESA_NO_DITHER set - dithering disabled\n");
jtgafb833d1999-08-19 00:55:39 +00001283 }
Brian Paul4d053dd2000-01-14 04:45:47 +00001284 ctx->Color.DitherFlag = GL_FALSE;
Brian Paul00037781999-12-17 14:52:35 +00001285 }
1286}
1287
1288
1289
1290
jtgafb833d1999-08-19 00:55:39 +00001291/*
1292 * Allocate the proxy textures. If we run out of memory part way through
1293 * the allocations clean up and return GL_FALSE.
1294 * Return: GL_TRUE=success, GL_FALSE=failure
1295 */
Brian Paul178a1c52000-04-22 01:05:00 +00001296static GLboolean
1297alloc_proxy_textures( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +00001298{
1299 GLboolean out_of_memory;
1300 GLint i;
1301
Brian Paula8523782000-11-19 23:10:25 +00001302 ctx->Texture.Proxy1D = _mesa_alloc_texture_object(NULL, 0, 1);
jtgafb833d1999-08-19 00:55:39 +00001303 if (!ctx->Texture.Proxy1D) {
1304 return GL_FALSE;
1305 }
1306
Brian Paula8523782000-11-19 23:10:25 +00001307 ctx->Texture.Proxy2D = _mesa_alloc_texture_object(NULL, 0, 2);
jtgafb833d1999-08-19 00:55:39 +00001308 if (!ctx->Texture.Proxy2D) {
Brian Paula8523782000-11-19 23:10:25 +00001309 _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
jtgafb833d1999-08-19 00:55:39 +00001310 return GL_FALSE;
1311 }
1312
Brian Paula8523782000-11-19 23:10:25 +00001313 ctx->Texture.Proxy3D = _mesa_alloc_texture_object(NULL, 0, 3);
jtgafb833d1999-08-19 00:55:39 +00001314 if (!ctx->Texture.Proxy3D) {
Brian Paula8523782000-11-19 23:10:25 +00001315 _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
1316 _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
1317 return GL_FALSE;
1318 }
1319
1320 ctx->Texture.ProxyCubeMap = _mesa_alloc_texture_object(NULL, 0, 6);
1321 if (!ctx->Texture.ProxyCubeMap) {
1322 _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
1323 _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
1324 _mesa_free_texture_object(NULL, ctx->Texture.Proxy3D);
jtgafb833d1999-08-19 00:55:39 +00001325 return GL_FALSE;
1326 }
1327
1328 out_of_memory = GL_FALSE;
1329 for (i=0;i<MAX_TEXTURE_LEVELS;i++) {
Brian Paul021a5252000-03-27 17:54:17 +00001330 ctx->Texture.Proxy1D->Image[i] = _mesa_alloc_texture_image();
1331 ctx->Texture.Proxy2D->Image[i] = _mesa_alloc_texture_image();
1332 ctx->Texture.Proxy3D->Image[i] = _mesa_alloc_texture_image();
jtgafb833d1999-08-19 00:55:39 +00001333 if (!ctx->Texture.Proxy1D->Image[i]
1334 || !ctx->Texture.Proxy2D->Image[i]
1335 || !ctx->Texture.Proxy3D->Image[i]) {
1336 out_of_memory = GL_TRUE;
1337 }
1338 }
1339 if (out_of_memory) {
1340 for (i=0;i<MAX_TEXTURE_LEVELS;i++) {
1341 if (ctx->Texture.Proxy1D->Image[i]) {
Brian Paul021a5252000-03-27 17:54:17 +00001342 _mesa_free_texture_image(ctx->Texture.Proxy1D->Image[i]);
jtgafb833d1999-08-19 00:55:39 +00001343 }
1344 if (ctx->Texture.Proxy2D->Image[i]) {
Brian Paul021a5252000-03-27 17:54:17 +00001345 _mesa_free_texture_image(ctx->Texture.Proxy2D->Image[i]);
jtgafb833d1999-08-19 00:55:39 +00001346 }
1347 if (ctx->Texture.Proxy3D->Image[i]) {
Brian Paul021a5252000-03-27 17:54:17 +00001348 _mesa_free_texture_image(ctx->Texture.Proxy3D->Image[i]);
jtgafb833d1999-08-19 00:55:39 +00001349 }
1350 }
Brian Paula8523782000-11-19 23:10:25 +00001351 _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
1352 _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
1353 _mesa_free_texture_object(NULL, ctx->Texture.Proxy3D);
jtgafb833d1999-08-19 00:55:39 +00001354 return GL_FALSE;
1355 }
1356 else {
1357 return GL_TRUE;
1358 }
1359}
1360
1361
jtgafb833d1999-08-19 00:55:39 +00001362/*
Brian Paul8aee2a32000-08-29 18:57:58 +00001363 * Initialize a GLcontext struct. This includes allocating all the
1364 * other structs and arrays which hang off of the context by pointers.
jtgafb833d1999-08-19 00:55:39 +00001365 */
Brian Paul178a1c52000-04-22 01:05:00 +00001366GLboolean
1367_mesa_initialize_context( GLcontext *ctx,
1368 GLvisual *visual,
1369 GLcontext *share_list,
1370 void *driver_ctx,
1371 GLboolean direct )
jtgafb833d1999-08-19 00:55:39 +00001372{
Brian Paul5fb84d22000-05-24 15:04:45 +00001373 GLuint dispatchSize;
1374
jtgafb833d1999-08-19 00:55:39 +00001375 (void) direct; /* not used */
1376
jtgafb833d1999-08-19 00:55:39 +00001377 /* misc one-time initializations */
1378 one_time_init();
1379
Brian Paulb1394fa2000-09-26 20:53:53 +00001380 /**
1381 ** OpenGL SI stuff
1382 **/
1383 if (!ctx->imports.malloc) {
1384 _mesa_InitDefaultImports(&ctx->imports, driver_ctx, NULL);
1385 }
1386 /* exports are setup by the device driver */
1387
jtgafb833d1999-08-19 00:55:39 +00001388 ctx->DriverCtx = driver_ctx;
Brian Paulb1394fa2000-09-26 20:53:53 +00001389 ctx->Visual = *visual;
Brian Paul3f02f901999-11-24 18:48:30 +00001390 ctx->DrawBuffer = NULL;
1391 ctx->ReadBuffer = NULL;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001392
jtgafb833d1999-08-19 00:55:39 +00001393 if (share_list) {
1394 /* share the group of display lists of another context */
1395 ctx->Shared = share_list->Shared;
1396 }
1397 else {
1398 /* allocate new group of display lists */
1399 ctx->Shared = alloc_shared_state();
1400 if (!ctx->Shared) {
Brian Paul4d053dd2000-01-14 04:45:47 +00001401 return GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001402 }
1403 }
Brian Paul9560f052000-01-31 23:11:39 +00001404 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
jtgafb833d1999-08-19 00:55:39 +00001405 ctx->Shared->RefCount++;
Brian Paul9560f052000-01-31 23:11:39 +00001406 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
jtgafb833d1999-08-19 00:55:39 +00001407
Brian Paul4d053dd2000-01-14 04:45:47 +00001408 init_attrib_groups( ctx );
1409
jtgafb833d1999-08-19 00:55:39 +00001410 if (visual->DBflag) {
1411 ctx->Color.DrawBuffer = GL_BACK;
1412 ctx->Color.DriverDrawBuffer = GL_BACK_LEFT;
1413 ctx->Color.DrawDestMask = BACK_LEFT_BIT;
1414 ctx->Pixel.ReadBuffer = GL_BACK;
1415 ctx->Pixel.DriverReadBuffer = GL_BACK_LEFT;
1416 }
1417 else {
1418 ctx->Color.DrawBuffer = GL_FRONT;
1419 ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT;
1420 ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
1421 ctx->Pixel.ReadBuffer = GL_FRONT;
1422 ctx->Pixel.DriverReadBuffer = GL_FRONT_LEFT;
1423 }
1424
jtgafb833d1999-08-19 00:55:39 +00001425 if (!alloc_proxy_textures(ctx)) {
1426 free_shared_state(ctx, ctx->Shared);
Brian Paul4d053dd2000-01-14 04:45:47 +00001427 return GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001428 }
jtgafb833d1999-08-19 00:55:39 +00001429
Brian Paulf59afc92000-05-23 23:23:00 +00001430 /* register the most recent extension functions with libGL */
1431 _glapi_add_entrypoint("glTbufferMask3DFX", 553);
1432 _glapi_add_entrypoint("glCompressedTexImage3DARB", 554);
1433 _glapi_add_entrypoint("glCompressedTexImage2DARB", 555);
1434 _glapi_add_entrypoint("glCompressedTexImage1DARB", 556);
1435 _glapi_add_entrypoint("glCompressedTexSubImage3DARB", 557);
1436 _glapi_add_entrypoint("glCompressedTexSubImage2DARB", 558);
1437 _glapi_add_entrypoint("glCompressedTexSubImage1DARB", 559);
1438 _glapi_add_entrypoint("glGetCompressedTexImageARB", 560);
1439
Brian Paul5fb84d22000-05-24 15:04:45 +00001440 /* Find the larger of Mesa's dispatch table and libGL's dispatch table.
1441 * In practice, this'll be the same for stand-alone Mesa. But for DRI
1442 * Mesa we do this to accomodate different versions of libGL and various
1443 * DRI drivers.
1444 */
1445 dispatchSize = MAX2(_glapi_get_dispatch_table_size(),
1446 sizeof(struct _glapi_table) / sizeof(void *));
1447
Brian Paulfbd8f211999-11-11 01:22:25 +00001448 /* setup API dispatch tables */
Brian Paul5fb84d22000-05-24 15:04:45 +00001449 ctx->Exec = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
1450 ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001451 if (!ctx->Exec || !ctx->Save) {
1452 free_shared_state(ctx, ctx->Shared);
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001453 if (ctx->Exec)
Brian Paul2d8db392000-06-27 22:10:00 +00001454 FREE( ctx->Exec );
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001455 }
Brian Paul5fb84d22000-05-24 15:04:45 +00001456 _mesa_init_exec_table(ctx->Exec, dispatchSize);
1457 _mesa_init_dlist_table(ctx->Save, dispatchSize);
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001458 ctx->CurrentDispatch = ctx->Exec;
jtgafb833d1999-08-19 00:55:39 +00001459
Keith Whitwellad2ac212000-11-24 10:25:05 +00001460 ctx->ExecPrefersFloat = GL_FALSE;
1461 ctx->SavePrefersFloat = GL_FALSE;
1462
Brian Paul3b18a362000-09-26 15:27:20 +00001463#if defined(MESA_TRACE)
Brian Paul45f36342000-09-05 20:28:06 +00001464 ctx->TraceCtx = CALLOC( sizeof(trace_context_t) );
1465#if 0
1466 /* Brian: do you want to have CreateContext fail here,
1467 or should we just trap in NewTrace (currently done)? */
1468 if (!(ctx->TraceCtx)) {
1469 free_shared_state(ctx, ctx->Shared);
Brian Paul45f36342000-09-05 20:28:06 +00001470 FREE( ctx->Exec );
1471 FREE( ctx->Save );
1472 return GL_FALSE;
1473 }
1474#endif
1475 trInitContext(ctx->TraceCtx);
1476
1477 ctx->TraceDispatch = (struct _glapi_table *)
1478 CALLOC(dispatchSize * sizeof(void*));
1479#if 0
1480 if (!(ctx->TraceCtx)) {
1481 free_shared_state(ctx, ctx->Shared);
Brian Paul45f36342000-09-05 20:28:06 +00001482 FREE( ctx->Exec );
1483 FREE( ctx->Save );
1484 FREE( ctx->TraceCtx );
1485 return GL_FALSE;
1486 }
1487#endif
1488 trInitDispatch(ctx->TraceDispatch);
1489#endif
1490
Brian Paul4d053dd2000-01-14 04:45:47 +00001491 return GL_TRUE;
jtgafb833d1999-08-19 00:55:39 +00001492}
1493
jtgafb833d1999-08-19 00:55:39 +00001494
1495
1496/*
Brian Paul4d053dd2000-01-14 04:45:47 +00001497 * Allocate and initialize a GLcontext structure.
1498 * Input: visual - a GLvisual pointer
1499 * sharelist - another context to share display lists with or NULL
1500 * driver_ctx - pointer to device driver's context state struct
Brian Paulb1394fa2000-09-26 20:53:53 +00001501 * Return: pointer to a new __GLcontextRec or NULL if error.
Brian Paul4d053dd2000-01-14 04:45:47 +00001502 */
Brian Paul178a1c52000-04-22 01:05:00 +00001503GLcontext *
Brian Paulb1394fa2000-09-26 20:53:53 +00001504_mesa_create_context( GLvisual *visual,
1505 GLcontext *share_list,
1506 void *driver_ctx,
1507 GLboolean direct )
Brian Paul4d053dd2000-01-14 04:45:47 +00001508{
1509 GLcontext *ctx = (GLcontext *) CALLOC( sizeof(GLcontext) );
1510 if (!ctx) {
1511 return NULL;
1512 }
1513
Brian Paul178a1c52000-04-22 01:05:00 +00001514 if (_mesa_initialize_context(ctx, visual, share_list, driver_ctx, direct)) {
Brian Paul4d053dd2000-01-14 04:45:47 +00001515 return ctx;
1516 }
1517 else {
1518 FREE(ctx);
1519 return NULL;
1520 }
1521}
1522
1523
1524
1525/*
1526 * Free the data associated with the given context.
1527 * But don't free() the GLcontext struct itself!
1528 */
Brian Paul178a1c52000-04-22 01:05:00 +00001529void
Brian Paulb1394fa2000-09-26 20:53:53 +00001530_mesa_free_context_data( GLcontext *ctx )
Brian Paul4d053dd2000-01-14 04:45:47 +00001531{
Brian Paul4d053dd2000-01-14 04:45:47 +00001532 struct gl_shine_tab *s, *tmps;
Brian Paul7fc29c52000-03-06 17:03:03 +00001533 GLuint i, j;
Brian Paul4d053dd2000-01-14 04:45:47 +00001534
1535 /* if we're destroying the current context, unbind it first */
Brian Paulb1394fa2000-09-26 20:53:53 +00001536 if (ctx == _mesa_get_current_context()) {
1537 _mesa_make_current(NULL, NULL);
Brian Paul4d053dd2000-01-14 04:45:47 +00001538 }
1539
Keith Whitwell23caf202000-11-16 21:05:34 +00001540 _math_matrix_dtr( &ctx->ModelView );
Brian Paul7fc29c52000-03-06 17:03:03 +00001541 for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +00001542 _math_matrix_dtr( &ctx->ModelViewStack[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +00001543 }
Keith Whitwell23caf202000-11-16 21:05:34 +00001544 _math_matrix_dtr( &ctx->ProjectionMatrix );
Brian Paul7fc29c52000-03-06 17:03:03 +00001545 for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +00001546 _math_matrix_dtr( &ctx->ProjectionStack[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +00001547 }
Brian Paul7fc29c52000-03-06 17:03:03 +00001548 for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +00001549 _math_matrix_dtr( &ctx->TextureMatrix[i] );
Brian Paul7fc29c52000-03-06 17:03:03 +00001550 for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
Keith Whitwell23caf202000-11-16 21:05:34 +00001551 _math_matrix_dtr( &ctx->TextureStack[i][j] );
Brian Paul7fc29c52000-03-06 17:03:03 +00001552 }
1553 }
Brian Paul4d053dd2000-01-14 04:45:47 +00001554
Brian Paul9560f052000-01-31 23:11:39 +00001555 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
Brian Paul4d053dd2000-01-14 04:45:47 +00001556 ctx->Shared->RefCount--;
Brian Paul9560f052000-01-31 23:11:39 +00001557 assert(ctx->Shared->RefCount >= 0);
1558 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
1559 if (ctx->Shared->RefCount == 0) {
Brian Paul4d053dd2000-01-14 04:45:47 +00001560 /* free shared state */
1561 free_shared_state( ctx, ctx->Shared );
1562 }
1563
Keith Whitwell14940c42000-11-05 18:40:57 +00001564 foreach_s( s, tmps, ctx->_ShineTabList ) {
Brian Paul4d053dd2000-01-14 04:45:47 +00001565 FREE( s );
1566 }
Keith Whitwell14940c42000-11-05 18:40:57 +00001567 FREE( ctx->_ShineTabList );
Brian Paul4d053dd2000-01-14 04:45:47 +00001568
1569 /* Free proxy texture objects */
Brian Paula8523782000-11-19 23:10:25 +00001570 _mesa_free_texture_object( NULL, ctx->Texture.Proxy1D );
1571 _mesa_free_texture_object( NULL, ctx->Texture.Proxy2D );
1572 _mesa_free_texture_object( NULL, ctx->Texture.Proxy3D );
Brian Paul4d053dd2000-01-14 04:45:47 +00001573
1574 /* Free evaluator data */
1575 if (ctx->EvalMap.Map1Vertex3.Points)
1576 FREE( ctx->EvalMap.Map1Vertex3.Points );
1577 if (ctx->EvalMap.Map1Vertex4.Points)
1578 FREE( ctx->EvalMap.Map1Vertex4.Points );
1579 if (ctx->EvalMap.Map1Index.Points)
1580 FREE( ctx->EvalMap.Map1Index.Points );
1581 if (ctx->EvalMap.Map1Color4.Points)
1582 FREE( ctx->EvalMap.Map1Color4.Points );
1583 if (ctx->EvalMap.Map1Normal.Points)
1584 FREE( ctx->EvalMap.Map1Normal.Points );
1585 if (ctx->EvalMap.Map1Texture1.Points)
1586 FREE( ctx->EvalMap.Map1Texture1.Points );
1587 if (ctx->EvalMap.Map1Texture2.Points)
1588 FREE( ctx->EvalMap.Map1Texture2.Points );
1589 if (ctx->EvalMap.Map1Texture3.Points)
1590 FREE( ctx->EvalMap.Map1Texture3.Points );
1591 if (ctx->EvalMap.Map1Texture4.Points)
1592 FREE( ctx->EvalMap.Map1Texture4.Points );
1593
1594 if (ctx->EvalMap.Map2Vertex3.Points)
1595 FREE( ctx->EvalMap.Map2Vertex3.Points );
1596 if (ctx->EvalMap.Map2Vertex4.Points)
1597 FREE( ctx->EvalMap.Map2Vertex4.Points );
1598 if (ctx->EvalMap.Map2Index.Points)
1599 FREE( ctx->EvalMap.Map2Index.Points );
1600 if (ctx->EvalMap.Map2Color4.Points)
1601 FREE( ctx->EvalMap.Map2Color4.Points );
1602 if (ctx->EvalMap.Map2Normal.Points)
1603 FREE( ctx->EvalMap.Map2Normal.Points );
1604 if (ctx->EvalMap.Map2Texture1.Points)
1605 FREE( ctx->EvalMap.Map2Texture1.Points );
1606 if (ctx->EvalMap.Map2Texture2.Points)
1607 FREE( ctx->EvalMap.Map2Texture2.Points );
1608 if (ctx->EvalMap.Map2Texture3.Points)
1609 FREE( ctx->EvalMap.Map2Texture3.Points );
1610 if (ctx->EvalMap.Map2Texture4.Points)
1611 FREE( ctx->EvalMap.Map2Texture4.Points );
1612
Brian Paul4bdcfe52000-04-17 17:57:04 +00001613 _mesa_free_colortable_data( &ctx->ColorTable );
1614 _mesa_free_colortable_data( &ctx->PostConvolutionColorTable );
1615 _mesa_free_colortable_data( &ctx->PostColorMatrixColorTable );
1616 _mesa_free_colortable_data( &ctx->Texture.Palette );
1617
Brian Paul4d053dd2000-01-14 04:45:47 +00001618 gl_extensions_dtr(ctx);
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001619
1620 FREE(ctx->Exec);
1621 FREE(ctx->Save);
Brian Paul4d053dd2000-01-14 04:45:47 +00001622}
1623
1624
1625
1626/*
1627 * Destroy a GLcontext structure.
jtgafb833d1999-08-19 00:55:39 +00001628 */
Brian Paul178a1c52000-04-22 01:05:00 +00001629void
Brian Paulb1394fa2000-09-26 20:53:53 +00001630_mesa_destroy_context( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +00001631{
1632 if (ctx) {
Brian Paulb1394fa2000-09-26 20:53:53 +00001633 _mesa_free_context_data(ctx);
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001634 FREE( (void *) ctx );
jtgafb833d1999-08-19 00:55:39 +00001635 }
1636}
1637
1638
1639
1640/*
Brian Paul4d053dd2000-01-14 04:45:47 +00001641 * Called by the driver after both the context and driver are fully
1642 * initialized. Currently just reads the config file.
jtgafb833d1999-08-19 00:55:39 +00001643 */
Brian Paul178a1c52000-04-22 01:05:00 +00001644void
Brian Paulb1394fa2000-09-26 20:53:53 +00001645_mesa_context_initialize( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +00001646{
Brian Paul00037781999-12-17 14:52:35 +00001647 gl_read_config_file( ctx );
jtgafb833d1999-08-19 00:55:39 +00001648}
1649
1650
1651
1652/*
1653 * Copy attribute groups from one context to another.
1654 * Input: src - source context
1655 * dst - destination context
1656 * mask - bitwise OR of GL_*_BIT flags
1657 */
Brian Paul178a1c52000-04-22 01:05:00 +00001658void
Brian Paulb1394fa2000-09-26 20:53:53 +00001659_mesa_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask )
jtgafb833d1999-08-19 00:55:39 +00001660{
1661 if (mask & GL_ACCUM_BUFFER_BIT) {
1662 MEMCPY( &dst->Accum, &src->Accum, sizeof(struct gl_accum_attrib) );
1663 }
1664 if (mask & GL_COLOR_BUFFER_BIT) {
1665 MEMCPY( &dst->Color, &src->Color, sizeof(struct gl_colorbuffer_attrib) );
1666 }
1667 if (mask & GL_CURRENT_BIT) {
1668 MEMCPY( &dst->Current, &src->Current, sizeof(struct gl_current_attrib) );
1669 }
1670 if (mask & GL_DEPTH_BUFFER_BIT) {
1671 MEMCPY( &dst->Depth, &src->Depth, sizeof(struct gl_depthbuffer_attrib) );
1672 }
1673 if (mask & GL_ENABLE_BIT) {
1674 /* no op */
1675 }
1676 if (mask & GL_EVAL_BIT) {
1677 MEMCPY( &dst->Eval, &src->Eval, sizeof(struct gl_eval_attrib) );
1678 }
1679 if (mask & GL_FOG_BIT) {
1680 MEMCPY( &dst->Fog, &src->Fog, sizeof(struct gl_fog_attrib) );
1681 }
1682 if (mask & GL_HINT_BIT) {
1683 MEMCPY( &dst->Hint, &src->Hint, sizeof(struct gl_hint_attrib) );
1684 }
1685 if (mask & GL_LIGHTING_BIT) {
1686 MEMCPY( &dst->Light, &src->Light, sizeof(struct gl_light_attrib) );
Brian Paul00037781999-12-17 14:52:35 +00001687 /* gl_reinit_light_attrib( &dst->Light ); */
jtgafb833d1999-08-19 00:55:39 +00001688 }
1689 if (mask & GL_LINE_BIT) {
1690 MEMCPY( &dst->Line, &src->Line, sizeof(struct gl_line_attrib) );
1691 }
1692 if (mask & GL_LIST_BIT) {
1693 MEMCPY( &dst->List, &src->List, sizeof(struct gl_list_attrib) );
1694 }
1695 if (mask & GL_PIXEL_MODE_BIT) {
1696 MEMCPY( &dst->Pixel, &src->Pixel, sizeof(struct gl_pixel_attrib) );
1697 }
1698 if (mask & GL_POINT_BIT) {
1699 MEMCPY( &dst->Point, &src->Point, sizeof(struct gl_point_attrib) );
1700 }
1701 if (mask & GL_POLYGON_BIT) {
1702 MEMCPY( &dst->Polygon, &src->Polygon, sizeof(struct gl_polygon_attrib) );
1703 }
1704 if (mask & GL_POLYGON_STIPPLE_BIT) {
1705 /* Use loop instead of MEMCPY due to problem with Portland Group's
1706 * C compiler. Reported by John Stone.
1707 */
1708 int i;
1709 for (i=0;i<32;i++) {
1710 dst->PolygonStipple[i] = src->PolygonStipple[i];
1711 }
1712 }
1713 if (mask & GL_SCISSOR_BIT) {
1714 MEMCPY( &dst->Scissor, &src->Scissor, sizeof(struct gl_scissor_attrib) );
1715 }
1716 if (mask & GL_STENCIL_BUFFER_BIT) {
1717 MEMCPY( &dst->Stencil, &src->Stencil, sizeof(struct gl_stencil_attrib) );
1718 }
1719 if (mask & GL_TEXTURE_BIT) {
1720 MEMCPY( &dst->Texture, &src->Texture, sizeof(struct gl_texture_attrib) );
1721 }
1722 if (mask & GL_TRANSFORM_BIT) {
1723 MEMCPY( &dst->Transform, &src->Transform, sizeof(struct gl_transform_attrib) );
1724 }
1725 if (mask & GL_VIEWPORT_BIT) {
1726 MEMCPY( &dst->Viewport, &src->Viewport, sizeof(struct gl_viewport_attrib) );
1727 }
Keith Whitwella96308c2000-10-30 13:31:59 +00001728 /* XXX FIXME: Call callbacks?
1729 */
1730 dst->NewState = _NEW_ALL;
jtgafb833d1999-08-19 00:55:39 +00001731}
1732
1733
jtgafb833d1999-08-19 00:55:39 +00001734/*
Brian Paul00037781999-12-17 14:52:35 +00001735 * Set the current context, binding the given frame buffer to the context.
1736 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001737void
1738_mesa_make_current( GLcontext *newCtx, GLframebuffer *buffer )
Brian Paul00037781999-12-17 14:52:35 +00001739{
Brian Paulb1394fa2000-09-26 20:53:53 +00001740 _mesa_make_current2( newCtx, buffer, buffer );
Brian Paul00037781999-12-17 14:52:35 +00001741}
1742
1743
Keith Whitwell23caf202000-11-16 21:05:34 +00001744static void print_info( void )
1745{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001746 fprintf(stderr, "Mesa GL_VERSION = %s\n",
Keith Whitwell23caf202000-11-16 21:05:34 +00001747 (char *) _mesa_GetString(GL_VERSION));
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001748 fprintf(stderr, "Mesa GL_RENDERER = %s\n",
Keith Whitwell23caf202000-11-16 21:05:34 +00001749 (char *) _mesa_GetString(GL_RENDERER));
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001750 fprintf(stderr, "Mesa GL_VENDOR = %s\n",
Keith Whitwell23caf202000-11-16 21:05:34 +00001751 (char *) _mesa_GetString(GL_VENDOR));
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001752 fprintf(stderr, "Mesa GL_EXTENSIONS = %s\n",
Keith Whitwell23caf202000-11-16 21:05:34 +00001753 (char *) _mesa_GetString(GL_EXTENSIONS));
1754#if defined(THREADS)
1755 fprintf(stderr, "Mesa thread-safe: YES\n");
1756#else
1757 fprintf(stderr, "Mesa thread-safe: NO\n");
1758#endif
1759#if defined(USE_X86_ASM)
1760 fprintf(stderr, "Mesa x86-optimized: YES\n");
1761#else
1762 fprintf(stderr, "Mesa x86-optimized: NO\n");
1763#endif
1764}
1765
1766
Brian Paul00037781999-12-17 14:52:35 +00001767/*
1768 * Bind the given context to the given draw-buffer and read-buffer
1769 * and make it the current context for this thread.
1770 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001771void
1772_mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
1773 GLframebuffer *readBuffer )
Brian Paul00037781999-12-17 14:52:35 +00001774{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001775 if (MESA_VERBOSE)
Keith Whitwell23caf202000-11-16 21:05:34 +00001776 fprintf(stderr, "_mesa_make_current2()\n");
Brian Paul00037781999-12-17 14:52:35 +00001777
1778 /* We call this function periodically (just here for now) in
1779 * order to detect when multithreading has begun.
1780 */
1781 _glapi_check_multithread();
1782
Brian Paulf9b97d92000-01-28 20:17:42 +00001783 _glapi_set_context((void *) newCtx);
Brian Paulb1394fa2000-09-26 20:53:53 +00001784 ASSERT(_mesa_get_current_context() == newCtx);
Keith Whitwell23caf202000-11-16 21:05:34 +00001785
1786
1787 if (!newCtx) {
Brian Paul00037781999-12-17 14:52:35 +00001788 _glapi_set_dispatch(NULL); /* none current */
1789 }
Keith Whitwell23caf202000-11-16 21:05:34 +00001790 else {
1791 _glapi_set_dispatch(newCtx->CurrentDispatch);
Brian Paul00037781999-12-17 14:52:35 +00001792
Keith Whitwell23caf202000-11-16 21:05:34 +00001793 if (drawBuffer && readBuffer) {
1794 /* TODO: check if newCtx and buffer's visual match??? */
1795 newCtx->DrawBuffer = drawBuffer;
1796 newCtx->ReadBuffer = readBuffer;
1797 newCtx->NewState |= _NEW_BUFFERS;
1798 /* gl_update_state( newCtx ); */
Brian Paul00037781999-12-17 14:52:35 +00001799 }
Keith Whitwell23caf202000-11-16 21:05:34 +00001800
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001801 if (newCtx->Driver.MakeCurrent)
Keith Whitwell23caf202000-11-16 21:05:34 +00001802 newCtx->Driver.MakeCurrent( newCtx, drawBuffer, readBuffer );
1803
1804 /* We can use this to help debug user's problems. Tell them to set
1805 * the MESA_INFO env variable before running their app. Then the
1806 * first time each context is made current we'll print some useful
1807 * information.
1808 */
1809 if (newCtx->FirstTimeCurrent) {
1810 if (getenv("MESA_INFO")) {
1811 print_info();
1812 }
1813 newCtx->FirstTimeCurrent = GL_FALSE;
1814 }
Brian Paul00037781999-12-17 14:52:35 +00001815 }
1816}
1817
1818
1819
1820/*
1821 * Return current context handle for the calling thread.
1822 * This isn't the fastest way to get the current context.
1823 * If you need speed, see the GET_CURRENT_CONTEXT() macro in context.h
1824 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001825GLcontext *
1826_mesa_get_current_context( void )
Brian Paul00037781999-12-17 14:52:35 +00001827{
Brian Paulf9b97d92000-01-28 20:17:42 +00001828 return (GLcontext *) _glapi_get_context();
Brian Paul00037781999-12-17 14:52:35 +00001829}
1830
1831
1832
1833/*
Brian Paulfbd8f211999-11-11 01:22:25 +00001834 * This should be called by device drivers just before they do a
1835 * swapbuffers. Any pending rendering commands will be executed.
jtgafb833d1999-08-19 00:55:39 +00001836 */
Brian Paulfbd8f211999-11-11 01:22:25 +00001837void
1838_mesa_swapbuffers(GLcontext *ctx)
jtgafb833d1999-08-19 00:55:39 +00001839{
Keith Whitwellcab974c2000-12-26 05:09:27 +00001840 FLUSH_VERTICES( ctx, 0 );
jtgafb833d1999-08-19 00:55:39 +00001841}
1842
1843
Brian Paul00037781999-12-17 14:52:35 +00001844
Brian Paulfbd8f211999-11-11 01:22:25 +00001845/*
1846 * Return pointer to this context's current API dispatch table.
1847 * It'll either be the immediate-mode execute dispatcher or the
1848 * display list compile dispatcher.
1849 */
1850struct _glapi_table *
1851_mesa_get_dispatch(GLcontext *ctx)
1852{
1853 return ctx->CurrentDispatch;
1854}
1855
1856
1857
jtgafb833d1999-08-19 00:55:39 +00001858/**********************************************************************/
1859/***** Miscellaneous functions *****/
1860/**********************************************************************/
1861
1862
1863/*
1864 * This function is called when the Mesa user has stumbled into a code
1865 * path which may not be implemented fully or correctly.
1866 */
1867void gl_problem( const GLcontext *ctx, const char *s )
1868{
1869 fprintf( stderr, "Mesa implementation error: %s\n", s );
Brian Paul413d6a22000-05-26 14:44:59 +00001870 fprintf( stderr, "Report to Mesa bug database at www.mesa3d.org\n" );
jtgafb833d1999-08-19 00:55:39 +00001871 (void) ctx;
1872}
1873
1874
1875
1876/*
1877 * This is called to inform the user that he or she has tried to do
1878 * something illogical or if there's likely a bug in their program
1879 * (like enabled depth testing without a depth buffer).
1880 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001881void
1882_mesa_warning( const GLcontext *ctx, const char *s )
jtgafb833d1999-08-19 00:55:39 +00001883{
Brian Paulb1394fa2000-09-26 20:53:53 +00001884 (*ctx->imports.warning)((__GLcontext *) ctx, (char *) s);
jtgafb833d1999-08-19 00:55:39 +00001885}
1886
1887
1888
Brian Paulfa9df402000-02-02 19:16:46 +00001889/*
1890 * Compile an error into current display list.
1891 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001892void
1893_mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
jtgafb833d1999-08-19 00:55:39 +00001894{
1895 if (ctx->CompileFlag)
1896 gl_save_error( ctx, error, s );
1897
1898 if (ctx->ExecuteFlag)
1899 gl_error( ctx, error, s );
1900}
1901
1902
Brian Paulfa9df402000-02-02 19:16:46 +00001903
jtgafb833d1999-08-19 00:55:39 +00001904/*
1905 * This is Mesa's error handler. Normally, all that's done is the updating
1906 * of the current error value. If Mesa is compiled with -DDEBUG or if the
1907 * environment variable "MESA_DEBUG" is defined then a real error message
1908 * is printed to stderr.
Brian Paul7eb06032000-07-14 04:13:40 +00001909 * Input: ctx - the GL context
1910 * error - the error value
1911 * where - usually the name of function where error was detected
jtgafb833d1999-08-19 00:55:39 +00001912 */
Brian Paul7eb06032000-07-14 04:13:40 +00001913void
1914gl_error( GLcontext *ctx, GLenum error, const char *where )
jtgafb833d1999-08-19 00:55:39 +00001915{
Brian Paul7eb06032000-07-14 04:13:40 +00001916 const char *debugEnv = getenv("MESA_DEBUG");
jtgafb833d1999-08-19 00:55:39 +00001917 GLboolean debug;
1918
1919#ifdef DEBUG
Brian Paul7eb06032000-07-14 04:13:40 +00001920 if (debugEnv && strstr(debugEnv, "silent"))
jtgafb833d1999-08-19 00:55:39 +00001921 debug = GL_FALSE;
Brian Paul7eb06032000-07-14 04:13:40 +00001922 else
1923 debug = GL_TRUE;
1924#else
1925 if (debugEnv)
1926 debug = GL_TRUE;
1927 else
1928 debug = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001929#endif
1930
1931 if (debug) {
Brian Paul7eb06032000-07-14 04:13:40 +00001932 const char *errstr;
jtgafb833d1999-08-19 00:55:39 +00001933 switch (error) {
1934 case GL_NO_ERROR:
Brian Paul7eb06032000-07-14 04:13:40 +00001935 errstr = "GL_NO_ERROR";
jtgafb833d1999-08-19 00:55:39 +00001936 break;
1937 case GL_INVALID_VALUE:
Brian Paul7eb06032000-07-14 04:13:40 +00001938 errstr = "GL_INVALID_VALUE";
jtgafb833d1999-08-19 00:55:39 +00001939 break;
1940 case GL_INVALID_ENUM:
Brian Paul7eb06032000-07-14 04:13:40 +00001941 errstr = "GL_INVALID_ENUM";
jtgafb833d1999-08-19 00:55:39 +00001942 break;
1943 case GL_INVALID_OPERATION:
Brian Paul7eb06032000-07-14 04:13:40 +00001944 errstr = "GL_INVALID_OPERATION";
jtgafb833d1999-08-19 00:55:39 +00001945 break;
1946 case GL_STACK_OVERFLOW:
Brian Paul7eb06032000-07-14 04:13:40 +00001947 errstr = "GL_STACK_OVERFLOW";
jtgafb833d1999-08-19 00:55:39 +00001948 break;
1949 case GL_STACK_UNDERFLOW:
Brian Paul7eb06032000-07-14 04:13:40 +00001950 errstr = "GL_STACK_UNDERFLOW";
jtgafb833d1999-08-19 00:55:39 +00001951 break;
1952 case GL_OUT_OF_MEMORY:
Brian Paul7eb06032000-07-14 04:13:40 +00001953 errstr = "GL_OUT_OF_MEMORY";
jtgafb833d1999-08-19 00:55:39 +00001954 break;
Brian Paul86586aa2000-06-29 18:55:52 +00001955 case GL_TABLE_TOO_LARGE:
Brian Paul7eb06032000-07-14 04:13:40 +00001956 errstr = "GL_TABLE_TOO_LARGE";
Brian Paul86586aa2000-06-29 18:55:52 +00001957 break;
jtgafb833d1999-08-19 00:55:39 +00001958 default:
Brian Paul7eb06032000-07-14 04:13:40 +00001959 errstr = "unknown";
jtgafb833d1999-08-19 00:55:39 +00001960 break;
1961 }
Brian Paul7eb06032000-07-14 04:13:40 +00001962 fprintf(stderr, "Mesa user error: %s in %s\n", errstr, where);
jtgafb833d1999-08-19 00:55:39 +00001963 }
1964
Brian Paul7eb06032000-07-14 04:13:40 +00001965 if (ctx->ErrorValue == GL_NO_ERROR) {
jtgafb833d1999-08-19 00:55:39 +00001966 ctx->ErrorValue = error;
1967 }
1968
1969 /* Call device driver's error handler, if any. This is used on the Mac. */
1970 if (ctx->Driver.Error) {
1971 (*ctx->Driver.Error)( ctx );
1972 }
1973}
1974
1975
1976
Brian Paulfa9df402000-02-02 19:16:46 +00001977void
1978_mesa_Finish( void )
jtgafb833d1999-08-19 00:55:39 +00001979{
Brian Paulfa9df402000-02-02 19:16:46 +00001980 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +00001981 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Brian Paulfa9df402000-02-02 19:16:46 +00001982 if (ctx->Driver.Finish) {
1983 (*ctx->Driver.Finish)( ctx );
jtgafb833d1999-08-19 00:55:39 +00001984 }
1985}
1986
1987
1988
Brian Paulfa9df402000-02-02 19:16:46 +00001989void
1990_mesa_Flush( void )
jtgafb833d1999-08-19 00:55:39 +00001991{
Brian Paulfa9df402000-02-02 19:16:46 +00001992 GET_CURRENT_CONTEXT(ctx);
Keith Whitwellcab974c2000-12-26 05:09:27 +00001993 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
Brian Paulfa9df402000-02-02 19:16:46 +00001994 if (ctx->Driver.Flush) {
1995 (*ctx->Driver.Flush)( ctx );
jtgafb833d1999-08-19 00:55:39 +00001996 }
jtgafb833d1999-08-19 00:55:39 +00001997}
Brian Paul48c6a6e2000-09-08 21:28:04 +00001998
1999
2000
Keith Whitwellcab974c2000-12-26 05:09:27 +00002001const char *_mesa_prim_name[GL_POLYGON+4] = {
Brian Paul48c6a6e2000-09-08 21:28:04 +00002002 "GL_POINTS",
2003 "GL_LINES",
2004 "GL_LINE_LOOP",
2005 "GL_LINE_STRIP",
2006 "GL_TRIANGLES",
2007 "GL_TRIANGLE_STRIP",
2008 "GL_TRIANGLE_FAN",
2009 "GL_QUADS",
2010 "GL_QUAD_STRIP",
2011 "GL_POLYGON",
Keith Whitwellcab974c2000-12-26 05:09:27 +00002012 "outside begin/end",
2013 "inside unkown primitive",
2014 "unknown state"
Brian Paul48c6a6e2000-09-08 21:28:04 +00002015};
2016
Brian Paul1c56fdc2000-09-17 21:56:07 +00002017
2018GLenum gl_reduce_prim[GL_POLYGON+1] = {
2019 GL_POINTS,
2020 GL_LINES,
2021 GL_LINES,
2022 GL_LINES,
2023 GL_TRIANGLES,
2024 GL_TRIANGLES,
2025 GL_TRIANGLES,
2026 GL_TRIANGLES,
2027 GL_TRIANGLES,
2028 GL_TRIANGLES,
Gareth Hughesfc2427e2000-10-23 00:16:28 +00002029};