summaryrefslogtreecommitdiff
path: root/progs/tests
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-05-19 16:42:01 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-05-19 16:42:01 +0000
commit5ec34f0ff96d5104f30b63a66ab7ee55a5f7250f (patch)
tree4c3882c8c88e05c2697e91c7d762a722ee17d4a3 /progs/tests
parent083f8111aac27f47feb2f35a10970fc40b940eb1 (diff)
also test 3D textures (press '2'/'3' to toggle)
Diffstat (limited to 'progs/tests')
-rw-r--r--progs/tests/packedpixels.c52
1 files changed, 44 insertions, 8 deletions
diff --git a/progs/tests/packedpixels.c b/progs/tests/packedpixels.c
index 842cf7f34b..94f0a887c4 100644
--- a/progs/tests/packedpixels.c
+++ b/progs/tests/packedpixels.c
@@ -106,6 +106,9 @@ static const struct name_format IntFormats[] = {
#define NUM_INT_FORMATS (sizeof(IntFormats) / sizeof(IntFormats[0]))
static GLuint CurFormat = 0;
+static GLboolean Test3D = GL_FALSE;
+
+
static void
PrintString(const char *s)
@@ -167,8 +170,25 @@ MakeTexture(const struct pixel_format *format, GLenum intFormat, GLboolean swap)
else {
abort();
}
- glTexImage2D(GL_TEXTURE_2D, 0, intFormat, 4, 4, 0,
- format->format, format->type, texBuffer);
+
+ if (Test3D) {
+ /* 4 x 4 x 4 texture, undefined data */
+ glTexImage3D(GL_TEXTURE_3D, 0, intFormat, 4, 4, 4, 0,
+ format->format, format->type, NULL);
+ /* fill in Z=1 and Z=2 slices with the real texture data */
+ glTexSubImage3D(GL_TEXTURE_3D, 0,
+ 0, 0, 1, /* offset */
+ 4, 4, 1, /* size */
+ format->format, format->type, texBuffer);
+ glTexSubImage3D(GL_TEXTURE_3D, 0,
+ 0, 0, 2, /* offset */
+ 4, 4, 1, /* size */
+ format->format, format->type, texBuffer);
+ }
+ else {
+ glTexImage2D(GL_TEXTURE_2D, 0, intFormat, 4, 4, 0,
+ format->format, format->type, texBuffer);
+ }
if (glGetError()) {
printf("GL Error for %s\n", format->name);
@@ -196,15 +216,21 @@ Draw(void)
MakeTexture(Formats + i, IntFormats[CurFormat].format, swap);
- glEnable(GL_TEXTURE_2D);
+ if (Test3D)
+ glEnable(GL_TEXTURE_3D);
+ else
+ glEnable(GL_TEXTURE_2D);
glBegin(GL_POLYGON);
- glTexCoord2f(0, 0); glVertex2f(0, 0);
- glTexCoord2f(1, 0); glVertex2f(w, 0);
- glTexCoord2f(1, 1); glVertex2f(w, h);
- glTexCoord2f(0, 1); glVertex2f(0, h);
+ glTexCoord3f(0, 0, 0.5); glVertex2f(0, 0);
+ glTexCoord3f(1, 0, 0.5); glVertex2f(w, 0);
+ glTexCoord3f(1, 1, 0.5); glVertex2f(w, h);
+ glTexCoord3f(0, 1, 0.5); glVertex2f(0, h);
glEnd();
- glDisable(GL_TEXTURE_2D);
+ if (Test3D)
+ glDisable(GL_TEXTURE_3D);
+ else
+ glDisable(GL_TEXTURE_2D);
glColor3f(0, 0, 0);
glRasterPos2i(8, 6);
PrintString(Formats[i].name);
@@ -263,6 +289,14 @@ Key(unsigned char key, int x, int y)
if (CurFormat == NUM_INT_FORMATS)
CurFormat = 0;
break;
+ case '2':
+ Test3D = GL_FALSE;
+ printf("Using 2D textures\n");
+ break;
+ case '3':
+ Test3D = GL_TRUE;
+ printf("Using 3D textures\n");
+ break;
case 27:
exit(0);
break;
@@ -278,6 +312,8 @@ Init(void)
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}