};
+
+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
}
-void
+void GLAPIENTRY
_mesa_GenQueriesARB(GLsizei n, GLuint *ids)
{
GET_CURRENT_CONTEXT(ctx);
first = _mesa_HashFindFreeKeyBlock(ctx->Occlusion.QueryObjects, n);
if (first) {
- GLuint i;
+ GLsizei i;
for (i = 0; i < n; i++) {
struct occlusion_query *q = new_query_object(GL_SAMPLES_PASSED_ARB,
first + i);
}
-void
+void GLAPIENTRY
_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids)
{
GET_CURRENT_CONTEXT(ctx);
}
-GLboolean
+GLboolean GLAPIENTRY
_mesa_IsQueryARB(GLuint id)
{
GET_CURRENT_CONTEXT(ctx);
}
-void
+void GLAPIENTRY
_mesa_BeginQueryARB(GLenum target, GLuint id)
{
GET_CURRENT_CONTEXT(ctx);
}
-void
+void GLAPIENTRY
_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_problem(ctx, "bad query object in glEndQueryARB");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glEndQuery with no glBeginQuery");
return;
}
}
-void
+void GLAPIENTRY
_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
}
-void
+void GLAPIENTRY
_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;
}
}
-void
+void GLAPIENTRY
_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;
}