fix GL_BACK color material bug
[mesa.git] / src / mesa / main / context.c
index cb463003c8b58f966373fdb6117c41e06d46b1fd..1fa5fb838134a06fa1de247a821db9b8e24c35d5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.67 2000/05/23 20:10:49 brianp Exp $ */
+/* $Id: context.c,v 1.70 2000/05/26 14:44:59 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -467,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)
@@ -479,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;
    }
@@ -603,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;
 }
 
 
@@ -1341,6 +1352,8 @@ _mesa_initialize_context( GLcontext *ctx,
                           void *driver_ctx,
                           GLboolean direct )
 {
+   GLuint dispatchSize;
+
    (void) direct;  /* not used */
 
    /* misc one-time initializations */
@@ -1411,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);
@@ -1422,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;
@@ -1815,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;
 }