diff options
author | Kristian Høgsberg <krh@redhat.com> | 2009-02-12 20:58:04 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2009-02-12 20:58:04 -0500 |
commit | 3ced4dfbb1575930b3e4de5155c6f3f641cd8d06 (patch) | |
tree | 47c94e10d7f6e75ac229f27b0e338b45b0f47aeb | |
parent | aa867ad6edd4b6c296431911e51462c679a8ef8c (diff) |
Add texture test case.
-rw-r--r-- | test/Makefile.in | 7 | ||||
-rw-r--r-- | test/gears.c | 4 | ||||
-rw-r--r-- | test/texture.c | 83 |
3 files changed, 91 insertions, 3 deletions
diff --git a/test/Makefile.in b/test/Makefile.in index 8944990..743d61f 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -4,13 +4,18 @@ LDLIBS = @EAGLE_LIBS@ -ldl prefix = @prefix@ exec_prefix = @exec_prefix@ -all : gears +all : gears texture gears_objs = gears.o setup.o gears : ../libeagle.so $(gears_objs) gcc -o $@ -L.. -leagle -lm $(gears_objs) +texture_objs = texture.o setup.o + +texture : ../libeagle.so $(texture_objs) + gcc -o $@ -L.. -leagle -lm $(texture_objs) + clean : rm -f *.o glapi/*.o libeagle.so test diff --git a/test/gears.c b/test/gears.c index 5a2868c..34da966 100644 --- a/test/gears.c +++ b/test/gears.c @@ -246,7 +246,7 @@ gears_draw(struct gears *gears, GLfloat angle) glFlush(); } -static void render(struct state *state) +static int render(struct state *state) { struct pollfd p[1]; GLfloat angle = 0.0; @@ -279,5 +279,5 @@ static void render(struct state *state) int main(int argc, char *argv[]) { - return setup(argv, argv, render); + return setup(argc, argv, render); } diff --git a/test/texture.c b/test/texture.c new file mode 100644 index 0000000..fde49bf --- /dev/null +++ b/test/texture.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright © 2009 Kristian Høgsberg + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <sys/time.h> +#include <math.h> +#include <GL/gl.h> +#include <poll.h> +#include <fcntl.h> +#include <unistd.h> + +#include "../eagle.h" +#include "setup.h" + +static int render(struct state *state) +{ + uint32_t texture[128 * 128]; + int i; + + for (i = 0; i < 128 * 128; i++) { + texture[i] = + (i >> 12) * 0x05103203 + + ((i >> 5) & 0x03) * 0x20100f28; + } + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, + GL_BGRA, GL_UNSIGNED_BYTE, texture); + + glEnable(GL_TEXTURE_2D); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glViewport(0, 0, state->width, state->height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glTexCoord2f(1,-1); + glVertex3f( 0.9, -0.9, -0.0); + glTexCoord2f(1,1); + glVertex3f( 0.9, 0.9, -0.0); + glTexCoord2f(-1,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + glFlush(); + + eglSwapBuffers(state->display, state->surface); + + getchar(); + + return 0; +} + +int main(int argc, char *argv[]) +{ + return setup(argc, argv, render); +} |