diff options
Diffstat (limited to 'progs/fp')
42 files changed, 4646 insertions, 0 deletions
diff --git a/progs/fp/Makefile b/progs/fp/Makefile new file mode 100644 index 00000000000..d461ebcc608 --- /dev/null +++ b/progs/fp/Makefile @@ -0,0 +1,127 @@ +# progs/tests/Makefile + + +# These programs aren't intended to be included with the normal distro. +# They're not too interesting but they're good for testing. + +TOP = ../.. +include $(TOP)/configs/current + + +LIBS = $(APP_LIB_DEPS) + +SOURCES = \ + tri-abs.c \ + tri-add.c \ + tri-cmp.c \ + tri-cos.c \ + tri-dp3.c \ + tri-dp4.c \ + tri-dph.c \ + tri-dst.c \ + tri-ex2.c \ + tri-flr.c \ + tri-frc.c \ + tri-kil.c \ + tri-lg2.c \ + tri-lit.c \ + tri-lrp.c \ + tri-mad.c \ + tri-max.c \ + tri-min.c \ + tri-mov.c \ + tri-mul.c \ + tri-pow.c \ + tri-param.c \ + tri-rcp.c \ + tri-rsq.c \ + tri-scs.c \ + tri-sge.c \ + tri-sge2.c \ + tri-sin.c \ + tri-slt.c \ + tri-sub.c \ + tri-swz.c \ + tri-swz2.c \ + tri-tex.c \ + tri-xpd.c \ + tri-position.c \ + tri-depth.c \ + tri-depth2.c \ + tri-depthwrite.c \ + tri-depthwrite2.c \ + +NOTDONE=\ + tri-txb.c \ + tri-txp.c \ + tri-depthwrite.c \ + tri-fogoption.c + + +PROGS = $(SOURCES:%.c=%) + +INCLUDES = -I. -I$(TOP)/include -I../samples + +UTIL_FILES = readtex.h readtex.c + + +##### RULES ##### + +.SUFFIXES: +.SUFFIXES: .c + +.c: + $(CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +.S.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +##### TARGETS ##### + +default: $(UTIL_FILES) $(PROGS) + +clean: + rm -f $(PROGS) + rm -f *.o + rm -f getproclist.h + + +# auto code generation +getprocaddress: getprocaddress.c getproclist.h + +getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py + python getprocaddress.py > getproclist.h + + +texrect: texrect.o readtex.o + $(CC) texrect.o readtex.o $(LIBS) -o $@ + +texrect.o: texrect.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +invert: invert.o readtex.o + $(CC) invert.o readtex.o $(LIBS) -o $@ + +invert.o: invert.c readtex.h + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + +readtex.o: readtex.c + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +readtex.h: $(TOP)/progs/util/readtex.h + ln -s $(TOP)/progs/util/readtex.h . + +readtex.c: $(TOP)/progs/util/readtex.c + ln -s $(TOP)/progs/util/readtex.c . + + + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` `find ../include` diff --git a/progs/fp/tri-abs.c b/progs/fp/tri-abs.c new file mode 100644 index 00000000000..44aa2cfa3ad --- /dev/null +++ b/progs/fp/tri-abs.c @@ -0,0 +1,107 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "SUB R0, {0.5}.x, fragment.color; \n" + "ABS result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-add.c b/progs/fp/tri-add.c new file mode 100644 index 00000000000..b086126c867 --- /dev/null +++ b/progs/fp/tri-add.c @@ -0,0 +1,110 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "ADD R0, fragment.color, fragment.color; \n" + "ADD result.color, R0, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-cmp.c b/progs/fp/tri-cmp.c new file mode 100644 index 00000000000..968b67f3d91 --- /dev/null +++ b/progs/fp/tri-cmp.c @@ -0,0 +1,110 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "SUB R0, {0.5}.x, fragment.color; \n" + "CMP result.color, R0, fragment.color, {0.0}.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-cos.c b/progs/fp/tri-cos.c new file mode 100644 index 00000000000..7ea24532189 --- /dev/null +++ b/progs/fp/tri-cos.c @@ -0,0 +1,113 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0; \n" + "MUL R0, fragment.color, {3.14}.x; \n" + "COS result.color.x, R0.x; \n" + "COS result.color.y, R0.y; \n" + "COS result.color.z, R0.z; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-depth.c b/progs/fp/tri-depth.c new file mode 100644 index 00000000000..a1f0579c8e1 --- /dev/null +++ b/progs/fp/tri-depth.c @@ -0,0 +1,111 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + /* scale of 10.0 gives me a visible result on nv hardware. + */ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.color, fragment.position.z, {10.0}.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -40.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -40.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -25.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-depth2.c b/progs/fp/tri-depth2.c new file mode 100644 index 00000000000..f3096282833 --- /dev/null +++ b/progs/fp/tri-depth2.c @@ -0,0 +1,116 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + /* scale of 10.0 gives me a visible result on nv hardware. + */ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "MUL R0, fragment.position.z, {10.0}.x;\n" + "MOV result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.0, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, -0.9, -40.0); + glVertex3f(-0.9, 0.9, -40.0); + glVertex3f( 0.9, 0.0, -25.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_DEPTH; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-depthwrite.c b/progs/fp/tri-depthwrite.c new file mode 100644 index 00000000000..fedeec4577d --- /dev/null +++ b/progs/fp/tri-depthwrite.c @@ -0,0 +1,107 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + +static void Init(void) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.depth.z, fragment.color.z, {.1}.x; \n" + "MOV result.color.xy, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + + + glBegin(GL_TRIANGLES); + glColor4f(.8,0,.5,0); + glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.0, -30.0); + + glColor4f(0,.8,.7,0); + glVertex3f(-0.9, -0.9, -40.0); + glColor4f(0,.8,.7,0); + glVertex3f(-0.9, 0.9, -40.0); + glColor4f(0,.8,.3,0); + glVertex3f( 0.9, 0.0, -40.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE); + + if (glutCreateWindow("Depth Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-depthwrite2.c b/progs/fp/tri-depthwrite2.c new file mode 100644 index 00000000000..5547092ec9b --- /dev/null +++ b/progs/fp/tri-depthwrite2.c @@ -0,0 +1,107 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + +static void Init(void) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.depth.z, fragment.color.z, {.1}.x; \n" + "MOV result.color, fragment.color.z; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + + + glBegin(GL_TRIANGLES); + glColor4f(.8,0,.5,0); + glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.0, -30.0); + + glColor4f(0,.8,.7,0); + glVertex3f(-0.9, -0.9, -40.0); + glColor4f(0,.8,.7,0); + glVertex3f(-0.9, 0.9, -40.0); + glColor4f(0,.8,.3,0); + glVertex3f( 0.9, 0.0, -40.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300); + + glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE); + + if (glutCreateWindow("Depth Test") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-dp3.c b/progs/fp/tri-dp3.c new file mode 100644 index 00000000000..0e18de2dc46 --- /dev/null +++ b/progs/fp/tri-dp3.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "DP3 result.color, fragment.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-dp4.c b/progs/fp/tri-dp4.c new file mode 100644 index 00000000000..400bbf4da2d --- /dev/null +++ b/progs/fp/tri-dp4.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "DP4 result.color, fragment.color.xxxx, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-dph.c b/progs/fp/tri-dph.c new file mode 100644 index 00000000000..958073c4131 --- /dev/null +++ b/progs/fp/tri-dph.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "DPH result.color, fragment.color, fragment.color.xyzx; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-dst.c b/progs/fp/tri-dst.c new file mode 100644 index 00000000000..3d85e85643c --- /dev/null +++ b/progs/fp/tri-dst.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "DST result.color, fragment.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-ex2.c b/progs/fp/tri-ex2.c new file mode 100644 index 00000000000..f09b1d78469 --- /dev/null +++ b/progs/fp/tri-ex2.c @@ -0,0 +1,110 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "EX2 R0, fragment.color.x; \n" + "SUB result.color, R0, {1.0}.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-flr.c b/progs/fp/tri-flr.c new file mode 100644 index 00000000000..059f6b67541 --- /dev/null +++ b/progs/fp/tri-flr.c @@ -0,0 +1,110 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "ADD R0, fragment.color, {0.5}.x; \n" + "FLR result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-fp.c b/progs/fp/tri-fp.c new file mode 100644 index 00000000000..4148a8def34 --- /dev/null +++ b/progs/fp/tri-fp.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SLT result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-frc.c b/progs/fp/tri-frc.c new file mode 100644 index 00000000000..8d60c9dc201 --- /dev/null +++ b/progs/fp/tri-frc.c @@ -0,0 +1,111 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0; \n" + "MUL R0, fragment.color, {3.0}.x; \n" + "FRC result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-inv.c b/progs/fp/tri-inv.c new file mode 100644 index 00000000000..e9023323862 --- /dev/null +++ b/progs/fp/tri-inv.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "INV result.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-kil.c b/progs/fp/tri-kil.c new file mode 100644 index 00000000000..47dbd049644 --- /dev/null +++ b/progs/fp/tri-kil.c @@ -0,0 +1,111 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "SUB R0, fragment.color, {0.5,0,0,0}; \n" + "KIL R0;" + "MOV result.color, R0;" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-lg2.c b/progs/fp/tri-lg2.c new file mode 100644 index 00000000000..c7eec469741 --- /dev/null +++ b/progs/fp/tri-lg2.c @@ -0,0 +1,110 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "MUL R0, fragment.color, {4.0}.x; \n" + "LG2 result.color, R0.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-lit.c b/progs/fp/tri-lit.c new file mode 100644 index 00000000000..21e3b6f2169 --- /dev/null +++ b/progs/fp/tri-lit.c @@ -0,0 +1,111 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "SUB R0, {0.5}.x, fragment.color; \n" + "LIT result.color, R0; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-lrp.c b/progs/fp/tri-lrp.c new file mode 100644 index 00000000000..a5659eed60d --- /dev/null +++ b/progs/fp/tri-lrp.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0, R1;\n" + "LRP result.color, fragment.color.z, {1,0,0,1}, {0,1,0,1}; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-mad.c b/progs/fp/tri-mad.c new file mode 100644 index 00000000000..b46d139fb3c --- /dev/null +++ b/progs/fp/tri-mad.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0, R1;\n" + "MAD result.color, fragment.color.z, {1,0,0,1}, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-max.c b/progs/fp/tri-max.c new file mode 100644 index 00000000000..481a0679165 --- /dev/null +++ b/progs/fp/tri-max.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MAX result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-min.c b/progs/fp/tri-min.c new file mode 100644 index 00000000000..7bb722f85ff --- /dev/null +++ b/progs/fp/tri-min.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MIN result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-mov.c b/progs/fp/tri-mov.c new file mode 100644 index 00000000000..40b5b66f5cc --- /dev/null +++ b/progs/fp/tri-mov.c @@ -0,0 +1,102 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MOV result.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-mul.c b/progs/fp/tri-mul.c new file mode 100644 index 00000000000..61dd3e0458c --- /dev/null +++ b/progs/fp/tri-mul.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.color, fragment.color, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-param.c b/progs/fp/tri-param.c new file mode 100644 index 00000000000..f3e55af3f1b --- /dev/null +++ b/progs/fp/tri-param.c @@ -0,0 +1,114 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MOV result.color, program.local[32]; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 32, 0.25, .5, 0.25, 1); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.0, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 32, 0.25, 0, 0.25, 1); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, 0.0, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-position.c b/progs/fp/tri-position.c new file mode 100644 index 00000000000..18e8182a684 --- /dev/null +++ b/progs/fp/tri-position.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "MUL result.color, fragment.position, {.005}.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-pow.c b/progs/fp/tri-pow.c new file mode 100644 index 00000000000..ef91e43e997 --- /dev/null +++ b/progs/fp/tri-pow.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "POW result.color, fragment.color.x, fragment.color.y; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-rcp.c b/progs/fp/tri-rcp.c new file mode 100644 index 00000000000..e2a27049343 --- /dev/null +++ b/progs/fp/tri-rcp.c @@ -0,0 +1,110 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "ADD R0, fragment.color.x, fragment.color.x; \n" + "RCP result.color, R0.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-rsq.c b/progs/fp/tri-rsq.c new file mode 100644 index 00000000000..c5b2c1b32e8 --- /dev/null +++ b/progs/fp/tri-rsq.c @@ -0,0 +1,110 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "MUL R0, fragment.color, {3.0}.x; \n" + "RSQ result.color, R0.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-scs.c b/progs/fp/tri-scs.c new file mode 100644 index 00000000000..ce7c0062c33 --- /dev/null +++ b/progs/fp/tri-scs.c @@ -0,0 +1,111 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0; \n" + "MUL R0, fragment.color, {3.14}.x; \n" + "SCS result.color, R0.x; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-sge.c b/progs/fp/tri-sge.c new file mode 100644 index 00000000000..6a360ca9328 --- /dev/null +++ b/progs/fp/tri-sge.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SGE result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-sge2.c b/progs/fp/tri-sge2.c new file mode 100644 index 00000000000..c4330098ed4 --- /dev/null +++ b/progs/fp/tri-sge2.c @@ -0,0 +1,114 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0;\n" + "TEMP R1;\n" + "SGE R0, fragment.color, fragment.color.yzxw; \n" + "SGE R1, fragment.color, fragment.color.zxyw; \n" + "MUL R0, R0, R1; \n" + "MUL result.color, R0, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-sin.c b/progs/fp/tri-sin.c new file mode 100644 index 00000000000..772903e4b23 --- /dev/null +++ b/progs/fp/tri-sin.c @@ -0,0 +1,114 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0; \n" + "MUL R0, fragment.color, {3.14}.x; \n" + "MOV result.color, {0.0}.x; \n" + "SIN result.color.x, R0.x; \n" + "SIN result.color.y, R0.y; \n" + "SIN result.color.z, R0.z; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-slt.c b/progs/fp/tri-slt.c new file mode 100644 index 00000000000..4148a8def34 --- /dev/null +++ b/progs/fp/tri-slt.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SLT result.color, {0.5}.x, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-sub.c b/progs/fp/tri-sub.c new file mode 100644 index 00000000000..6faa4145501 --- /dev/null +++ b/progs/fp/tri-sub.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SUB result.color, fragment.color.yzxw, fragment.color; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-swz.c b/progs/fp/tri-swz.c new file mode 100644 index 00000000000..5f34f7a3222 --- /dev/null +++ b/progs/fp/tri-swz.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "SWZ result.color, fragment.color, 1,x,y,z; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-swz2.c b/progs/fp/tri-swz2.c new file mode 100644 index 00000000000..fd76b58f539 --- /dev/null +++ b/progs/fp/tri-swz2.c @@ -0,0 +1,109 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEMP R0, R1;\n" + "SWZ result.color, fragment.color, 1, 0, 0, 1; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-tex.c b/progs/fp/tri-tex.c new file mode 100644 index 00000000000..87f63894ce9 --- /dev/null +++ b/progs/fp/tri-tex.c @@ -0,0 +1,130 @@ + +#include <assert.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> + +#include "readtex.c" + + +#define TEXTURE_FILE "../images/girl.rgb" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "TEX result.color, fragment.color, texture[0], 2D; \n" + "END" + ; + GLuint modulateProg; + GLuint Texture; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + assert(glIsProgramARB(modulateProg)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + /* Load texture */ + glGenTextures(1, &Texture); + glBindTexture(GL_TEXTURE_2D, Texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) { + printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE); + exit(1); + } + /* XXX this enable shouldn't really be needed!!! */ + glEnable(GL_TEXTURE_2D); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); +/* glTexCoord2f(1, 0); */ + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); +/* glTexCoord2f(1, 1); */ + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); +/* glTexCoord2f(0, .5); */ + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/fp/tri-xpd.c b/progs/fp/tri-xpd.c new file mode 100644 index 00000000000..9aca46b2faa --- /dev/null +++ b/progs/fp/tri-xpd.c @@ -0,0 +1,108 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#define GL_GLEXT_PROTOTYPES +#include <GL/glut.h> +#include "GL/gl.h" + + + +static void Init( void ) +{ + static const char *modulate2D = + "!!ARBfp1.0\n" + "XPD result.color, fragment.color, {2,2,2,0}; \n" + "END" + ; + GLuint modulateProg; + + if (!glutExtensionSupported("GL_ARB_fragment_program")) { + printf("Error: GL_ARB_fragment_program not supported!\n"); + exit(1); + } + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &modulateProg); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(modulate2D), (const GLubyte *)modulate2D); + + printf("glGetError = 0x%x\n", (int) glGetError()); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(.3, .3, .3, 0); +} + +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 Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,1); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(1,0,0); + glVertex3f( 0.9, 0.9, -30.0); + glColor3f(0,1,0); + glVertex3f(-0.9, 0.0, -30.0); + glEnd(); + + glFlush(); + + +} + + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB; + type |= GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} |