summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver McFadden <z3ro.geek@gmail.com>2007-09-30 12:30:27 +0000
committerOliver McFadden <z3ro.geek@gmail.com>2007-09-30 12:30:27 +0000
commita67e78c324b3c5c55b67face676910f8ba39fc40 (patch)
treeda8e7169910d804e5986815cc9de87e5976d14c0
parent78dd4db7327a5615ada2e474a2fb7f0e4f8cf070 (diff)
Added GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T tests.
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile.in11
-rw-r--r--src/gl_texture_wrap_s.c106
-rw-r--r--src/gl_texture_wrap_s.h28
-rw-r--r--src/gl_texture_wrap_t.c106
-rw-r--r--src/gl_texture_wrap_t.h28
-rw-r--r--src/test.c4
7 files changed, 285 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 33a44c2..bc1072e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,6 +51,10 @@ revenge_SOURCES = \
gl_texture_mag_filter.h \
gl_texture_min_filter.c \
gl_texture_min_filter.h \
+ gl_texture_wrap_s.c \
+ gl_texture_wrap_s.h \
+ gl_texture_wrap_t.c \
+ gl_texture_wrap_t.h \
main.c \
main.h \
memory.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index cfa2c75..b4a0004 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -54,8 +54,9 @@ am_revenge_OBJECTS = detect.$(OBJEXT) dump.$(OBJEXT) \
gl_primitives.$(OBJEXT) gl_render_mode.$(OBJEXT) \
gl_scissor_test.$(OBJEXT) gl_shade_model.$(OBJEXT) \
gl_texture.$(OBJEXT) gl_texture_mag_filter.$(OBJEXT) \
- gl_texture_min_filter.$(OBJEXT) main.$(OBJEXT) \
- memory.$(OBJEXT) register.$(OBJEXT) test.$(OBJEXT)
+ gl_texture_min_filter.$(OBJEXT) gl_texture_wrap_s.$(OBJEXT) \
+ gl_texture_wrap_t.$(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@
@@ -204,6 +205,10 @@ revenge_SOURCES = \
gl_texture_mag_filter.h \
gl_texture_min_filter.c \
gl_texture_min_filter.h \
+ gl_texture_wrap_s.c \
+ gl_texture_wrap_s.h \
+ gl_texture_wrap_t.c \
+ gl_texture_wrap_t.h \
main.c \
main.h \
memory.c \
@@ -303,6 +308,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_texture.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_texture_mag_filter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_texture_min_filter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_texture_wrap_s.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_texture_wrap_t.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_wrap_s.c b/src/gl_texture_wrap_s.c
new file mode 100644
index 0000000..e6fac4e
--- /dev/null
+++ b/src/gl_texture_wrap_s.c
@@ -0,0 +1,106 @@
+/*
+ * $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_wrap_s (void)
+{
+ data_store texture_wrap[] = {
+ {N_(GL_CLAMP)},
+ {N_(GL_REPEAT)},
+ };
+
+ GLuint *texture = NULL;;
+ GLuint texName;
+ int i;
+
+ if (!(texture = random_texture (TEXTURE_WIDTH, TEXTURE_HEIGHT)))
+ {
+ return;
+ }
+
+ for (i = 0;
+ i < sizeof (texture_wrap) / sizeof (texture_wrap[0]); i++)
+ {
+ test_prologue (texture_wrap[i].name);
+
+ glEnable (GL_TEXTURE_2D);
+
+ glGenTextures (1, &texName);
+ glBindTexture (GL_TEXTURE_2D, texName);
+
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ /* GL_NEAREST_MIPMAP_LINEAR */ GL_NEAREST);
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture_wrap[i].id);
+ 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_wrap_s.h b/src/gl_texture_wrap_s.h
new file mode 100644
index 0000000..a92b29d
--- /dev/null
+++ b/src/gl_texture_wrap_s.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_WRAP_S_H__
+#define __GL_TEXTURE_WRAP_S_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void gl_texture_wrap_s (void);
+
+#endif
diff --git a/src/gl_texture_wrap_t.c b/src/gl_texture_wrap_t.c
new file mode 100644
index 0000000..04bce87
--- /dev/null
+++ b/src/gl_texture_wrap_t.c
@@ -0,0 +1,106 @@
+/*
+ * $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_wrap_t (void)
+{
+ data_store texture_wrap[] = {
+ {N_(GL_CLAMP)},
+ {N_(GL_REPEAT)},
+ };
+
+ GLuint *texture = NULL;;
+ GLuint texName;
+ int i;
+
+ if (!(texture = random_texture (TEXTURE_WIDTH, TEXTURE_HEIGHT)))
+ {
+ return;
+ }
+
+ for (i = 0;
+ i < sizeof (texture_wrap) / sizeof (texture_wrap[0]); i++)
+ {
+ test_prologue (texture_wrap[i].name);
+
+ glEnable (GL_TEXTURE_2D);
+
+ glGenTextures (1, &texName);
+ glBindTexture (GL_TEXTURE_2D, texName);
+
+ glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ /* GL_NEAREST_MIPMAP_LINEAR */ GL_NEAREST);
+ 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, texture_wrap[i].id);
+
+ 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_wrap_t.h b/src/gl_texture_wrap_t.h
new file mode 100644
index 0000000..1a9befe
--- /dev/null
+++ b/src/gl_texture_wrap_t.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_WRAP_T_H__
+#define __GL_TEXTURE_WRAP_T_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void gl_texture_wrap_t (void);
+
+#endif
diff --git a/src/test.c b/src/test.c
index 7ffcfe2..9ad3934 100644
--- a/src/test.c
+++ b/src/test.c
@@ -55,6 +55,8 @@
#include <gl_texture.h>
#include <gl_texture_mag_filter.h>
#include <gl_texture_min_filter.h>
+#include <gl_texture_wrap_s.h>
+#include <gl_texture_wrap_t.h>
void
tri (void)
@@ -169,6 +171,8 @@ static struct test_t tests[] = {
{_(gl_texture)},
{_(gl_texture_mag_filter)},
{_(gl_texture_min_filter)},
+ {_(gl_texture_wrap_s)},
+ {_(gl_texture_wrap_t)},
};
#undef _