From 380385ab7d0c1964464b40aeea237671189d19cb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Aug 2008 15:22:44 -0600 Subject: mesa: added test for very long fixed-function vertex programs --- progs/trivial/Makefile | 1 + progs/trivial/long-fixed-func.c | 151 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 progs/trivial/long-fixed-func.c (limited to 'progs/trivial') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 786576cd13..d745fefbbf 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -41,6 +41,7 @@ SOURCES = \ linestrip-stipple-wide.c \ linestrip-stipple.c \ linestrip.c \ + long-fixed-func.c \ pgon-mode.c \ point-clip.c \ point-param.c \ diff --git a/progs/trivial/long-fixed-func.c b/progs/trivial/long-fixed-func.c new file mode 100644 index 0000000000..88f4fe01ec --- /dev/null +++ b/progs/trivial/long-fixed-func.c @@ -0,0 +1,151 @@ +/** + * Enable as much fixed-function vertex processing state as possible + * to test fixed-function -> program code generation. + */ + + + +#define GL_GLEXT_PROTOTYPES +#include +#include +#include +#include + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + + +static void +Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f(-0.9, -0.9, -30.0); + glColor3f(0,.9,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(0,0,.7); + glVertex3f( 0.0, 0.9, -30.0); + glEnd(); + + glFlush(); + + glutSwapBuffers(); +} + + +static void +Init(void) +{ + GLubyte tex[16][16][4]; + GLfloat pos[4] = {5, 10, 3, 1.0}; + int i, j; + + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.3, 0.1, 0.3, 0.0); + + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + if ((i+j) & 1) { + tex[i][j][0] = 100; + tex[i][j][1] = 100; + tex[i][j][2] = 100; + tex[i][j][3] = 255; + } + else { + tex[i][j][0] = 200; + tex[i][j][1] = 200; + tex[i][j][2] = 200; + tex[i][j][3] = 255; + } + } + } + + + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); + glFogi(GL_FOG_MODE, GL_LINEAR); + glEnable(GL_FOG); + + glPointParameterfv(GL_DISTANCE_ATTENUATION_EXT, pos); + + for (i = 0; i < 8; i++) { + GLuint texObj; + + glEnable(GL_LIGHT0 + i); + glLightf(GL_LIGHT0 + i, GL_SPOT_EXPONENT, 3.5); + glLightf(GL_LIGHT0 + i, GL_SPOT_CUTOFF, 30.); + glLightf(GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 3.); + glLightf(GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 3.); + glLightf(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 3.); + glLightfv(GL_LIGHT0 + i, GL_POSITION, pos); + + glActiveTexture(GL_TEXTURE0 + i); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_R); + glEnable(GL_TEXTURE_GEN_Q); + glEnable(GL_TEXTURE_2D); + + glMatrixMode(GL_TEXTURE); + glScalef(2.0, 1.0, 3.0); + + glGenTextures(1, &texObj); + glBindTexture(GL_TEXTURE_2D, texObj); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + GL_RGBA, GL_UNSIGNED_BYTE, tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + + glEnable(GL_LIGHTING); + glActiveTexture(GL_TEXTURE0); + glMatrixMode(GL_MODELVIEW); +} + + +static void +Key(unsigned char key, int x, int y) +{ + if (key == 27) { + exit(0); + } + glutPostRedisplay(); +} + + +int +main(int argc, char **argv) +{ + GLenum type = GLUT_RGB | GLUT_DOUBLE; + + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize( 250, 250); + glutInitDisplayMode(type); + if (glutCreateWindow("tri-long-fixedfunc") == GL_FALSE) { + exit(1); + } + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 8df4c3a21fe51280956e35d09ebacc9791b6a613 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Sep 2008 12:59:40 -0600 Subject: press 'f' to cycle through depth test funcs --- progs/trivial/tri-z.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'progs/trivial') diff --git a/progs/trivial/tri-z.c b/progs/trivial/tri-z.c index ae25900a35..c8296a9704 100644 --- a/progs/trivial/tri-z.c +++ b/progs/trivial/tri-z.c @@ -37,9 +37,27 @@ #include #include +#include static int leftFirst = GL_TRUE; +static struct { GLenum func; const char *str; } funcs[] = + { + { GL_LESS, "GL_LESS" }, + { GL_LEQUAL, "GL_LEQUAL" }, + { GL_GREATER, "GL_GREATER" }, + { GL_GEQUAL, "GL_GEQUAL" }, + { GL_EQUAL, "GL_EQUAL" }, + { GL_NOTEQUAL, "GL_NOTEQUAL" }, + { GL_ALWAYS, "GL_ALWAYS" }, + { GL_NEVER, "GL_NEVER" }, + }; + +#define NUM_FUNCS (sizeof(funcs) / sizeof(funcs[0])) + +static int curFunc = 0; + + static void init(void) { glEnable(GL_DEPTH_TEST); @@ -72,6 +90,9 @@ void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + printf("GL_DEPTH_FUNC = %s\n", funcs[curFunc].str); + glDepthFunc(funcs[curFunc].func); + if (leftFirst) { drawLeftTriangle(); drawRightTriangle(); @@ -99,6 +120,11 @@ void reshape(int w, int h) void keyboard(unsigned char key, int x, int y) { switch (key) { + case 'f': + case 'F': + curFunc = (curFunc + 1) % NUM_FUNCS; + glutPostRedisplay(); + break; case 't': case 'T': leftFirst = !leftFirst; -- cgit v1.2.3 From 83054d9297d12dbd7bd7c86a6bed6a5fc63debdc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Sep 2008 13:07:43 -0600 Subject: press 'c' to toggle Z clear value between 0/1 --- progs/trivial/tri-z.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'progs/trivial') diff --git a/progs/trivial/tri-z.c b/progs/trivial/tri-z.c index c8296a9704..335d2b90e2 100644 --- a/progs/trivial/tri-z.c +++ b/progs/trivial/tri-z.c @@ -56,6 +56,15 @@ static struct { GLenum func; const char *str; } funcs[] = #define NUM_FUNCS (sizeof(funcs) / sizeof(funcs[0])) static int curFunc = 0; +static double clearVal = 1.0; + + +static void usage(void) +{ + printf("t - toggle rendering order of triangles\n"); + printf("c - toggle Z clear value between 0, 1\n"); + printf("f - cycle through depth test functions\n"); +} static void init(void) @@ -88,11 +97,13 @@ static void drawRightTriangle(void) void display(void) { - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - printf("GL_DEPTH_FUNC = %s\n", funcs[curFunc].str); + printf("GL_CLEAR_DEPTH = %f GL_DEPTH_FUNC = %s\n", + clearVal, funcs[curFunc].str); + glClearDepth(clearVal); glDepthFunc(funcs[curFunc].func); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + if (leftFirst) { drawLeftTriangle(); drawRightTriangle(); @@ -120,6 +131,11 @@ void reshape(int w, int h) void keyboard(unsigned char key, int x, int y) { switch (key) { + case 'c': + case 'C': + clearVal = 1.0 - clearVal; + glutPostRedisplay(); + break; case 'f': case 'F': curFunc = (curFunc + 1) % NUM_FUNCS; @@ -148,10 +164,11 @@ int main(int argc, char** argv) glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize (200, 200); glutCreateWindow (argv[0]); - init(); glutReshapeFunc (reshape); glutKeyboardFunc (keyboard); glutDisplayFunc (display); + init(); + usage(); glutMainLoop(); return 0; } -- cgit v1.2.3 From 90c93bbeeec1a8ca75b68004afc5d8cb689860bc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Sep 2008 11:00:54 -0600 Subject: define new APP_CC configuration variable for building apps/demos/tests For Cell, need to use different compilers for the libraries vs. the demos/tests to avoid strange link error regarding "_Unwind_GetIPInfo@GCC_4.2.0" --- progs/trivial/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'progs/trivial') diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index d745fefbbf..c868ab6e6f 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -139,13 +139,13 @@ UTIL_FILES = readtex.h readtex.c .SUFFIXES: .c .c: - $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ .c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ ##### TARGETS ##### @@ -166,19 +166,19 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress. texrect: texrect.o readtex.o - $(CC) texrect.o readtex.o $(LIBS) -o $@ + $(APP_CC) texrect.o readtex.o $(LIBS) -o $@ texrect.o: texrect.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ invert: invert.o readtex.o - $(CC) invert.o readtex.o $(LIBS) -o $@ + $(APP_CC) invert.o readtex.o $(LIBS) -o $@ invert.o: invert.c readtex.h - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.o: readtex.c - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + $(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ readtex.h: $(TOP)/progs/util/readtex.h -- cgit v1.2.3