summaryrefslogtreecommitdiff
path: root/progs/fp
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2005-10-20 21:40:23 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2005-10-20 21:40:23 +0000
commita90909e89234b95e44a2cd08181167ba234b5fac (patch)
treeacde20d993b76825ca98d07c07095fa99b4c8491 /progs/fp
parentf344be793c7322bc43d17c85e90a875383d8ade8 (diff)
A bunch of little tests which exercise each ARB_fp instruction plus
a couple of other interesting cases.
Diffstat (limited to 'progs/fp')
-rw-r--r--progs/fp/Makefile122
-rw-r--r--progs/fp/tri-abs.c160
-rw-r--r--progs/fp/tri-add.c160
-rw-r--r--progs/fp/tri-cmp.c160
-rw-r--r--progs/fp/tri-cos.c162
-rw-r--r--progs/fp/tri-dp3.c159
-rw-r--r--progs/fp/tri-dp4.c159
-rw-r--r--progs/fp/tri-dph.c159
-rw-r--r--progs/fp/tri-dst.c159
-rw-r--r--progs/fp/tri-ex2.c160
-rw-r--r--progs/fp/tri-flat.c142
-rw-r--r--progs/fp/tri-flr.c160
-rw-r--r--progs/fp/tri-fp.c159
-rw-r--r--progs/fp/tri-frc.c161
-rw-r--r--progs/fp/tri-inv.c159
-rw-r--r--progs/fp/tri-kil.c161
-rw-r--r--progs/fp/tri-lg2.c160
-rw-r--r--progs/fp/tri-lit.c161
-rw-r--r--progs/fp/tri-lrp.c159
-rw-r--r--progs/fp/tri-mad.c159
-rw-r--r--progs/fp/tri-max.c159
-rw-r--r--progs/fp/tri-min.c159
-rw-r--r--progs/fp/tri-mov.c159
-rw-r--r--progs/fp/tri-mul.c159
-rw-r--r--progs/fp/tri-position.c159
-rw-r--r--progs/fp/tri-pow.c159
-rw-r--r--progs/fp/tri-rcp.c159
-rw-r--r--progs/fp/tri-rsq.c160
-rw-r--r--progs/fp/tri-scs.c161
-rw-r--r--progs/fp/tri-sge.c159
-rw-r--r--progs/fp/tri-sge2.c164
-rw-r--r--progs/fp/tri-sin.c160
-rw-r--r--progs/fp/tri-slt.c159
-rw-r--r--progs/fp/tri-sub.c159
-rw-r--r--progs/fp/tri-swz.c159
-rw-r--r--progs/fp/tri-swz2.c159
-rw-r--r--progs/fp/tri-tex.c178
-rw-r--r--progs/fp/tri-xpd.c159
38 files changed, 6031 insertions, 0 deletions
diff --git a/progs/fp/Makefile b/progs/fp/Makefile
new file mode 100644
index 0000000000..d6e0ef8b19
--- /dev/null
+++ b/progs/fp/Makefile
@@ -0,0 +1,122 @@
+# 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-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 \
+
+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 0000000000..3e7d734325
--- /dev/null
+++ b/progs/fp/tri-abs.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..ffe88065d9
--- /dev/null
+++ b/progs/fp/tri-add.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..2ef37d199e
--- /dev/null
+++ b/progs/fp/tri-cmp.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..ec83804a68
--- /dev/null
+++ b/progs/fp/tri-cos.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init( void )
+{
+ static const char *modulate2D =
+ "!!ARBfp1.0\n"
+ "TEMP R0; \n"
+ "MUL R0, fragment.color, {3.14}.x; \n"
+ "SIN result.color.x, R0.x; \n"
+ "COS result.color.y, R0.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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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-dp3.c b/progs/fp/tri-dp3.c
new file mode 100644
index 0000000000..bc45ce242a
--- /dev/null
+++ b/progs/fp/tri-dp3.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..daf593727a
--- /dev/null
+++ b/progs/fp/tri-dp4.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..5b8bb1d849
--- /dev/null
+++ b/progs/fp/tri-dph.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..5e01a3c838
--- /dev/null
+++ b/progs/fp/tri-dst.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init( void )
+{
+ static const char *modulate2D =
+ "!!ARBfp1.0\n"
+ "DST result.color, fragment.position, 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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..79e0c6de9d
--- /dev/null
+++ b/progs/fp/tri-ex2.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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-flat.c b/progs/fp/tri-flat.c
new file mode 100644
index 0000000000..12ac920519
--- /dev/null
+++ b/progs/fp/tri-flat.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.5, 0.5, 0.5, 0.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);
+ glShadeModel(GL_FLAT);
+
+ 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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+
+ /* Exit after first frame
+ */
+ exit(0);
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..9c702babc4
--- /dev/null
+++ b/progs/fp/tri-flr.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..fd25fb5258
--- /dev/null
+++ b/progs/fp/tri-fp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..80cad47017
--- /dev/null
+++ b/progs/fp/tri-frc.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..badea7842a
--- /dev/null
+++ b/progs/fp/tri-inv.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..d3e1da8d26
--- /dev/null
+++ b/progs/fp/tri-kil.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..5321cbd436
--- /dev/null
+++ b/progs/fp/tri-lg2.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..91e3ce5521
--- /dev/null
+++ b/progs/fp/tri-lit.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..26926877e2
--- /dev/null
+++ b/progs/fp/tri-lrp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..4090aad472
--- /dev/null
+++ b/progs/fp/tri-mad.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..2e35cd8f2c
--- /dev/null
+++ b/progs/fp/tri-max.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..d25ac36b24
--- /dev/null
+++ b/progs/fp/tri-min.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..0a32aee859
--- /dev/null
+++ b/progs/fp/tri-mov.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..30ba871b8d
--- /dev/null
+++ b/progs/fp/tri-mul.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..25ed89916b
--- /dev/null
+++ b/progs/fp/tri-position.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init( void )
+{
+ static const char *modulate2D =
+ "!!ARBfp1.0\n"
+ "MOV result.color, fragment.position; \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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..8ef57173af
--- /dev/null
+++ b/progs/fp/tri-pow.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..41a0033566
--- /dev/null
+++ b/progs/fp/tri-rcp.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init( void )
+{
+ static const char *modulate2D =
+ "!!ARBfp1.0\n"
+ "TEMP R0;\n"
+ "RCP result.color, fragment.color.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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..39c75e8eb1
--- /dev/null
+++ b/progs/fp/tri-rsq.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..ba342744c3
--- /dev/null
+++ b/progs/fp/tri-scs.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..7f1d2df489
--- /dev/null
+++ b/progs/fp/tri-sge.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..ea1a415328
--- /dev/null
+++ b/progs/fp/tri-sge2.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..d9c5c44c30
--- /dev/null
+++ b/progs/fp/tri-sin.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+static void Init( void )
+{
+ static const char *modulate2D =
+ "!!ARBfp1.0\n"
+ "MOV result.color, {0.0}.x; \n"
+ "COS result.color.y, 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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..fd25fb5258
--- /dev/null
+++ b/progs/fp/tri-slt.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..c676c4fa6a
--- /dev/null
+++ b/progs/fp/tri-sub.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..848387c972
--- /dev/null
+++ b/progs/fp/tri-swz.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..0d6bcbca3f
--- /dev/null
+++ b/progs/fp/tri-swz2.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..12fdc3730a
--- /dev/null
+++ b/progs/fp/tri-tex.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#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"
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : 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 0000000000..4c5cc33c12
--- /dev/null
+++ b/progs/fp/tri-xpd.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+#include "GL/gl.h"
+
+
+#define CI_OFFSET_1 16
+#define CI_OFFSET_2 32
+
+
+GLenum doubleBuffer;
+
+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();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+
+ if (glutCreateWindow("First Tri") == GL_FALSE) {
+ exit(1);
+ }
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}