blob: 2d5b6569cd1105b2f024bb30fc1a94e81b0940b9 [file] [log] [blame]
Brian Paul9da422c2000-12-16 00:21:28 +00001/* $Id: context.c,v 1.113 2000/12/16 00:21:28 brianp 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"
62#include "math/math.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 */
80/* | VERBOSE_CULL */
81/* | VERBOSE_DISPLAY_LIST */
82;
83#endif
84
85#ifndef MESA_DEBUG_FLAGS
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000086int MESA_DEBUG_FLAGS = 0
Keith Whitwell23caf202000-11-16 21:05:34 +000087/* | DEBUG_ALWAYS_FLUSH */
88;
89#endif
Brian Paulb1394fa2000-09-26 20:53:53 +000090
91/**********************************************************************/
92/***** OpenGL SI-style interface (new in Mesa 3.5) *****/
93/**********************************************************************/
94
95static GLboolean
96_mesa_DestroyContext(__GLcontext *gc)
97{
98 if (gc) {
99 _mesa_free_context_data(gc);
100 (*gc->imports.free)(gc, gc);
101 }
102 return GL_TRUE;
103}
104
105
106/* exported OpenGL SI interface */
107__GLcontext *
108__glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes)
109{
110 GLcontext *ctx;
111
112 ctx = (GLcontext *) (*imports->calloc)(0, 1, sizeof(GLcontext));
113 if (ctx == NULL) {
114 return NULL;
115 }
116 ctx->imports = *imports;
117
118 _mesa_initialize_visual(&ctx->Visual,
119 modes->rgbMode,
120 modes->doubleBufferMode,
121 modes->stereoMode,
122 modes->redBits,
123 modes->greenBits,
124 modes->blueBits,
125 modes->alphaBits,
126 modes->indexBits,
127 modes->depthBits,
128 modes->stencilBits,
129 modes->accumRedBits,
130 modes->accumGreenBits,
131 modes->accumBlueBits,
132 modes->accumAlphaBits,
133 0);
134
135 _mesa_initialize_context(ctx, &ctx->Visual, NULL, imports->wscx, GL_FALSE);
136
137 ctx->exports.destroyContext = _mesa_DestroyContext;
138
139 return ctx;
140}
141
142
143/* exported OpenGL SI interface */
144void
145__glCoreNopDispatch(void)
146{
147#if 0
148 /* SI */
149 __gl_dispatch = __glNopDispatchState;
150#else
151 /* Mesa */
152 _glapi_set_dispatch(NULL);
153#endif
154}
155
156
jtgafb833d1999-08-19 00:55:39 +0000157/**********************************************************************/
158/***** Context and Thread management *****/
159/**********************************************************************/
160
161
jtgafb833d1999-08-19 00:55:39 +0000162
jtgafb833d1999-08-19 00:55:39 +0000163/**********************************************************************/
Brian Paul4d053dd2000-01-14 04:45:47 +0000164/***** GL Visual allocation/destruction *****/
165/**********************************************************************/
166
167
168/*
169 * Allocate a new GLvisual object.
170 * Input: rgbFlag - GL_TRUE=RGB(A) mode, GL_FALSE=Color Index mode
Brian Paul4d053dd2000-01-14 04:45:47 +0000171 * dbFlag - double buffering?
172 * stereoFlag - stereo buffer?
Brian Pauled30dfa2000-03-03 17:47:39 +0000173 * depthBits - requested bits per depth buffer value
174 * Any value in [0, 32] is acceptable but the actual
175 * depth type will be GLushort or GLuint as needed.
176 * stencilBits - requested minimum bits per stencil buffer value
177 * accumBits - requested minimum bits per accum buffer component
178 * indexBits - number of bits per pixel if rgbFlag==GL_FALSE
179 * red/green/blue/alphaBits - number of bits per color component
180 * in frame buffer for RGB(A) mode.
181 * We always use 8 in core Mesa though.
Brian Paul4d053dd2000-01-14 04:45:47 +0000182 * Return: pointer to new GLvisual or NULL if requested parameters can't
183 * be met.
184 */
Brian Paulb371e0d2000-03-31 01:05:51 +0000185GLvisual *
186_mesa_create_visual( GLboolean rgbFlag,
Brian Paulb371e0d2000-03-31 01:05:51 +0000187 GLboolean dbFlag,
188 GLboolean stereoFlag,
189 GLint redBits,
190 GLint greenBits,
191 GLint blueBits,
192 GLint alphaBits,
193 GLint indexBits,
194 GLint depthBits,
195 GLint stencilBits,
196 GLint accumRedBits,
197 GLint accumGreenBits,
198 GLint accumBlueBits,
199 GLint accumAlphaBits,
200 GLint numSamples )
Brian Paul4d053dd2000-01-14 04:45:47 +0000201{
Brian Paul178a1c52000-04-22 01:05:00 +0000202 GLvisual *vis = (GLvisual *) CALLOC( sizeof(GLvisual) );
203 if (vis) {
Brian Paule70c6232000-05-04 13:53:55 +0000204 if (!_mesa_initialize_visual(vis, rgbFlag, dbFlag, stereoFlag,
Brian Paul178a1c52000-04-22 01:05:00 +0000205 redBits, greenBits, blueBits, alphaBits,
206 indexBits, depthBits, stencilBits,
207 accumRedBits, accumGreenBits,
208 accumBlueBits, accumAlphaBits,
Brian Paulb1394fa2000-09-26 20:53:53 +0000209 numSamples)) {
Brian Paul178a1c52000-04-22 01:05:00 +0000210 FREE(vis);
211 return NULL;
212 }
213 }
214 return vis;
215}
216
217
218/*
219 * Initialize the fields of the given GLvisual.
220 * Input: see _mesa_create_visual() above.
221 * Return: GL_TRUE = success
222 * GL_FALSE = failure.
223 */
224GLboolean
225_mesa_initialize_visual( GLvisual *vis,
226 GLboolean rgbFlag,
Brian Paul178a1c52000-04-22 01:05:00 +0000227 GLboolean dbFlag,
228 GLboolean stereoFlag,
229 GLint redBits,
230 GLint greenBits,
231 GLint blueBits,
232 GLint alphaBits,
233 GLint indexBits,
234 GLint depthBits,
235 GLint stencilBits,
236 GLint accumRedBits,
237 GLint accumGreenBits,
238 GLint accumBlueBits,
239 GLint accumAlphaBits,
240 GLint numSamples )
241{
242 assert(vis);
Brian Paul4d053dd2000-01-14 04:45:47 +0000243
Brian Pauled30dfa2000-03-03 17:47:39 +0000244 /* This is to catch bad values from device drivers not updated for
245 * Mesa 3.3. Some device drivers just passed 1. That's a REALLY
246 * bad value now (a 1-bit depth buffer!?!).
247 */
248 assert(depthBits == 0 || depthBits > 1);
249
250 if (depthBits < 0 || depthBits > 32) {
Brian Paul178a1c52000-04-22 01:05:00 +0000251 return GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000252 }
Brian Pauled30dfa2000-03-03 17:47:39 +0000253 if (stencilBits < 0 || stencilBits > (GLint) (8 * sizeof(GLstencil))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000254 return GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000255 }
Brian Paulb371e0d2000-03-31 01:05:51 +0000256 if (accumRedBits < 0 || accumRedBits > (GLint) (8 * sizeof(GLaccum))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000257 return GL_FALSE;
Brian Paulb371e0d2000-03-31 01:05:51 +0000258 }
259 if (accumGreenBits < 0 || accumGreenBits > (GLint) (8 * sizeof(GLaccum))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000260 return GL_FALSE;
Brian Paulb371e0d2000-03-31 01:05:51 +0000261 }
262 if (accumBlueBits < 0 || accumBlueBits > (GLint) (8 * sizeof(GLaccum))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000263 return GL_FALSE;
Brian Paulb371e0d2000-03-31 01:05:51 +0000264 }
265 if (accumAlphaBits < 0 || accumAlphaBits > (GLint) (8 * sizeof(GLaccum))) {
Brian Paul178a1c52000-04-22 01:05:00 +0000266 return GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000267 }
268
269 vis->RGBAflag = rgbFlag;
270 vis->DBflag = dbFlag;
271 vis->StereoFlag = stereoFlag;
272 vis->RedBits = redBits;
273 vis->GreenBits = greenBits;
274 vis->BlueBits = blueBits;
Brian Paule70c6232000-05-04 13:53:55 +0000275 vis->AlphaBits = alphaBits;
Brian Paul4d053dd2000-01-14 04:45:47 +0000276
Brian Paulb371e0d2000-03-31 01:05:51 +0000277 vis->IndexBits = indexBits;
278 vis->DepthBits = depthBits;
279 vis->AccumRedBits = (accumRedBits > 0) ? (8 * sizeof(GLaccum)) : 0;
280 vis->AccumGreenBits = (accumGreenBits > 0) ? (8 * sizeof(GLaccum)) : 0;
281 vis->AccumBlueBits = (accumBlueBits > 0) ? (8 * sizeof(GLaccum)) : 0;
282 vis->AccumAlphaBits = (accumAlphaBits > 0) ? (8 * sizeof(GLaccum)) : 0;
283 vis->StencilBits = (stencilBits > 0) ? (8 * sizeof(GLstencil)) : 0;
Brian Paul4d053dd2000-01-14 04:45:47 +0000284
Brian Pauled30dfa2000-03-03 17:47:39 +0000285 if (depthBits == 0) {
286 /* Special case. Even if we don't have a depth buffer we need
Brian Paul35324a62000-10-09 22:42:40 +0000287 * good values for DepthMax for Z vertex transformation purposes
288 * and for per-fragment fog computation.
Brian Pauled30dfa2000-03-03 17:47:39 +0000289 */
Brian Paul35324a62000-10-09 22:42:40 +0000290 vis->DepthMax = 1 << 16;
291 vis->DepthMaxF = (GLfloat) vis->DepthMax;
Brian Pauled30dfa2000-03-03 17:47:39 +0000292 }
Brian Paul3a94f5c2000-05-18 18:12:36 +0000293 else if (depthBits < 32) {
Brian Pauled30dfa2000-03-03 17:47:39 +0000294 vis->DepthMax = (1 << depthBits) - 1;
295 vis->DepthMaxF = (GLfloat) vis->DepthMax;
296 }
Brian Paul3a94f5c2000-05-18 18:12:36 +0000297 else {
298 /* Special case since shift values greater than or equal to the
299 * number of bits in the left hand expression's type are
300 * undefined.
301 */
302 vis->DepthMax = 0xffffffff;
303 vis->DepthMaxF = (GLfloat) vis->DepthMax;
304 }
Brian Paul9da422c2000-12-16 00:21:28 +0000305 vis->MRD = 2.0; /* XXX temporary value */
Brian Pauled30dfa2000-03-03 17:47:39 +0000306
Brian Paul178a1c52000-04-22 01:05:00 +0000307 return GL_TRUE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000308}
309
310
Brian Paulb371e0d2000-03-31 01:05:51 +0000311void
312_mesa_destroy_visual( GLvisual *vis )
313{
314 FREE(vis);
315}
316
317
Brian Paul4d053dd2000-01-14 04:45:47 +0000318/**********************************************************************/
319/***** GL Framebuffer allocation/destruction *****/
320/**********************************************************************/
321
322
323/*
324 * Create a new framebuffer. A GLframebuffer is a struct which
325 * encapsulates the depth, stencil and accum buffers and related
326 * parameters.
327 * Input: visual - a GLvisual pointer
328 * softwareDepth - create/use a software depth buffer?
329 * softwareStencil - create/use a software stencil buffer?
330 * softwareAccum - create/use a software accum buffer?
331 * softwareAlpha - create/use a software alpha buffer?
332
333 * Return: pointer to new GLframebuffer struct or NULL if error.
334 */
Brian Paul178a1c52000-04-22 01:05:00 +0000335GLframebuffer *
Brian Paulb1394fa2000-09-26 20:53:53 +0000336_mesa_create_framebuffer( GLvisual *visual,
337 GLboolean softwareDepth,
338 GLboolean softwareStencil,
339 GLboolean softwareAccum,
340 GLboolean softwareAlpha )
Brian Paul4d053dd2000-01-14 04:45:47 +0000341{
Brian Paul178a1c52000-04-22 01:05:00 +0000342 GLframebuffer *buffer = CALLOC_STRUCT(gl_frame_buffer);
343 assert(visual);
344 if (buffer) {
345 _mesa_initialize_framebuffer(buffer, visual,
346 softwareDepth, softwareStencil,
347 softwareAccum, softwareAlpha );
Brian Paul4d053dd2000-01-14 04:45:47 +0000348 }
Brian Paul178a1c52000-04-22 01:05:00 +0000349 return buffer;
350}
351
352
353/*
354 * Initialize a GLframebuffer object.
Brian Paulb1394fa2000-09-26 20:53:53 +0000355 * Input: See _mesa_create_framebuffer() above.
Brian Paul178a1c52000-04-22 01:05:00 +0000356 */
357void
358_mesa_initialize_framebuffer( GLframebuffer *buffer,
359 GLvisual *visual,
360 GLboolean softwareDepth,
361 GLboolean softwareStencil,
362 GLboolean softwareAccum,
363 GLboolean softwareAlpha )
364{
365 assert(buffer);
366 assert(visual);
Brian Paul4d053dd2000-01-14 04:45:47 +0000367
368 /* sanity checks */
369 if (softwareDepth ) {
370 assert(visual->DepthBits > 0);
371 }
372 if (softwareStencil) {
373 assert(visual->StencilBits > 0);
374 }
375 if (softwareAccum) {
376 assert(visual->RGBAflag);
Brian Paulb371e0d2000-03-31 01:05:51 +0000377 assert(visual->AccumRedBits > 0);
378 assert(visual->AccumGreenBits > 0);
379 assert(visual->AccumBlueBits > 0);
Brian Paul4d053dd2000-01-14 04:45:47 +0000380 }
381 if (softwareAlpha) {
382 assert(visual->RGBAflag);
383 assert(visual->AlphaBits > 0);
384 }
385
386 buffer->Visual = visual;
387 buffer->UseSoftwareDepthBuffer = softwareDepth;
388 buffer->UseSoftwareStencilBuffer = softwareStencil;
389 buffer->UseSoftwareAccumBuffer = softwareAccum;
390 buffer->UseSoftwareAlphaBuffers = softwareAlpha;
Brian Paul4d053dd2000-01-14 04:45:47 +0000391}
392
393
Brian Paul4d053dd2000-01-14 04:45:47 +0000394/*
395 * Free a framebuffer struct and its buffers.
396 */
Brian Paul178a1c52000-04-22 01:05:00 +0000397void
Brian Paulb1394fa2000-09-26 20:53:53 +0000398_mesa_destroy_framebuffer( GLframebuffer *buffer )
Brian Paul4d053dd2000-01-14 04:45:47 +0000399{
400 if (buffer) {
Brian Paul650cb742000-03-17 15:31:52 +0000401 if (buffer->DepthBuffer) {
402 FREE( buffer->DepthBuffer );
Brian Paul4d053dd2000-01-14 04:45:47 +0000403 }
404 if (buffer->Accum) {
405 FREE( buffer->Accum );
406 }
407 if (buffer->Stencil) {
408 FREE( buffer->Stencil );
409 }
410 if (buffer->FrontLeftAlpha) {
411 FREE( buffer->FrontLeftAlpha );
412 }
413 if (buffer->BackLeftAlpha) {
414 FREE( buffer->BackLeftAlpha );
415 }
416 if (buffer->FrontRightAlpha) {
417 FREE( buffer->FrontRightAlpha );
418 }
419 if (buffer->BackRightAlpha) {
420 FREE( buffer->BackRightAlpha );
421 }
422 FREE(buffer);
423 }
424}
425
426
427
428/**********************************************************************/
jtgafb833d1999-08-19 00:55:39 +0000429/***** Context allocation, initialization, destroying *****/
430/**********************************************************************/
431
432
Brian Paul9560f052000-01-31 23:11:39 +0000433_glthread_DECLARE_STATIC_MUTEX(OneTimeLock);
434
435
jtgafb833d1999-08-19 00:55:39 +0000436/*
437 * This function just calls all the various one-time-init functions in Mesa.
438 */
Brian Paul178a1c52000-04-22 01:05:00 +0000439static void
440one_time_init( void )
jtgafb833d1999-08-19 00:55:39 +0000441{
442 static GLboolean alreadyCalled = GL_FALSE;
Brian Paul9560f052000-01-31 23:11:39 +0000443 _glthread_LOCK_MUTEX(OneTimeLock);
jtgafb833d1999-08-19 00:55:39 +0000444 if (!alreadyCalled) {
Brian Paul4d053dd2000-01-14 04:45:47 +0000445 /* do some implementation tests */
446 assert( sizeof(GLbyte) == 1 );
447 assert( sizeof(GLshort) >= 2 );
448 assert( sizeof(GLint) >= 4 );
449 assert( sizeof(GLubyte) == 1 );
450 assert( sizeof(GLushort) >= 2 );
451 assert( sizeof(GLuint) >= 4 );
452
jtgafb833d1999-08-19 00:55:39 +0000453 gl_init_lists();
Keith Whitwell23caf202000-11-16 21:05:34 +0000454
455 _mesa_init_math();
456 _math_init();
Brian Paul68ee4bc2000-01-28 19:02:22 +0000457
458 if (getenv("MESA_DEBUG")) {
459 _glapi_noop_enable_warnings(GL_TRUE);
460 }
461 else {
462 _glapi_noop_enable_warnings(GL_FALSE);
463 }
464
jtgafb833d1999-08-19 00:55:39 +0000465#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
466 fprintf(stderr, "Mesa DEBUG build %s %s\n", __DATE__, __TIME__);
467#endif
Brian Paul68ee4bc2000-01-28 19:02:22 +0000468
469 alreadyCalled = GL_TRUE;
470 }
Brian Paul9560f052000-01-31 23:11:39 +0000471 _glthread_UNLOCK_MUTEX(OneTimeLock);
jtgafb833d1999-08-19 00:55:39 +0000472}
473
474
Brian Paul4d053dd2000-01-14 04:45:47 +0000475
jtgafb833d1999-08-19 00:55:39 +0000476/*
477 * Allocate and initialize a shared context state structure.
478 */
Brian Paul178a1c52000-04-22 01:05:00 +0000479static struct gl_shared_state *
480alloc_shared_state( void )
jtgafb833d1999-08-19 00:55:39 +0000481{
jtgafb833d1999-08-19 00:55:39 +0000482 struct gl_shared_state *ss;
483 GLboolean outOfMemory;
484
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000485 ss = CALLOC_STRUCT(gl_shared_state);
jtgafb833d1999-08-19 00:55:39 +0000486 if (!ss)
487 return NULL;
488
Brian Paule4b684c2000-09-12 21:07:40 +0000489 _glthread_INIT_MUTEX(ss->Mutex);
jtgafb833d1999-08-19 00:55:39 +0000490
Brian Paule4b684c2000-09-12 21:07:40 +0000491 ss->DisplayList = _mesa_NewHashTable();
Brian Paulbb797902000-01-24 16:19:54 +0000492 ss->TexObjects = _mesa_NewHashTable();
jtgafb833d1999-08-19 00:55:39 +0000493
494 /* Default Texture objects */
495 outOfMemory = GL_FALSE;
Brian Paula8523782000-11-19 23:10:25 +0000496
497 ss->Default1D = _mesa_alloc_texture_object(ss, 0, 1);
498 if (!ss->Default1D) {
499 outOfMemory = GL_TRUE;
500 }
501 else {
502 ss->Default1D->RefCount++;
jtgafb833d1999-08-19 00:55:39 +0000503 }
504
Brian Paula8523782000-11-19 23:10:25 +0000505 ss->Default2D = _mesa_alloc_texture_object(ss, 0, 2);
506 if (!ss->Default2D) {
507 outOfMemory = GL_TRUE;
508 }
509 else {
510 ss->Default2D->RefCount++;
511 }
512
513 ss->Default3D = _mesa_alloc_texture_object(ss, 0, 3);
514 if (!ss->Default3D) {
515 outOfMemory = GL_TRUE;
516 }
517 else {
518 ss->Default1D->RefCount++;
519 }
520
521 ss->DefaultCubeMap = _mesa_alloc_texture_object(ss, 0, 6);
Brian Paul413d6a22000-05-26 14:44:59 +0000522 if (!ss->DefaultCubeMap) {
523 outOfMemory = GL_TRUE;
524 }
525 else {
526 ss->DefaultCubeMap->RefCount++;
527 }
528
jtgafb833d1999-08-19 00:55:39 +0000529 if (!ss->DisplayList || !ss->TexObjects || outOfMemory) {
530 /* Ran out of memory at some point. Free everything and return NULL */
531 if (ss->DisplayList)
Brian Paulbb797902000-01-24 16:19:54 +0000532 _mesa_DeleteHashTable(ss->DisplayList);
jtgafb833d1999-08-19 00:55:39 +0000533 if (ss->TexObjects)
Brian Paulbb797902000-01-24 16:19:54 +0000534 _mesa_DeleteHashTable(ss->TexObjects);
Brian Paula8523782000-11-19 23:10:25 +0000535 if (ss->Default1D)
536 _mesa_free_texture_object(ss, ss->Default1D);
537 if (ss->Default2D)
538 _mesa_free_texture_object(ss, ss->Default2D);
539 if (ss->Default3D)
540 _mesa_free_texture_object(ss, ss->Default3D);
Brian Paul413d6a22000-05-26 14:44:59 +0000541 if (ss->DefaultCubeMap)
Brian Paula8523782000-11-19 23:10:25 +0000542 _mesa_free_texture_object(ss, ss->DefaultCubeMap);
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000543 FREE(ss);
jtgafb833d1999-08-19 00:55:39 +0000544 return NULL;
545 }
546 else {
547 return ss;
548 }
549}
550
551
552/*
553 * Deallocate a shared state context and all children structures.
554 */
Brian Paul178a1c52000-04-22 01:05:00 +0000555static void
556free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
jtgafb833d1999-08-19 00:55:39 +0000557{
558 /* Free display lists */
559 while (1) {
Brian Paulbb797902000-01-24 16:19:54 +0000560 GLuint list = _mesa_HashFirstEntry(ss->DisplayList);
jtgafb833d1999-08-19 00:55:39 +0000561 if (list) {
562 gl_destroy_list(ctx, list);
563 }
564 else {
565 break;
566 }
567 }
Brian Paulbb797902000-01-24 16:19:54 +0000568 _mesa_DeleteHashTable(ss->DisplayList);
jtgafb833d1999-08-19 00:55:39 +0000569
570 /* Free texture objects */
571 while (ss->TexObjectList)
572 {
573 if (ctx->Driver.DeleteTexture)
574 (*ctx->Driver.DeleteTexture)( ctx, ss->TexObjectList );
575 /* this function removes from linked list too! */
Brian Paula8523782000-11-19 23:10:25 +0000576 _mesa_free_texture_object(ss, ss->TexObjectList);
jtgafb833d1999-08-19 00:55:39 +0000577 }
Brian Paulbb797902000-01-24 16:19:54 +0000578 _mesa_DeleteHashTable(ss->TexObjects);
jtgafb833d1999-08-19 00:55:39 +0000579
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000580 FREE(ss);
jtgafb833d1999-08-19 00:55:39 +0000581}
582
583
584
jtgafb833d1999-08-19 00:55:39 +0000585/*
586 * Initialize the nth light. Note that the defaults for light 0 are
587 * different than the other lights.
588 */
Brian Paul178a1c52000-04-22 01:05:00 +0000589static void
590init_light( struct gl_light *l, GLuint n )
jtgafb833d1999-08-19 00:55:39 +0000591{
592 make_empty_list( l );
593
594 ASSIGN_4V( l->Ambient, 0.0, 0.0, 0.0, 1.0 );
595 if (n==0) {
596 ASSIGN_4V( l->Diffuse, 1.0, 1.0, 1.0, 1.0 );
597 ASSIGN_4V( l->Specular, 1.0, 1.0, 1.0, 1.0 );
598 }
599 else {
600 ASSIGN_4V( l->Diffuse, 0.0, 0.0, 0.0, 1.0 );
601 ASSIGN_4V( l->Specular, 0.0, 0.0, 0.0, 1.0 );
602 }
603 ASSIGN_4V( l->EyePosition, 0.0, 0.0, 1.0, 0.0 );
604 ASSIGN_3V( l->EyeDirection, 0.0, 0.0, -1.0 );
605 l->SpotExponent = 0.0;
606 gl_compute_spot_exp_table( l );
607 l->SpotCutoff = 180.0;
Keith Whitwell14940c42000-11-05 18:40:57 +0000608 l->_CosCutoff = 0.0; /* KW: -ve values not admitted */
jtgafb833d1999-08-19 00:55:39 +0000609 l->ConstantAttenuation = 1.0;
610 l->LinearAttenuation = 0.0;
611 l->QuadraticAttenuation = 0.0;
612 l->Enabled = GL_FALSE;
613}
614
615
616
Brian Paul178a1c52000-04-22 01:05:00 +0000617static void
618init_lightmodel( struct gl_lightmodel *lm )
jtgafb833d1999-08-19 00:55:39 +0000619{
620 ASSIGN_4V( lm->Ambient, 0.2, 0.2, 0.2, 1.0 );
621 lm->LocalViewer = GL_FALSE;
622 lm->TwoSide = GL_FALSE;
623 lm->ColorControl = GL_SINGLE_COLOR;
624}
625
626
Brian Paul178a1c52000-04-22 01:05:00 +0000627static void
628init_material( struct gl_material *m )
jtgafb833d1999-08-19 00:55:39 +0000629{
630 ASSIGN_4V( m->Ambient, 0.2, 0.2, 0.2, 1.0 );
631 ASSIGN_4V( m->Diffuse, 0.8, 0.8, 0.8, 1.0 );
632 ASSIGN_4V( m->Specular, 0.0, 0.0, 0.0, 1.0 );
633 ASSIGN_4V( m->Emission, 0.0, 0.0, 0.0, 1.0 );
634 m->Shininess = 0.0;
635 m->AmbientIndex = 0;
636 m->DiffuseIndex = 1;
637 m->SpecularIndex = 1;
638}
639
640
641
Brian Paul178a1c52000-04-22 01:05:00 +0000642static void
643init_texture_unit( GLcontext *ctx, GLuint unit )
jtgafb833d1999-08-19 00:55:39 +0000644{
645 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
646
647 texUnit->EnvMode = GL_MODULATE;
Brian Paul24507ff2000-06-27 21:42:13 +0000648 texUnit->CombineModeRGB = GL_MODULATE;
649 texUnit->CombineModeA = GL_MODULATE;
650 texUnit->CombineSourceRGB[0] = GL_TEXTURE;
651 texUnit->CombineSourceRGB[1] = GL_PREVIOUS_EXT;
652 texUnit->CombineSourceRGB[2] = GL_CONSTANT_EXT;
653 texUnit->CombineSourceA[0] = GL_TEXTURE;
654 texUnit->CombineSourceA[1] = GL_PREVIOUS_EXT;
655 texUnit->CombineSourceA[2] = GL_CONSTANT_EXT;
656 texUnit->CombineOperandRGB[0] = GL_SRC_COLOR;
657 texUnit->CombineOperandRGB[1] = GL_SRC_COLOR;
658 texUnit->CombineOperandRGB[2] = GL_SRC_ALPHA;
659 texUnit->CombineOperandA[0] = GL_SRC_ALPHA;
660 texUnit->CombineOperandA[1] = GL_SRC_ALPHA;
661 texUnit->CombineOperandA[2] = GL_SRC_ALPHA;
662 texUnit->CombineScaleShiftRGB = 0;
663 texUnit->CombineScaleShiftA = 0;
664
jtgafb833d1999-08-19 00:55:39 +0000665 ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
666 texUnit->TexGenEnabled = 0;
667 texUnit->GenModeS = GL_EYE_LINEAR;
668 texUnit->GenModeT = GL_EYE_LINEAR;
669 texUnit->GenModeR = GL_EYE_LINEAR;
670 texUnit->GenModeQ = GL_EYE_LINEAR;
Keith Whitwell14940c42000-11-05 18:40:57 +0000671 texUnit->_GenBitS = TEXGEN_EYE_LINEAR;
672 texUnit->_GenBitT = TEXGEN_EYE_LINEAR;
673 texUnit->_GenBitR = TEXGEN_EYE_LINEAR;
674 texUnit->_GenBitQ = TEXGEN_EYE_LINEAR;
Brian Paul26f3b052000-07-19 20:58:59 +0000675
jtgafb833d1999-08-19 00:55:39 +0000676 /* Yes, these plane coefficients are correct! */
677 ASSIGN_4V( texUnit->ObjectPlaneS, 1.0, 0.0, 0.0, 0.0 );
678 ASSIGN_4V( texUnit->ObjectPlaneT, 0.0, 1.0, 0.0, 0.0 );
679 ASSIGN_4V( texUnit->ObjectPlaneR, 0.0, 0.0, 0.0, 0.0 );
680 ASSIGN_4V( texUnit->ObjectPlaneQ, 0.0, 0.0, 0.0, 0.0 );
681 ASSIGN_4V( texUnit->EyePlaneS, 1.0, 0.0, 0.0, 0.0 );
682 ASSIGN_4V( texUnit->EyePlaneT, 0.0, 1.0, 0.0, 0.0 );
683 ASSIGN_4V( texUnit->EyePlaneR, 0.0, 0.0, 0.0, 0.0 );
684 ASSIGN_4V( texUnit->EyePlaneQ, 0.0, 0.0, 0.0, 0.0 );
685
Brian Paula8523782000-11-19 23:10:25 +0000686 texUnit->Current1D = ctx->Shared->Default1D;
687 texUnit->Current2D = ctx->Shared->Default2D;
688 texUnit->Current3D = ctx->Shared->Default3D;
Brian Paul413d6a22000-05-26 14:44:59 +0000689 texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
jtgafb833d1999-08-19 00:55:39 +0000690}
691
692
jtgafb833d1999-08-19 00:55:39 +0000693
Brian Paul4d053dd2000-01-14 04:45:47 +0000694
jtgafb833d1999-08-19 00:55:39 +0000695/* Initialize a 1-D evaluator map */
Brian Paul178a1c52000-04-22 01:05:00 +0000696static void
697init_1d_map( struct gl_1d_map *map, int n, const float *initial )
jtgafb833d1999-08-19 00:55:39 +0000698{
699 map->Order = 1;
700 map->u1 = 0.0;
701 map->u2 = 1.0;
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000702 map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000703 if (map->Points) {
704 GLint i;
705 for (i=0;i<n;i++)
706 map->Points[i] = initial[i];
707 }
jtgafb833d1999-08-19 00:55:39 +0000708}
709
710
711/* Initialize a 2-D evaluator map */
Brian Paul178a1c52000-04-22 01:05:00 +0000712static void
713init_2d_map( struct gl_2d_map *map, int n, const float *initial )
jtgafb833d1999-08-19 00:55:39 +0000714{
715 map->Uorder = 1;
716 map->Vorder = 1;
717 map->u1 = 0.0;
718 map->u2 = 1.0;
719 map->v1 = 0.0;
720 map->v2 = 1.0;
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000721 map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000722 if (map->Points) {
723 GLint i;
724 for (i=0;i<n;i++)
725 map->Points[i] = initial[i];
726 }
jtgafb833d1999-08-19 00:55:39 +0000727}
728
729
jtgafb833d1999-08-19 00:55:39 +0000730/*
Brian Paul4d053dd2000-01-14 04:45:47 +0000731 * Initialize the attribute groups in a GLcontext.
jtgafb833d1999-08-19 00:55:39 +0000732 */
Brian Paul178a1c52000-04-22 01:05:00 +0000733static void
734init_attrib_groups( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +0000735{
736 GLuint i, j;
737
Brian Paul4d053dd2000-01-14 04:45:47 +0000738 assert(ctx);
jtgafb833d1999-08-19 00:55:39 +0000739
Brian Paul539cce52000-02-03 19:40:07 +0000740 /* Constants, may be overriden by device drivers */
Brian Paul4d053dd2000-01-14 04:45:47 +0000741 ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
742 ctx->Const.MaxTextureSize = 1 << (MAX_TEXTURE_LEVELS - 1);
Brian Paul86fc3702000-05-22 16:33:20 +0000743 ctx->Const.MaxCubeTextureSize = ctx->Const.MaxTextureSize;
Brian Paul4d053dd2000-01-14 04:45:47 +0000744 ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS;
745 ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
Brian Paul539cce52000-02-03 19:40:07 +0000746 ctx->Const.SubPixelBits = SUB_PIXEL_BITS;
747 ctx->Const.MinPointSize = MIN_POINT_SIZE;
748 ctx->Const.MaxPointSize = MAX_POINT_SIZE;
749 ctx->Const.MinPointSizeAA = MIN_POINT_SIZE;
750 ctx->Const.MaxPointSizeAA = MAX_POINT_SIZE;
751 ctx->Const.PointSizeGranularity = POINT_SIZE_GRANULARITY;
752 ctx->Const.MinLineWidth = MIN_LINE_WIDTH;
753 ctx->Const.MaxLineWidth = MAX_LINE_WIDTH;
754 ctx->Const.MinLineWidthAA = MIN_LINE_WIDTH;
755 ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH;
756 ctx->Const.LineWidthGranularity = LINE_WIDTH_GRANULARITY;
757 ctx->Const.NumAuxBuffers = NUM_AUX_BUFFERS;
Brian Paul4bdcfe52000-04-17 17:57:04 +0000758 ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE;
Brian Paul82b02f02000-05-07 20:37:40 +0000759 ctx->Const.MaxConvolutionWidth = MAX_CONVOLUTION_WIDTH;
760 ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT;
Brian Paul1207bf02000-05-23 20:10:49 +0000761 ctx->Const.NumCompressedTextureFormats = 0;
Brian Paula8644322000-11-27 18:22:13 +0000762 ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES;
763 ctx->Const.MaxLights = MAX_LIGHTS;
jtgafb833d1999-08-19 00:55:39 +0000764
Brian Paul4d053dd2000-01-14 04:45:47 +0000765 /* Modelview matrix */
Keith Whitwell23caf202000-11-16 21:05:34 +0000766 _math_matrix_ctr( &ctx->ModelView );
767 _math_matrix_alloc_inv( &ctx->ModelView );
Brian Paul4d053dd2000-01-14 04:45:47 +0000768
769 ctx->ModelViewStackDepth = 0;
Brian Paul7fc29c52000-03-06 17:03:03 +0000770 for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000771 _math_matrix_ctr( &ctx->ModelViewStack[i] );
772 _math_matrix_alloc_inv( &ctx->ModelViewStack[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +0000773 }
774
775 /* Projection matrix - need inv for user clipping in clip space*/
Keith Whitwell23caf202000-11-16 21:05:34 +0000776 _math_matrix_ctr( &ctx->ProjectionMatrix );
777 _math_matrix_alloc_inv( &ctx->ProjectionMatrix );
Brian Paul4d053dd2000-01-14 04:45:47 +0000778
779 ctx->ProjectionStackDepth = 0;
Brian Paul7fc29c52000-03-06 17:03:03 +0000780 for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000781 _math_matrix_ctr( &ctx->ProjectionStack[i] );
782 _math_matrix_alloc_inv( &ctx->ProjectionStack[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +0000783 }
784
Keith Whitwell23caf202000-11-16 21:05:34 +0000785 /* Derived ModelProject matrix */
786 _math_matrix_ctr( &ctx->_ModelProjectMatrix );
787
Brian Paul4d053dd2000-01-14 04:45:47 +0000788 /* Texture matrix */
Brian Paul904ecb22000-06-27 23:38:45 +0000789 for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000790 _math_matrix_ctr( &ctx->TextureMatrix[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +0000791 ctx->TextureStackDepth[i] = 0;
Brian Paul7fc29c52000-03-06 17:03:03 +0000792 for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000793 _math_matrix_ctr( &ctx->TextureStack[i][j] );
Brian Paul4d053dd2000-01-14 04:45:47 +0000794 ctx->TextureStack[i][j].inv = 0;
jtgafb833d1999-08-19 00:55:39 +0000795 }
Brian Paul4d053dd2000-01-14 04:45:47 +0000796 }
jtgafb833d1999-08-19 00:55:39 +0000797
Brian Paul250069d2000-04-08 18:57:45 +0000798 /* Color matrix */
Keith Whitwell23caf202000-11-16 21:05:34 +0000799 _math_matrix_ctr(&ctx->ColorMatrix);
Brian Paul250069d2000-04-08 18:57:45 +0000800 ctx->ColorStackDepth = 0;
801 for (j = 0; j < MAX_COLOR_STACK_DEPTH - 1; j++) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000802 _math_matrix_ctr(&ctx->ColorStack[j]);
Brian Paul250069d2000-04-08 18:57:45 +0000803 }
804
Brian Paul4d053dd2000-01-14 04:45:47 +0000805 /* Accumulate buffer group */
806 ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 );
jtgafb833d1999-08-19 00:55:39 +0000807
Brian Paul4d053dd2000-01-14 04:45:47 +0000808 /* Color buffer group */
809 ctx->Color.IndexMask = 0xffffffff;
810 ctx->Color.ColorMask[0] = 0xff;
811 ctx->Color.ColorMask[1] = 0xff;
812 ctx->Color.ColorMask[2] = 0xff;
813 ctx->Color.ColorMask[3] = 0xff;
Brian Paul4d053dd2000-01-14 04:45:47 +0000814 ctx->Color.ClearIndex = 0;
815 ASSIGN_4V( ctx->Color.ClearColor, 0.0, 0.0, 0.0, 0.0 );
816 ctx->Color.DrawBuffer = GL_FRONT;
817 ctx->Color.AlphaEnabled = GL_FALSE;
818 ctx->Color.AlphaFunc = GL_ALWAYS;
819 ctx->Color.AlphaRef = 0;
820 ctx->Color.BlendEnabled = GL_FALSE;
821 ctx->Color.BlendSrcRGB = GL_ONE;
822 ctx->Color.BlendDstRGB = GL_ZERO;
823 ctx->Color.BlendSrcA = GL_ONE;
824 ctx->Color.BlendDstA = GL_ZERO;
825 ctx->Color.BlendEquation = GL_FUNC_ADD_EXT;
Brian Paul4d053dd2000-01-14 04:45:47 +0000826 ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
827 ctx->Color.IndexLogicOpEnabled = GL_FALSE;
828 ctx->Color.ColorLogicOpEnabled = GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000829 ctx->Color.LogicOp = GL_COPY;
830 ctx->Color.DitherFlag = GL_TRUE;
831 ctx->Color.MultiDrawBuffer = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000832
Brian Paul4d053dd2000-01-14 04:45:47 +0000833 /* Current group */
Brian Paul19300532000-10-29 19:02:23 +0000834 ASSIGN_4V( ctx->Current.Color, CHAN_MAX, CHAN_MAX, CHAN_MAX, CHAN_MAX );
Brian Paul4d053dd2000-01-14 04:45:47 +0000835 ctx->Current.Index = 1;
836 for (i=0; i<MAX_TEXTURE_UNITS; i++)
837 ASSIGN_4V( ctx->Current.Texcoord[i], 0.0, 0.0, 0.0, 1.0 );
838 ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 );
839 ctx->Current.RasterDistance = 0.0;
840 ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 );
841 ctx->Current.RasterIndex = 1;
842 for (i=0; i<MAX_TEXTURE_UNITS; i++)
843 ASSIGN_4V( ctx->Current.RasterMultiTexCoord[i], 0.0, 0.0, 0.0, 1.0 );
844 ctx->Current.RasterTexCoord = ctx->Current.RasterMultiTexCoord[0];
845 ctx->Current.RasterPosValid = GL_TRUE;
846 ctx->Current.EdgeFlag = GL_TRUE;
847 ASSIGN_3V( ctx->Current.Normal, 0.0, 0.0, 1.0 );
jtgafb833d1999-08-19 00:55:39 +0000848
jtgafb833d1999-08-19 00:55:39 +0000849
Brian Paul4d053dd2000-01-14 04:45:47 +0000850 /* Depth buffer group */
851 ctx->Depth.Test = GL_FALSE;
852 ctx->Depth.Clear = 1.0;
853 ctx->Depth.Func = GL_LESS;
854 ctx->Depth.Mask = GL_TRUE;
Brian Paul1b2ff692000-03-11 23:23:26 +0000855 ctx->Depth.OcclusionTest = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000856
Brian Paul4d053dd2000-01-14 04:45:47 +0000857 /* Evaluators group */
858 ctx->Eval.Map1Color4 = GL_FALSE;
859 ctx->Eval.Map1Index = GL_FALSE;
860 ctx->Eval.Map1Normal = GL_FALSE;
861 ctx->Eval.Map1TextureCoord1 = GL_FALSE;
862 ctx->Eval.Map1TextureCoord2 = GL_FALSE;
863 ctx->Eval.Map1TextureCoord3 = GL_FALSE;
864 ctx->Eval.Map1TextureCoord4 = GL_FALSE;
865 ctx->Eval.Map1Vertex3 = GL_FALSE;
866 ctx->Eval.Map1Vertex4 = GL_FALSE;
867 ctx->Eval.Map2Color4 = GL_FALSE;
868 ctx->Eval.Map2Index = GL_FALSE;
869 ctx->Eval.Map2Normal = GL_FALSE;
870 ctx->Eval.Map2TextureCoord1 = GL_FALSE;
871 ctx->Eval.Map2TextureCoord2 = GL_FALSE;
872 ctx->Eval.Map2TextureCoord3 = GL_FALSE;
873 ctx->Eval.Map2TextureCoord4 = GL_FALSE;
874 ctx->Eval.Map2Vertex3 = GL_FALSE;
875 ctx->Eval.Map2Vertex4 = GL_FALSE;
876 ctx->Eval.AutoNormal = GL_FALSE;
877 ctx->Eval.MapGrid1un = 1;
878 ctx->Eval.MapGrid1u1 = 0.0;
879 ctx->Eval.MapGrid1u2 = 1.0;
880 ctx->Eval.MapGrid2un = 1;
881 ctx->Eval.MapGrid2vn = 1;
882 ctx->Eval.MapGrid2u1 = 0.0;
883 ctx->Eval.MapGrid2u2 = 1.0;
884 ctx->Eval.MapGrid2v1 = 0.0;
885 ctx->Eval.MapGrid2v2 = 1.0;
jtgafb833d1999-08-19 00:55:39 +0000886
Brian Paul4d053dd2000-01-14 04:45:47 +0000887 /* Evaluator data */
888 {
889 static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 };
890 static GLfloat normal[3] = { 0.0, 0.0, 1.0 };
891 static GLfloat index[1] = { 1.0 };
892 static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 };
893 static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 };
jtgafb833d1999-08-19 00:55:39 +0000894
Brian Paul4d053dd2000-01-14 04:45:47 +0000895 init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex );
896 init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex );
897 init_1d_map( &ctx->EvalMap.Map1Index, 1, index );
898 init_1d_map( &ctx->EvalMap.Map1Color4, 4, color );
899 init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal );
900 init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord );
901 init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord );
902 init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord );
903 init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord );
jtgafb833d1999-08-19 00:55:39 +0000904
Brian Paul4d053dd2000-01-14 04:45:47 +0000905 init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex );
906 init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex );
907 init_2d_map( &ctx->EvalMap.Map2Index, 1, index );
908 init_2d_map( &ctx->EvalMap.Map2Color4, 4, color );
909 init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal );
910 init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord );
911 init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord );
912 init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord );
913 init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord );
914 }
jtgafb833d1999-08-19 00:55:39 +0000915
Brian Paul4d053dd2000-01-14 04:45:47 +0000916 /* Fog group */
917 ctx->Fog.Enabled = GL_FALSE;
918 ctx->Fog.Mode = GL_EXP;
919 ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 );
920 ctx->Fog.Index = 0.0;
921 ctx->Fog.Density = 1.0;
922 ctx->Fog.Start = 0.0;
923 ctx->Fog.End = 1.0;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000924 ctx->Fog.ColorSumEnabled = GL_FALSE;
925 ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
jtgafb833d1999-08-19 00:55:39 +0000926
Brian Paul4d053dd2000-01-14 04:45:47 +0000927 /* Hint group */
928 ctx->Hint.PerspectiveCorrection = GL_DONT_CARE;
929 ctx->Hint.PointSmooth = GL_DONT_CARE;
930 ctx->Hint.LineSmooth = GL_DONT_CARE;
931 ctx->Hint.PolygonSmooth = GL_DONT_CARE;
932 ctx->Hint.Fog = GL_DONT_CARE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000933 ctx->Hint.AllowDrawWin = GL_TRUE;
Brian Paul8cce3142000-04-10 15:52:25 +0000934 ctx->Hint.AllowDrawFrg = GL_TRUE;
Brian Paul4d053dd2000-01-14 04:45:47 +0000935 ctx->Hint.AllowDrawMem = GL_TRUE;
936 ctx->Hint.StrictLighting = GL_TRUE;
Brian Paul1207bf02000-05-23 20:10:49 +0000937 ctx->Hint.ClipVolumeClipping = GL_DONT_CARE;
938 ctx->Hint.TextureCompression = GL_DONT_CARE;
jtgafb833d1999-08-19 00:55:39 +0000939
Brian Paul0771d152000-04-07 00:19:41 +0000940 /* Histogram group */
941 ctx->Histogram.Width = 0;
942 ctx->Histogram.Format = GL_RGBA;
943 ctx->Histogram.Sink = GL_FALSE;
944 ctx->Histogram.RedSize = 0xffffffff;
945 ctx->Histogram.GreenSize = 0xffffffff;
946 ctx->Histogram.BlueSize = 0xffffffff;
947 ctx->Histogram.AlphaSize = 0xffffffff;
948 ctx->Histogram.LuminanceSize = 0xffffffff;
949 for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) {
950 ctx->Histogram.Count[i][0] = 0;
951 ctx->Histogram.Count[i][1] = 0;
952 ctx->Histogram.Count[i][2] = 0;
953 ctx->Histogram.Count[i][3] = 0;
954 }
955
956 /* Min/Max group */
957 ctx->MinMax.Format = GL_RGBA;
958 ctx->MinMax.Sink = GL_FALSE;
959 ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000;
960 ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000;
961 ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000;
962 ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000;
963
Brian Paul4d053dd2000-01-14 04:45:47 +0000964 /* Extensions */
965 gl_extensions_ctr( ctx );
jtgafb833d1999-08-19 00:55:39 +0000966
Brian Paul4d053dd2000-01-14 04:45:47 +0000967 /* Lighting group */
968 for (i=0;i<MAX_LIGHTS;i++) {
969 init_light( &ctx->Light.Light[i], i );
970 }
971 make_empty_list( &ctx->Light.EnabledList );
jtgafb833d1999-08-19 00:55:39 +0000972
Brian Paul4d053dd2000-01-14 04:45:47 +0000973 init_lightmodel( &ctx->Light.Model );
974 init_material( &ctx->Light.Material[0] );
975 init_material( &ctx->Light.Material[1] );
976 ctx->Light.ShadeModel = GL_SMOOTH;
977 ctx->Light.Enabled = GL_FALSE;
978 ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK;
979 ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE;
980 ctx->Light.ColorMaterialBitmask
981 = gl_material_bitmask( ctx,
982 GL_FRONT_AND_BACK,
983 GL_AMBIENT_AND_DIFFUSE, ~0, 0 );
jtgafb833d1999-08-19 00:55:39 +0000984
Brian Paul4d053dd2000-01-14 04:45:47 +0000985 ctx->Light.ColorMaterialEnabled = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +0000986
Brian Paul4d053dd2000-01-14 04:45:47 +0000987 /* Lighting miscellaneous */
Keith Whitwell14940c42000-11-05 18:40:57 +0000988 ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab );
989 make_empty_list( ctx->_ShineTabList );
Brian Paul4d053dd2000-01-14 04:45:47 +0000990 for (i = 0 ; i < 10 ; i++) {
991 struct gl_shine_tab *s = MALLOC_STRUCT( gl_shine_tab );
992 s->shininess = -1;
993 s->refcount = 0;
Keith Whitwell14940c42000-11-05 18:40:57 +0000994 insert_at_tail( ctx->_ShineTabList, s );
Brian Paul4d053dd2000-01-14 04:45:47 +0000995 }
996 for (i = 0 ; i < 4 ; i++) {
Keith Whitwell14940c42000-11-05 18:40:57 +0000997 ctx->_ShineTable[i] = ctx->_ShineTabList->prev;
998 ctx->_ShineTable[i]->refcount++;
Brian Paul4d053dd2000-01-14 04:45:47 +0000999 }
jtgafb833d1999-08-19 00:55:39 +00001000
Brian Paul77d61af2000-06-28 04:20:21 +00001001 gl_compute_shine_table( ctx, 0, ctx->Light.Material[0].Shininess );
1002 gl_compute_shine_table( ctx, 2, ctx->Light.Material[0].Shininess * .5 );
1003 gl_compute_shine_table( ctx, 1, ctx->Light.Material[1].Shininess );
1004 gl_compute_shine_table( ctx, 3, ctx->Light.Material[1].Shininess * .5 );
1005
jtgafb833d1999-08-19 00:55:39 +00001006
Brian Paul4d053dd2000-01-14 04:45:47 +00001007 /* Line group */
1008 ctx->Line.SmoothFlag = GL_FALSE;
1009 ctx->Line.StippleFlag = GL_FALSE;
1010 ctx->Line.Width = 1.0;
1011 ctx->Line.StipplePattern = 0xffff;
1012 ctx->Line.StippleFactor = 1;
jtgafb833d1999-08-19 00:55:39 +00001013
Brian Paul4d053dd2000-01-14 04:45:47 +00001014 /* Display List group */
1015 ctx->List.ListBase = 0;
jtgafb833d1999-08-19 00:55:39 +00001016
Brian Paul4d053dd2000-01-14 04:45:47 +00001017 /* Pixel group */
1018 ctx->Pixel.RedBias = 0.0;
1019 ctx->Pixel.RedScale = 1.0;
1020 ctx->Pixel.GreenBias = 0.0;
1021 ctx->Pixel.GreenScale = 1.0;
1022 ctx->Pixel.BlueBias = 0.0;
1023 ctx->Pixel.BlueScale = 1.0;
1024 ctx->Pixel.AlphaBias = 0.0;
1025 ctx->Pixel.AlphaScale = 1.0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001026 ctx->Pixel.DepthBias = 0.0;
1027 ctx->Pixel.DepthScale = 1.0;
1028 ctx->Pixel.IndexOffset = 0;
1029 ctx->Pixel.IndexShift = 0;
1030 ctx->Pixel.ZoomX = 1.0;
1031 ctx->Pixel.ZoomY = 1.0;
1032 ctx->Pixel.MapColorFlag = GL_FALSE;
1033 ctx->Pixel.MapStencilFlag = GL_FALSE;
1034 ctx->Pixel.MapStoSsize = 1;
1035 ctx->Pixel.MapItoIsize = 1;
1036 ctx->Pixel.MapItoRsize = 1;
1037 ctx->Pixel.MapItoGsize = 1;
1038 ctx->Pixel.MapItoBsize = 1;
1039 ctx->Pixel.MapItoAsize = 1;
1040 ctx->Pixel.MapRtoRsize = 1;
1041 ctx->Pixel.MapGtoGsize = 1;
1042 ctx->Pixel.MapBtoBsize = 1;
1043 ctx->Pixel.MapAtoAsize = 1;
1044 ctx->Pixel.MapStoS[0] = 0;
1045 ctx->Pixel.MapItoI[0] = 0;
1046 ctx->Pixel.MapItoR[0] = 0.0;
1047 ctx->Pixel.MapItoG[0] = 0.0;
1048 ctx->Pixel.MapItoB[0] = 0.0;
1049 ctx->Pixel.MapItoA[0] = 0.0;
1050 ctx->Pixel.MapItoR8[0] = 0;
1051 ctx->Pixel.MapItoG8[0] = 0;
1052 ctx->Pixel.MapItoB8[0] = 0;
1053 ctx->Pixel.MapItoA8[0] = 0;
1054 ctx->Pixel.MapRtoR[0] = 0.0;
1055 ctx->Pixel.MapGtoG[0] = 0.0;
1056 ctx->Pixel.MapBtoB[0] = 0.0;
1057 ctx->Pixel.MapAtoA[0] = 0.0;
Brian Paul2b2e9252000-04-07 16:27:26 +00001058 ctx->Pixel.HistogramEnabled = GL_FALSE;
1059 ctx->Pixel.MinMaxEnabled = GL_FALSE;
1060 ctx->Pixel.PixelTextureEnabled = GL_FALSE;
1061 ctx->Pixel.FragmentRgbSource = GL_PIXEL_GROUP_COLOR_SGIS;
1062 ctx->Pixel.FragmentAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS;
Brian Paul82b02f02000-05-07 20:37:40 +00001063 ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0);
1064 ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0);
1065 ASSIGN_4V(ctx->Pixel.ColorTableScale, 1.0, 1.0, 1.0, 1.0);
1066 ASSIGN_4V(ctx->Pixel.ColorTableBias, 0.0, 0.0, 0.0, 0.0);
Brian Paul6c50e162000-06-30 22:11:04 +00001067 ASSIGN_4V(ctx->Pixel.PCCTscale, 1.0, 1.0, 1.0, 1.0);
1068 ASSIGN_4V(ctx->Pixel.PCCTbias, 0.0, 0.0, 0.0, 0.0);
1069 ASSIGN_4V(ctx->Pixel.PCMCTscale, 1.0, 1.0, 1.0, 1.0);
1070 ASSIGN_4V(ctx->Pixel.PCMCTbias, 0.0, 0.0, 0.0, 0.0);
Brian Paul4fe34b22000-04-11 15:07:48 +00001071 ctx->Pixel.ColorTableEnabled = GL_FALSE;
1072 ctx->Pixel.PostConvolutionColorTableEnabled = GL_FALSE;
1073 ctx->Pixel.PostColorMatrixColorTableEnabled = GL_FALSE;
Brian Paul82b02f02000-05-07 20:37:40 +00001074 ctx->Pixel.Convolution1DEnabled = GL_FALSE;
1075 ctx->Pixel.Convolution2DEnabled = GL_FALSE;
1076 ctx->Pixel.Separable2DEnabled = GL_FALSE;
1077 for (i = 0; i < 3; i++) {
1078 ASSIGN_4V(ctx->Pixel.ConvolutionBorderColor[i], 0.0, 0.0, 0.0, 0.0);
1079 ctx->Pixel.ConvolutionBorderMode[i] = GL_REDUCE;
1080 ASSIGN_4V(ctx->Pixel.ConvolutionFilterScale[i], 1.0, 1.0, 1.0, 1.0);
1081 ASSIGN_4V(ctx->Pixel.ConvolutionFilterBias[i], 0.0, 0.0, 0.0, 0.0);
1082 }
Brian Paul67adba12000-12-09 20:35:54 +00001083 for (i = 0; i < MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_WIDTH * 4; i++) {
1084 ctx->Convolution1D.Filter[i] = 0.0;
1085 ctx->Convolution2D.Filter[i] = 0.0;
1086 ctx->Separable2D.Filter[i] = 0.0;
1087 }
Brian Paul82b02f02000-05-07 20:37:40 +00001088 ASSIGN_4V(ctx->Pixel.PostConvolutionScale, 1.0, 1.0, 1.0, 1.0);
1089 ASSIGN_4V(ctx->Pixel.PostConvolutionBias, 0.0, 0.0, 0.0, 0.0);
jtgafb833d1999-08-19 00:55:39 +00001090
Brian Paul4d053dd2000-01-14 04:45:47 +00001091 /* Point group */
1092 ctx->Point.SmoothFlag = GL_FALSE;
1093 ctx->Point.Size = 1.0;
Brian Paul24a32622000-11-15 16:38:40 +00001094 ctx->Point._Size = 1.0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001095 ctx->Point.Params[0] = 1.0;
1096 ctx->Point.Params[1] = 0.0;
1097 ctx->Point.Params[2] = 0.0;
Keith Whitwell14940c42000-11-05 18:40:57 +00001098 ctx->Point._Attenuated = GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +00001099 ctx->Point.MinSize = 0.0;
Brian Paul24a32622000-11-15 16:38:40 +00001100 ctx->Point.MaxSize = ctx->Const.MaxPointSize;
Brian Paul4d053dd2000-01-14 04:45:47 +00001101 ctx->Point.Threshold = 1.0;
Brian Paul06d05af2000-12-08 00:20:15 +00001102 ctx->Point.SpriteMode = GL_FALSE; /* GL_MESA_sprite_point */
jtgafb833d1999-08-19 00:55:39 +00001103
Brian Paul4d053dd2000-01-14 04:45:47 +00001104 /* Polygon group */
1105 ctx->Polygon.CullFlag = GL_FALSE;
1106 ctx->Polygon.CullFaceMode = GL_BACK;
1107 ctx->Polygon.FrontFace = GL_CCW;
1108 ctx->Polygon.FrontBit = 0;
1109 ctx->Polygon.FrontMode = GL_FILL;
1110 ctx->Polygon.BackMode = GL_FILL;
Keith Whitwell14940c42000-11-05 18:40:57 +00001111 ctx->Polygon._Unfilled = GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +00001112 ctx->Polygon.SmoothFlag = GL_FALSE;
1113 ctx->Polygon.StippleFlag = GL_FALSE;
1114 ctx->Polygon.OffsetFactor = 0.0F;
1115 ctx->Polygon.OffsetUnits = 0.0F;
Brian Pauld0d7d622000-10-21 00:02:47 +00001116 ctx->Polygon.OffsetMRD = 0.0F;
Brian Paul4d053dd2000-01-14 04:45:47 +00001117 ctx->Polygon.OffsetPoint = GL_FALSE;
1118 ctx->Polygon.OffsetLine = GL_FALSE;
1119 ctx->Polygon.OffsetFill = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001120
Brian Paul4d053dd2000-01-14 04:45:47 +00001121 /* Polygon Stipple group */
1122 MEMSET( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) );
jtgafb833d1999-08-19 00:55:39 +00001123
Brian Paul4d053dd2000-01-14 04:45:47 +00001124 /* Scissor group */
1125 ctx->Scissor.Enabled = GL_FALSE;
1126 ctx->Scissor.X = 0;
1127 ctx->Scissor.Y = 0;
1128 ctx->Scissor.Width = 0;
1129 ctx->Scissor.Height = 0;
jtgafb833d1999-08-19 00:55:39 +00001130
Brian Paul4d053dd2000-01-14 04:45:47 +00001131 /* Stencil group */
1132 ctx->Stencil.Enabled = GL_FALSE;
1133 ctx->Stencil.Function = GL_ALWAYS;
1134 ctx->Stencil.FailFunc = GL_KEEP;
1135 ctx->Stencil.ZPassFunc = GL_KEEP;
1136 ctx->Stencil.ZFailFunc = GL_KEEP;
1137 ctx->Stencil.Ref = 0;
1138 ctx->Stencil.ValueMask = STENCIL_MAX;
1139 ctx->Stencil.Clear = 0;
1140 ctx->Stencil.WriteMask = STENCIL_MAX;
jtgafb833d1999-08-19 00:55:39 +00001141
Brian Paul4d053dd2000-01-14 04:45:47 +00001142 /* Texture group */
1143 ctx->Texture.CurrentUnit = 0; /* multitexture */
1144 ctx->Texture.CurrentTransformUnit = 0; /* multitexture */
Keith Whitwell14940c42000-11-05 18:40:57 +00001145 ctx->Texture._ReallyEnabled = 0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001146 for (i=0; i<MAX_TEXTURE_UNITS; i++)
1147 init_texture_unit( ctx, i );
Brian Paul23316032000-09-14 23:13:23 +00001148 ctx->Texture.SharedPalette = GL_FALSE;
Brian Paul4bdcfe52000-04-17 17:57:04 +00001149 _mesa_init_colortable(&ctx->Texture.Palette);
jtgafb833d1999-08-19 00:55:39 +00001150
Brian Paul4d053dd2000-01-14 04:45:47 +00001151 /* Transformation group */
1152 ctx->Transform.MatrixMode = GL_MODELVIEW;
1153 ctx->Transform.Normalize = GL_FALSE;
1154 ctx->Transform.RescaleNormals = GL_FALSE;
1155 for (i=0;i<MAX_CLIP_PLANES;i++) {
1156 ctx->Transform.ClipEnabled[i] = GL_FALSE;
1157 ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 );
1158 }
Keith Whitwell14940c42000-11-05 18:40:57 +00001159 ctx->Transform._AnyClip = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001160
Brian Paul4d053dd2000-01-14 04:45:47 +00001161 /* Viewport group */
1162 ctx->Viewport.X = 0;
1163 ctx->Viewport.Y = 0;
1164 ctx->Viewport.Width = 0;
1165 ctx->Viewport.Height = 0;
1166 ctx->Viewport.Near = 0.0;
1167 ctx->Viewport.Far = 1.0;
Keith Whitwell23caf202000-11-16 21:05:34 +00001168 _math_matrix_ctr(&ctx->Viewport._WindowMap);
jtgafb833d1999-08-19 00:55:39 +00001169
1170#define Sz 10
1171#define Tz 14
Keith Whitwell14940c42000-11-05 18:40:57 +00001172 ctx->Viewport._WindowMap.m[Sz] = 0.5 * ctx->Visual.DepthMaxF;
1173 ctx->Viewport._WindowMap.m[Tz] = 0.5 * ctx->Visual.DepthMaxF;
jtgafb833d1999-08-19 00:55:39 +00001174#undef Sz
1175#undef Tz
1176
Keith Whitwell14940c42000-11-05 18:40:57 +00001177 ctx->Viewport._WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION;
1178 ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
jtgafb833d1999-08-19 00:55:39 +00001179
Brian Paul4d053dd2000-01-14 04:45:47 +00001180 /* Vertex arrays */
1181 ctx->Array.Vertex.Size = 4;
1182 ctx->Array.Vertex.Type = GL_FLOAT;
1183 ctx->Array.Vertex.Stride = 0;
1184 ctx->Array.Vertex.StrideB = 0;
1185 ctx->Array.Vertex.Ptr = NULL;
1186 ctx->Array.Vertex.Enabled = GL_FALSE;
1187 ctx->Array.Normal.Type = GL_FLOAT;
1188 ctx->Array.Normal.Stride = 0;
1189 ctx->Array.Normal.StrideB = 0;
1190 ctx->Array.Normal.Ptr = NULL;
1191 ctx->Array.Normal.Enabled = GL_FALSE;
1192 ctx->Array.Color.Size = 4;
1193 ctx->Array.Color.Type = GL_FLOAT;
1194 ctx->Array.Color.Stride = 0;
1195 ctx->Array.Color.StrideB = 0;
1196 ctx->Array.Color.Ptr = NULL;
1197 ctx->Array.Color.Enabled = GL_FALSE;
1198 ctx->Array.Index.Type = GL_FLOAT;
1199 ctx->Array.Index.Stride = 0;
1200 ctx->Array.Index.StrideB = 0;
1201 ctx->Array.Index.Ptr = NULL;
1202 ctx->Array.Index.Enabled = GL_FALSE;
1203 for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
1204 ctx->Array.TexCoord[i].Size = 4;
1205 ctx->Array.TexCoord[i].Type = GL_FLOAT;
1206 ctx->Array.TexCoord[i].Stride = 0;
1207 ctx->Array.TexCoord[i].StrideB = 0;
1208 ctx->Array.TexCoord[i].Ptr = NULL;
1209 ctx->Array.TexCoord[i].Enabled = GL_FALSE;
1210 }
1211 ctx->Array.TexCoordInterleaveFactor = 1;
1212 ctx->Array.EdgeFlag.Stride = 0;
1213 ctx->Array.EdgeFlag.StrideB = 0;
1214 ctx->Array.EdgeFlag.Ptr = NULL;
1215 ctx->Array.EdgeFlag.Enabled = GL_FALSE;
1216 ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
1217
1218 /* Pixel transfer */
1219 ctx->Pack.Alignment = 4;
1220 ctx->Pack.RowLength = 0;
1221 ctx->Pack.ImageHeight = 0;
1222 ctx->Pack.SkipPixels = 0;
1223 ctx->Pack.SkipRows = 0;
1224 ctx->Pack.SkipImages = 0;
1225 ctx->Pack.SwapBytes = GL_FALSE;
1226 ctx->Pack.LsbFirst = GL_FALSE;
1227 ctx->Unpack.Alignment = 4;
1228 ctx->Unpack.RowLength = 0;
1229 ctx->Unpack.ImageHeight = 0;
1230 ctx->Unpack.SkipPixels = 0;
1231 ctx->Unpack.SkipRows = 0;
1232 ctx->Unpack.SkipImages = 0;
1233 ctx->Unpack.SwapBytes = GL_FALSE;
1234 ctx->Unpack.LsbFirst = GL_FALSE;
1235
1236 /* Feedback */
1237 ctx->Feedback.Type = GL_2D; /* TODO: verify */
1238 ctx->Feedback.Buffer = NULL;
1239 ctx->Feedback.BufferSize = 0;
1240 ctx->Feedback.Count = 0;
1241
1242 /* Selection/picking */
1243 ctx->Select.Buffer = NULL;
1244 ctx->Select.BufferSize = 0;
1245 ctx->Select.BufferCount = 0;
1246 ctx->Select.Hits = 0;
1247 ctx->Select.NameStackDepth = 0;
1248
Brian Paul4d053dd2000-01-14 04:45:47 +00001249 /* Renderer and client attribute stacks */
1250 ctx->AttribStackDepth = 0;
1251 ctx->ClientAttribStackDepth = 0;
1252
Brian Paul13811372000-04-12 00:27:37 +00001253 /* Display list */
1254 ctx->CallDepth = 0;
1255 ctx->ExecuteFlag = GL_TRUE;
1256 ctx->CompileFlag = GL_FALSE;
1257 ctx->CurrentListPtr = NULL;
1258 ctx->CurrentBlock = NULL;
1259 ctx->CurrentListNum = 0;
1260 ctx->CurrentPos = 0;
1261
1262 /* Color tables */
Brian Paul4bdcfe52000-04-17 17:57:04 +00001263 _mesa_init_colortable(&ctx->ColorTable);
1264 _mesa_init_colortable(&ctx->ProxyColorTable);
1265 _mesa_init_colortable(&ctx->PostConvolutionColorTable);
1266 _mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable);
1267 _mesa_init_colortable(&ctx->PostColorMatrixColorTable);
1268 _mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable);
Brian Paul13811372000-04-12 00:27:37 +00001269
Brian Paul4d053dd2000-01-14 04:45:47 +00001270 /* Miscellaneous */
Keith Whitwella96308c2000-10-30 13:31:59 +00001271 ctx->NewState = _NEW_ALL;
Brian Paul4d053dd2000-01-14 04:45:47 +00001272 ctx->RenderMode = GL_RENDER;
Keith Whitwell14940c42000-11-05 18:40:57 +00001273 ctx->_ImageTransferState = 0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001274
Keith Whitwell1e1aac02000-11-13 20:02:56 +00001275 ctx->_NeedNormals = 0;
1276 ctx->_NeedEyeCoords = 0;
1277 ctx->_ModelViewInvScale = 1.0;
Brian Paul4d053dd2000-01-14 04:45:47 +00001278
Brian Paul4d053dd2000-01-14 04:45:47 +00001279 ctx->ErrorValue = (GLenum) GL_NO_ERROR;
1280
1281 ctx->CatchSignals = GL_TRUE;
Brian Paul1b2ff692000-03-11 23:23:26 +00001282 ctx->OcclusionResult = GL_FALSE;
Brian Paul7e67fb42000-04-04 15:14:10 +00001283 ctx->OcclusionResultSaved = GL_FALSE;
Brian Paul4d053dd2000-01-14 04:45:47 +00001284
1285 /* For debug/development only */
1286 ctx->NoRaster = getenv("MESA_NO_RASTER") ? GL_TRUE : GL_FALSE;
1287 ctx->FirstTimeCurrent = GL_TRUE;
1288
1289 /* Dither disable */
1290 ctx->NoDither = getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
1291 if (ctx->NoDither) {
1292 if (getenv("MESA_DEBUG")) {
1293 fprintf(stderr, "MESA_NO_DITHER set - dithering disabled\n");
jtgafb833d1999-08-19 00:55:39 +00001294 }
Brian Paul4d053dd2000-01-14 04:45:47 +00001295 ctx->Color.DitherFlag = GL_FALSE;
Brian Paul00037781999-12-17 14:52:35 +00001296 }
1297}
1298
1299
1300
1301
jtgafb833d1999-08-19 00:55:39 +00001302/*
1303 * Allocate the proxy textures. If we run out of memory part way through
1304 * the allocations clean up and return GL_FALSE.
1305 * Return: GL_TRUE=success, GL_FALSE=failure
1306 */
Brian Paul178a1c52000-04-22 01:05:00 +00001307static GLboolean
1308alloc_proxy_textures( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +00001309{
1310 GLboolean out_of_memory;
1311 GLint i;
1312
Brian Paula8523782000-11-19 23:10:25 +00001313 ctx->Texture.Proxy1D = _mesa_alloc_texture_object(NULL, 0, 1);
jtgafb833d1999-08-19 00:55:39 +00001314 if (!ctx->Texture.Proxy1D) {
1315 return GL_FALSE;
1316 }
1317
Brian Paula8523782000-11-19 23:10:25 +00001318 ctx->Texture.Proxy2D = _mesa_alloc_texture_object(NULL, 0, 2);
jtgafb833d1999-08-19 00:55:39 +00001319 if (!ctx->Texture.Proxy2D) {
Brian Paula8523782000-11-19 23:10:25 +00001320 _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
jtgafb833d1999-08-19 00:55:39 +00001321 return GL_FALSE;
1322 }
1323
Brian Paula8523782000-11-19 23:10:25 +00001324 ctx->Texture.Proxy3D = _mesa_alloc_texture_object(NULL, 0, 3);
jtgafb833d1999-08-19 00:55:39 +00001325 if (!ctx->Texture.Proxy3D) {
Brian Paula8523782000-11-19 23:10:25 +00001326 _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
1327 _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
1328 return GL_FALSE;
1329 }
1330
1331 ctx->Texture.ProxyCubeMap = _mesa_alloc_texture_object(NULL, 0, 6);
1332 if (!ctx->Texture.ProxyCubeMap) {
1333 _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
1334 _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
1335 _mesa_free_texture_object(NULL, ctx->Texture.Proxy3D);
jtgafb833d1999-08-19 00:55:39 +00001336 return GL_FALSE;
1337 }
1338
1339 out_of_memory = GL_FALSE;
1340 for (i=0;i<MAX_TEXTURE_LEVELS;i++) {
Brian Paul021a5252000-03-27 17:54:17 +00001341 ctx->Texture.Proxy1D->Image[i] = _mesa_alloc_texture_image();
1342 ctx->Texture.Proxy2D->Image[i] = _mesa_alloc_texture_image();
1343 ctx->Texture.Proxy3D->Image[i] = _mesa_alloc_texture_image();
jtgafb833d1999-08-19 00:55:39 +00001344 if (!ctx->Texture.Proxy1D->Image[i]
1345 || !ctx->Texture.Proxy2D->Image[i]
1346 || !ctx->Texture.Proxy3D->Image[i]) {
1347 out_of_memory = GL_TRUE;
1348 }
1349 }
1350 if (out_of_memory) {
1351 for (i=0;i<MAX_TEXTURE_LEVELS;i++) {
1352 if (ctx->Texture.Proxy1D->Image[i]) {
Brian Paul021a5252000-03-27 17:54:17 +00001353 _mesa_free_texture_image(ctx->Texture.Proxy1D->Image[i]);
jtgafb833d1999-08-19 00:55:39 +00001354 }
1355 if (ctx->Texture.Proxy2D->Image[i]) {
Brian Paul021a5252000-03-27 17:54:17 +00001356 _mesa_free_texture_image(ctx->Texture.Proxy2D->Image[i]);
jtgafb833d1999-08-19 00:55:39 +00001357 }
1358 if (ctx->Texture.Proxy3D->Image[i]) {
Brian Paul021a5252000-03-27 17:54:17 +00001359 _mesa_free_texture_image(ctx->Texture.Proxy3D->Image[i]);
jtgafb833d1999-08-19 00:55:39 +00001360 }
1361 }
Brian Paula8523782000-11-19 23:10:25 +00001362 _mesa_free_texture_object(NULL, ctx->Texture.Proxy1D);
1363 _mesa_free_texture_object(NULL, ctx->Texture.Proxy2D);
1364 _mesa_free_texture_object(NULL, ctx->Texture.Proxy3D);
jtgafb833d1999-08-19 00:55:39 +00001365 return GL_FALSE;
1366 }
1367 else {
1368 return GL_TRUE;
1369 }
1370}
1371
1372
jtgafb833d1999-08-19 00:55:39 +00001373/*
Brian Paul8aee2a32000-08-29 18:57:58 +00001374 * Initialize a GLcontext struct. This includes allocating all the
1375 * other structs and arrays which hang off of the context by pointers.
jtgafb833d1999-08-19 00:55:39 +00001376 */
Brian Paul178a1c52000-04-22 01:05:00 +00001377GLboolean
1378_mesa_initialize_context( GLcontext *ctx,
1379 GLvisual *visual,
1380 GLcontext *share_list,
1381 void *driver_ctx,
1382 GLboolean direct )
jtgafb833d1999-08-19 00:55:39 +00001383{
Brian Paul5fb84d22000-05-24 15:04:45 +00001384 GLuint dispatchSize;
1385
jtgafb833d1999-08-19 00:55:39 +00001386 (void) direct; /* not used */
1387
jtgafb833d1999-08-19 00:55:39 +00001388 /* misc one-time initializations */
1389 one_time_init();
1390
Brian Paulb1394fa2000-09-26 20:53:53 +00001391 /**
1392 ** OpenGL SI stuff
1393 **/
1394 if (!ctx->imports.malloc) {
1395 _mesa_InitDefaultImports(&ctx->imports, driver_ctx, NULL);
1396 }
1397 /* exports are setup by the device driver */
1398
jtgafb833d1999-08-19 00:55:39 +00001399 ctx->DriverCtx = driver_ctx;
Brian Paulb1394fa2000-09-26 20:53:53 +00001400 ctx->Visual = *visual;
Brian Paul3f02f901999-11-24 18:48:30 +00001401 ctx->DrawBuffer = NULL;
1402 ctx->ReadBuffer = NULL;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001403
jtgafb833d1999-08-19 00:55:39 +00001404 if (share_list) {
1405 /* share the group of display lists of another context */
1406 ctx->Shared = share_list->Shared;
1407 }
1408 else {
1409 /* allocate new group of display lists */
1410 ctx->Shared = alloc_shared_state();
1411 if (!ctx->Shared) {
Brian Paul4d053dd2000-01-14 04:45:47 +00001412 return GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001413 }
1414 }
Brian Paul9560f052000-01-31 23:11:39 +00001415 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
jtgafb833d1999-08-19 00:55:39 +00001416 ctx->Shared->RefCount++;
Brian Paul9560f052000-01-31 23:11:39 +00001417 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
jtgafb833d1999-08-19 00:55:39 +00001418
Brian Paul4d053dd2000-01-14 04:45:47 +00001419 init_attrib_groups( ctx );
1420
jtgafb833d1999-08-19 00:55:39 +00001421 if (visual->DBflag) {
1422 ctx->Color.DrawBuffer = GL_BACK;
1423 ctx->Color.DriverDrawBuffer = GL_BACK_LEFT;
1424 ctx->Color.DrawDestMask = BACK_LEFT_BIT;
1425 ctx->Pixel.ReadBuffer = GL_BACK;
1426 ctx->Pixel.DriverReadBuffer = GL_BACK_LEFT;
1427 }
1428 else {
1429 ctx->Color.DrawBuffer = GL_FRONT;
1430 ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT;
1431 ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
1432 ctx->Pixel.ReadBuffer = GL_FRONT;
1433 ctx->Pixel.DriverReadBuffer = GL_FRONT_LEFT;
1434 }
1435
jtgafb833d1999-08-19 00:55:39 +00001436 if (!alloc_proxy_textures(ctx)) {
1437 free_shared_state(ctx, ctx->Shared);
Brian Paul4d053dd2000-01-14 04:45:47 +00001438 return GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001439 }
jtgafb833d1999-08-19 00:55:39 +00001440
Brian Paulf59afc92000-05-23 23:23:00 +00001441 /* register the most recent extension functions with libGL */
1442 _glapi_add_entrypoint("glTbufferMask3DFX", 553);
1443 _glapi_add_entrypoint("glCompressedTexImage3DARB", 554);
1444 _glapi_add_entrypoint("glCompressedTexImage2DARB", 555);
1445 _glapi_add_entrypoint("glCompressedTexImage1DARB", 556);
1446 _glapi_add_entrypoint("glCompressedTexSubImage3DARB", 557);
1447 _glapi_add_entrypoint("glCompressedTexSubImage2DARB", 558);
1448 _glapi_add_entrypoint("glCompressedTexSubImage1DARB", 559);
1449 _glapi_add_entrypoint("glGetCompressedTexImageARB", 560);
1450
Brian Paul5fb84d22000-05-24 15:04:45 +00001451 /* Find the larger of Mesa's dispatch table and libGL's dispatch table.
1452 * In practice, this'll be the same for stand-alone Mesa. But for DRI
1453 * Mesa we do this to accomodate different versions of libGL and various
1454 * DRI drivers.
1455 */
1456 dispatchSize = MAX2(_glapi_get_dispatch_table_size(),
1457 sizeof(struct _glapi_table) / sizeof(void *));
1458
Brian Paulfbd8f211999-11-11 01:22:25 +00001459 /* setup API dispatch tables */
Brian Paul5fb84d22000-05-24 15:04:45 +00001460 ctx->Exec = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
1461 ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001462 if (!ctx->Exec || !ctx->Save) {
1463 free_shared_state(ctx, ctx->Shared);
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001464 if (ctx->Exec)
Brian Paul2d8db392000-06-27 22:10:00 +00001465 FREE( ctx->Exec );
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001466 }
Brian Paul5fb84d22000-05-24 15:04:45 +00001467 _mesa_init_exec_table(ctx->Exec, dispatchSize);
1468 _mesa_init_dlist_table(ctx->Save, dispatchSize);
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001469 ctx->CurrentDispatch = ctx->Exec;
jtgafb833d1999-08-19 00:55:39 +00001470
Keith Whitwellad2ac212000-11-24 10:25:05 +00001471 ctx->ExecPrefersFloat = GL_FALSE;
1472 ctx->SavePrefersFloat = GL_FALSE;
1473
Brian Paul3b18a362000-09-26 15:27:20 +00001474#if defined(MESA_TRACE)
Brian Paul45f36342000-09-05 20:28:06 +00001475 ctx->TraceCtx = CALLOC( sizeof(trace_context_t) );
1476#if 0
1477 /* Brian: do you want to have CreateContext fail here,
1478 or should we just trap in NewTrace (currently done)? */
1479 if (!(ctx->TraceCtx)) {
1480 free_shared_state(ctx, ctx->Shared);
Brian Paul45f36342000-09-05 20:28:06 +00001481 FREE( ctx->Exec );
1482 FREE( ctx->Save );
1483 return GL_FALSE;
1484 }
1485#endif
1486 trInitContext(ctx->TraceCtx);
1487
1488 ctx->TraceDispatch = (struct _glapi_table *)
1489 CALLOC(dispatchSize * sizeof(void*));
1490#if 0
1491 if (!(ctx->TraceCtx)) {
1492 free_shared_state(ctx, ctx->Shared);
Brian Paul45f36342000-09-05 20:28:06 +00001493 FREE( ctx->Exec );
1494 FREE( ctx->Save );
1495 FREE( ctx->TraceCtx );
1496 return GL_FALSE;
1497 }
1498#endif
1499 trInitDispatch(ctx->TraceDispatch);
1500#endif
1501
Brian Paul4d053dd2000-01-14 04:45:47 +00001502 return GL_TRUE;
jtgafb833d1999-08-19 00:55:39 +00001503}
1504
jtgafb833d1999-08-19 00:55:39 +00001505
1506
1507/*
Brian Paul4d053dd2000-01-14 04:45:47 +00001508 * Allocate and initialize a GLcontext structure.
1509 * Input: visual - a GLvisual pointer
1510 * sharelist - another context to share display lists with or NULL
1511 * driver_ctx - pointer to device driver's context state struct
Brian Paulb1394fa2000-09-26 20:53:53 +00001512 * Return: pointer to a new __GLcontextRec or NULL if error.
Brian Paul4d053dd2000-01-14 04:45:47 +00001513 */
Brian Paul178a1c52000-04-22 01:05:00 +00001514GLcontext *
Brian Paulb1394fa2000-09-26 20:53:53 +00001515_mesa_create_context( GLvisual *visual,
1516 GLcontext *share_list,
1517 void *driver_ctx,
1518 GLboolean direct )
Brian Paul4d053dd2000-01-14 04:45:47 +00001519{
1520 GLcontext *ctx = (GLcontext *) CALLOC( sizeof(GLcontext) );
1521 if (!ctx) {
1522 return NULL;
1523 }
1524
Brian Paul178a1c52000-04-22 01:05:00 +00001525 if (_mesa_initialize_context(ctx, visual, share_list, driver_ctx, direct)) {
Brian Paul4d053dd2000-01-14 04:45:47 +00001526 return ctx;
1527 }
1528 else {
1529 FREE(ctx);
1530 return NULL;
1531 }
1532}
1533
1534
1535
1536/*
1537 * Free the data associated with the given context.
1538 * But don't free() the GLcontext struct itself!
1539 */
Brian Paul178a1c52000-04-22 01:05:00 +00001540void
Brian Paulb1394fa2000-09-26 20:53:53 +00001541_mesa_free_context_data( GLcontext *ctx )
Brian Paul4d053dd2000-01-14 04:45:47 +00001542{
Brian Paul4d053dd2000-01-14 04:45:47 +00001543 struct gl_shine_tab *s, *tmps;
Brian Paul7fc29c52000-03-06 17:03:03 +00001544 GLuint i, j;
Brian Paul4d053dd2000-01-14 04:45:47 +00001545
1546 /* if we're destroying the current context, unbind it first */
Brian Paulb1394fa2000-09-26 20:53:53 +00001547 if (ctx == _mesa_get_current_context()) {
1548 _mesa_make_current(NULL, NULL);
Brian Paul4d053dd2000-01-14 04:45:47 +00001549 }
1550
Keith Whitwell23caf202000-11-16 21:05:34 +00001551 _math_matrix_dtr( &ctx->ModelView );
Brian Paul7fc29c52000-03-06 17:03:03 +00001552 for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +00001553 _math_matrix_dtr( &ctx->ModelViewStack[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +00001554 }
Keith Whitwell23caf202000-11-16 21:05:34 +00001555 _math_matrix_dtr( &ctx->ProjectionMatrix );
Brian Paul7fc29c52000-03-06 17:03:03 +00001556 for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +00001557 _math_matrix_dtr( &ctx->ProjectionStack[i] );
Brian Paul4d053dd2000-01-14 04:45:47 +00001558 }
Brian Paul7fc29c52000-03-06 17:03:03 +00001559 for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
Keith Whitwell23caf202000-11-16 21:05:34 +00001560 _math_matrix_dtr( &ctx->TextureMatrix[i] );
Brian Paul7fc29c52000-03-06 17:03:03 +00001561 for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
Keith Whitwell23caf202000-11-16 21:05:34 +00001562 _math_matrix_dtr( &ctx->TextureStack[i][j] );
Brian Paul7fc29c52000-03-06 17:03:03 +00001563 }
1564 }
Brian Paul4d053dd2000-01-14 04:45:47 +00001565
Brian Paul9560f052000-01-31 23:11:39 +00001566 _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
Brian Paul4d053dd2000-01-14 04:45:47 +00001567 ctx->Shared->RefCount--;
Brian Paul9560f052000-01-31 23:11:39 +00001568 assert(ctx->Shared->RefCount >= 0);
1569 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
1570 if (ctx->Shared->RefCount == 0) {
Brian Paul4d053dd2000-01-14 04:45:47 +00001571 /* free shared state */
1572 free_shared_state( ctx, ctx->Shared );
1573 }
1574
Keith Whitwell14940c42000-11-05 18:40:57 +00001575 foreach_s( s, tmps, ctx->_ShineTabList ) {
Brian Paul4d053dd2000-01-14 04:45:47 +00001576 FREE( s );
1577 }
Keith Whitwell14940c42000-11-05 18:40:57 +00001578 FREE( ctx->_ShineTabList );
Brian Paul4d053dd2000-01-14 04:45:47 +00001579
1580 /* Free proxy texture objects */
Brian Paula8523782000-11-19 23:10:25 +00001581 _mesa_free_texture_object( NULL, ctx->Texture.Proxy1D );
1582 _mesa_free_texture_object( NULL, ctx->Texture.Proxy2D );
1583 _mesa_free_texture_object( NULL, ctx->Texture.Proxy3D );
Brian Paul4d053dd2000-01-14 04:45:47 +00001584
1585 /* Free evaluator data */
1586 if (ctx->EvalMap.Map1Vertex3.Points)
1587 FREE( ctx->EvalMap.Map1Vertex3.Points );
1588 if (ctx->EvalMap.Map1Vertex4.Points)
1589 FREE( ctx->EvalMap.Map1Vertex4.Points );
1590 if (ctx->EvalMap.Map1Index.Points)
1591 FREE( ctx->EvalMap.Map1Index.Points );
1592 if (ctx->EvalMap.Map1Color4.Points)
1593 FREE( ctx->EvalMap.Map1Color4.Points );
1594 if (ctx->EvalMap.Map1Normal.Points)
1595 FREE( ctx->EvalMap.Map1Normal.Points );
1596 if (ctx->EvalMap.Map1Texture1.Points)
1597 FREE( ctx->EvalMap.Map1Texture1.Points );
1598 if (ctx->EvalMap.Map1Texture2.Points)
1599 FREE( ctx->EvalMap.Map1Texture2.Points );
1600 if (ctx->EvalMap.Map1Texture3.Points)
1601 FREE( ctx->EvalMap.Map1Texture3.Points );
1602 if (ctx->EvalMap.Map1Texture4.Points)
1603 FREE( ctx->EvalMap.Map1Texture4.Points );
1604
1605 if (ctx->EvalMap.Map2Vertex3.Points)
1606 FREE( ctx->EvalMap.Map2Vertex3.Points );
1607 if (ctx->EvalMap.Map2Vertex4.Points)
1608 FREE( ctx->EvalMap.Map2Vertex4.Points );
1609 if (ctx->EvalMap.Map2Index.Points)
1610 FREE( ctx->EvalMap.Map2Index.Points );
1611 if (ctx->EvalMap.Map2Color4.Points)
1612 FREE( ctx->EvalMap.Map2Color4.Points );
1613 if (ctx->EvalMap.Map2Normal.Points)
1614 FREE( ctx->EvalMap.Map2Normal.Points );
1615 if (ctx->EvalMap.Map2Texture1.Points)
1616 FREE( ctx->EvalMap.Map2Texture1.Points );
1617 if (ctx->EvalMap.Map2Texture2.Points)
1618 FREE( ctx->EvalMap.Map2Texture2.Points );
1619 if (ctx->EvalMap.Map2Texture3.Points)
1620 FREE( ctx->EvalMap.Map2Texture3.Points );
1621 if (ctx->EvalMap.Map2Texture4.Points)
1622 FREE( ctx->EvalMap.Map2Texture4.Points );
1623
Brian Paul4bdcfe52000-04-17 17:57:04 +00001624 _mesa_free_colortable_data( &ctx->ColorTable );
1625 _mesa_free_colortable_data( &ctx->PostConvolutionColorTable );
1626 _mesa_free_colortable_data( &ctx->PostColorMatrixColorTable );
1627 _mesa_free_colortable_data( &ctx->Texture.Palette );
1628
Brian Paul4d053dd2000-01-14 04:45:47 +00001629 gl_extensions_dtr(ctx);
Brian Paul3ab6bbe2000-02-12 17:26:15 +00001630
1631 FREE(ctx->Exec);
1632 FREE(ctx->Save);
Brian Paul4d053dd2000-01-14 04:45:47 +00001633}
1634
1635
1636
1637/*
1638 * Destroy a GLcontext structure.
jtgafb833d1999-08-19 00:55:39 +00001639 */
Brian Paul178a1c52000-04-22 01:05:00 +00001640void
Brian Paulb1394fa2000-09-26 20:53:53 +00001641_mesa_destroy_context( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +00001642{
1643 if (ctx) {
Brian Paulb1394fa2000-09-26 20:53:53 +00001644 _mesa_free_context_data(ctx);
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001645 FREE( (void *) ctx );
jtgafb833d1999-08-19 00:55:39 +00001646 }
1647}
1648
1649
1650
1651/*
Brian Paul4d053dd2000-01-14 04:45:47 +00001652 * Called by the driver after both the context and driver are fully
1653 * initialized. Currently just reads the config file.
jtgafb833d1999-08-19 00:55:39 +00001654 */
Brian Paul178a1c52000-04-22 01:05:00 +00001655void
Brian Paulb1394fa2000-09-26 20:53:53 +00001656_mesa_context_initialize( GLcontext *ctx )
jtgafb833d1999-08-19 00:55:39 +00001657{
Brian Paul00037781999-12-17 14:52:35 +00001658 gl_read_config_file( ctx );
jtgafb833d1999-08-19 00:55:39 +00001659}
1660
1661
1662
1663/*
1664 * Copy attribute groups from one context to another.
1665 * Input: src - source context
1666 * dst - destination context
1667 * mask - bitwise OR of GL_*_BIT flags
1668 */
Brian Paul178a1c52000-04-22 01:05:00 +00001669void
Brian Paulb1394fa2000-09-26 20:53:53 +00001670_mesa_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask )
jtgafb833d1999-08-19 00:55:39 +00001671{
1672 if (mask & GL_ACCUM_BUFFER_BIT) {
1673 MEMCPY( &dst->Accum, &src->Accum, sizeof(struct gl_accum_attrib) );
1674 }
1675 if (mask & GL_COLOR_BUFFER_BIT) {
1676 MEMCPY( &dst->Color, &src->Color, sizeof(struct gl_colorbuffer_attrib) );
1677 }
1678 if (mask & GL_CURRENT_BIT) {
1679 MEMCPY( &dst->Current, &src->Current, sizeof(struct gl_current_attrib) );
1680 }
1681 if (mask & GL_DEPTH_BUFFER_BIT) {
1682 MEMCPY( &dst->Depth, &src->Depth, sizeof(struct gl_depthbuffer_attrib) );
1683 }
1684 if (mask & GL_ENABLE_BIT) {
1685 /* no op */
1686 }
1687 if (mask & GL_EVAL_BIT) {
1688 MEMCPY( &dst->Eval, &src->Eval, sizeof(struct gl_eval_attrib) );
1689 }
1690 if (mask & GL_FOG_BIT) {
1691 MEMCPY( &dst->Fog, &src->Fog, sizeof(struct gl_fog_attrib) );
1692 }
1693 if (mask & GL_HINT_BIT) {
1694 MEMCPY( &dst->Hint, &src->Hint, sizeof(struct gl_hint_attrib) );
1695 }
1696 if (mask & GL_LIGHTING_BIT) {
1697 MEMCPY( &dst->Light, &src->Light, sizeof(struct gl_light_attrib) );
Brian Paul00037781999-12-17 14:52:35 +00001698 /* gl_reinit_light_attrib( &dst->Light ); */
jtgafb833d1999-08-19 00:55:39 +00001699 }
1700 if (mask & GL_LINE_BIT) {
1701 MEMCPY( &dst->Line, &src->Line, sizeof(struct gl_line_attrib) );
1702 }
1703 if (mask & GL_LIST_BIT) {
1704 MEMCPY( &dst->List, &src->List, sizeof(struct gl_list_attrib) );
1705 }
1706 if (mask & GL_PIXEL_MODE_BIT) {
1707 MEMCPY( &dst->Pixel, &src->Pixel, sizeof(struct gl_pixel_attrib) );
1708 }
1709 if (mask & GL_POINT_BIT) {
1710 MEMCPY( &dst->Point, &src->Point, sizeof(struct gl_point_attrib) );
1711 }
1712 if (mask & GL_POLYGON_BIT) {
1713 MEMCPY( &dst->Polygon, &src->Polygon, sizeof(struct gl_polygon_attrib) );
1714 }
1715 if (mask & GL_POLYGON_STIPPLE_BIT) {
1716 /* Use loop instead of MEMCPY due to problem with Portland Group's
1717 * C compiler. Reported by John Stone.
1718 */
1719 int i;
1720 for (i=0;i<32;i++) {
1721 dst->PolygonStipple[i] = src->PolygonStipple[i];
1722 }
1723 }
1724 if (mask & GL_SCISSOR_BIT) {
1725 MEMCPY( &dst->Scissor, &src->Scissor, sizeof(struct gl_scissor_attrib) );
1726 }
1727 if (mask & GL_STENCIL_BUFFER_BIT) {
1728 MEMCPY( &dst->Stencil, &src->Stencil, sizeof(struct gl_stencil_attrib) );
1729 }
1730 if (mask & GL_TEXTURE_BIT) {
1731 MEMCPY( &dst->Texture, &src->Texture, sizeof(struct gl_texture_attrib) );
1732 }
1733 if (mask & GL_TRANSFORM_BIT) {
1734 MEMCPY( &dst->Transform, &src->Transform, sizeof(struct gl_transform_attrib) );
1735 }
1736 if (mask & GL_VIEWPORT_BIT) {
1737 MEMCPY( &dst->Viewport, &src->Viewport, sizeof(struct gl_viewport_attrib) );
1738 }
Keith Whitwella96308c2000-10-30 13:31:59 +00001739 /* XXX FIXME: Call callbacks?
1740 */
1741 dst->NewState = _NEW_ALL;
jtgafb833d1999-08-19 00:55:39 +00001742}
1743
1744
jtgafb833d1999-08-19 00:55:39 +00001745/*
Brian Paul00037781999-12-17 14:52:35 +00001746 * Set the current context, binding the given frame buffer to the context.
1747 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001748void
1749_mesa_make_current( GLcontext *newCtx, GLframebuffer *buffer )
Brian Paul00037781999-12-17 14:52:35 +00001750{
Brian Paulb1394fa2000-09-26 20:53:53 +00001751 _mesa_make_current2( newCtx, buffer, buffer );
Brian Paul00037781999-12-17 14:52:35 +00001752}
1753
1754
Keith Whitwell23caf202000-11-16 21:05:34 +00001755static void print_info( void )
1756{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001757 fprintf(stderr, "Mesa GL_VERSION = %s\n",
Keith Whitwell23caf202000-11-16 21:05:34 +00001758 (char *) _mesa_GetString(GL_VERSION));
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001759 fprintf(stderr, "Mesa GL_RENDERER = %s\n",
Keith Whitwell23caf202000-11-16 21:05:34 +00001760 (char *) _mesa_GetString(GL_RENDERER));
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001761 fprintf(stderr, "Mesa GL_VENDOR = %s\n",
Keith Whitwell23caf202000-11-16 21:05:34 +00001762 (char *) _mesa_GetString(GL_VENDOR));
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001763 fprintf(stderr, "Mesa GL_EXTENSIONS = %s\n",
Keith Whitwell23caf202000-11-16 21:05:34 +00001764 (char *) _mesa_GetString(GL_EXTENSIONS));
1765#if defined(THREADS)
1766 fprintf(stderr, "Mesa thread-safe: YES\n");
1767#else
1768 fprintf(stderr, "Mesa thread-safe: NO\n");
1769#endif
1770#if defined(USE_X86_ASM)
1771 fprintf(stderr, "Mesa x86-optimized: YES\n");
1772#else
1773 fprintf(stderr, "Mesa x86-optimized: NO\n");
1774#endif
1775}
1776
1777
Brian Paul00037781999-12-17 14:52:35 +00001778/*
1779 * Bind the given context to the given draw-buffer and read-buffer
1780 * and make it the current context for this thread.
1781 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001782void
1783_mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
1784 GLframebuffer *readBuffer )
Brian Paul00037781999-12-17 14:52:35 +00001785{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001786 if (MESA_VERBOSE)
Keith Whitwell23caf202000-11-16 21:05:34 +00001787 fprintf(stderr, "_mesa_make_current2()\n");
Brian Paul00037781999-12-17 14:52:35 +00001788
1789 /* We call this function periodically (just here for now) in
1790 * order to detect when multithreading has begun.
1791 */
1792 _glapi_check_multithread();
1793
Brian Paulf9b97d92000-01-28 20:17:42 +00001794 _glapi_set_context((void *) newCtx);
Brian Paulb1394fa2000-09-26 20:53:53 +00001795 ASSERT(_mesa_get_current_context() == newCtx);
Keith Whitwell23caf202000-11-16 21:05:34 +00001796
1797
1798 if (!newCtx) {
Brian Paul00037781999-12-17 14:52:35 +00001799 _glapi_set_dispatch(NULL); /* none current */
1800 }
Keith Whitwell23caf202000-11-16 21:05:34 +00001801 else {
1802 _glapi_set_dispatch(newCtx->CurrentDispatch);
Brian Paul00037781999-12-17 14:52:35 +00001803
Keith Whitwell23caf202000-11-16 21:05:34 +00001804 if (drawBuffer && readBuffer) {
1805 /* TODO: check if newCtx and buffer's visual match??? */
1806 newCtx->DrawBuffer = drawBuffer;
1807 newCtx->ReadBuffer = readBuffer;
1808 newCtx->NewState |= _NEW_BUFFERS;
1809 /* gl_update_state( newCtx ); */
Brian Paul00037781999-12-17 14:52:35 +00001810 }
Keith Whitwell23caf202000-11-16 21:05:34 +00001811
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001812 if (newCtx->Driver.MakeCurrent)
Keith Whitwell23caf202000-11-16 21:05:34 +00001813 newCtx->Driver.MakeCurrent( newCtx, drawBuffer, readBuffer );
1814
1815 /* We can use this to help debug user's problems. Tell them to set
1816 * the MESA_INFO env variable before running their app. Then the
1817 * first time each context is made current we'll print some useful
1818 * information.
1819 */
1820 if (newCtx->FirstTimeCurrent) {
1821 if (getenv("MESA_INFO")) {
1822 print_info();
1823 }
1824 newCtx->FirstTimeCurrent = GL_FALSE;
1825 }
Brian Paul00037781999-12-17 14:52:35 +00001826 }
1827}
1828
1829
1830
1831/*
1832 * Return current context handle for the calling thread.
1833 * This isn't the fastest way to get the current context.
1834 * If you need speed, see the GET_CURRENT_CONTEXT() macro in context.h
1835 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001836GLcontext *
1837_mesa_get_current_context( void )
Brian Paul00037781999-12-17 14:52:35 +00001838{
Brian Paulf9b97d92000-01-28 20:17:42 +00001839 return (GLcontext *) _glapi_get_context();
Brian Paul00037781999-12-17 14:52:35 +00001840}
1841
1842
1843
1844/*
Brian Paulfbd8f211999-11-11 01:22:25 +00001845 * This should be called by device drivers just before they do a
1846 * swapbuffers. Any pending rendering commands will be executed.
jtgafb833d1999-08-19 00:55:39 +00001847 */
Brian Paulfbd8f211999-11-11 01:22:25 +00001848void
1849_mesa_swapbuffers(GLcontext *ctx)
jtgafb833d1999-08-19 00:55:39 +00001850{
Keith Whitwell23caf202000-11-16 21:05:34 +00001851 FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
jtgafb833d1999-08-19 00:55:39 +00001852}
1853
1854
Brian Paul00037781999-12-17 14:52:35 +00001855
Brian Paulfbd8f211999-11-11 01:22:25 +00001856/*
1857 * Return pointer to this context's current API dispatch table.
1858 * It'll either be the immediate-mode execute dispatcher or the
1859 * display list compile dispatcher.
1860 */
1861struct _glapi_table *
1862_mesa_get_dispatch(GLcontext *ctx)
1863{
1864 return ctx->CurrentDispatch;
1865}
1866
1867
1868
jtgafb833d1999-08-19 00:55:39 +00001869/**********************************************************************/
1870/***** Miscellaneous functions *****/
1871/**********************************************************************/
1872
1873
1874/*
1875 * This function is called when the Mesa user has stumbled into a code
1876 * path which may not be implemented fully or correctly.
1877 */
1878void gl_problem( const GLcontext *ctx, const char *s )
1879{
1880 fprintf( stderr, "Mesa implementation error: %s\n", s );
Brian Paul413d6a22000-05-26 14:44:59 +00001881 fprintf( stderr, "Report to Mesa bug database at www.mesa3d.org\n" );
jtgafb833d1999-08-19 00:55:39 +00001882 (void) ctx;
1883}
1884
1885
1886
1887/*
1888 * This is called to inform the user that he or she has tried to do
1889 * something illogical or if there's likely a bug in their program
1890 * (like enabled depth testing without a depth buffer).
1891 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001892void
1893_mesa_warning( const GLcontext *ctx, const char *s )
jtgafb833d1999-08-19 00:55:39 +00001894{
Brian Paulb1394fa2000-09-26 20:53:53 +00001895 (*ctx->imports.warning)((__GLcontext *) ctx, (char *) s);
jtgafb833d1999-08-19 00:55:39 +00001896}
1897
1898
1899
Brian Paulfa9df402000-02-02 19:16:46 +00001900/*
1901 * Compile an error into current display list.
1902 */
Brian Paulb1394fa2000-09-26 20:53:53 +00001903void
1904_mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
jtgafb833d1999-08-19 00:55:39 +00001905{
1906 if (ctx->CompileFlag)
1907 gl_save_error( ctx, error, s );
1908
1909 if (ctx->ExecuteFlag)
1910 gl_error( ctx, error, s );
1911}
1912
1913
Brian Paulfa9df402000-02-02 19:16:46 +00001914
jtgafb833d1999-08-19 00:55:39 +00001915/*
1916 * This is Mesa's error handler. Normally, all that's done is the updating
1917 * of the current error value. If Mesa is compiled with -DDEBUG or if the
1918 * environment variable "MESA_DEBUG" is defined then a real error message
1919 * is printed to stderr.
Brian Paul7eb06032000-07-14 04:13:40 +00001920 * Input: ctx - the GL context
1921 * error - the error value
1922 * where - usually the name of function where error was detected
jtgafb833d1999-08-19 00:55:39 +00001923 */
Brian Paul7eb06032000-07-14 04:13:40 +00001924void
1925gl_error( GLcontext *ctx, GLenum error, const char *where )
jtgafb833d1999-08-19 00:55:39 +00001926{
Brian Paul7eb06032000-07-14 04:13:40 +00001927 const char *debugEnv = getenv("MESA_DEBUG");
jtgafb833d1999-08-19 00:55:39 +00001928 GLboolean debug;
1929
1930#ifdef DEBUG
Brian Paul7eb06032000-07-14 04:13:40 +00001931 if (debugEnv && strstr(debugEnv, "silent"))
jtgafb833d1999-08-19 00:55:39 +00001932 debug = GL_FALSE;
Brian Paul7eb06032000-07-14 04:13:40 +00001933 else
1934 debug = GL_TRUE;
1935#else
1936 if (debugEnv)
1937 debug = GL_TRUE;
1938 else
1939 debug = GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001940#endif
1941
1942 if (debug) {
Brian Paul7eb06032000-07-14 04:13:40 +00001943 const char *errstr;
jtgafb833d1999-08-19 00:55:39 +00001944 switch (error) {
1945 case GL_NO_ERROR:
Brian Paul7eb06032000-07-14 04:13:40 +00001946 errstr = "GL_NO_ERROR";
jtgafb833d1999-08-19 00:55:39 +00001947 break;
1948 case GL_INVALID_VALUE:
Brian Paul7eb06032000-07-14 04:13:40 +00001949 errstr = "GL_INVALID_VALUE";
jtgafb833d1999-08-19 00:55:39 +00001950 break;
1951 case GL_INVALID_ENUM:
Brian Paul7eb06032000-07-14 04:13:40 +00001952 errstr = "GL_INVALID_ENUM";
jtgafb833d1999-08-19 00:55:39 +00001953 break;
1954 case GL_INVALID_OPERATION:
Brian Paul7eb06032000-07-14 04:13:40 +00001955 errstr = "GL_INVALID_OPERATION";
jtgafb833d1999-08-19 00:55:39 +00001956 break;
1957 case GL_STACK_OVERFLOW:
Brian Paul7eb06032000-07-14 04:13:40 +00001958 errstr = "GL_STACK_OVERFLOW";
jtgafb833d1999-08-19 00:55:39 +00001959 break;
1960 case GL_STACK_UNDERFLOW:
Brian Paul7eb06032000-07-14 04:13:40 +00001961 errstr = "GL_STACK_UNDERFLOW";
jtgafb833d1999-08-19 00:55:39 +00001962 break;
1963 case GL_OUT_OF_MEMORY:
Brian Paul7eb06032000-07-14 04:13:40 +00001964 errstr = "GL_OUT_OF_MEMORY";
jtgafb833d1999-08-19 00:55:39 +00001965 break;
Brian Paul86586aa2000-06-29 18:55:52 +00001966 case GL_TABLE_TOO_LARGE:
Brian Paul7eb06032000-07-14 04:13:40 +00001967 errstr = "GL_TABLE_TOO_LARGE";
Brian Paul86586aa2000-06-29 18:55:52 +00001968 break;
jtgafb833d1999-08-19 00:55:39 +00001969 default:
Brian Paul7eb06032000-07-14 04:13:40 +00001970 errstr = "unknown";
jtgafb833d1999-08-19 00:55:39 +00001971 break;
1972 }
Brian Paul7eb06032000-07-14 04:13:40 +00001973 fprintf(stderr, "Mesa user error: %s in %s\n", errstr, where);
jtgafb833d1999-08-19 00:55:39 +00001974 }
1975
Brian Paul7eb06032000-07-14 04:13:40 +00001976 if (ctx->ErrorValue == GL_NO_ERROR) {
jtgafb833d1999-08-19 00:55:39 +00001977 ctx->ErrorValue = error;
1978 }
1979
1980 /* Call device driver's error handler, if any. This is used on the Mac. */
1981 if (ctx->Driver.Error) {
1982 (*ctx->Driver.Error)( ctx );
1983 }
1984}
1985
1986
1987
Brian Paulfa9df402000-02-02 19:16:46 +00001988void
1989_mesa_Finish( void )
jtgafb833d1999-08-19 00:55:39 +00001990{
Brian Paulfa9df402000-02-02 19:16:46 +00001991 GET_CURRENT_CONTEXT(ctx);
1992 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glFinish");
1993 if (ctx->Driver.Finish) {
1994 (*ctx->Driver.Finish)( ctx );
jtgafb833d1999-08-19 00:55:39 +00001995 }
1996}
1997
1998
1999
Brian Paulfa9df402000-02-02 19:16:46 +00002000void
2001_mesa_Flush( void )
jtgafb833d1999-08-19 00:55:39 +00002002{
Brian Paulfa9df402000-02-02 19:16:46 +00002003 GET_CURRENT_CONTEXT(ctx);
2004 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glFlush");
2005 if (ctx->Driver.Flush) {
2006 (*ctx->Driver.Flush)( ctx );
jtgafb833d1999-08-19 00:55:39 +00002007 }
jtgafb833d1999-08-19 00:55:39 +00002008}
Brian Paul48c6a6e2000-09-08 21:28:04 +00002009
2010
2011
2012const char *_mesa_prim_name[GL_POLYGON+2] = {
2013 "GL_POINTS",
2014 "GL_LINES",
2015 "GL_LINE_LOOP",
2016 "GL_LINE_STRIP",
2017 "GL_TRIANGLES",
2018 "GL_TRIANGLE_STRIP",
2019 "GL_TRIANGLE_FAN",
2020 "GL_QUADS",
2021 "GL_QUAD_STRIP",
2022 "GL_POLYGON",
2023 "culled primitive"
2024};
2025
Brian Paul1c56fdc2000-09-17 21:56:07 +00002026
2027GLenum gl_reduce_prim[GL_POLYGON+1] = {
2028 GL_POINTS,
2029 GL_LINES,
2030 GL_LINES,
2031 GL_LINES,
2032 GL_TRIANGLES,
2033 GL_TRIANGLES,
2034 GL_TRIANGLES,
2035 GL_TRIANGLES,
2036 GL_TRIANGLES,
2037 GL_TRIANGLES,
Gareth Hughesfc2427e2000-10-23 00:16:28 +00002038};