From df27d0f83e55a0ed7b41a2bd0dce7c7534a0863b Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 6 Nov 2008 01:11:46 -0800 Subject: [PATCH] Add occlusion query test. --- src/Makefile.am | 2 + src/Makefile.in | 17 ++++++++------ src/gl_occlusion_query.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ src/gl_occlusion_query.h | 27 ++++++++++++++++++++++ src/revenge_test.c | 2 + 5 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 src/gl_occlusion_query.c create mode 100644 src/gl_occlusion_query.h diff --git a/src/Makefile.am b/src/Makefile.am index 756de9d..75757cd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,6 +33,8 @@ revenge_SOURCES = \ gl_line_width.h \ gl_null.c \ gl_null.h \ + gl_occlusion_query.c \ + gl_occlusion_query.h \ gl_point_size.c \ gl_point_size.h \ gl_primitives.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 1b38317..a1d5c2b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -51,12 +51,13 @@ am_revenge_OBJECTS = gl_alpha_test.$(OBJEXT) gl_blend.$(OBJEXT) \ gl_ext_texture_filter_anisotropic.$(OBJEXT) \ gl_front_face.$(OBJEXT) gl_line_smooth.$(OBJEXT) \ gl_line_smooth_hint.$(OBJEXT) gl_line_width.$(OBJEXT) \ - gl_null.$(OBJEXT) gl_point_size.$(OBJEXT) \ - gl_primitives.$(OBJEXT) gl_render_mode.$(OBJEXT) \ - gl_scissor_test.$(OBJEXT) gl_shade_model.$(OBJEXT) \ - gl_stencil_func.$(OBJEXT) gl_stencil_mask.$(OBJEXT) \ - gl_stencil_op.$(OBJEXT) gl_stencil_test.$(OBJEXT) \ - gl_texture.$(OBJEXT) gl_texture_mag_filter.$(OBJEXT) \ + gl_null.$(OBJEXT) gl_occlusion_query.$(OBJEXT) \ + gl_point_size.$(OBJEXT) gl_primitives.$(OBJEXT) \ + gl_render_mode.$(OBJEXT) gl_scissor_test.$(OBJEXT) \ + gl_shade_model.$(OBJEXT) gl_stencil_func.$(OBJEXT) \ + gl_stencil_mask.$(OBJEXT) gl_stencil_op.$(OBJEXT) \ + gl_stencil_test.$(OBJEXT) gl_texture.$(OBJEXT) \ + gl_texture_mag_filter.$(OBJEXT) \ gl_texture_min_filter.$(OBJEXT) gl_texture_wrap_s.$(OBJEXT) \ gl_texture_wrap_t.$(OBJEXT) revenge_detect.$(OBJEXT) \ revenge_dump.$(OBJEXT) revenge_dump_misc.$(OBJEXT) \ @@ -158,7 +159,6 @@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -DGL_GLEXT_PROTOTYPES -Wall `sdl-config --cflags` @@ -193,6 +193,8 @@ revenge_SOURCES = \ gl_line_width.h \ gl_null.c \ gl_null.h \ + gl_occlusion_query.c \ + gl_occlusion_query.h \ gl_point_size.c \ gl_point_size.h \ gl_primitives.c \ @@ -317,6 +319,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_line_smooth_hint.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_line_width.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_null.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_occlusion_query.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_point_size.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_primitives.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_render_mode.Po@am__quote@ diff --git a/src/gl_occlusion_query.c b/src/gl_occlusion_query.c new file mode 100644 index 0000000..32c5ea4 --- /dev/null +++ b/src/gl_occlusion_query.c @@ -0,0 +1,55 @@ +/* + * $Id$ + * Copyright (C) 2007 Oliver McFadden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +#include + +void +gl_occlusion_query (void) +{ + GLuint q[1]; + GLuint count; + + test_prologue (NULL); + + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + glDepthMask(GL_FALSE); + + glGenQueriesARB(1, q); + + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, q[0]); + glBegin(GL_QUADS); + glVertex3i(-1, -1, 0); + glVertex3i( 1, -1, 0); + glVertex3i( 1, 1, 0); + glVertex3i(-1, 1, 0); + glEnd(); + glEndQueryARB(GL_SAMPLES_PASSED_ARB); + + glFlush(); + + glGetQueryObjectuivARB(q[0], GL_QUERY_RESULT_ARB, &count); + + test_epilogue (false); +} diff --git a/src/gl_occlusion_query.h b/src/gl_occlusion_query.h new file mode 100644 index 0000000..898bd8f --- /dev/null +++ b/src/gl_occlusion_query.h @@ -0,0 +1,27 @@ +/* + * $Id$ + * Copyright (C) 2007 Oliver McFadden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __GL_OCCLUSION_QUERY_H__ +#define __GL_OCCLUSION_QUERY_H__ + +#include +#include + +void gl_occlusion_query (void); + +#endif diff --git a/src/revenge_test.c b/src/revenge_test.c index 02ea6a3..1626d87 100644 --- a/src/revenge_test.c +++ b/src/revenge_test.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -207,6 +208,7 @@ static struct test_t tests[] = { {_(gl_line_smooth_hint)}, {_(gl_line_width)}, {_(gl_null)}, + {_(gl_occlusion_query)}, {_(gl_point_size)}, {_(gl_primitives)}, {_(gl_render_mode_feedback)}, -- 1.5.6.5