From ecf09819d157e3b2bb05b18ce314246ee8fb9668 Mon Sep 17 00:00:00 2001From: Corbin Simpson <MostAwesomeDude@gmail.com>Date: Thu, 6 Nov 2008 02:02:11 -0800Subject: [PATCH] Shamelessly borrow Mesa's progs/tests/fog test.--- src/Makefile.am | 2 + src/Makefile.in | 5 ++- src/gl_fog.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/gl_fog.h | 27 ++++++++++++++ src/revenge_test.c | 2 + 5 files changed, 135 insertions(+), 1 deletions(-) create mode 100644 src/gl_fog.c create mode 100644 src/gl_fog.hdiff --git a/src/Makefile.am b/src/Makefile.amindex 75757cd..1954960 100644--- a/src/Makefile.am+++ b/src/Makefile.am@@ -23,6 +23,8 @@ revenge_SOURCES = \ gl_depth_range.h \ gl_ext_texture_filter_anisotropic.c \ gl_ext_texture_filter_anisotropic.h \+ gl_fog.c \+ gl_fog.h \ gl_front_face.c \ gl_front_face.h \ gl_line_smooth.c \diff --git a/src/Makefile.in b/src/Makefile.inindex a1d5c2b..ca4b4d6 100644--- a/src/Makefile.in+++ b/src/Makefile.in@@ -48,7 +48,7 @@ am_revenge_OBJECTS = gl_alpha_test.$(OBJEXT) gl_blend.$(OBJEXT) \ gl_color_logic_op.$(OBJEXT) gl_cull_face.$(OBJEXT) \ gl_depth_func.$(OBJEXT) gl_depth_mask.$(OBJEXT) \ gl_depth_range.$(OBJEXT) \- gl_ext_texture_filter_anisotropic.$(OBJEXT) \+ gl_ext_texture_filter_anisotropic.$(OBJEXT) gl_fog.$(OBJEXT) \ gl_front_face.$(OBJEXT) gl_line_smooth.$(OBJEXT) \ gl_line_smooth_hint.$(OBJEXT) gl_line_width.$(OBJEXT) \ gl_null.$(OBJEXT) gl_occlusion_query.$(OBJEXT) \@@ -183,6 +183,8 @@ revenge_SOURCES = \ gl_depth_range.h \ gl_ext_texture_filter_anisotropic.c \ gl_ext_texture_filter_anisotropic.h \+ gl_fog.c \+ gl_fog.h \ gl_front_face.c \ gl_front_face.h \ gl_line_smooth.c \@@ -314,6 +316,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_depth_mask.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_depth_range.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_ext_texture_filter_anisotropic.Po@am__quote@+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_fog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_front_face.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_line_smooth.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_line_smooth_hint.Po@am__quote@diff --git a/src/gl_fog.c b/src/gl_fog.cnew file mode 100644index 0000000..bf2fa57--- /dev/null+++ b/src/gl_fog.c@@ -0,0 +1,100 @@+/*+ * $Id$+ * Copyright (C) 2007 Oliver McFadden <z3ro.geek@gmail.com>+ *+ * 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 <http://www.gnu.org/licenses/>.+ */++#include <GL/gl.h>+#include <GL/glext.h>+#include <stdbool.h>+#include <stdio.h>+#include <stdlib.h>++#include <revenge_test.h>++/* Shamelessly based on Eric Anholt's fog test program in Mesa. */++void+gl_fog (void)+{+ test_prologue (NULL);++ GLint i, depthi;+ GLfloat fogcolor[4] = {1, 1, 1, 1};++ static GLfloat Near = 0.0, Far = 1.0;++ glEnable(GL_FOG);+ glFogfv(GL_FOG_COLOR, fogcolor);++ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );++ glPushMatrix();+ for (i = 0; i < 6; i++) {++ glPushMatrix();+ for (depthi = 0; depthi < 5; depthi++) {+ GLfloat depth = Near + (Far - Near) * depthi / 4;++ switch (i % 3) {+ case 0:+ glFogi(GL_FOG_MODE, GL_LINEAR);+ glFogf(GL_FOG_START, Near);+ glFogf(GL_FOG_END, Far);+ break;+ case 1:+ glFogi(GL_FOG_MODE, GL_EXP);+ glFogf(GL_FOG_DENSITY, 2);+ break;+ case 2:+ glFogi(GL_FOG_MODE, GL_EXP2);+ glFogf(GL_FOG_DENSITY, 2);+ break;+ }++ glColor4f(0, 0, 0, 0);+ if (i < 3) {+ glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);++ glBegin(GL_POLYGON);+ glVertex3f(0, 0, depth);+ glVertex3f(1, 0, depth);+ glVertex3f(1, 1, depth);+ glVertex3f(0, 1, depth);+ glEnd();+ } else {+ glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);+ glFogCoordfEXT(depth);++ glBegin(GL_POLYGON);+ glVertex3f(0, 0, (Near + Far) / 2);+ glVertex3f(1, 0, (Near + Far) / 2);+ glVertex3f(1, 1, (Near + Far) / 2);+ glVertex3f(0, 1, (Near + Far) / 2);+ glEnd();+ }+ glTranslatef(1.5, 0, 0);+ }++ glPopMatrix();+ glTranslatef(0, 1.5, 0);+ }+ glPopMatrix();++ glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);+ glDisable(GL_FOG);++ test_epilogue (false);+}diff --git a/src/gl_fog.h b/src/gl_fog.hnew file mode 100644index 0000000..1936df7--- /dev/null+++ b/src/gl_fog.h@@ -0,0 +1,27 @@+/*+ * $Id$+ * Copyright (C) 2007 Oliver McFadden <z3ro.geek@gmail.com>+ *+ * 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 <http://www.gnu.org/licenses/>.+ */++#ifndef __GL_FOG_H__+#define __GL_FOG_H__++#include <stdio.h>+#include <stdlib.h>++void gl_fog (void);++#endifdiff --git a/src/revenge_test.c b/src/revenge_test.cindex 1626d87..aa3ec68 100644--- a/src/revenge_test.c+++ b/src/revenge_test.c@@ -44,6 +44,7 @@ #include <gl_depth_mask.h> #include <gl_depth_range.h> #include <gl_ext_texture_filter_anisotropic.h>+#include <gl_fog.h> #include <gl_front_face.h> #include <gl_line_smooth.h> #include <gl_line_smooth_hint.h>@@ -203,6 +204,7 @@ static struct test_t tests[] = { {_(gl_depth_mask)}, {_(gl_depth_range)}, {_(gl_ext_texture_filter_anisotropic)},+ {_(gl_fog)}, {_(gl_front_face)}, {_(gl_line_smooth)}, {_(gl_line_smooth_hint)},-- 1.5.6.5