/*
* 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
{
};
-
-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
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;
_mesa_EndQueryARB(GLenum target)
{
GET_CURRENT_CONTEXT(ctx);
- struct occlusion_query *q;
+ struct occlusion_query *q = NULL;
ASSERT_OUTSIDE_BEGIN_END(ctx);
FLUSH_VERTICES(ctx, _NEW_DEPTH);
return;
}
- q = (struct occlusion_query *)
- _mesa_HashLookup(ctx->Occlusion.QueryObjects,
- ctx->Occlusion.CurrentQueryObject);
+ if (ctx->Occlusion.CurrentQueryObject)
+ q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects,
+ ctx->Occlusion.CurrentQueryObject);
if (!q || !q->Active) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glEndQuery with glBeginQuery");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glEndQuery with no glBeginQuery");
return;
}
_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
- struct occlusion_query *q;
+ struct occlusion_query *q = NULL;
ASSERT_OUTSIDE_BEGIN_END(ctx);
- q = (struct occlusion_query *)
- _mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
+ if (id)
+ q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
+
if (!q || q->Active) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectivARB");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectivARB(id=%d)", id);
return;
}
_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
{
GET_CURRENT_CONTEXT(ctx);
- struct occlusion_query *q;
+ struct occlusion_query *q = NULL;
ASSERT_OUTSIDE_BEGIN_END(ctx);
- q = (struct occlusion_query *)
- _mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
+ if (id)
+ q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
if (!q || q->Active) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectuivARB");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectuivARB(id=%d", id);
return;
}
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);
+}