fix for-loop in _mesa_GetDouble to avoid out of bounds memory read
[mesa.git] / src / mesa / main / depth.c
index 8d61ff4126cff41b94c78c00a4626e7a99964148..aca471a06c876d965c7acaf0f5b42b53995205e6 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.3
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -39,7 +39,7 @@
 
 
 
-void
+void GLAPIENTRY
 _mesa_ClearDepth( GLclampd depth )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -58,7 +58,7 @@ _mesa_ClearDepth( GLclampd depth )
 
 
 
-void
+void GLAPIENTRY
 _mesa_DepthFunc( GLenum func )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -94,7 +94,7 @@ _mesa_DepthFunc( GLenum func )
 
 
 
-void
+void GLAPIENTRY
 _mesa_DepthMask( GLboolean flag )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -119,8 +119,10 @@ _mesa_DepthMask( GLboolean flag )
 
 
 
-/* GL_EXT_depth_bounds_test */
-void
+/**
+ * Specified by the GL_EXT_depth_bounds_test extension.
+ */
+void GLAPIENTRY
 _mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -147,6 +149,10 @@ _mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
 /*****                      Initialization                        *****/
 /**********************************************************************/
 
+
+/**
+ * Initialize the depth buffer attribute group in the given context.
+ */
 void _mesa_init_depth( GLcontext * ctx )
 {
    /* Depth buffer group */
@@ -156,13 +162,15 @@ void _mesa_init_depth( GLcontext * ctx )
    ctx->Depth.Mask = GL_TRUE;
    ctx->Depth.OcclusionTest = GL_FALSE;
 
+   /* XXX this is now per-framebuffer state */
+#if 00
    /* Z buffer stuff */
    if (ctx->Visual.depthBits == 0) {
       /* Special case.  Even if we don't have a depth buffer we need
        * good values for DepthMax for Z vertex transformation purposes
        * and for per-fragment fog computation.
        */
-      ctx->DepthMax = 1 << 16;
+      ctx->DepthMax = (1 << 16) - 1;
       ctx->DepthMaxF = (GLfloat) ctx->DepthMax;
    }
    else if (ctx->Visual.depthBits < 32) {
@@ -177,10 +185,5 @@ void _mesa_init_depth( GLcontext * ctx )
       ctx->DepthMaxF = (GLfloat) ctx->DepthMax;
    }
    ctx->MRD = 1.0;  /* Minimum resolvable depth value, for polygon offset */
-
-#if FEATURE_ARB_occlusion_query
-   ctx->Occlusion.QueryObjects = _mesa_NewHashTable();
 #endif
-   ctx->OcclusionResult = GL_FALSE;
-   ctx->OcclusionResultSaved = GL_FALSE;
 }