fix GL_BACK color material bug
[mesa.git] / src / mesa / main / context.c
index 14446130c1b7782624d526b0b084934838c9940c..1fa5fb838134a06fa1de247a821db9b8e24c35d5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.64 2000/05/07 20:41:30 brianp Exp $ */
+/* $Id: context.c,v 1.70 2000/05/26 14:44:59 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -216,10 +216,18 @@ _mesa_initialize_visual( GLvisual *vis,
       vis->DepthMax = 1;
       vis->DepthMaxF = 1.0F;
    }
-   else {
+   else if (depthBits < 32) {
       vis->DepthMax = (1 << depthBits) - 1;
       vis->DepthMaxF = (GLfloat) vis->DepthMax;
    }
+   else {
+      /* Special case since shift values greater than or equal to the
+       * number of bits in the left hand expression's type are
+       * undefined.
+       */
+      vis->DepthMax = 0xffffffff;
+      vis->DepthMaxF = (GLfloat) vis->DepthMax;
+   }
 
    return GL_TRUE;
 }
@@ -459,6 +467,14 @@ alloc_shared_state( void )
       ss->DefaultD[d]->RefCount++; /* don't free if not in use */
    }
 
+   ss->DefaultCubeMap = gl_alloc_texture_object(ss, 0, 6);
+   if (!ss->DefaultCubeMap) {
+      outOfMemory = GL_TRUE;
+   }
+   else {
+      ss->DefaultCubeMap->RefCount++;
+   }
+
    if (!ss->DisplayList || !ss->TexObjects || outOfMemory) {
       /* Ran out of memory at some point.  Free everything and return NULL */
       if (ss->DisplayList)
@@ -471,6 +487,8 @@ alloc_shared_state( void )
          gl_free_texture_object(ss, ss->DefaultD[2]);
       if (ss->DefaultD[3])
          gl_free_texture_object(ss, ss->DefaultD[3]);
+      if (ss->DefaultCubeMap)
+         gl_free_texture_object(ss, ss->DefaultCubeMap);
       FREE(ss);
       return NULL;
    }
@@ -595,6 +613,7 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
    texUnit->CurrentD[1] = ctx->Shared->DefaultD[1];
    texUnit->CurrentD[2] = ctx->Shared->DefaultD[2];
    texUnit->CurrentD[3] = ctx->Shared->DefaultD[3];
+   texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
 }
 
 
@@ -696,6 +715,7 @@ init_attrib_groups( GLcontext *ctx )
    /* Constants, may be overriden by device drivers */
    ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
    ctx->Const.MaxTextureSize = 1 << (MAX_TEXTURE_LEVELS - 1);
+   ctx->Const.MaxCubeTextureSize = ctx->Const.MaxTextureSize;
    ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS;
    ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
    ctx->Const.SubPixelBits = SUB_PIXEL_BITS;
@@ -713,6 +733,7 @@ init_attrib_groups( GLcontext *ctx )
    ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE;
    ctx->Const.MaxConvolutionWidth = MAX_CONVOLUTION_WIDTH;
    ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT;
+   ctx->Const.NumCompressedTextureFormats = 0;
 
    /* Modelview matrix */
    gl_matrix_ctr( &ctx->ModelView );
@@ -891,11 +912,12 @@ init_attrib_groups( GLcontext *ctx )
    ctx->Hint.LineSmooth = GL_DONT_CARE;
    ctx->Hint.PolygonSmooth = GL_DONT_CARE;
    ctx->Hint.Fog = GL_DONT_CARE;
-
    ctx->Hint.AllowDrawWin = GL_TRUE;
    ctx->Hint.AllowDrawFrg = GL_TRUE;
    ctx->Hint.AllowDrawMem = GL_TRUE;
    ctx->Hint.StrictLighting = GL_TRUE;
+   ctx->Hint.ClipVolumeClipping = GL_DONT_CARE;
+   ctx->Hint.TextureCompression = GL_DONT_CARE;
 
    /* Histogram group */
    ctx->Histogram.Width = 0;
@@ -1330,6 +1352,8 @@ _mesa_initialize_context( GLcontext *ctx,
                           void *driver_ctx,
                           GLboolean direct )
 {
+   GLuint dispatchSize;
+
    (void) direct;  /* not used */
 
    /* misc one-time initializations */
@@ -1400,9 +1424,27 @@ _mesa_initialize_context( GLcontext *ctx,
       return GL_FALSE;
    }
 
+   /* register the most recent extension functions with libGL */
+   _glapi_add_entrypoint("glTbufferMask3DFX", 553);
+   _glapi_add_entrypoint("glCompressedTexImage3DARB", 554);
+   _glapi_add_entrypoint("glCompressedTexImage2DARB", 555);
+   _glapi_add_entrypoint("glCompressedTexImage1DARB", 556);
+   _glapi_add_entrypoint("glCompressedTexSubImage3DARB", 557);
+   _glapi_add_entrypoint("glCompressedTexSubImage2DARB", 558);
+   _glapi_add_entrypoint("glCompressedTexSubImage1DARB", 559);
+   _glapi_add_entrypoint("glGetCompressedTexImageARB", 560);
+
+   /* Find the larger of Mesa's dispatch table and libGL's dispatch table.
+    * In practice, this'll be the same for stand-alone Mesa.  But for DRI
+    * Mesa we do this to accomodate different versions of libGL and various
+    * DRI drivers.
+    */
+   dispatchSize = MAX2(_glapi_get_dispatch_table_size(),
+                       sizeof(struct _glapi_table) / sizeof(void *));
+
    /* setup API dispatch tables */
-   ctx->Exec = (struct _glapi_table *) CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *));
-   ctx->Save = (struct _glapi_table *) CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *));
+   ctx->Exec = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
+   ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
    if (!ctx->Exec || !ctx->Save) {
       free_shared_state(ctx, ctx->Shared);
       FREE(ctx->VB);
@@ -1411,8 +1453,8 @@ _mesa_initialize_context( GLcontext *ctx,
          FREE(ctx->Exec);
       FREE(ctx);
    }
-   _mesa_init_exec_table( ctx->Exec );
-   _mesa_init_dlist_table( ctx->Save );
+   _mesa_init_exec_table(ctx->Exec, dispatchSize);
+   _mesa_init_dlist_table(ctx->Save, dispatchSize);
    ctx->CurrentDispatch = ctx->Exec;
 
    return GL_TRUE;
@@ -1804,7 +1846,7 @@ _mesa_get_dispatch(GLcontext *ctx)
 void gl_problem( const GLcontext *ctx, const char *s )
 {
    fprintf( stderr, "Mesa implementation error: %s\n", s );
-   fprintf( stderr, "Report to mesa-bugs@mesa3d.org\n" );
+   fprintf( stderr, "Report to Mesa bug database at www.mesa3d.org\n" );
    (void) ctx;
 }