summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
Diffstat (limited to 'progs')
-rw-r--r--progs/demos/Makefile1
-rw-r--r--progs/demos/textures.c304
-rw-r--r--progs/glsl/CH11-bumpmap.frag2
-rw-r--r--progs/glsl/Makefile8
-rw-r--r--progs/glsl/identity.c208
-rw-r--r--progs/trivial/Makefile3
-rw-r--r--progs/trivial/tri-mask-tri.c123
-rw-r--r--progs/trivial/vp-tri-cb.c107
-rw-r--r--progs/trivial/vp-tri-imm.c101
-rw-r--r--progs/trivial/vp-tri-swap.c103
10 files changed, 899 insertions, 61 deletions
diff --git a/progs/demos/Makefile b/progs/demos/Makefile
index 123d1e59e9..467dbc5cdf 100644
--- a/progs/demos/Makefile
+++ b/progs/demos/Makefile
@@ -66,6 +66,7 @@ PROGS = \
texdown \
texenv \
texobj \
+ textures \
trispd \
tunnel \
tunnel2 \
diff --git a/progs/demos/textures.c b/progs/demos/textures.c
new file mode 100644
index 0000000000..9f11604635
--- /dev/null
+++ b/progs/demos/textures.c
@@ -0,0 +1,304 @@
+/*
+ * Simple test of multiple textures
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+#include "readtex.h"
+
+#define MAX_TEXTURES 8
+
+
+static int Win;
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLboolean Anim = GL_TRUE;
+static GLboolean Blend = GL_FALSE;
+static GLboolean MipMap = 1+GL_FALSE;
+
+static GLuint NumTextures;
+static GLuint Textures[MAX_TEXTURES];
+static float TexRot[MAX_TEXTURES][3];
+static float TexPos[MAX_TEXTURES][3];
+static float TexAspect[MAX_TEXTURES];
+
+static const char *DefaultFiles[] = {
+ "../images/arch.rgb",
+ "../images/reflect.rgb",
+ "../images/tree2.rgba",
+ "../images/tile.rgb"
+};
+
+
+static void
+Idle(void)
+{
+ Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.02;
+ Yrot = glutGet(GLUT_ELAPSED_TIME) * 0.04;
+ //Zrot += 2.0;
+ glutPostRedisplay();
+}
+
+
+static void
+DrawTextures(void)
+{
+ GLuint i;
+
+ for (i = 0; i < NumTextures; i++) {
+ GLfloat ar = TexAspect[i];
+
+ glPushMatrix();
+ glTranslatef(TexPos[i][0], TexPos[i][1], TexPos[i][2]);
+ glRotatef(TexRot[i][0], 1, 0, 0);
+ glRotatef(TexRot[i][1], 0, 1, 0);
+ glRotatef(TexRot[i][2], 0, 0, 1);
+
+ glBindTexture(GL_TEXTURE_2D, Textures[i]);
+ glBegin(GL_POLYGON);
+ glTexCoord2f( 0.0, 0.0 ); glVertex2f( -ar, -1.0 );
+ glTexCoord2f( 1.0, 0.0 ); glVertex2f( ar, -1.0 );
+ glTexCoord2f( 1.0, 1.0 ); glVertex2f( ar, 1.0 );
+ glTexCoord2f( 0.0, 1.0 ); glVertex2f( -ar, 1.0 );
+ glEnd();
+
+ glPopMatrix();
+ }
+}
+
+static void
+Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ if (Blend) {
+ glEnable(GL_BLEND);
+ glDisable(GL_DEPTH_TEST);
+ }
+ else {
+ glDisable(GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
+ }
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ DrawTextures();
+
+ glPopMatrix();
+
+ glutSwapBuffers();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 50.0);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0, 0.0, -10.0);
+}
+
+
+static GLfloat
+RandFloat(float min, float max)
+{
+ float x = (float) (rand() % 1000) * 0.001;
+ x = x * (max - min) + min;
+ return x;
+}
+
+
+static void
+Randomize(void)
+{
+ GLfloat k = 1.0;
+ GLuint i;
+
+ srand(glutGet(GLUT_ELAPSED_TIME));
+
+ for (i = 0; i < NumTextures; i++) {
+ TexRot[i][0] = RandFloat(0.0, 360);
+ TexRot[i][1] = RandFloat(0.0, 360);
+ TexRot[i][2] = RandFloat(0.0, 360);
+ TexPos[i][0] = RandFloat(-k, k);
+ TexPos[i][1] = RandFloat(-k, k);
+ TexPos[i][2] = RandFloat(-k, k);
+ }
+}
+
+
+static void
+SetTexFilters(void)
+{
+ GLuint i;
+ for (i = 0; i < NumTextures; i++) {
+ glBindTexture(GL_TEXTURE_2D, Textures[i]);
+ if (MipMap) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ }
+ }
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'b':
+ Blend = !Blend;
+ break;
+ case 'm':
+ MipMap = !MipMap;
+ SetTexFilters();
+ break;
+ case 'r':
+ Randomize();
+ case 'z':
+ Zrot -= step;
+ break;
+ case 'Z':
+ Zrot += step;
+ break;
+ case 27:
+ glutDestroyWindow(Win);
+ exit(0);
+ break;
+ }
+
+ printf("Blend=%s MipMap=%s\n",
+ Blend ? "Y" : "n",
+ MipMap ? "Y" : "n");
+
+ glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+LoadTextures(GLuint n, const char *files[])
+{
+ GLuint i;
+
+ NumTextures = n < MAX_TEXTURES ? n : MAX_TEXTURES;
+
+ glGenTextures(n, Textures);
+
+ for (i = 0; i < n; i++) {
+ GLint w, h;
+ glBindTexture(GL_TEXTURE_2D, Textures[i]);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ if (!LoadRGBMipmaps2(files[i], GL_TEXTURE_2D, GL_RGB, &w, &h)) {
+ printf("Error: couldn't load %s\n", files[i]);
+ exit(1);
+ }
+ TexAspect[i] = (float) w / (float) h;
+ printf("Loaded %s\n", files[i]);
+ }
+}
+
+
+static void
+Init(int argc, const char *argv[])
+{
+ if (argc == 1)
+ LoadTextures(4, DefaultFiles);
+ else
+ LoadTextures(argc - 1, argv + 1);
+
+ Randomize();
+
+ glEnable(GL_TEXTURE_2D);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(1, 1, 1, 0.5);
+
+#if 0
+ /* setup lighting, etc */
+ glEnable(GL_LIGHTING);
+ glEnable(GL_LIGHT0);
+#endif
+}
+
+
+static void
+Usage(void)
+{
+ printf("Usage:\n");
+ printf(" textures [file.rgb] ...\n");
+ printf("Keys:\n");
+ printf(" a - toggle animation\n");
+ printf(" b - toggle blending\n");
+ printf(" m - toggle mipmapping\n");
+ printf(" r - randomize\n");
+ printf(" ESC - exit\n");
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 400);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ Win = glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Draw);
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init(argc, (const char **) argv);
+ Usage();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/glsl/CH11-bumpmap.frag b/progs/glsl/CH11-bumpmap.frag
index 063576f5a3..e12c5d374c 100644
--- a/progs/glsl/CH11-bumpmap.frag
+++ b/progs/glsl/CH11-bumpmap.frag
@@ -24,7 +24,7 @@ void main()
float d, f;
d = p.x * p.x + p.y * p.y;
- f = 1.0 / sqrt(d + 1.0);
+ f = inversesqrt(d + 1.0);
if (d >= BumpSize)
{ p = vec2(0.0); f = 1.0; }
diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile
index 9999d6c08a..04c1d25ed7 100644
--- a/progs/glsl/Makefile
+++ b/progs/glsl/Makefile
@@ -15,6 +15,7 @@ PROGS = \
bump \
convolutions \
deriv \
+ identity \
mandelbrot \
multitex \
noise \
@@ -106,6 +107,13 @@ deriv: deriv.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@
+identity.o: identity.c extfuncs.h shaderutil.h
+ $(APP_CC) -c -I$(INCDIR) $(CFLAGS) identity.c
+
+identity: identity.o shaderutil.o
+ $(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) identity.o shaderutil.o $(LIBS) -o $@
+
+
mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c
diff --git a/progs/glsl/identity.c b/progs/glsl/identity.c
new file mode 100644
index 0000000000..dce140fc64
--- /dev/null
+++ b/progs/glsl/identity.c
@@ -0,0 +1,208 @@
+/**
+ * Test very basic glsl functionality (identity vertex and fragment shaders).
+ * Brian Paul & Stephane Marchesin
+ */
+
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glut.h>
+#include <GL/glext.h>
+#include "extfuncs.h"
+#include "shaderutil.h"
+
+
+static char *FragProgFile = NULL;
+static char *VertProgFile = NULL;
+static GLuint fragShader;
+static GLuint vertShader;
+static GLuint program;
+static GLint win = 0;
+static GLboolean anim = GL_TRUE;
+static GLfloat xRot = 0.0f, yRot = 0.0f;
+static int w,h;
+
+
+static void
+Redisplay(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(.8,0,0);
+ glVertex3f(-0.9, -0.9, 0.0);
+ glColor3f(0,.9,0);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.0, 0.9, 0.0);
+ glEnd();
+
+ glutSwapBuffers();
+}
+
+
+static void
+Idle(void)
+{
+ yRot = glutGet(GLUT_ELAPSED_TIME) * 0.1;
+ glutPostRedisplay();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ w = width;
+ h = height;
+}
+
+
+static void
+CleanUp(void)
+{
+ glDeleteShader_func(fragShader);
+ glDeleteShader_func(vertShader);
+ glDeleteProgram_func(program);
+ glutDestroyWindow(win);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ (void) x;
+ (void) y;
+
+ switch(key) {
+ case ' ':
+ case 'a':
+ anim = !anim;
+ if (anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 27:
+ CleanUp();
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+ const GLfloat step = 3.0f;
+
+ (void) x;
+ (void) y;
+
+ switch(key) {
+ case GLUT_KEY_UP:
+ xRot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ xRot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ yRot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ yRot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+ static const char *fragShaderText =
+ "void main() {\n"
+ " gl_FragColor = vec4(1.0,0.0,0.0,1.0);\n"
+ "}\n";
+ static const char *vertShaderText =
+ "void main() {\n"
+ " gl_Position = gl_Vertex;\n"
+ "}\n";
+
+ if (!ShadersSupported())
+ exit(1);
+
+ GetExtensionFuncs();
+
+ if (FragProgFile)
+ fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragProgFile);
+ else
+ fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText);
+
+ if (VertProgFile)
+ vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertProgFile);
+ else
+ vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText);
+
+ program = LinkShaders(vertShader, fragShader);
+
+ glUseProgram_func(program);
+
+ /*assert(glGetError() == 0);*/
+
+ glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
+ glEnable(GL_DEPTH_TEST);
+
+ printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
+
+ assert(glIsProgram_func(program));
+ assert(glIsShader_func(fragShader));
+ assert(glIsShader_func(vertShader));
+
+ glColor3f(1, 0, 0);
+}
+
+
+static void
+ParseOptions(int argc, char *argv[])
+{
+ int i;
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-fs") == 0) {
+ FragProgFile = argv[i+1];
+ }
+ else if (strcmp(argv[i], "-vs") == 0) {
+ VertProgFile = argv[i+1];
+ }
+ }
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition( 0, 0);
+ glutInitWindowSize(200, 200);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ win = glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Redisplay);
+ if (anim)
+ glutIdleFunc(Idle);
+ ParseOptions(argc, argv);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile
index 28c0b12fa4..a4077bd016 100644
--- a/progs/trivial/Makefile
+++ b/progs/trivial/Makefile
@@ -125,6 +125,9 @@ SOURCES = \
vp-clip.c \
vp-line-clip.c \
vp-tri.c \
+ vp-tri-swap.c \
+ vp-tri-imm.c \
+ vp-tri-cb.c \
vp-unfilled.c
PROGS = $(SOURCES:%.c=%)
diff --git a/progs/trivial/tri-mask-tri.c b/progs/trivial/tri-mask-tri.c
index 38ecd20a73..8333f7ed8a 100644
--- a/progs/trivial/tri-mask-tri.c
+++ b/progs/trivial/tri-mask-tri.c
@@ -28,48 +28,53 @@
#include <GL/glut.h>
-#define CI_OFFSET_1 16
-#define CI_OFFSET_2 32
-
GLint Width = 250, Height = 250;
-
GLenum doubleBuffer;
+GLint Win;
+GLboolean Rmask = GL_TRUE, Gmask = GL_FALSE, Bmask = GL_TRUE;
+
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.0, 0.0, 1.0, 0.0);
+ glClearColor(0.0, 0.0, 1.0, 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);
+ 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();
+ switch (key) {
+ case 'r':
+ Rmask = !Rmask;
+ break;
+ case 'g':
+ Gmask = !Gmask;
+ break;
+ case 'b':
+ Bmask = !Bmask;
+ break;
+ case 27:
+ glutDestroyWindow(Win);
+ exit(1);
+ default:
+ return;
+ }
+ glutPostRedisplay();
}
static void Draw(void)
{
+ printf("ColorMask = %d, %d, %d\n", Rmask, Gmask, Bmask);
glColorMask(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
@@ -82,7 +87,7 @@ static void Draw(void)
glVertex3f(-0.9, 0.0, -30.0);
glEnd();
- glColorMask(1,0,1,0);
+ glColorMask(Rmask, Gmask, Bmask, 0);
/* left triangle: white&mask: purple middle region: white */
glBegin(GL_TRIANGLES);
@@ -103,48 +108,46 @@ static void Draw(void)
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;
+ 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);
+ GLenum type;
- if (Args(argc, argv) == GL_FALSE) {
- exit(1);
- }
+ glutInit(&argc, argv);
- glutInitWindowPosition(100, 0); glutInitWindowSize(Width, Height);
-
- type = GLUT_RGB;
- type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
- glutInitDisplayMode(type);
-
- if (glutCreateWindow("First Tri") == GL_FALSE) {
- exit(1);
- }
-
- Init();
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Draw);
- glutMainLoop();
- return 0;
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+
+ glutInitWindowPosition(100, 0); glutInitWindowSize(Width, Height);
+ glutInitDisplayMode(type);
+ Win = glutCreateWindow("First Tri");
+ Init();
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
}
diff --git a/progs/trivial/vp-tri-cb.c b/progs/trivial/vp-tri-cb.c
new file mode 100644
index 0000000000..f9d0d7f559
--- /dev/null
+++ b/progs/trivial/vp-tri-cb.c
@@ -0,0 +1,107 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "PARAM Diffuse = state.material.diffuse; \n"
+ "MOV result.color, Diffuse;\n"
+ "MOV result.position, vertex.position;\n"
+ "END\n";
+
+ const float Diffuse[4] = { 0.0, 1.0, 0.0, 1.0 };
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse);
+
+
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog1), (const GLubyte *) prog1);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+}
+
+static void Display( void )
+{
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+
+ glFlush();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ /*glTranslatef( 0.0, 0.0, -15.0 );*/
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/vp-tri-imm.c b/progs/trivial/vp-tri-imm.c
new file mode 100644
index 0000000000..c774573ba8
--- /dev/null
+++ b/progs/trivial/vp-tri-imm.c
@@ -0,0 +1,101 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "ADD result.color, vertex.color, {.5}.x;\n"
+ "MOV result.position, vertex.position;\n"
+ "END\n";
+
+
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog1), (const GLubyte *) prog1);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+}
+
+static void Display( void )
+{
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,0);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+
+ glFlush();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ /*glTranslatef( 0.0, 0.0, -15.0 );*/
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/vp-tri-swap.c b/progs/trivial/vp-tri-swap.c
new file mode 100644
index 0000000000..e9ca1a0378
--- /dev/null
+++ b/progs/trivial/vp-tri-swap.c
@@ -0,0 +1,103 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.position, vertex.color;\n"
+ "MOV result.color, vertex.position;\n"
+ "END\n";
+
+
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog1), (const GLubyte *) prog1);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+}
+
+static void Display( void )
+{
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+
+ glFlush();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ /*glTranslatef( 0.0, 0.0, -15.0 );*/
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}