Support ARB_texture_env_crossbar. Changes the way programs are
[mesa.git] / src / mesa / main / occlude.c
index c8fa1dfacd85d0c8238037916bd2de9697a9eaa5..bc61a475d663e2b679fcf7f75fe6622d0b1748cc 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
+ * Version:  6.0.2
  *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2004  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"),
 #include "occlude.h"
 #include "mtypes.h"
 
-#ifndef GL_SAMPLES_PASSED_ARB
-#define GL_SAMPLES_PASSED_ARB         0x8914
-#define GL_QUERY_COUNTER_BITS_ARB     0x8864
-#define GL_CURRENT_QUERY_ARB          0x8865
-#define GL_QUERY_RESULT_ARB           0x8866
-#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
-#endif
-
 
 struct occlusion_query
 {
@@ -53,20 +45,6 @@ struct occlusion_query
 };
 
 
-
-void
-_mesa_init_occlude(GLcontext *ctx)
-{
-#if FEATURE_ARB_occlusion_query
-   ctx->Occlusion.QueryObjects = _mesa_NewHashTable();
-#endif
-
-   ctx->OcclusionResult = GL_FALSE;
-   ctx->OcclusionResultSaved = GL_FALSE;
-}
-
-
-
 /**
  * Allocate a new occlusion query object.
  * \param target - must be GL_SAMPLES_PASSED_ARB at this time
@@ -188,6 +166,11 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
       return;
    }
 
+   if (id == 0) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(id==0)");
+      return;
+   }
+
    if (ctx->Occlusion.CurrentQueryObject) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(target)");
       return;
@@ -330,3 +313,41 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
          return;
    }
 }
+
+
+
+/**
+ * Allocate/init the context state related to occlusion query objects.
+ */
+void
+_mesa_init_occlude(GLcontext *ctx)
+{
+#if FEATURE_ARB_occlusion_query
+   ctx->Occlusion.QueryObjects = _mesa_NewHashTable();
+#endif
+   ctx->OcclusionResult = GL_FALSE;
+   ctx->OcclusionResultSaved = GL_FALSE;
+}
+
+
+/**
+ * Free the context state related to occlusion query objects.
+ */
+void
+_mesa_free_occlude_data(GLcontext *ctx)
+{
+   while (1) {
+      GLuint query = _mesa_HashFirstEntry(ctx->Occlusion.QueryObjects);
+      if (query) {
+         struct occlusion_query *q = (struct occlusion_query *)
+            _mesa_HashLookup(ctx->Occlusion.QueryObjects, query);
+         ASSERT(q);
+         delete_query_object(q);
+         _mesa_HashRemove(ctx->Occlusion.QueryObjects, query);
+      }
+      else {
+         break;
+      }
+   }
+   _mesa_DeleteHashTable(ctx->Occlusion.QueryObjects);
+}