summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver McFadden <z3ro.geek@gmail.com>2007-09-23 23:18:25 +0000
committerOliver McFadden <z3ro.geek@gmail.com>2007-09-23 23:18:25 +0000
commit9288fa432d4884a825ad538ead465481b7a6ee33 (patch)
tree4a17ba415cdf10bf0d0ca90f51c4edef4a51dc1a
parent083f602435531169a9b1179aa6a74e32b9c26900 (diff)
Added a GL_TEXTURE_MIN_FILTER test.
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in8
-rw-r--r--src/gl_texture.c2
-rw-r--r--src/gl_texture_min_filter.c110
-rw-r--r--src/gl_texture_min_filter.h28
-rw-r--r--src/test.c2
6 files changed, 149 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 93a0bd2..4f1a6e9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,6 +47,8 @@ revenge_SOURCES = \
gl_shade_model.h \
gl_texture.c \
gl_texture.h \
+ gl_texture_min_filter.c \
+ gl_texture_min_filter.h \
main.c \
main.h \
memory.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index 632d54f..a9db4f3 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -53,8 +53,9 @@ am_revenge_OBJECTS = detect.$(OBJEXT) dump.$(OBJEXT) \
gl_null.$(OBJEXT) gl_point_size.$(OBJEXT) \
gl_primitives.$(OBJEXT) gl_render_mode.$(OBJEXT) \
gl_scissor_test.$(OBJEXT) gl_shade_model.$(OBJEXT) \
- gl_texture.$(OBJEXT) main.$(OBJEXT) memory.$(OBJEXT) \
- register.$(OBJEXT) test.$(OBJEXT)
+ gl_texture.$(OBJEXT) gl_texture_min_filter.$(OBJEXT) \
+ main.$(OBJEXT) memory.$(OBJEXT) register.$(OBJEXT) \
+ test.$(OBJEXT)
revenge_OBJECTS = $(am_revenge_OBJECTS)
revenge_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
@@ -199,6 +200,8 @@ revenge_SOURCES = \
gl_shade_model.h \
gl_texture.c \
gl_texture.h \
+ gl_texture_min_filter.c \
+ gl_texture_min_filter.h \
main.c \
main.h \
memory.c \
@@ -296,6 +299,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_scissor_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_shade_model.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_texture.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_texture_min_filter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/register.Po@am__quote@
diff --git a/src/gl_texture.c b/src/gl_texture.c
index 62a4f3d..8296f72 100644
--- a/src/gl_texture.c
+++ b/src/gl_texture.c
@@ -30,7 +30,7 @@
#define TEXTURE_WIDTH 16
#define TEXTURE_HEIGHT 16
-GLuint *
+static GLuint *
random_texture (int width, int height)
{
GLuint *texture = NULL;
diff --git a/src/gl_texture_min_filter.c b/src/gl_texture_min_filter.c
new file mode 100644
index 0000000..4b13a49
--- /dev/null
+++ b/src/gl_texture_min_filter.c
@@ -0,0 +1,110 @@
+/*
+ * $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 2 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <GL/gl.h>
+#include <GL/glext.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <test.h>
+
+typedef struct
+{
+ unsigned int id;
+ char *name;
+} data_store;
+
+#define N_(name) name, # name
+
+#define TEXTURE_WIDTH 16
+#define TEXTURE_HEIGHT 16
+
+static GLuint *
+random_texture (int width, int height)
+{
+ GLuint *texture = NULL;
+ int i;
+
+ if (!(texture = (GLuint *) malloc (width * height * sizeof (GLuint))))
+ {
+ fprintf (stderr, "%s: %s\n", program_invocation_short_name,
+ strerror (errno));
+ return NULL;
+ }
+
+ for (i = 0; i < width * height; i++)
+ {
+ texture[i] = random ();
+ }
+
+ return texture;
+}
+
+void
+gl_texture_min_filter (void)
+{
+ data_store texture_min_filter[] = {
+ {N_(GL_NEAREST)},
+ {N_(GL_LINEAR)},
+ {N_(GL_NEAREST_MIPMAP_NEAREST)},
+ {N_(GL_LINEAR_MIPMAP_NEAREST)},
+ {N_(GL_NEAREST_MIPMAP_LINEAR)},
+ {N_(GL_LINEAR_MIPMAP_LINEAR)},
+ };
+
+ GLuint *texture = NULL;;
+ GLuint texName;
+ int i;
+
+ if (!(texture = random_texture (TEXTURE_WIDTH, TEXTURE_HEIGHT)))
+ {
+ return;
+ }
+
+ for (i = 0;
+ i < sizeof (texture_min_filter) / sizeof (texture_min_filter[0]); i++)
+ {
+ test_prologue (texture_min_filter[i].name);
+
+ glEnable (GL_TEXTURE_2D);
+
+ glGenTextures (1, &texName);
+ glBindTexture (GL_TEXTURE_2D, texName);
+
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ texture_min_filter[i].id);
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, TEXTURE_WIDTH, TEXTURE_HEIGHT,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
+
+ tex_tri ();
+
+ glDisable (GL_TEXTURE_2D);
+
+ test_epilogue (true);
+ }
+
+ free (texture);
+}
diff --git a/src/gl_texture_min_filter.h b/src/gl_texture_min_filter.h
new file mode 100644
index 0000000..ece68fb
--- /dev/null
+++ b/src/gl_texture_min_filter.h
@@ -0,0 +1,28 @@
+/*
+ * $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 2 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __GL_TEXTURE_MIN_FILTER_H__
+#define __GL_TEXTURE_MIN_FILTER_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void gl_texture_min_filter (void);
+
+#endif
diff --git a/src/test.c b/src/test.c
index 40c3a37..a58b788 100644
--- a/src/test.c
+++ b/src/test.c
@@ -53,6 +53,7 @@
#include <gl_scissor_test.h>
#include <gl_shade_model.h>
#include <gl_texture.h>
+#include <gl_texture_min_filter.h>
void
tri (void)
@@ -161,6 +162,7 @@ static struct test_t tests[] = {
{_(gl_scissor_test)},
{_(gl_shade_model)},
{_(gl_texture)},
+ {_(gl_texture_min_filter)},
};
#undef _