summaryrefslogtreecommitdiff
path: root/progs/trivial
diff options
context:
space:
mode:
Diffstat (limited to 'progs/trivial')
-rw-r--r--progs/trivial/Makefile4
-rw-r--r--progs/trivial/SConscript3
-rw-r--r--progs/trivial/sub-tex.c137
-rw-r--r--progs/trivial/tex-quads.c143
-rw-r--r--progs/trivial/tri-fbo-tex-mip.c2
-rw-r--r--progs/trivial/tri-fbo-tex.c2
-rw-r--r--progs/trivial/tri-point-line-clipped.c116
-rw-r--r--progs/trivial/tri-scissor-tri.c58
-rw-r--r--progs/trivial/tri-z-eq.c14
-rw-r--r--progs/trivial/vp-array-hf.c215
10 files changed, 676 insertions, 18 deletions
diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile
index e15ec33ab5..6c78ae90a9 100644
--- a/progs/trivial/Makefile
+++ b/progs/trivial/Makefile
@@ -90,6 +90,8 @@ SOURCES = \
quadstrip-flat.c \
quadstrip.c \
readpixels.c \
+ sub-tex.c \
+ tex-quads.c \
tri-alpha.c \
tri-alpha-tex.c \
tri-array-interleaved.c \
@@ -119,6 +121,7 @@ SOURCES = \
tri-lit-material.c \
tri-mask-tri.c \
tri-orig.c \
+ tri-point-line-clipped.c \
tri-query.c \
tri-repeat.c \
tri-scissor-tri.c \
@@ -159,6 +162,7 @@ SOURCES = \
vbo-drawelements.c \
vbo-drawrange.c \
vp-array.c \
+ vp-array-hf.c \
vp-array-int.c \
vp-clip.c \
vp-line-clip.c \
diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript
index 613383c77b..87a4d2164b 100644
--- a/progs/trivial/SConscript
+++ b/progs/trivial/SConscript
@@ -70,6 +70,8 @@ progs = [
'quadstrip-cont',
'quadstrip-flat',
'quadstrip',
+ 'sub-tex',
+ 'tex-quads',
'tri-alpha',
'tri-blend-color',
'tri-blend-max',
@@ -96,6 +98,7 @@ progs = [
'tri-logicop-xor',
'tri-mask-tri',
'tri-orig',
+ 'tri-point-line-clipped',
'tri-query',
'tri-repeat',
'tri-scissor-tri',
diff --git a/progs/trivial/sub-tex.c b/progs/trivial/sub-tex.c
new file mode 100644
index 0000000000..0b8bb28182
--- /dev/null
+++ b/progs/trivial/sub-tex.c
@@ -0,0 +1,137 @@
+/**
+ * Draw a series of textured quads after each quad, use glTexSubImage()
+ * to change one row of the texture image.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+
+static GLint Win = 0;
+static GLuint Tex = 0;
+
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fflush(stderr);
+
+ glGenTextures(1, &Tex);
+ glBindTexture(GL_TEXTURE_2D, Tex);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+}
+
+
+static void Reshape(int width, int height)
+{
+ float ar = (float) width / height;
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-ar, ar, -1.0, 1.0, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+
+static void Key(unsigned char key, int x, int y)
+{
+ if (key == 27) {
+ glDeleteTextures(1, &Tex);
+ glutDestroyWindow(Win);
+ exit(1);
+ }
+ glutPostRedisplay();
+}
+
+
+static void Draw(void)
+{
+ GLubyte tex[16][16][4];
+ GLubyte row[16][4];
+ int i, j;
+
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ if ((i + j) & 1) {
+ tex[i][j][0] = 128;
+ tex[i][j][1] = 128;
+ tex[i][j][2] = 128;
+ tex[i][j][3] = 255;
+ }
+ else {
+ tex[i][j][0] = 255;
+ tex[i][j][1] = 255;
+ tex[i][j][2] = 255;
+ tex[i][j][3] = 255;
+ }
+ }
+ }
+
+ for (i = 0; i < 16; i++) {
+ row[i][0] = 255;
+ row[i][1] = 0;
+ row[i][2] = 0;
+ row[i][3] = 255;
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, tex);
+ glEnable(GL_TEXTURE_2D);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ for (i = 0; i < 9; i++) {
+
+ glPushMatrix();
+ glTranslatef(-4.0 + i, 0, 0);
+ glScalef(0.5, 0.5, 1.0);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(1,0);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glTexCoord2f(1,1);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glTexCoord2f(0,1);
+ glVertex3f(-0.9, 0.9, 0.0);
+ glTexCoord2f(0,0);
+ glVertex3f(-0.9, -0.9, 0.0);
+ glEnd();
+
+ glPopMatrix();
+
+ /* replace a row of the texture image with red texels */
+ if (i * 2 < 16)
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i*2, 16, 1,
+ GL_RGBA, GL_UNSIGNED_BYTE, row);
+ }
+
+
+ glutSwapBuffers();
+}
+
+
+int main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+ glutInitWindowSize(900, 200);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+ Win = glutCreateWindow(*argv);
+ if (!Win) {
+ exit(1);
+ }
+ glewInit();
+ Init();
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/tex-quads.c b/progs/trivial/tex-quads.c
new file mode 100644
index 0000000000..626e178b87
--- /dev/null
+++ b/progs/trivial/tex-quads.c
@@ -0,0 +1,143 @@
+/**
+ * Draw a series of quads, each with a different texture.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+#define NUM_TEX 10
+
+static GLint Win = 0;
+static GLuint Tex[NUM_TEX];
+
+
+static void Init(void)
+{
+ int i;
+
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fflush(stderr);
+
+ glGenTextures(NUM_TEX, Tex);
+
+ for (i = 0; i < NUM_TEX; i++) {
+ glBindTexture(GL_TEXTURE_2D, Tex[i]);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
+}
+
+
+static void Reshape(int width, int height)
+{
+ float ar = (float) width / height;
+ glViewport(0, 0, width, height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-ar, ar, -1.0, 1.0, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+
+static void Key(unsigned char key, int x, int y)
+{
+ if (key == 27) {
+ glDeleteTextures(NUM_TEX, Tex);
+ glutDestroyWindow(Win);
+ exit(1);
+ }
+ glutPostRedisplay();
+}
+
+
+static void Draw(void)
+{
+ GLubyte tex[16][16][4];
+ int t, i, j;
+
+ for (t = 0; t < NUM_TEX; t++) {
+
+ for (i = 0; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ if (i < t) {
+ /* red row */
+ tex[i][j][0] = 255;
+ tex[i][j][1] = 0;
+ tex[i][j][2] = 0;
+ tex[i][j][3] = 255;
+ }
+ else if ((i + j) & 1) {
+ tex[i][j][0] = 128;
+ tex[i][j][1] = 128;
+ tex[i][j][2] = 128;
+ tex[i][j][3] = 255;
+ }
+ else {
+ tex[i][j][0] = 255;
+ tex[i][j][1] = 255;
+ tex[i][j][2] = 255;
+ tex[i][j][3] = 255;
+ }
+ }
+ }
+
+ glBindTexture(GL_TEXTURE_2D, Tex[t]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, tex);
+ }
+
+ glEnable(GL_TEXTURE_2D);
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ for (i = 0; i < NUM_TEX; i++) {
+
+ glBindTexture(GL_TEXTURE_2D, Tex[i]);
+
+ glPushMatrix();
+ glTranslatef(-4.0 + i, 0, 0);
+ glScalef(0.5, 0.5, 1.0);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(1,0);
+ glVertex3f( 0.9, -0.9, 0.0);
+ glTexCoord2f(1,1);
+ glVertex3f( 0.9, 0.9, 0.0);
+ glTexCoord2f(0,1);
+ glVertex3f(-0.9, 0.9, 0.0);
+ glTexCoord2f(0,0);
+ glVertex3f(-0.9, -0.9, 0.0);
+ glEnd();
+
+ glPopMatrix();
+ }
+
+
+ glutSwapBuffers();
+}
+
+
+int main(int argc, char **argv)
+{
+ glutInit(&argc, argv);
+ glutInitWindowSize(900, 200);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
+ Win = glutCreateWindow(*argv);
+ if (!Win) {
+ exit(1);
+ }
+ glewInit();
+ Init();
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/tri-fbo-tex-mip.c b/progs/trivial/tri-fbo-tex-mip.c
index 0744369501..2e8fb74a00 100644
--- a/progs/trivial/tri-fbo-tex-mip.c
+++ b/progs/trivial/tri-fbo-tex-mip.c
@@ -6,8 +6,6 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <math.h>
/* For debug */
diff --git a/progs/trivial/tri-fbo-tex.c b/progs/trivial/tri-fbo-tex.c
index 8d1f871328..eacb7d577b 100644
--- a/progs/trivial/tri-fbo-tex.c
+++ b/progs/trivial/tri-fbo-tex.c
@@ -6,8 +6,6 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <math.h>
/* For debug */
diff --git a/progs/trivial/tri-point-line-clipped.c b/progs/trivial/tri-point-line-clipped.c
new file mode 100644
index 0000000000..f8c1015f5f
--- /dev/null
+++ b/progs/trivial/tri-point-line-clipped.c
@@ -0,0 +1,116 @@
+/**
+ * Test frustum/user clipping w/ glPolygonMode LINE/POINT.
+ *
+ * The bottom/left and bottom/right verts are outside the frustum and clipped.
+ * The top vertex is clipped by a user clipping plane.
+ *
+ * A filled gray reference triangle is shown underneath the points/lines.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+static int win;
+
+
+static void
+ColorTri(void)
+{
+ glBegin(GL_TRIANGLES);
+ glColor3f(1, 0, 0); glVertex3f(-1.5, -0.8, 0.0);
+ glColor3f(0, 1, 0); glVertex3f( 1.5, -0.8, 0.0);
+ glColor3f(0, 0, 1); glVertex3f( 0.0, 0.9, 0.0);
+ glEnd();
+}
+
+
+static void
+GrayTri(void)
+{
+ glColor3f(0.3, 0.3, 0.3);
+ glBegin(GL_TRIANGLES);
+ glVertex3f(-1.5, -0.8, 0.0);
+ glVertex3f( 1.5, -0.8, 0.0);
+ glVertex3f( 0.0, 0.9, 0.0);
+ glEnd();
+}
+
+
+static void
+Draw(void)
+{
+ static const GLdouble plane[4] = { 0, -1.0, 0, 0.5 };
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glPointSize(13.0);
+ glLineWidth(5.0);
+
+ glClipPlane(GL_CLIP_PLANE0, plane);
+ glEnable(GL_CLIP_PLANE0);
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ GrayTri();
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ ColorTri();
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+ ColorTri();
+
+ glutSwapBuffers();
+}
+
+
+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, -1.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+}
+
+
+static void
+Key(unsigned char key, int x, int y)
+{
+ if (key == 27) {
+ glutDestroyWindow(win);
+ exit(0);
+ }
+ else {
+ glutPostRedisplay();
+ }
+}
+
+
+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));
+ fflush(stderr);
+}
+
+
+int
+main(int argc, char **argv)
+{
+ glutInitWindowSize(300, 300);
+ glutInit(&argc, argv);
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
+ win = glutCreateWindow(*argv);
+ if (!win) {
+ return 1;
+ }
+ Init();
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/tri-scissor-tri.c b/progs/trivial/tri-scissor-tri.c
index d65502d91b..1bb15501bb 100644
--- a/progs/trivial/tri-scissor-tri.c
+++ b/progs/trivial/tri-scissor-tri.c
@@ -31,10 +31,14 @@
#define CI_OFFSET_1 16
#define CI_OFFSET_2 32
-GLint Width = 250, Height = 250;
+GLint Width = 300, Height = 300;
GLenum doubleBuffer;
+/* scissor bounds */
+static GLint Left, Right, Bottom, Top;
+
+
static void Init(void)
{
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
@@ -47,26 +51,57 @@ static void Init(void)
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);
+
+ Width = width;
+ Height = height;
+
+ Left = Width / 4;
+ Right = Width * 3 / 4;
+ Bottom = Height / 4;
+ Top = Height * 3 / 4;
}
static void Key(unsigned char key, int x, int y)
{
+ int step = 2;
+ switch (key) {
+ case 'l':
+ Left -= step;
+ break;
+ case 'L':
+ Left += step;
+ break;
+ case 'r':
+ Right -= step;
+ break;
+ case 'R':
+ Right += step;
+ break;
+ case 'b':
+ Bottom -= step;
+ break;
+ case 'B':
+ Bottom += step;
+ break;
+ case 't':
+ Top -= step;
+ break;
+ case 'T':
+ Top += step;
+ break;
+ case 27:
+ exit(1);
+ default:
+ ;
+ }
- switch (key) {
- case 27:
- exit(1);
- default:
- break;
- }
-
- glutPostRedisplay();
+ glutPostRedisplay();
}
static void Draw(void)
@@ -82,7 +117,8 @@ static void Draw(void)
glVertex3f(-0.9, 0.0, -30.0);
glEnd();
- glScissor(Width / 4, Height / 4, Width / 2, Height / 2);
+ printf("Scissor %d, %d .. %d, %d\n", Left, Bottom, Right, Top);
+ glScissor(Left, Bottom, Right-Left, Top-Bottom);
glEnable(GL_SCISSOR_TEST);
glBegin(GL_TRIANGLES);
diff --git a/progs/trivial/tri-z-eq.c b/progs/trivial/tri-z-eq.c
index 6bdac47419..c04ffae7f1 100644
--- a/progs/trivial/tri-z-eq.c
+++ b/progs/trivial/tri-z-eq.c
@@ -69,6 +69,8 @@ static void Key(unsigned char key, int x, int y)
static void Draw(void)
{
+ float z = 1.0;
+
glClearColor(0.0, 0.0, 1.0, 0.0);
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -77,15 +79,21 @@ static void Draw(void)
glBegin(GL_TRIANGLES);
glColor3f(0,0,.7);
- glVertex3f( 0.9, -0.9, 1.0);
+ glVertex3f( 0.9, -0.9, z);
glColor3f(.8,0,0);
- glVertex3f( 0.9, 0.9, 1.0);
+ glVertex3f( 0.9, 0.9, z);
glColor3f(0,.9,0);
- glVertex3f(-0.9, 0.0, 1.0);
+ glVertex3f(-0.9, 0.0, z);
glEnd();
glFlush();
+ {
+ GLfloat z;
+ glReadPixels(125, 125, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
+ printf("Z at (125, 125) = %f\n", z);
+ }
+
if (doubleBuffer) {
glutSwapBuffers();
}
diff --git a/progs/trivial/vp-array-hf.c b/progs/trivial/vp-array-hf.c
new file mode 100644
index 0000000000..f812436437
--- /dev/null
+++ b/progs/trivial/vp-array-hf.c
@@ -0,0 +1,215 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+typedef union { GLfloat f; GLint i; } fi_type;
+/**
+ * Convert a 4-byte float to a 2-byte half float.
+ * Based on code from:
+ * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
+ */
+static GLhalf
+_mesa_float_to_half(GLfloat val)
+{
+
+ const fi_type fi = {val};
+ const int flt_m = fi.i & 0x7fffff;
+ const int flt_e = (fi.i >> 23) & 0xff;
+ const int flt_s = (fi.i >> 31) & 0x1;
+ int s, e, m = 0;
+ GLhalf result;
+
+ /* sign bit */
+ s = flt_s;
+
+ /* handle special cases */
+ if ((flt_e == 0) && (flt_m == 0)) {
+ /* zero */
+ /* m = 0; - already set */
+ e = 0;
+ }
+ else if ((flt_e == 0) && (flt_m != 0)) {
+ /* denorm -- denorm float maps to 0 half */
+ /* m = 0; - already set */
+ e = 0;
+ }
+ else if ((flt_e == 0xff) && (flt_m == 0)) {
+ /* infinity */
+ /* m = 0; - already set */
+ e = 31;
+ }
+ else if ((flt_e == 0xff) && (flt_m != 0)) {
+ /* NaN */
+ m = 1;
+ e = 31;
+ }
+ else {
+ /* regular number */
+ const int new_exp = flt_e - 127;
+ if (new_exp < -24) {
+ /* this maps to 0 */
+ /* m = 0; - already set */
+ e = 0;
+ }
+ else if (new_exp < -14) {
+ /* this maps to a denorm */
+ unsigned int exp_val = (unsigned int) (-14 - new_exp); /* 2^-exp_val*/
+ e = 0;
+ switch (exp_val) {
+ case 0:
+ /* m = 0; - already set */
+ break;
+ case 1: m = 512 + (flt_m >> 14); break;
+ case 2: m = 256 + (flt_m >> 15); break;
+ case 3: m = 128 + (flt_m >> 16); break;
+ case 4: m = 64 + (flt_m >> 17); break;
+ case 5: m = 32 + (flt_m >> 18); break;
+ case 6: m = 16 + (flt_m >> 19); break;
+ case 7: m = 8 + (flt_m >> 20); break;
+ case 8: m = 4 + (flt_m >> 21); break;
+ case 9: m = 2 + (flt_m >> 22); break;
+ case 10: m = 1; break;
+ }
+ }
+ else if (new_exp > 15) {
+ /* map this value to infinity */
+ /* m = 0; - already set */
+ e = 31;
+ }
+ else {
+ /* regular */
+ e = new_exp + 15;
+ m = flt_m >> 13;
+ }
+ }
+
+ result = (s << 15) | (e << 10) | m;
+ return result;
+}
+
+
+GLfloat verts[][4] = {
+ { 0.9, -0.9, 0.0, 1.0 },
+ { 0.9, 0.9, 0.0, 1.0 },
+ { -0.9, 0.9, 0.0, 1.0 },
+ { -0.9, -0.9, 0.0, 1.0 },
+};
+
+GLhalf hverts[16];
+
+GLubyte color[][4] = {
+ { 0x00, 0x00, 0xff, 0x00 },
+ { 0x00, 0xff, 0x00, 0x00 },
+ { 0xff, 0x00, 0x00, 0x00 },
+ { 0xff, 0xff, 0xff, 0x00 },
+};
+
+GLuint indices[] = { 0, 1, 2, 3 };
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+ GLuint i, j;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.color, vertex.color;\n"
+ "MOV result.position, vertex.position;\n"
+ "END\n";
+
+ if (!glutExtensionSupported("GL_ARB_half_float_vertex")) {
+ printf("GL_ARB_half_float_vertex not found!\n");
+ exit(0);
+ }
+
+ 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));
+ }
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++)
+ hverts[i * 4 + j] = _mesa_float_to_half(verts[i][j]);
+
+ glEnableClientState( GL_VERTEX_ARRAY );
+ glEnableClientState( GL_COLOR_ARRAY );
+ glVertexPointer( 4, GL_HALF_FLOAT, 8, hverts );
+ glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color );
+
+}
+
+
+
+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);
+ glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices );
+
+ 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_RGB | GLUT_SINGLE | GLUT_DEPTH );
+ glutCreateWindow(argv[0]);
+ glewInit();
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}