diff options
author | Julien Cristau <[email protected]> | 2009-06-28 18:09:58 +0200 |
---|---|---|
committer | Julien Cristau <[email protected]> | 2009-06-28 18:09:58 +0200 |
commit | d2c8712fa45da0551b4e1711fe151bf428d97c2e (patch) | |
tree | c456e6c9e7145dea06f403f99156f92cbe4824c6 /progs | |
parent | b59211a602de650108028b563a1d3a5223a2845b (diff) |
Remove some directories absent from the tarballs, and add some missing ones
Diffstat (limited to 'progs')
128 files changed, 1942 insertions, 16665 deletions
diff --git a/progs/demos/dinoshade.c b/progs/demos/dinoshade.c new file mode 100644 index 00000000000..cbf8751e257 --- /dev/null +++ b/progs/demos/dinoshade.c @@ -0,0 +1,914 @@ + +/* Copyright (c) Mark J. Kilgard, 1994, 1997. */ + +/* This program is freely distributable without licensing fees + and is provided without guarantee or warrantee expressed or + implied. This program is -not- in the public domain. */ + +/* Example for PC game developers to show how to *combine* texturing, + reflections, and projected shadows all in real-time with OpenGL. + Robust reflections use stenciling. Robust projected shadows + use both stenciling and polygon offset. PC game programmers + should realize that neither stenciling nor polygon offset are + supported by Direct3D, so these real-time rendering algorithms + are only really viable with OpenGL. + + The program has modes for disabling the stenciling and polygon + offset uses. It is worth running this example with these features + toggled off so you can see the sort of artifacts that result. + + Notice that the floor texturing, reflections, and shadowing + all co-exist properly. */ + +/* When you run this program: Left mouse button controls the + view. Middle mouse button controls light position (left & + right rotates light around dino; up & down moves light + position up and down). Right mouse button pops up menu. */ + +/* Check out the comments in the "redraw" routine to see how the + reflection blending and surface stenciling is done. You can + also see in "redraw" how the projected shadows are rendered, + including the use of stenciling and polygon offset. */ + +/* This program is derived from glutdino.c */ + +/* Compile: cc -o dinoshade dinoshade.c -lglut -lGLU -lGL -lXmu -lXext -lX11 -lm */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> /* for cos(), sin(), and sqrt() */ +#include <stddef.h> /* for ptrdiff_t, referenced by GL.h when GL_GLEXT_LEGACY defined */ +#ifdef _WIN32 +#include <windows.h> +#endif +#define GL_GLEXT_LEGACY +#include <GL/glew.h> /* OpenGL Utility Toolkit header */ +#include <GL/glut.h> /* OpenGL Utility Toolkit header */ + +/* Some <math.h> files do not define M_PI... */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* Variable controlling various rendering modes. */ +static int stencilReflection = 1, stencilShadow = 1, offsetShadow = 1; +static int renderShadow = 1, renderDinosaur = 1, renderReflection = 1; +static int linearFiltering = 0, useMipmaps = 0, useTexture = 1; +static int reportSpeed = 0; +static int animation = 1; +static GLboolean lightSwitch = GL_TRUE; +static int directionalLight = 1; +static int forceExtension = 0; + +/* Time varying or user-controled variables. */ +static float jump = 0.0; +static float lightAngle = 0.0, lightHeight = 20; +GLfloat angle = -150; /* in degrees */ +GLfloat angle2 = 30; /* in degrees */ + +int moving, startx, starty; +int lightMoving = 0, lightStartX, lightStartY; + +enum { + MISSING, EXTENSION, ONE_DOT_ONE +}; +int polygonOffsetVersion; + +static GLdouble bodyWidth = 3.0; +/* *INDENT-OFF* */ +static GLfloat body[][2] = { {0, 3}, {1, 1}, {5, 1}, {8, 4}, {10, 4}, {11, 5}, + {11, 11.5}, {13, 12}, {13, 13}, {10, 13.5}, {13, 14}, {13, 15}, {11, 16}, + {8, 16}, {7, 15}, {7, 13}, {8, 12}, {7, 11}, {6, 6}, {4, 3}, {3, 2}, + {1, 2} }; +static GLfloat arm[][2] = { {8, 10}, {9, 9}, {10, 9}, {13, 8}, {14, 9}, {16, 9}, + {15, 9.5}, {16, 10}, {15, 10}, {15.5, 11}, {14.5, 10}, {14, 11}, {14, 10}, + {13, 9}, {11, 11}, {9, 11} }; +static GLfloat leg[][2] = { {8, 6}, {8, 4}, {9, 3}, {9, 2}, {8, 1}, {8, 0.5}, {9, 0}, + {12, 0}, {10, 1}, {10, 2}, {12, 4}, {11, 6}, {10, 7}, {9, 7} }; +static GLfloat eye[][2] = { {8.75, 15}, {9, 14.7}, {9.6, 14.7}, {10.1, 15}, + {9.6, 15.25}, {9, 15.25} }; +static GLfloat lightPosition[4]; +static GLfloat lightColor[] = {0.8, 1.0, 0.8, 1.0}; /* green-tinted */ +static GLfloat skinColor[] = {0.1, 1.0, 0.1, 1.0}, eyeColor[] = {1.0, 0.2, 0.2, 1.0}; +/* *INDENT-ON* */ + +/* Nice floor texture tiling pattern. */ +static char *circles[] = { + "....xxxx........", + "..xxxxxxxx......", + ".xxxxxxxxxx.....", + ".xxx....xxx.....", + "xxx......xxx....", + "xxx......xxx....", + "xxx......xxx....", + "xxx......xxx....", + ".xxx....xxx.....", + ".xxxxxxxxxx.....", + "..xxxxxxxx......", + "....xxxx........", + "................", + "................", + "................", + "................", +}; + +static void +makeFloorTexture(void) +{ + GLubyte floorTexture[16][16][3]; + GLubyte *loc; + int s, t; + + /* Setup RGB image for the texture. */ + loc = (GLubyte*) floorTexture; + for (t = 0; t < 16; t++) { + for (s = 0; s < 16; s++) { + if (circles[t][s] == 'x') { + /* Nice green. */ + loc[0] = 0x1f; + loc[1] = 0x8f; + loc[2] = 0x1f; + } else { + /* Light gray. */ + loc[0] = 0xaa; + loc[1] = 0xaa; + loc[2] = 0xaa; + } + loc += 3; + } + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if (useMipmaps) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + gluBuild2DMipmaps(GL_TEXTURE_2D, 3, 16, 16, + GL_RGB, GL_UNSIGNED_BYTE, floorTexture); + } else { + if (linearFiltering) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + glTexImage2D(GL_TEXTURE_2D, 0, 3, 16, 16, 0, + GL_RGB, GL_UNSIGNED_BYTE, floorTexture); + } +} + +enum { + X, Y, Z, W +}; +enum { + A, B, C, D +}; + +/* Create a matrix that will project the desired shadow. */ +static void +shadowMatrix(GLfloat shadowMat[4][4], + GLfloat groundplane[4], + GLfloat lightpos[4]) +{ + GLfloat dot; + + /* Find dot product between light position vector and ground plane normal. */ + dot = groundplane[X] * lightpos[X] + + groundplane[Y] * lightpos[Y] + + groundplane[Z] * lightpos[Z] + + groundplane[W] * lightpos[W]; + + shadowMat[0][0] = dot - lightpos[X] * groundplane[X]; + shadowMat[1][0] = 0.f - lightpos[X] * groundplane[Y]; + shadowMat[2][0] = 0.f - lightpos[X] * groundplane[Z]; + shadowMat[3][0] = 0.f - lightpos[X] * groundplane[W]; + + shadowMat[X][1] = 0.f - lightpos[Y] * groundplane[X]; + shadowMat[1][1] = dot - lightpos[Y] * groundplane[Y]; + shadowMat[2][1] = 0.f - lightpos[Y] * groundplane[Z]; + shadowMat[3][1] = 0.f - lightpos[Y] * groundplane[W]; + + shadowMat[X][2] = 0.f - lightpos[Z] * groundplane[X]; + shadowMat[1][2] = 0.f - lightpos[Z] * groundplane[Y]; + shadowMat[2][2] = dot - lightpos[Z] * groundplane[Z]; + shadowMat[3][2] = 0.f - lightpos[Z] * groundplane[W]; + + shadowMat[X][3] = 0.f - lightpos[W] * groundplane[X]; + shadowMat[1][3] = 0.f - lightpos[W] * groundplane[Y]; + shadowMat[2][3] = 0.f - lightpos[W] * groundplane[Z]; + shadowMat[3][3] = dot - lightpos[W] * groundplane[W]; + +} + +/* Find the plane equation given 3 points. */ +static void +findPlane(GLfloat plane[4], + GLfloat v0[3], GLfloat v1[3], GLfloat v2[3]) +{ + GLfloat vec0[3], vec1[3]; + + /* Need 2 vectors to find cross product. */ + vec0[X] = v1[X] - v0[X]; + vec0[Y] = v1[Y] - v0[Y]; + vec0[Z] = v1[Z] - v0[Z]; + + vec1[X] = v2[X] - v0[X]; + vec1[Y] = v2[Y] - v0[Y]; + vec1[Z] = v2[Z] - v0[Z]; + + /* find cross product to get A, B, and C of plane equation */ + plane[A] = vec0[Y] * vec1[Z] - vec0[Z] * vec1[Y]; + plane[B] = -(vec0[X] * vec1[Z] - vec0[Z] * vec1[X]); + plane[C] = vec0[X] * vec1[Y] - vec0[Y] * vec1[X]; + + plane[D] = -(plane[A] * v0[X] + plane[B] * v0[Y] + plane[C] * v0[Z]); +} + +static void +extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize, + GLdouble thickness, GLuint side, GLuint edge, GLuint whole) +{ + static GLUtriangulatorObj *tobj = NULL; + GLdouble vertex[3], dx, dy, len; + int i; + int count = (int) (dataSize / (2 * sizeof(GLfloat))); + + if (tobj == NULL) { + tobj = gluNewTess(); /* create and initialize a GLU + polygon tesselation object */ + gluTessCallback(tobj, GLU_BEGIN, glBegin); + gluTessCallback(tobj, GLU_VERTEX, glVertex2fv); /* semi-tricky */ + gluTessCallback(tobj, GLU_END, glEnd); + } + glNewList(side, GL_COMPILE); + glShadeModel(GL_SMOOTH); /* smooth minimizes seeing + tessellation */ + gluBeginPolygon(tobj); + for (i = 0; i < count; i++) { + vertex[0] = data[i][0]; + vertex[1] = data[i][1]; + vertex[2] = 0; + gluTessVertex(tobj, vertex, data[i]); + } + gluEndPolygon(tobj); + glEndList(); + glNewList(edge, GL_COMPILE); + glShadeModel(GL_FLAT); /* flat shade keeps angular hands + from being "smoothed" */ + glBegin(GL_QUAD_STRIP); + for (i = 0; i <= count; i++) { +#if 1 /* weird, but seems to be legal */ + /* mod function handles closing the edge */ + glVertex3f(data[i % count][0], data[i % count][1], 0.0); + glVertex3f(data[i % count][0], data[i % count][1], thickness); + /* Calculate a unit normal by dividing by Euclidean + distance. We * could be lazy and use + glEnable(GL_NORMALIZE) so we could pass in * arbitrary + normals for a very slight performance hit. */ + dx = data[(i + 1) % count][1] - data[i % count][1]; + dy = data[i % count][0] - data[(i + 1) % count][0]; + len = sqrt(dx * dx + dy * dy); + glNormal3f(dx / len, dy / len, 0.0); +#else /* the nice way of doing it */ + /* Calculate a unit normal by dividing by Euclidean + distance. We * could be lazy and use + glEnable(GL_NORMALIZE) so we could pass in * arbitrary + normals for a very slight performance hit. */ + dx = data[i % count][1] - data[(i - 1 + count) % count][1]; + dy = data[(i - 1 + count) % count][0] - data[i % count][0]; + len = sqrt(dx * dx + dy * dy); + glNormal3f(dx / len, dy / len, 0.0); + /* mod function handles closing the edge */ + glVertex3f(data[i % count][0], data[i % count][1], 0.0); + glVertex3f(data[i % count][0], data[i % count][1], thickness); +#endif + } + glEnd(); + glEndList(); + glNewList(whole, GL_COMPILE); + glFrontFace(GL_CW); + glCallList(edge); + glNormal3f(0.0, 0.0, -1.0); /* constant normal for side */ + glCallList(side); + glPushMatrix(); + glTranslatef(0.0, 0.0, thickness); + glFrontFace(GL_CCW); + glNormal3f(0.0, 0.0, 1.0); /* opposite normal for other side */ + glCallList(side); + glPopMatrix(); + glEndList(); +} + +/* Enumerants for refering to display lists. */ +typedef enum { + RESERVED, BODY_SIDE, BODY_EDGE, BODY_WHOLE, ARM_SIDE, ARM_EDGE, ARM_WHOLE, + LEG_SIDE, LEG_EDGE, LEG_WHOLE, EYE_SIDE, EYE_EDGE, EYE_WHOLE +} displayLists; + +static void +makeDinosaur(void) +{ + extrudeSolidFromPolygon(body, sizeof(body), bodyWidth, + BODY_SIDE, BODY_EDGE, BODY_WHOLE); + extrudeSolidFromPolygon(arm, sizeof(arm), bodyWidth / 4, + ARM_SIDE, ARM_EDGE, ARM_WHOLE); + extrudeSolidFromPolygon(leg, sizeof(leg), bodyWidth / 2, + LEG_SIDE, LEG_EDGE, LEG_WHOLE); + extrudeSolidFromPolygon(eye, sizeof(eye), bodyWidth + 0.2, + EYE_SIDE, EYE_EDGE, EYE_WHOLE); +} + +static void +drawDinosaur(void) + +{ + glPushMatrix(); + /* Translate the dinosaur to be at (0,8,0). */ + glTranslatef(-8, 0, -bodyWidth / 2); + glTranslatef(0.0, jump, 0.0); + glMaterialfv(GL_FRONT, GL_DIFFUSE, skinColor); + glCallList(BODY_WHOLE); + glTranslatef(0.0, 0.0, bodyWidth); + glCallList(ARM_WHOLE); + glCallList(LEG_WHOLE); + glTranslatef(0.0, 0.0, -bodyWidth - bodyWidth / 4); + glCallList(ARM_WHOLE); + glTranslatef(0.0, 0.0, -bodyWidth / 4); + glCallList(LEG_WHOLE); + glTranslatef(0.0, 0.0, bodyWidth / 2 - 0.1); + glMaterialfv(GL_FRONT, GL_DIFFUSE, eyeColor); + glCallList(EYE_WHOLE); + glPopMatrix(); +} + +static GLfloat floorVertices[4][3] = { + { -20.0, 0.0, 20.0 }, + { 20.0, 0.0, 20.0 }, + { 20.0, 0.0, -20.0 }, + { -20.0, 0.0, -20.0 }, +}; + +/* Draw a floor (possibly textured). */ +static void +drawFloor(void) +{ + glDisable(GL_LIGHTING); + + if (useTexture) { + glEnable(GL_TEXTURE_2D); + } + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex3fv(floorVertices[0]); + glTexCoord2f(0.0, 16.0); + glVertex3fv(floorVertices[1]); + glTexCoord2f(16.0, 16.0); + glVertex3fv(floorVertices[2]); + glTexCoord2f(16.0, 0.0); + glVertex3fv(floorVertices[3]); + glEnd(); + + if (useTexture) { + glDisable(GL_TEXTURE_2D); + } + + glEnable(GL_LIGHTING); +} + +static GLfloat floorPlane[4]; +static GLfloat floorShadow[4][4]; + +static void +redraw(void) +{ + int start = 0, end = 0; + + if (reportSpeed) { + start = glutGet(GLUT_ELAPSED_TIME); + } + + /* Clear; default stencil clears to zero. */ + if ((stencilReflection && renderReflection) || (stencilShadow && renderShadow)) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + } else { + /* Avoid clearing stencil when not using it. */ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + + /* Reposition the light source. */ + lightPosition[0] = 12*cos(lightAngle); + lightPosition[1] = lightHeight; + lightPosition[2] = 12*sin(lightAngle); + if (directionalLight) { + lightPosition[3] = 0.0; + } else { + lightPosition[3] = 1.0; + } + + shadowMatrix(floorShadow, floorPlane, lightPosition); + + glPushMatrix(); + /* Perform scene rotations based on user mouse input. */ + glRotatef(angle2, 1.0, 0.0, 0.0); + glRotatef(angle, 0.0, 1.0, 0.0); + + /* Tell GL new light source position. */ + glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); + + if (renderReflection) { + if (stencilReflection) { + /* We can eliminate the visual "artifact" of seeing the "flipped" + dinosaur underneath the floor by using stencil. The idea is + draw the floor without color or depth update but so that + a stencil value of one is where the floor will be. Later when + rendering the dinosaur reflection, we will only update pixels + with a stencil value of 1 to make sure the reflection only + lives on the floor, not below the floor. */ + + /* Don't update color or depth. */ + glDisable(GL_DEPTH_TEST); + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + + /* Draw 1 into the stencil buffer. */ + glEnable(GL_STENCIL_TEST); + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + glStencilFunc(GL_ALWAYS, 1, 0xffffffff); + + /* Now render floor; floor pixels just get their stencil set to 1. */ + drawFloor(); + + /* Re-enable update of color and depth. */ + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glEnable(GL_DEPTH_TEST); + + /* Now, only render where stencil is set to 1. */ + glStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if ==1 */ + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + } + + glPushMatrix(); + + /* The critical reflection step: Reflect dinosaur through the floor + (the Y=0 plane) to make a relection. */ + glScalef(1.0, -1.0, 1.0); + + /* Reflect the light position. */ + glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); + + /* To avoid our normals getting reversed and hence botched lighting + on the reflection, turn on normalize. */ + glEnable(GL_NORMALIZE); + glCullFace(GL_FRONT); + + /* Draw the reflected dinosaur. */ + drawDinosaur(); + + /* Disable noramlize again and re-enable back face culling. */ + glDisable(GL_NORMALIZE); + glCullFace(GL_BACK); + + glPopMatrix(); + + /* Switch back to the unreflected light position. */ + glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); + + if (stencilReflection) { + glDisable(GL_STENCIL_TEST); + } + } + + /* Back face culling will get used to only draw either the top or the + bottom floor. This let's us get a floor with two distinct + appearances. The top floor surface is reflective and kind of red. + The bottom floor surface is not reflective and blue. */ + + /* Draw "bottom" of floor in blue. */ + glFrontFace(GL_CW); /* Switch face orientation. */ + glColor4f(0.1, 0.1, 0.7, 1.0); + drawFloor(); + glFrontFace(GL_CCW); + + if (renderShadow) { + if (stencilShadow) { + /* Draw the floor with stencil value 3. This helps us only + draw the shadow once per floor pixel (and only on the + floor pixels). */ + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 3, 0xffffffff); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + } + } + + /* Draw "top" of floor. Use blending to blend in reflection. */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(0.7, 0.0, 0.0, 0.3); + glColor4f(1.0, 1.0, 1.0, 0.3); + drawFloor(); + glDisable(GL_BLEND); + + if (renderDinosaur) { + /* Draw "actual" dinosaur, not its reflection. */ + drawDinosaur(); + } + + if (renderShadow) { + + /* Render the projected shadow. */ + + if (stencilShadow) { + + /* Now, only render where stencil is set above 2 (ie, 3 where + the top floor is). Update stencil with 2 where the shadow + gets drawn so we don't redraw (and accidently reblend) the + shadow). */ + glStencilFunc(GL_LESS, 2, 0xffffffff); /* draw if ==1 */ + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); + } + + /* To eliminate depth buffer artifacts, we use polygon offset + to raise the depth of the projected shadow slightly so + that it does not depth buffer alias with the floor. */ + if (offsetShadow) { + switch (polygonOffsetVersion) { + case EXTENSION: +#ifdef GL_EXT_polygon_offset + glEnable(GL_POLYGON_OFFSET_EXT); + break; +#endif +#ifdef GL_VERSION_1_1 + case ONE_DOT_ONE: + glEnable(GL_POLYGON_OFFSET_FILL); + break; +#endif + case MISSING: + /* Oh well. */ + break; + } + } + + /* Render 50% black shadow color on top of whatever the + floor appareance is. */ + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_LIGHTING); /* Force the 50% black. */ + glColor4f(0.0, 0.0, 0.0, 0.5); + + glPushMatrix(); + /* Project the shadow. */ + glMultMatrixf((GLfloat *) floorShadow); + drawDinosaur(); + glPopMatrix(); + + glDisable(GL_BLEND); + glEnable(GL_LIGHTING); + + if (offsetShadow) { + switch (polygonOffsetVersion) { +#ifdef GL_EXT_polygon_offset + case EXTENSION: + glDisable(GL_POLYGON_OFFSET_EXT); + break; +#endif +#ifdef GL_VERSION_1_1 + case ONE_DOT_ONE: + glDisable(GL_POLYGON_OFFSET_FILL); + break; +#endif + case MISSING: + /* Oh well. */ + break; + } + } + if (stencilShadow) { + glDisable(GL_STENCIL_TEST); + } + } + + glPushMatrix(); + glDisable(GL_LIGHTING); + glColor3f(1.0, 1.0, 0.0); + if (directionalLight) { + /* Draw an arrowhead. */ + glDisable(GL_CULL_FACE); + glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]); + glRotatef(lightAngle * -180.0 / M_PI, 0, 1, 0); + glRotatef(atan(lightHeight/12) * 180.0 / M_PI, 0, 0, 1); + glBegin(GL_TRIANGLE_FAN); + glVertex3f(0, 0, 0); + glVertex3f(2, 1, 1); + glVertex3f(2, -1, 1); + glVertex3f(2, -1, -1); + glVertex3f(2, 1, -1); + glVertex3f(2, 1, 1); + glEnd(); + /* Draw a white line from light direction. */ + glColor3f(1.0, 1.0, 1.0); + glBegin(GL_LINES); + glVertex3f(0, 0, 0); + glVertex3f(5, 0, 0); + glEnd(); + glEnable(GL_CULL_FACE); + } else { + /* Draw a yellow ball at the light source. */ + glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]); + glutSolidSphere(1.0, 5, 5); + } + glEnable(GL_LIGHTING); + glPopMatrix(); + + glPopMatrix(); + + if (reportSpeed) { + glFinish(); + end = glutGet(GLUT_ELAPSED_TIME); + printf("Speed %.3g frames/sec (%d ms)\n", 1000.0/(end-start), end-start); + fflush(stdout); + } + + glutSwapBuffers(); +} + +/* ARGSUSED2 */ +static void +mouse(int button, int state, int x, int y) +{ + if (button == GLUT_LEFT_BUTTON) { + if (state == GLUT_DOWN) { + moving = 1; + startx = x; + starty = y; + } + if (state == GLUT_UP) { + moving = 0; + } + } + if (button == GLUT_MIDDLE_BUTTON) { + if (state == GLUT_DOWN) { + lightMoving = 1; + lightStartX = x; + lightStartY = y; + } + if (state == GLUT_UP) { + lightMoving = 0; + } + } +} + +/* ARGSUSED1 */ +static void +motion(int x, int y) +{ + if (moving) { + angle = angle + (x - startx); + angle2 = angle2 + (y - starty); + startx = x; + starty = y; + glutPostRedisplay(); + } + if (lightMoving) { + lightAngle += (x - lightStartX)/40.0; + lightHeight += (lightStartY - y)/20.0; + lightStartX = x; + lightStartY = y; + glutPostRedisplay(); + } +} + +/* Advance time varying state when idle callback registered. */ +static void +idle(void) +{ + static float time = 0.0; + + time = glutGet(GLUT_ELAPSED_TIME) / 500.0; + + jump = 4.0 * fabs(sin(time)*0.5); + if (!lightMoving) { + lightAngle += 0.03; + } + glutPostRedisplay(); +} + +enum { + M_NONE, M_MOTION, M_LIGHT, M_TEXTURE, M_SHADOWS, M_REFLECTION, M_DINOSAUR, + M_STENCIL_REFLECTION, M_STENCIL_SHADOW, M_OFFSET_SHADOW, + M_POSITIONAL, M_DIRECTIONAL, M_PERFORMANCE +}; + +static void +controlLights(int value) +{ + switch (value) { + case M_NONE: + return; + case M_MOTION: + animation = 1 - animation; + if (animation) { + glutIdleFunc(idle); + } else { + glutIdleFunc(NULL); + } + break; + case M_LIGHT: + lightSwitch = !lightSwitch; + if (lightSwitch) { + glEnable(GL_LIGHT0); + } else { + glDisable(GL_LIGHT0); + } + break; + case M_TEXTURE: + useTexture = !useTexture; + break; + case M_SHADOWS: + renderShadow = 1 - renderShadow; + break; + case M_REFLECTION: + renderReflection = 1 - renderReflection; + break; + case M_DINOSAUR: + renderDinosaur = 1 - renderDinosaur; + break; + case M_STENCIL_REFLECTION: + stencilReflection = 1 - stencilReflection; + break; + case M_STENCIL_SHADOW: + stencilShadow = 1 - stencilShadow; + break; + case M_OFFSET_SHADOW: + offsetShadow = 1 - offsetShadow; + break; + case M_POSITIONAL: + directionalLight = 0; + break; + case M_DIRECTIONAL: + directionalLight = 1; + break; + case M_PERFORMANCE: + reportSpeed = 1 - reportSpeed; + break; + } + glutPostRedisplay(); +} + +/* When not visible, stop animating. Restart when visible again. */ +static void +visible(int vis) +{ + if (vis == GLUT_VISIBLE) { + if (animation) + glutIdleFunc(idle); + } else { + if (!animation) + glutIdleFunc(NULL); + } +} + +/* Press any key to redraw; good when motion stopped and + performance reporting on. */ +/* ARGSUSED */ +static void +key(unsigned char c, int x, int y) +{ + if (c == 27) { + exit(0); /* IRIS GLism, Escape quits. */ + } + glutPostRedisplay(); +} + +/* Press any key to redraw; good when motion stopped and + performance reporting on. */ +/* ARGSUSED */ +static void +special(int k, int x, int y) +{ + glutPostRedisplay(); +} + +static int +supportsOneDotOne(void) +{ + const char *version; + int major, minor; + + version = (char *) glGetString(GL_VERSION); + if (sscanf(version, "%d.%d", &major, &minor) == 2) + return major * 10 + minor >= 11; + return 0; /* OpenGL version string malformed! */ +} + +int +main(int argc, char **argv) +{ + int i; + + glutInit(&argc, argv); + + for (i=1; i<argc; i++) { + if (!strcmp("-linear", argv[i])) { + linearFiltering = 1; + } else if (!strcmp("-mipmap", argv[i])) { + useMipmaps = 1; + } else if (!strcmp("-ext", argv[i])) { + forceExtension = 1; + } + } + + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL); + +#if 0 + /* In GLUT 4.0, you'll be able to do this an be sure to + get 2 bits of stencil if the machine has it for you. */ + glutInitDisplayString("samples stencil>=2 rgb double depth"); +#endif + + glutCreateWindow("Shadowy Leapin' Lizards"); + glewInit(); + + if (glutGet(GLUT_WINDOW_STENCIL_SIZE) <= 1) { + printf("dinoshade: Sorry, I need at least 2 bits of stencil.\n"); + exit(1); + } + + /* Register GLUT callbacks. */ + glutDisplayFunc(redraw); + glutMouseFunc(mouse); + glutMotionFunc(motion); + glutVisibilityFunc(visible); + glutKeyboardFunc(key); + glutSpecialFunc(special); + + glutCreateMenu(controlLights); + + glutAddMenuEntry("Toggle motion", M_MOTION); + glutAddMenuEntry("-----------------------", M_NONE); + glutAddMenuEntry("Toggle light", M_LIGHT); + glutAddMenuEntry("Toggle texture", M_TEXTURE); + glutAddMenuEntry("Toggle shadows", M_SHADOWS); + glutAddMenuEntry("Toggle reflection", M_REFLECTION); + glutAddMenuEntry("Toggle dinosaur", M_DINOSAUR); + glutAddMenuEntry("-----------------------", M_NONE); + glutAddMenuEntry("Toggle reflection stenciling", M_STENCIL_REFLECTION); + glutAddMenuEntry("Toggle shadow stenciling", M_STENCIL_SHADOW); + glutAddMenuEntry("Toggle shadow offset", M_OFFSET_SHADOW); + glutAddMenuEntry("----------------------", M_NONE); + glutAddMenuEntry("Positional light", M_POSITIONAL); + glutAddMenuEntry("Directional light", M_DIRECTIONAL); + glutAddMenuEntry("-----------------------", M_NONE); + glutAddMenuEntry("Toggle performance", M_PERFORMANCE); + glutAttachMenu(GLUT_RIGHT_BUTTON); + makeDinosaur(); + +#ifdef GL_VERSION_1_1 + if (supportsOneDotOne() && !forceExtension) { + polygonOffsetVersion = ONE_DOT_ONE; + glPolygonOffset(-2.0, -9.0); + } else +#endif + { +#ifdef GL_EXT_polygon_offset + /* check for the polygon offset extension */ + if (glutExtensionSupported("GL_EXT_polygon_offset")) { + polygonOffsetVersion = EXTENSION; + glPolygonOffsetEXT(-2.0, -0.002); + } else +#endif + { + polygonOffsetVersion = MISSING; + printf("\ndinoshine: Missing polygon offset.\n"); + printf(" Expect shadow depth aliasing artifacts.\n\n"); + fflush(stdout); + } + } + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + glLineWidth(3.0); + + glMatrixMode(GL_PROJECTION); + gluPerspective( /* field of view in degree */ 40.0, + /* aspect ratio */ 1.0, + /* Z near */ 20.0, /* Z far */ 100.0); + glMatrixMode(GL_MODELVIEW); + gluLookAt(0.0, 8.0, 60.0, /* eye is at (0,8,60) */ + 0.0, 8.0, 0.0, /* center is at (0,8,0) */ + 0.0, 1.0, 0.); /* up is in postivie Y direction */ + + glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); + glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor); + glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.1); + glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); + + makeFloorTexture(); + + /* Setup floor plane for projected shadow calculations. */ + findPlane(floorPlane, floorVertices[1], floorVertices[2], floorVertices[3]); + + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/demos/projtex.c b/progs/demos/projtex.c new file mode 100644 index 00000000000..99154d7bdc8 --- /dev/null +++ b/progs/demos/projtex.c @@ -0,0 +1,1028 @@ + +/* projtex.c - by David Yu and David Blythe, SGI */ + +/** + ** Demonstrates simple projective texture mapping. + ** + ** Button1 changes view, Button2 moves texture. + ** + ** (See: Segal, Korobkin, van Widenfelt, Foran, and Haeberli + ** "Fast Shadows and Lighting Effects Using Texture Mapping", SIGGRAPH '92) + ** + ** 1994,1995 -- David G Yu + ** + ** cc -o projtex projtex.c texture.c -lglut -lGLU -lGL -lX11 -lm + **/ + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> +#include "readtex.h" + + +/* Some <math.h> files do not define M_PI... */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +#define MAX_TEX 4 +int NumTextures = 1; + +int winWidth, winHeight; + +GLboolean redrawContinuously = GL_FALSE; + +float angle, axis[3]; +enum MoveModes { + MoveNone, MoveView, MoveObject, MoveTexture +}; +enum MoveModes mode = MoveNone; + +GLfloat objectXform[4][4]; +GLfloat textureXform[MAX_TEX][4][4]; + +void (*drawObject) (void); +void (*loadTexture) (void); +GLboolean textureEnabled = GL_TRUE; +GLboolean showProjection = GL_TRUE; +GLboolean linearFilter = GL_TRUE; + +char *texFilename[MAX_TEX] = { + "../images/girl.rgb", + "../images/tile.rgb", + "../images/bw.rgb", + "../images/reflect.rgb" +}; + + +GLfloat zoomFactor = 1.0; + +/*****************************************************************/ + + +static void +ActiveTexture(int i) +{ + glActiveTextureARB(i); +} + + +/* matrix = identity */ +static void +matrixIdentity(GLfloat matrix[16]) +{ + matrix[0] = 1.0; + matrix[1] = 0.0; + matrix[2] = 0.0; + matrix[3] = 0.0; + matrix[4] = 0.0; + matrix[5] = 1.0; + matrix[6] = 0.0; + matrix[7] = 0.0; + matrix[8] = 0.0; + matrix[9] = 0.0; + matrix[10] = 1.0; + matrix[11] = 0.0; + matrix[12] = 0.0; + matrix[13] = 0.0; + matrix[14] = 0.0; + matrix[15] = 1.0; +} + +/* matrix2 = transpose(matrix1) */ +static void +matrixTranspose(GLfloat matrix2[16], GLfloat matrix1[16]) +{ + matrix2[0] = matrix1[0]; + matrix2[1] = matrix1[4]; + matrix2[2] = matrix1[8]; + matrix2[3] = matrix1[12]; + + matrix2[4] = matrix1[1]; + matrix2[5] = matrix1[5]; + matrix2[6] = matrix1[9]; + matrix2[7] = matrix1[13]; + + matrix2[8] = matrix1[2]; + matrix2[9] = matrix1[6]; + matrix2[10] = matrix1[10]; + matrix2[11] = matrix1[14]; + + matrix2[12] = matrix1[3]; + matrix2[13] = matrix1[7]; + matrix2[14] = matrix1[14]; + matrix2[15] = matrix1[15]; +} + +/*****************************************************************/ + +/* load SGI .rgb image (pad with a border of the specified width and color) */ +#if 0 +static void +imgLoad(char *filenameIn, int borderIn, GLfloat borderColorIn[4], + int *wOut, int *hOut, GLubyte ** imgOut) +{ + int border = borderIn; + int width, height; + int w, h; + GLubyte *image, *img, *p; + int i, j, components; + + image = (GLubyte *) read_texture(filenameIn, &width, &height, &components); + w = width + 2 * border; + h = height + 2 * border; + img = (GLubyte *) calloc(w * h, 4 * sizeof(unsigned char)); + + p = img; + for (j = -border; j < height + border; ++j) { + for (i = -border; i < width + border; ++i) { + if (0 <= j && j <= height - 1 && 0 <= i && i <= width - 1) { + p[0] = image[4 * (j * width + i) + 0]; + p[1] = image[4 * (j * width + i) + 1]; + p[2] = image[4 * (j * width + i) + 2]; + p[3] = 0xff; + } else { + p[0] = borderColorIn[0] * 0xff; + p[1] = borderColorIn[1] * 0xff; + p[2] = borderColorIn[2] * 0xff; + p[3] = borderColorIn[3] * 0xff; + } + p += 4; + } + } + free(image); + *wOut = w; + *hOut = h; + *imgOut = img; +} +#endif + + +/*****************************************************************/ + +/* Load the image file specified on the command line as the current texture */ +static void +loadImageTextures(void) +{ + GLfloat borderColor[4] = + {1.0, 1.0, 1.0, 1.0}; + int tex; + + for (tex = 0; tex < NumTextures; tex++) { + GLubyte *image, *texData3, *texData4; + GLint imgWidth, imgHeight; + GLenum imgFormat; + int i, j; + + printf("loading %s\n", texFilename[tex]); + image = LoadRGBImage(texFilename[tex], &imgWidth, &imgHeight, &imgFormat); + if (!image) { + printf("can't find %s\n", texFilename[tex]); + exit(1); + } + assert(imgFormat == GL_RGB); + + /* scale to 256x256 */ + texData3 = malloc(256 * 256 * 4); + texData4 = malloc(256 * 256 * 4); + assert(texData3); + assert(texData4); + gluScaleImage(imgFormat, imgWidth, imgHeight, GL_UNSIGNED_BYTE, image, + 256, 256, GL_UNSIGNED_BYTE, texData3); + + /* convert to rgba */ + for (i = 0; i < 256 * 256; i++) { + texData4[i*4+0] = texData3[i*3+0]; + texData4[i*4+1] = texData3[i*3+1]; + texData4[i*4+2] = texData3[i*3+2]; + texData4[i*4+3] = 128; + } + + /* put transparent border around image */ + for (i = 0; i < 256; i++) { + texData4[i*4+0] = 255; + texData4[i*4+1] = 255; + texData4[i*4+2] = 255; + texData4[i*4+3] = 0; + } + j = 256 * 255 * 4; + for (i = 0; i < 256; i++) { + texData4[j + i*4+0] = 255; + texData4[j + i*4+1] = 255; + texData4[j + i*4+2] = 255; + texData4[j + i*4+3] = 0; + } + for (i = 0; i < 256; i++) { + j = i * 256 * 4; + texData4[j+0] = 255; + texData4[j+1] = 255; + texData4[j+2] = 255; + texData4[j+3] = 0; + } + for (i = 0; i < 256; i++) { + j = i * 256 * 4 + 255 * 4; + texData4[j+0] = 255; + texData4[j+1] = 255; + texData4[j+2] = 255; + texData4[j+3] = 0; + } + + ActiveTexture(GL_TEXTURE0_ARB + tex); + glBindTexture(GL_TEXTURE_2D, tex + 1); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, + GL_RGBA, GL_UNSIGNED_BYTE, texData4); + + if (linearFilter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + } +} + +/* Create a simple spotlight pattern and make it the current texture */ +static void +loadSpotlightTexture(void) +{ + static int texWidth = 64, texHeight = 64; + static GLubyte *texData; + GLfloat borderColor[4] = + {0.1, 0.1, 0.1, 1.0}; + + if (!texData) { + GLubyte *p; + int i, j; + + texData = (GLubyte *) malloc(texWidth * texHeight * 4 * sizeof(GLubyte)); + + p = texData; + for (j = 0; j < texHeight; ++j) { + float dy = (texHeight * 0.5 - j + 0.5) / (texHeight * 0.5); + + for (i = 0; i < texWidth; ++i) { + float dx = (texWidth * 0.5 - i + 0.5) / (texWidth * 0.5); + float r = cos(M_PI / 2.0 * sqrt(dx * dx + dy * dy)); + float c; + + r = (r < 0) ? 0 : r * r; + c = 0xff * (r + borderColor[0]); + p[0] = (c <= 0xff) ? c : 0xff; + c = 0xff * (r + borderColor[1]); + p[1] = (c <= 0xff) ? c : 0xff; + c = 0xff * (r + borderColor[2]); + p[2] = (c <= 0xff) ? c : 0xff; + c = 0xff * (r + borderColor[3]); + p[3] = (c <= 0xff) ? c : 0xff; + p += 4; + } + } + } + if (linearFilter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + gluBuild2DMipmaps(GL_TEXTURE_2D, 4, texWidth, texHeight, + GL_RGBA, GL_UNSIGNED_BYTE, texData); +} + +/*****************************************************************/ + +static void +checkErrors(void) +{ + GLenum error; + while ((error = glGetError()) != GL_NO_ERROR) { + fprintf(stderr, "Error: %s\n", (char *) gluErrorString(error)); + } +} + +static void +drawCube(void) +{ + glBegin(GL_QUADS); + + glNormal3f(-1.0, 0.0, 0.0); + glColor3f(0.80, 0.50, 0.50); + glVertex3f(-0.5, -0.5, -0.5); + glVertex3f(-0.5, -0.5, 0.5); + glVertex3f(-0.5, 0.5, 0.5); + glVertex3f(-0.5, 0.5, -0.5); + + glNormal3f(1.0, 0.0, 0.0); + glColor3f(0.50, 0.80, 0.50); + glVertex3f(0.5, 0.5, 0.5); + glVertex3f(0.5, -0.5, 0.5); + glVertex3f(0.5, -0.5, -0.5); + glVertex3f(0.5, 0.5, -0.5); + + glNormal3f(0.0, -1.0, 0.0); + glColor3f(0.50, 0.50, 0.80); + glVertex3f(-0.5, -0.5, -0.5); + glVertex3f(0.5, -0.5, -0.5); + glVertex3f(0.5, -0.5, 0.5); + glVertex3f(-0.5, -0.5, 0.5); + + glNormal3f(0.0, 1.0, 0.0); + glColor3f(0.50, 0.80, 0.80); + glVertex3f(0.5, 0.5, 0.5); + glVertex3f(0.5, 0.5, -0.5); + glVertex3f(-0.5, 0.5, -0.5); + glVertex3f(-0.5, 0.5, 0.5); + + glNormal3f(0.0, 0.0, -1.0); + glColor3f(0.80, 0.50, 0.80); + glVertex3f(-0.5, -0.5, -0.5); + glVertex3f(-0.5, 0.5, -0.5); + glVertex3f(0.5, 0.5, -0.5); + glVertex3f(0.5, -0.5, -0.5); + + glNormal3f(0.0, 0.0, 1.0); + glColor3f(1.00, 0.80, 0.50); + glVertex3f(0.5, 0.5, 0.5); + glVertex3f(-0.5, 0.5, 0.5); + glVertex3f(-0.5, -0.5, 0.5); + glVertex3f(0.5, -0.5, 0.5); + glEnd(); +} + +static void +drawDodecahedron(void) +{ +#define A (0.5 * 1.61803) /* (sqrt(5) + 1) / 2 */ +#define B (0.5 * 0.61803) /* (sqrt(5) - 1) / 2 */ +#define C (0.5 * 1.0) + GLfloat vertexes[20][3] = + { + {-A, 0.0, B}, + {-A, 0.0, -B}, + {A, 0.0, -B}, + {A, 0.0, B}, + {B, -A, 0.0}, + {-B, -A, 0.0}, + {-B, A, 0.0}, + {B, A, 0.0}, + {0.0, B, -A}, + {0.0, -B, -A}, + {0.0, -B, A}, + {0.0, B, A}, + {-C, -C, C}, + {-C, -C, -C}, + {C, -C, -C}, + {C, -C, C}, + {-C, C, C}, + {-C, C, -C}, + {C, C, -C}, + {C, C, C}, + }; +#undef A +#undef B +#undef C + GLint polygons[12][5] = + { + {0, 12, 10, 11, 16}, + {1, 17, 8, 9, 13}, + {2, 14, 9, 8, 18}, + {3, 19, 11, 10, 15}, + {4, 14, 2, 3, 15}, + {5, 12, 0, 1, 13}, + {6, 17, 1, 0, 16}, + {7, 19, 3, 2, 18}, + {8, 17, 6, 7, 18}, + {9, 14, 4, 5, 13}, + {10, 12, 5, 4, 15}, + {11, 19, 7, 6, 16}, + }; + int i; + + glColor3f(0.75, 0.75, 0.75); + for (i = 0; i < 12; ++i) { + GLfloat *p0, *p1, *p2, d; + GLfloat u[3], v[3], n[3]; + + p0 = &vertexes[polygons[i][0]][0]; + p1 = &vertexes[polygons[i][1]][0]; + p2 = &vertexes[polygons[i][2]][0]; + + u[0] = p2[0] - p1[0]; + u[1] = p2[1] - p1[1]; + u[2] = p2[2] - p1[2]; + + v[0] = p0[0] - p1[0]; + v[1] = p0[1] - p1[1]; + v[2] = p0[2] - p1[2]; + + n[0] = u[1] * v[2] - u[2] * v[1]; + n[1] = u[2] * v[0] - u[0] * v[2]; + n[2] = u[0] * v[1] - u[1] * v[0]; + + d = 1.0 / sqrt(n[0] * n[0] + n[1] * n[1] + n[2] * n[2]); + n[0] *= d; + n[1] *= d; + n[2] *= d; + + glBegin(GL_POLYGON); + glNormal3fv(n); + glVertex3fv(p0); + glVertex3fv(p1); + glVertex3fv(p2); + glVertex3fv(vertexes[polygons[i][3]]); + glVertex3fv(vertexes[polygons[i][4]]); + glEnd(); + } +} + +static void +drawSphere(void) +{ + int numMajor = 24; + int numMinor = 32; + float radius = 0.8; + double majorStep = (M_PI / numMajor); + double minorStep = (2.0 * M_PI / numMinor); + int i, j; + + glColor3f(0.50, 0.50, 0.50); + for (i = 0; i < numMajor; ++i) { + double a = i * majorStep; + double b = a + majorStep; + double r0 = radius * sin(a); + double r1 = radius * sin(b); + GLfloat z0 = radius * cos(a); + GLfloat z1 = radius * cos(b); + + glBegin(GL_TRIANGLE_STRIP); + for (j = 0; j <= numMinor; ++j) { + double c = j * minorStep; + GLfloat x = cos(c); + GLfloat y = sin(c); + + glNormal3f((x * r0) / radius, (y * r0) / radius, z0 / radius); + glTexCoord2f(j / (GLfloat) numMinor, i / (GLfloat) numMajor); + glVertex3f(x * r0, y * r0, z0); + + glNormal3f((x * r1) / radius, (y * r1) / radius, z1 / radius); + glTexCoord2f(j / (GLfloat) numMinor, (i + 1) / (GLfloat) numMajor); + glVertex3f(x * r1, y * r1, z1); + } + glEnd(); + } +} + +/*****************************************************************/ + +float xmin = -0.035, xmax = 0.035; +float ymin = -0.035, ymax = 0.035; +float nnear = 0.1; +float ffar = 1.9; +float distance = -1.0; + +static void +loadTextureProjection(int texUnit, GLfloat m[16]) +{ + GLfloat mInverse[4][4]; + + /* Should use true inverse, but since m consists only of rotations, we can + just use the transpose. */ + matrixTranspose((GLfloat *) mInverse, m); + + ActiveTexture(GL_TEXTURE0_ARB + texUnit); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glTranslatef(0.5, 0.5, 0.0); + glScalef(0.5, 0.5, 1.0); + glFrustum(xmin, xmax, ymin, ymax, nnear, ffar); + glTranslatef(0.0, 0.0, distance); + glMultMatrixf((GLfloat *) mInverse); + glMatrixMode(GL_MODELVIEW); +} + +static void +drawTextureProjection(void) +{ + float t = ffar / nnear; + GLfloat n[4][3]; + GLfloat f[4][3]; + + n[0][0] = xmin; + n[0][1] = ymin; + n[0][2] = -(nnear + distance); + + n[1][0] = xmax; + n[1][1] = ymin; + n[1][2] = -(nnear + distance); + + n[2][0] = xmax; + n[2][1] = ymax; + n[2][2] = -(nnear + distance); + + n[3][0] = xmin; + n[3][1] = ymax; + n[3][2] = -(nnear + distance); + + f[0][0] = xmin * t; + f[0][1] = ymin * t; + f[0][2] = -(ffar + distance); + + f[1][0] = xmax * t; + f[1][1] = ymin * t; + f[1][2] = -(ffar + distance); + + f[2][0] = xmax * t; + f[2][1] = ymax * t; + f[2][2] = -(ffar + distance); + + f[3][0] = xmin * t; + f[3][1] = ymax * t; + f[3][2] = -(ffar + distance); + + glColor3f(1.0, 1.0, 0.0); + glBegin(GL_LINE_LOOP); + glVertex3fv(n[0]); + glVertex3fv(n[1]); + glVertex3fv(n[2]); + glVertex3fv(n[3]); + glVertex3fv(f[3]); + glVertex3fv(f[2]); + glVertex3fv(f[1]); + glVertex3fv(f[0]); + glVertex3fv(n[0]); + glVertex3fv(n[1]); + glVertex3fv(f[1]); + glVertex3fv(f[0]); + glVertex3fv(f[3]); + glVertex3fv(f[2]); + glVertex3fv(n[2]); + glVertex3fv(n[3]); + glEnd(); +} + +/*****************************************************************/ + +static void +initialize(void) +{ + GLfloat light0Pos[4] = + {0.3, 0.3, 0.0, 1.0}; + GLfloat matAmb[4] = + {0.01, 0.01, 0.01, 1.00}; + GLfloat matDiff[4] = + {0.65, 0.65, 0.65, 1.00}; + GLfloat matSpec[4] = + {0.30, 0.30, 0.30, 1.00}; + GLfloat matShine = 10.0; + GLfloat eyePlaneS[] = + {1.0, 0.0, 0.0, 0.0}; + GLfloat eyePlaneT[] = + {0.0, 1.0, 0.0, 0.0}; + GLfloat eyePlaneR[] = + {0.0, 0.0, 1.0, 0.0}; + GLfloat eyePlaneQ[] = + {0.0, 0.0, 0.0, 1.0}; + int i; + + /* Setup Misc. */ + glClearColor(0.41, 0.41, 0.31, 0.0); + + glEnable(GL_DEPTH_TEST); + + /* glLineWidth(2.0);*/ + + glCullFace(GL_FRONT); + glEnable(GL_CULL_FACE); + + glMatrixMode(GL_PROJECTION); + glFrustum(-0.5, 0.5, -0.5, 0.5, 1, 3); + glMatrixMode(GL_MODELVIEW); + glTranslatef(0, 0, -2); + + matrixIdentity((GLfloat *) objectXform); + for (i = 0; i < NumTextures; i++) { + matrixIdentity((GLfloat *) textureXform[i]); + } + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, 1, 0, 1, -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glRasterPos2i(0, 0); + + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + /* Setup Lighting */ + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, matAmb); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiff); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matSpec); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, matShine); + + glEnable(GL_COLOR_MATERIAL); + + glLightfv(GL_LIGHT0, GL_POSITION, light0Pos); + glEnable(GL_LIGHT0); + + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + glEnable(GL_LIGHTING); + + /* Setup Texture */ + + (*loadTexture) (); + + + for (i = 0; i < NumTextures; i++) { + ActiveTexture(GL_TEXTURE0_ARB + i); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_S, GL_EYE_PLANE, eyePlaneS); + + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_T, GL_EYE_PLANE, eyePlaneT); + + glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_R, GL_EYE_PLANE, eyePlaneR); + + glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_Q, GL_EYE_PLANE, eyePlaneQ); + } +} + +static void +display(void) +{ + int i; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + if (textureEnabled) { + if (mode == MoveTexture || mode == MoveView) { + /* Have OpenGL compute the new transformation (simple but slow). */ + for (i = 0; i < NumTextures; i++) { + glPushMatrix(); + glLoadIdentity(); +#if 0 + if (i & 1) + glRotatef(angle, axis[0], axis[1], axis[2]); + else +#endif + glRotatef(angle*(i+1), axis[0], axis[1], axis[2]); + + glMultMatrixf((GLfloat *) textureXform[i]); + glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) textureXform[i]); + glPopMatrix(); + } + } + for (i = 0; i < NumTextures; i++) { + loadTextureProjection(i, (GLfloat *) textureXform[i]); + } + + if (showProjection) { + for (i = 0; i < NumTextures; i++) { + ActiveTexture(GL_TEXTURE0_ARB + i); + glPushMatrix(); + glMultMatrixf((GLfloat *) textureXform[i]); + glDisable(GL_LIGHTING); + drawTextureProjection(); + glEnable(GL_LIGHTING); + glPopMatrix(); + } + } + for (i = 0; i < NumTextures; i++) { + ActiveTexture(GL_TEXTURE0_ARB + i); + glEnable(GL_TEXTURE_2D); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_R); + glEnable(GL_TEXTURE_GEN_Q); + } + } + if (mode == MoveObject || mode == MoveView) { + /* Have OpenGL compute the new transformation (simple but slow). */ + glPushMatrix(); + glLoadIdentity(); + glRotatef(angle, axis[0], axis[1], axis[2]); + glMultMatrixf((GLfloat *) objectXform); + glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *) objectXform); + glPopMatrix(); + } + glPushMatrix(); + glMultMatrixf((GLfloat *) objectXform); + (*drawObject) (); + glPopMatrix(); + + for (i = 0; i < NumTextures; i++) { + ActiveTexture(GL_TEXTURE0_ARB + i); + glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_GEN_R); + glDisable(GL_TEXTURE_GEN_Q); + } + + if (zoomFactor > 1.0) { + glDisable(GL_DEPTH_TEST); + glCopyPixels(0, 0, winWidth / zoomFactor, winHeight / zoomFactor, GL_COLOR); + glEnable(GL_DEPTH_TEST); + } + glFlush(); + glutSwapBuffers(); + checkErrors(); +} + +/*****************************************************************/ + +/* simple trackball-like motion control */ +static float lastPos[3]; +static int lastTime; + +static void +ptov(int x, int y, int width, int height, float v[3]) +{ + float d, a; + + /* project x,y onto a hemi-sphere centered within width, height */ + v[0] = (2.0 * x - width) / width; + v[1] = (height - 2.0 * y) / height; + d = sqrt(v[0] * v[0] + v[1] * v[1]); + v[2] = cos((M_PI / 2.0) * ((d < 1.0) ? d : 1.0)); + a = 1.0 / sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + v[0] *= a; + v[1] *= a; + v[2] *= a; +} + +static void +startMotion(int x, int y, int but, int time) +{ + if (but == GLUT_LEFT_BUTTON) { + mode = MoveView; + } else if (but == GLUT_MIDDLE_BUTTON) { + mode = MoveTexture; + } else { + return; + } + + lastTime = time; + ptov(x, y, winWidth, winHeight, lastPos); +} + +static void +animate(void) +{ + glutPostRedisplay(); +} + +static void +vis(int visible) +{ + if (visible == GLUT_VISIBLE) { + if (redrawContinuously) + glutIdleFunc(animate); + } else { + if (redrawContinuously) + glutIdleFunc(NULL); + } +} + +static void +stopMotion(int but, int time) +{ + if ((but == GLUT_LEFT_BUTTON && mode == MoveView) || + (but == GLUT_MIDDLE_BUTTON && mode == MoveTexture)) { + } else { + return; + } + + if (time == lastTime) { + /* redrawContinuously = GL_TRUE;*/ + glutIdleFunc(animate); + } else { + angle = 0.0; + redrawContinuously = GL_FALSE; + glutIdleFunc(0); + } + if (!redrawContinuously) { + mode = MoveNone; + } +} + +static void +trackMotion(int x, int y) +{ + float curPos[3], dx, dy, dz; + + ptov(x, y, winWidth, winHeight, curPos); + + dx = curPos[0] - lastPos[0]; + dy = curPos[1] - lastPos[1]; + dz = curPos[2] - lastPos[2]; + angle = 90.0 * sqrt(dx * dx + dy * dy + dz * dz); + + axis[0] = lastPos[1] * curPos[2] - lastPos[2] * curPos[1]; + axis[1] = lastPos[2] * curPos[0] - lastPos[0] * curPos[2]; + axis[2] = lastPos[0] * curPos[1] - lastPos[1] * curPos[0]; + + lastTime = glutGet(GLUT_ELAPSED_TIME); + lastPos[0] = curPos[0]; + lastPos[1] = curPos[1]; + lastPos[2] = curPos[2]; + glutPostRedisplay(); +} + +/*****************************************************************/ + +static void +object(void) +{ + static int object; + + object++; + object %= 3; + switch (object) { + case 0: + drawObject = drawCube; + break; + case 1: + drawObject = drawDodecahedron; + break; + case 2: + drawObject = drawSphere; + break; + default: + break; + } +} + +static void +nop(void) +{ +} + +static void +texture(void) +{ + static int texture = 0; + + texture++; + texture %= 3; + if (texture == 1 && texFilename == NULL) { + /* Skip file texture if not loaded. */ + texture++; + } + switch (texture) { + case 0: + loadTexture = nop; + textureEnabled = GL_FALSE; + break; + case 1: + loadTexture = loadImageTextures; + (*loadTexture) (); + textureEnabled = GL_TRUE; + break; + case 2: + loadTexture = loadSpotlightTexture; + (*loadTexture) (); + textureEnabled = GL_TRUE; + break; + default: + break; + } +} + +static void +help(void) +{ + printf("'h' - help\n"); + printf("'l' - toggle linear/nearest filter\n"); + printf("'s' - toggle projection frustum\n"); + printf("'t' - toggle projected texture\n"); + printf("'o' - toggle object\n"); + printf("'z' - increase zoom factor\n"); + printf("'Z' - decrease zoom factor\n"); + printf("left mouse - move view\n"); + printf("middle mouse - move projection\n"); +} + +/* ARGSUSED1 */ +static void +key(unsigned char key, int x, int y) +{ + switch (key) { + case '\033': + exit(0); + break; + case 'l': + linearFilter = !linearFilter; + (*loadTexture) (); + break; + case 's': + showProjection = !showProjection; + break; + case 't': + texture(); + break; + case 'o': + object(); + break; + case 'z': + zoomFactor += 1.0; + glPixelZoom(zoomFactor, zoomFactor); + glViewport(0, 0, winWidth / zoomFactor, winHeight / zoomFactor); + break; + case 'Z': + zoomFactor -= 1.0; + if (zoomFactor < 1.0) + zoomFactor = 1.0; + glPixelZoom(zoomFactor, zoomFactor); + glViewport(0, 0, winWidth / zoomFactor, winHeight / zoomFactor); + break; + case 'h': + help(); + break; + } + glutPostRedisplay(); +} + +static void +mouse(int button, int state, int x, int y) +{ + if (state == GLUT_DOWN) + startMotion(x, y, button, glutGet(GLUT_ELAPSED_TIME)); + else if (state == GLUT_UP) + stopMotion(button, glutGet(GLUT_ELAPSED_TIME)); + glutPostRedisplay(); +} + +static void +reshape(int w, int h) +{ + winWidth = w; + winHeight = h; + glViewport(0, 0, w / zoomFactor, h / zoomFactor); +} + + +static void +menu(int selection) +{ + if (selection == 666) { + exit(0); + } + key((unsigned char) selection, 0, 0); +} + +int +main(int argc, char **argv) +{ + glutInit(&argc, argv); + + if (argc > 1) { + NumTextures = atoi(argv[1]); + } + assert(NumTextures <= MAX_TEX); + + glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE); + glutInitWindowSize(500,500); + (void) glutCreateWindow("projtex"); + glewInit(); + + loadTexture = loadImageTextures; + drawObject = drawCube; + initialize(); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutReshapeFunc(reshape); + glutMouseFunc(mouse); + glutMotionFunc(trackMotion); + glutVisibilityFunc(vis); + glutCreateMenu(menu); + glutAddMenuEntry("Toggle showing projection", 's'); + glutAddMenuEntry("Switch texture", 't'); + glutAddMenuEntry("Switch object", 'o'); + glutAddMenuEntry("Toggle filtering", 'l'); + glutAddMenuEntry("Quit", 666); + glutAttachMenu(GLUT_RIGHT_BUTTON); + texture(); + glutMainLoop(); + return 0; /* ANSI C requires main to return int. */ +} diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript deleted file mode 100644 index 9a1f3575bdc..00000000000 --- a/progs/trivial/SConscript +++ /dev/null @@ -1,177 +0,0 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) - -progs = [ - 'clear-fbo-tex', - 'clear-fbo', - 'clear-scissor', - 'clear-undefined', - 'clear-repeat', - 'clear', - 'dlist-dangling', - 'dlist-edgeflag-dangling', - 'dlist-edgeflag', - 'dlist-degenerate', - 'drawarrays', - 'draw2arrays', - 'drawelements', - 'drawrange', - 'flat-clip', - 'fs-tri', - 'line-clip', - 'line-cull', - 'line-flat', - 'line-smooth', - 'line-stipple-wide', - 'line-userclip-clip', - 'line-userclip-nop-clip', - 'line-userclip-nop', - 'line-userclip', - 'line-wide', - 'line', - 'lineloop-clip', - 'lineloop-elts', - 'lineloop', - 'linestrip-flat-stipple', - 'linestrip-stipple-wide', - 'linestrip-stipple', - 'linestrip', - 'long-fixed-func', - 'pgon-mode', - 'point-clip', - 'point-param', - 'point-sprite', - 'point-wide', - 'point-wide-smooth', - 'point', - 'poly-flat', - 'poly-flat-clip', - 'poly-flat-unfilled-clip', - 'poly-unfilled', - 'poly', - 'quad-clip-all-vertices', - 'quad-clip-nearplane', - 'quad-clip', - 'quad-degenerate', - 'quad-flat', - 'quad-offset-factor', - 'quad-offset-unfilled', - 'quad-offset-units', - 'quad-tex-2d', - 'quad-tex-3d', - 'quad-tex-alpha', - 'quad-tex-pbo', - 'quad-tex-sub', - 'quad-unfilled-clip', - 'quad-unfilled-stipple', - 'quad-unfilled', - 'quad', - 'quads', - 'quadstrip-clip', - 'quadstrip-cont', - 'quadstrip-flat', - 'quadstrip', - 'tri-alpha', - 'tri-blend-color', - 'tri-blend-max', - 'tri-blend-min', - 'tri-blend-revsub', - 'tri-blend-sub', - 'tri-blend', - 'tri-clip', - 'tri-clear', - 'tri-cull-both', - 'tri-cull', - 'tri-dlist', - 'tri-edgeflag', - 'tri-fbo-tex-mip', - 'tri-fbo-tex', - 'tri-fbo', - 'tri-flat-clip', - 'tri-flat', - 'tri-fog', - 'tri-fp', - 'tri-fp-const-imm', - 'tri-lit', - 'tri-logicop-none', - 'tri-logicop-xor', - 'tri-mask-tri', - 'tri-orig', - 'tri-query', - 'tri-repeat', - 'tri-scissor-tri', - 'tri-stencil', - 'tri-stipple', - 'tri-multitex-vbo', - 'tri-tex', - 'tri-tex-3d', - 'tri-tri', - 'tri-unfilled-fog', - 'tri-unfilled-edgeflag', - 'tri-unfilled-clip', - 'tri-unfilled-smooth', - 'tri-unfilled-tri', - 'tri-unfilled-tri-lit', - 'tri-unfilled-userclip-stip', - 'tri-unfilled-userclip', - 'tri-unfilled', - 'tri-userclip', - 'tri-viewport', - 'tri-z-eq', - 'tri-z', - 'tri', - 'trifan-flat', - 'trifan-flat-clip', - 'trifan-flat-unfilled-clip', - 'trifan-unfilled', - 'trifan', - 'tristrip-clip', - 'tristrip-flat', - 'tristrip', - 'vbo-drawarrays', - 'vbo-noninterleaved', - 'vbo-drawelements', - 'vbo-drawrange', - 'vp-array', - 'vp-array-int', - 'vp-clip', - 'vp-line-clip', - 'vp-tri', - 'vp-tri-invariant', - 'vp-tri-swap', - 'vp-tri-tex', - 'vp-tri-imm', - 'vp-tri-cb', - 'vp-tri-cb-pos', - 'vp-tri-cb-tex', - 'vp-unfilled', -] - -for prog in progs: - prog = env.Program( - target = prog, - source = prog + '.c', - ) - -# 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 - - -#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 . - - -#extfuncs.h: $(TOP)/progs/util/extfuncs.h -# cp $< . diff --git a/progs/trivial/clear-fbo-tex.c b/progs/trivial/clear-fbo-tex.c deleted file mode 100644 index a206676e48e..00000000000 --- a/progs/trivial/clear-fbo-tex.c +++ /dev/null @@ -1,223 +0,0 @@ - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> - -#include <GL/glew.h> -#include <GL/glut.h> - - - -static GLenum TexTarget = GL_TEXTURE_2D; -static int TexWidth = 512, TexHeight = 512; -static GLenum TexIntFormat = GL_RGBA; /* either GL_RGB or GL_RGBA */ - -static int Width = 512, Height = 512; -static GLuint MyFB, TexObj; - - -#define CheckError() assert(glGetError() == 0) - -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)); - fflush(stderr); - - - if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { - printf("GL_EXT_framebuffer_object not found!\n"); - exit(0); - } - - - glGenFramebuffersEXT(1, &MyFB); - glGenTextures(1, &TexObj); - - /* Make texture object/image */ - glBindTexture(TexTarget, TexObj); - glTexParameteri(TexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(TexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(TexTarget, GL_TEXTURE_BASE_LEVEL, 0); - glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, 0); - - glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - - - { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - TexTarget, TexObj, 0); - - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } - -} - - - -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 ); - - Width = width; - Height = height; -} - -static void Key(unsigned char key, int x, int y) -{ - - switch (key) { - case 27: - exit(1); - default: - return; - } - - glutPostRedisplay(); -} - - - -static void Draw( void ) -{ - - - /* draw to texture image */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); -// glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); -// glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); - - - glViewport(0, 0, TexWidth, TexHeight); - CheckError(); - - glClearColor(0.5, 0.5, 1.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - CheckError(); - - if (0) { - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - } - - { - GLubyte *buffer = malloc(Width * Height * 4); - - /* read from user framebuffer */ - glReadPixels(0, 0, Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - CheckError(); - - /* draw to window */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glViewport(0, 0, Width, Height); - - /* Try to clear the window, but will overwrite: - */ - glClearColor(0.8, 0.8, 0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - glWindowPos2iARB(30, 30); - glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); - } - - /* Bind normal framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glViewport(0, 0, Width, Height); - - if (0) { - glBegin(GL_TRIANGLES); - glColor3f(0,.7,0); - glVertex3f( 0.5, -0.5, -30.0); - glColor3f(0,0,.8); - glVertex3f( 0.5, 0.5, -30.0); - glColor3f(.9,0,0); - glVertex3f(-0.5, 0.0, -30.0); - glEnd(); - } - - if (doubleBuffer) { - glutSwapBuffers(); - } - - CheckError(); -} - - -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(100, 0); glutInitWindowSize( Width, Height ); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(argv[0]) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/clear-fbo.c b/progs/trivial/clear-fbo.c deleted file mode 100644 index 0aeb45489f2..00000000000 --- a/progs/trivial/clear-fbo.c +++ /dev/null @@ -1,208 +0,0 @@ - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> - -#include <GL/glew.h> -#include <GL/glut.h> - - - -static int Width = 512, Height = 512; -static GLuint MyFB, MyRB; - - -#define CheckError() assert(glGetError() == 0) - -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)); - fflush(stderr); - - - if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { - printf("GL_EXT_framebuffer_object not found!\n"); - exit(0); - } - - - glGenFramebuffersEXT(1, &MyFB); - glGenRenderbuffersEXT(1, &MyRB); - - { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB); - - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, - GL_RENDERBUFFER_EXT, MyRB); - - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } - -} - - - -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 ); - - Width = width; - Height = height; - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); -} - -static void Key(unsigned char key, int x, int y) -{ - - switch (key) { - case 27: - exit(1); - default: - return; - } - - glutPostRedisplay(); -} - - - -static void Draw( void ) -{ - - /* draw to user framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); - glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); - - - glViewport(0, 0, Width, Height); - CheckError(); - - glClearColor(0.5, 0.5, 1.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - CheckError(); - - if (0) { - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - } - - { - GLubyte *buffer = malloc(Width * Height * 4); - - /* read from user framebuffer */ - glReadPixels(0, 0, Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - CheckError(); - - /* draw to window */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glViewport(0, 0, Width, Height); - - /* Try to clear the window, but will overwrite: - */ - glClearColor(0.8, 0.8, 0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - glWindowPos2iARB(30, 30); - glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - free(buffer); - } - - /* Bind normal framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - glViewport(0, 0, Width, Height); - - if (0) { - glBegin(GL_TRIANGLES); - glColor3f(0,.7,0); - glVertex3f( 0.5, -0.5, -30.0); - glColor3f(0,0,.8); - glVertex3f( 0.5, 0.5, -30.0); - glColor3f(.9,0,0); - glVertex3f(-0.5, 0.0, -30.0); - glEnd(); - } - - if (doubleBuffer) - glutSwapBuffers(); - else - glFinish(); - - CheckError(); -} - - -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(100, 0); glutInitWindowSize( Width, Height ); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(argv[0]) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/clear-random.c b/progs/trivial/clear-random.c deleted file mode 100644 index e3da23a8f55..00000000000 --- a/progs/trivial/clear-random.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - -} - -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(0); - default: - return; - } - - glutPostRedisplay(); -} - -static void Draw(void) -{ - glClearColor( - rand() / (float)RAND_MAX, - rand() / (float)RAND_MAX, - rand() / (float)RAND_MAX, - 0.0); - - glClear(GL_COLOR_BUFFER_BIT); - 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( 256, 256); - - type = GLUT_RGB | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/clear-repeat.c b/progs/trivial/clear-repeat.c deleted file mode 100644 index f966adb0801..00000000000 --- a/progs/trivial/clear-repeat.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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> -#include <math.h> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -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); - - glClearColor(0.3, 0.1, 0.3, 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(0); - default: - glutPostRedisplay(); - return; - } -} - -static void Draw(void) -{ - static float f = 0; - while (1) { - f += .1; - glClearColor((sin(f)+1)/2.0,(cos(f)+1)/2.0,0.5,1); - glClear(GL_COLOR_BUFFER_BIT); - glutSwapBuffers(); - - { - static GLint T0 = 0; - static GLint Frames = 0; - GLint t = glutGet(GLUT_ELAPSED_TIME); - - Frames++; - - if (t - T0 >= 5000) { - GLfloat seconds = (t - T0) / 1000.0; - GLfloat fps = Frames / seconds; - printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); - fflush(stdout); - T0 = t; - Frames = 0; - } - } - - } - glutPostRedisplay(); -} - -static GLenum Args(int argc, char **argv) -{ - 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( 300, 300); - - type = GLUT_RGB | GLUT_ALPHA; - type |= GLUT_DOUBLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/clear-scissor.c b/progs/trivial/clear-scissor.c deleted file mode 100644 index 01735327480..00000000000 --- a/progs/trivial/clear-scissor.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * glClear + glScissor - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <GL/glut.h> - - -GLenum doubleBuffer; -GLint Width = 200, Height = 150; - -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); -} - -static void Reshape(int width, int height) -{ - Width = width; - Height = 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) -{ - glEnable(GL_SCISSOR_TEST); - - glClearColor(1, 0, 0, 0); - glScissor(0, 0, Width / 2, Height / 2); - glClear(GL_COLOR_BUFFER_BIT); - - glClearColor(0, 1, 0, 0); - glScissor(Width / 2, 0, Width - Width / 2, Height / 2); - glClear(GL_COLOR_BUFFER_BIT); - - glClearColor(0, 0, 1, 0); - glScissor(0, Height / 2, Width / 2, Height - Height / 2); - glClear(GL_COLOR_BUFFER_BIT); - - glClearColor(1, 1, 1, 0); - glScissor(Width / 2, Height / 2, Width - Width / 2, Height - Height / 2); - glClear(GL_COLOR_BUFFER_BIT); - - 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( Width, Height ); - - type = GLUT_RGB | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(argv[0]) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/clear-undefined.c b/progs/trivial/clear-undefined.c deleted file mode 100644 index 5ec33bf3d78..00000000000 --- a/progs/trivial/clear-undefined.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * glClear + glScissor + Undefined content of framebuffer - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <GL/glut.h> - - -GLenum doubleBuffer; -GLint Width = 200, Height = 150; - -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)); - fprintf(stderr, "Top right corner should be red\n"); - fflush(stderr); -} - -static void Reshape(int width, int height) -{ - Width = width; - Height = 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: - glutPostRedisplay(); - return; - } - -} - -static void Draw(void) -{ - glColor4f(1.0, 0.0, 0.0, 1.0); - glBegin(GL_QUADS); - glVertex2d(0.0, 0.0); - glVertex2d(0.0, 1.0); - glVertex2d(1.0, 1.0); - glVertex2d(1.0, 0.0); - glEnd(); - - glBegin(GL_QUADS); - glVertex2d(0.0, 0.0); - glVertex2d(0.0, -1.0); - glVertex2d(1.0, -1.0); - glVertex2d(1.0, 0.0); - glEnd(); - - glEnable(GL_SCISSOR_TEST); - glClearColor(1, 1, 0, 0); - glScissor(Width / 2, 0, Width - Width / 2, Height / 2); - glClear(GL_COLOR_BUFFER_BIT); - - glClearColor(0, 0, 1, 0); - glScissor(0, Height / 2, Width / 2, Height - Height / 2); - glClear(GL_COLOR_BUFFER_BIT); - glDisable(GL_SCISSOR_TEST); - - glColor4f(0.0, 1.0, 0.0, 1.0); - glBegin(GL_QUADS); - glVertex2d( 0.0, 0.0); - glVertex2d( 0.0, -1.0); - glVertex2d(-1.0, -1.0); - glVertex2d(-1.0, 0.0); - glEnd(); - - glFlush(); - - if (doubleBuffer) { - glutSwapBuffers(); - } -} - -static GLenum Args(int argc, char **argv) -{ - GLint i; - - doubleBuffer = GL_TRUE; - - 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( Width, Height ); - - - type = GLUT_RGB | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(argv[0]) == GL_FALSE) { - exit(1); - } - - Init(); - Reshape(Width, Height); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/createwin.c b/progs/trivial/createwin.c deleted file mode 100644 index f2cc6f1cffc..00000000000 --- a/progs/trivial/createwin.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -static void Key(unsigned char key, int x, int y) -{ - - switch (key) { - case 27: - exit(1); - default: - return; - } - - glutPostRedisplay(); -} - -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; -} - -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); -// glutMainLoop(); - return 0; -} diff --git a/progs/trivial/draw2arrays.c b/progs/trivial/draw2arrays.c deleted file mode 100644 index 95a89981d3a..00000000000 --- a/progs/trivial/draw2arrays.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Basic VBO */ - -#include <assert.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glew.h> -#include <GL/glut.h> - -GLfloat pos[][3] = - { { 0.9, -0.9, 0.0 }, - { 0.9, 0.9, 0.0 }, - { -0.9, 0.9, 0.0 }, - { -0.9, -0.9, 0.0 } }; - -GLubyte color[][4] = -{ { 0x00, 0x00, 0xff, 0x00 }, - { 0x00, 0xff, 0x00, 0x00 }, - { 0xff, 0x00, 0x00, 0x00 }, - { 0xff, 0xff, 0xff, 0x00 } }; - -static void Init( void ) -{ - GLint errno; - GLuint prognum; - - static const char *prog1 = - "!!ARBvp1.0\n" - "MOV result.color, vertex.color;\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)); - } - - - glEnableClientState( GL_VERTEX_ARRAY ); - glEnableClientState( GL_COLOR_ARRAY ); - - glVertexPointer( 3, GL_FLOAT, sizeof(pos[0]), pos ); - glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof(color[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_ARB); - -// glDrawArrays( GL_TRIANGLES, 0, 3 ); - glDrawArrays( GL_TRIANGLES, 1, 3 ); - - 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; -} diff --git a/progs/trivial/flat-clip.c b/progs/trivial/flat-clip.c deleted file mode 100644 index dbe17a342eb..00000000000 --- a/progs/trivial/flat-clip.c +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Test flat shading and clipping. - * - * Brian Paul - * 30 August 2007 - */ - - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glut.h> - -static int Win; -static GLfloat Scale = 2.0, Zrot = 50; -static GLenum Mode = GL_LINE_LOOP; -static GLboolean Smooth = 0; -static GLenum PolygonMode = GL_FILL; - - -static void -Draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if (Smooth) - glShadeModel(GL_SMOOTH); - else - glShadeModel(GL_FLAT); - - glPushMatrix(); - glScalef(Scale, Scale, 1); - glRotatef(Zrot, 0, 0, 1); - - glPolygonMode(GL_FRONT_AND_BACK, PolygonMode); - - glBegin(Mode); - glColor3f(1, 0, 0); - glVertex2f(-1, -1); - glColor3f(0, 1, 0); - glVertex2f( 2, -1); - glColor3f(0, 0, 1); - glVertex2f( 0, 1); - glEnd(); - - glPushMatrix(); - glScalef(0.9, 0.9, 1); - glBegin(Mode); - glColor3f(1, 0, 0); - glVertex2f( 0, 1); - - glColor3f(0, 0, 1); - glVertex2f( 2, -1); - - glColor3f(0, 1, 0); - glVertex2f(-1, -1); - - glEnd(); - glPopMatrix(); - - 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, 25.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 'p': - if (Mode == GL_TRIANGLES) - Mode = GL_LINE_LOOP; - else - Mode = GL_TRIANGLES; - break; - case 'f': - if (PolygonMode == GL_POINT) - PolygonMode = GL_LINE; - else if (PolygonMode == GL_LINE) - PolygonMode = GL_FILL; - else - PolygonMode = GL_POINT; - printf("PolygonMode = 0x%x\n", PolygonMode); - break; - case 'r': - Zrot -= 5.0; - break; - case 'R': - Zrot += 5.0; - break; - case 'z': - Scale *= 1.1; - break; - case 'Z': - Scale /= 1.1; - break; - case 's': - Smooth = !Smooth; - break; - case 27: - glutDestroyWindow(Win); - exit(0); - break; - } - glutPostRedisplay(); -} - - -static void -Init(void) -{ - printf("Usage:\n"); - printf(" z/Z: change triangle size\n"); - printf(" r/R: rotate\n"); - printf(" p: toggle line/fill mode\n"); - printf(" s: toggle smooth/flat shading\n"); - printf(" f: switch polygon fill mode\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); - glutDisplayFunc(Draw); - Init(); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/fs-tri.c b/progs/trivial/fs-tri.c deleted file mode 100644 index 6e86df1dcfa..00000000000 --- a/progs/trivial/fs-tri.c +++ /dev/null @@ -1,209 +0,0 @@ -/* Test fragment shader */ - -#include <assert.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glew.h> -#include <GL/glut.h> - - -static GLuint fragShader; -static GLuint vertShader; -static GLuint program; -static GLint win = 0; -static GLfloat xpos = 0, ypos = 0; - - -static void -Redisplay(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glTranslatef(xpos, ypos, 0); - - glBegin(GL_TRIANGLES); - glColor3f(1, 0, 0); - glVertex2f(-0.9, -0.9); - glColor3f(0, 1, 0); - glVertex2f( 0.9, -0.9); - glColor3f(0, 0, 1); - glVertex2f( 0, 0.9); - glEnd(); - - glPopMatrix(); - - glutSwapBuffers(); -} - - -static void -Reshape(int width, int height) -{ - glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1, 1, -1, 1, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - - -static void -CleanUp(void) -{ - glDeleteShader(fragShader); - glDeleteShader(vertShader); - glDeleteProgram(program); - glutDestroyWindow(win); -} - - -static void -Key(unsigned char key, int x, int y) -{ - (void) x; - (void) y; - - switch(key) { - case 27: - CleanUp(); - exit(0); - break; - } - glutPostRedisplay(); -} - - -static void -SpecialKey(int key, int x, int y) -{ - const GLfloat step = 0.1; - - (void) x; - (void) y; - - switch(key) { - case GLUT_KEY_UP: - ypos += step; - break; - case GLUT_KEY_DOWN: - ypos -= step; - break; - case GLUT_KEY_LEFT: - xpos -= step; - break; - case GLUT_KEY_RIGHT: - xpos += step; - break; - } - glutPostRedisplay(); -} - - -static void -LoadAndCompileShader(GLuint shader, const char *text) -{ - GLint stat; - - glShaderSource(shader, 1, (const GLchar **) &text, NULL); - - glCompileShader(shader); - - glGetShaderiv(shader, GL_COMPILE_STATUS, &stat); - if (!stat) { - GLchar log[1000]; - GLsizei len; - glGetShaderInfoLog(shader, 1000, &len, log); - fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log); - exit(1); - } -} - - -static void -CheckLink(GLuint prog) -{ - GLint stat; - glGetProgramiv(prog, GL_LINK_STATUS, &stat); - if (!stat) { - GLchar log[1000]; - GLsizei len; - glGetProgramInfoLog(prog, 1000, &len, log); - fprintf(stderr, "Linker error:\n%s\n", log); - } -} - - -static void -Init(void) -{ - /* fragment color is a function of fragment position: */ - static const char *fragShaderText = - "void main() {\n" - " gl_FragColor = gl_FragCoord * vec4(0.005); \n" - " //gl_FragColor = gl_Color; \n" - " //gl_FragColor = vec4(1, 0, 0.5, 0); \n" - "}\n"; -#if 0 - static const char *vertShaderText = - "varying vec3 normal;\n" - "void main() {\n" - " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" - " normal = gl_NormalMatrix * gl_Normal;\n" - "}\n"; -#endif - const char *version; - - version = (const char *) glGetString(GL_VERSION); - if (version[0] != '2' || version[1] != '.') { - printf("This program requires OpenGL 2.x, found %s\n", version); - exit(1); - } - - fragShader = glCreateShader(GL_FRAGMENT_SHADER); - LoadAndCompileShader(fragShader, fragShaderText); - -#if 0 - vertShader = glCreateShader(GL_VERTEX_SHADER); - LoadAndCompileShader(vertShader, vertShaderText); -#endif - - program = glCreateProgram(); - glAttachShader(program, fragShader); -#if 0 - glAttachShader(program, vertShader); -#endif - glLinkProgram(program); - CheckLink(program); - glUseProgram(program); - - assert(glGetError() == 0); - - glClearColor(0.3f, 0.3f, 0.3f, 0.0f); - - printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); -} - - -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]); - glewInit(); - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutSpecialFunc(SpecialKey); - glutDisplayFunc(Redisplay); - Init(); - glutMainLoop(); - return 0; -} - - diff --git a/progs/trivial/line-flat.c b/progs/trivial/line-flat.c deleted file mode 100644 index 14f0ac07825..00000000000 --- a/progs/trivial/line-flat.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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_LINES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - - - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/line-smooth.c b/progs/trivial/line-smooth.c deleted file mode 100644 index 9c4b9a01155..00000000000 --- a/progs/trivial/line-smooth.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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 <math.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -GLenum doubleBuffer; -GLboolean smooth = GL_TRUE; -GLfloat width = 1.0; - - -static void Init(void) -{ - float range[2], aarange[2]; - 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); - glGetFloatv(GL_LINE_WIDTH_RANGE, aarange); - glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, range); - printf("Non-AA line width range: %f .. %f\n", range[0], range[1]); - printf("AA line width range: %f .. %f\n", aarange[0], aarange[1]); - fflush(stdout); -} - - -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); - glLoadIdentity(); - glTranslatef(0, 0, -30); -} - -static void Key(unsigned char key, int x, int y) -{ - switch (key) { - case 'w': - width -= 0.5; - if (width < 0.5) - width = 0.5; - break; - case 'W': - width += 0.5; - break; - case 's': - smooth = !smooth; - break; - case 27: - exit(1); - default: - return; - } - printf("LineWidth: %g\n", width); - glutPostRedisplay(); -} - - -static void Draw(void) -{ - float a; - - glClear(GL_COLOR_BUFFER_BIT); - - glLineWidth(width); - - if (smooth) { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); - } - - glColor3f(1, 1, 1); - - glBegin(GL_LINES); - for (a = 0; a < 3.14159; a += 0.2) { - float x = .9 * cos(a); - float y = .9 * sin(a); - - glVertex2f(-x, -y); - glVertex2f( x, y); - } - glEnd(); - - glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); - - 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(argv[0]) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/line-stipple-wide.c b/progs/trivial/line-stipple-wide.c deleted file mode 100644 index 1804ffad3f0..00000000000 --- a/progs/trivial/line-stipple-wide.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glEnable(GL_LINE_STIPPLE); - glLineStipple( 5, 0xfffe ); - glLineWidth( 4 ); - - glBegin(GL_LINES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/line-wide.c b/progs/trivial/line-wide.c deleted file mode 100644 index b74021dea73..00000000000 --- a/progs/trivial/line-wide.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glLineWidth(4.0); - - glBegin(GL_LINES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - - - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/lineloop-elts.c b/progs/trivial/lineloop-elts.c deleted file mode 100644 index ab944157c01..00000000000 --- a/progs/trivial/lineloop-elts.c +++ /dev/null @@ -1,121 +0,0 @@ -/* Test rebasing */ - -#include <assert.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glew.h> -#include <GL/glut.h> - -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 }, -}; - -GLubyte color[][4] = { - { 0x00, 0x00, 0xff, 0x00 }, - { 0x00, 0xff, 0x00, 0x00 }, - { 0xff, 0x00, 0x00, 0x00 }, - { 0xff, 0xff, 0xff, 0x00 }, -}; - -GLuint indices[] = { 1, 2, 3 }; - -static void Init( void ) -{ - GLint errno; - GLuint prognum; - - static const char *prog1 = - "!!ARBvp1.0\n" - "MOV result.color, vertex.color;\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)); - } - - - glEnableClientState( GL_VERTEX_ARRAY ); - glEnableClientState( GL_COLOR_ARRAY ); - glVertexPointer( 3, GL_FLOAT, sizeof(verts[0]), verts ); - 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); - - /* Should have min_index == 1, maybe force a rebase: - */ - glDrawElements( GL_LINE_LOOP, 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; -} diff --git a/progs/trivial/linestrip-clip.c b/progs/trivial/linestrip-clip.c deleted file mode 100644 index f2528229218..00000000000 --- a/progs/trivial/linestrip-clip.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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_LINE_STRIP); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - - glColor3f(0,.9,0); - glVertex3f(-1.9, 0.0, -30.0); - - glColor3f(0,0,.7); - glVertex3f( 0.8, -0.8, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/linestrip-flat-stipple.c b/progs/trivial/linestrip-flat-stipple.c deleted file mode 100644 index 5caa7244235..00000000000 --- a/progs/trivial/linestrip-flat-stipple.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - glEnable(GL_LINE_STIPPLE); - glLineStipple( 5, 0xfffe ); - - glBegin(GL_LINE_STRIP); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/linestrip-stipple-wide.c b/progs/trivial/linestrip-stipple-wide.c deleted file mode 100644 index 701c82c266a..00000000000 --- a/progs/trivial/linestrip-stipple-wide.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glEnable(GL_LINE_STIPPLE); - glLineStipple( 5, 0xfffe ); - glLineWidth( 4 ); - - glBegin(GL_LINE_STRIP); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/linestrip-stipple.c b/progs/trivial/linestrip-stipple.c deleted file mode 100644 index df2eef96b5d..00000000000 --- a/progs/trivial/linestrip-stipple.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glEnable(GL_LINE_STIPPLE); - glLineStipple( 5, 0xfffe ); - - glBegin(GL_LINE_STRIP); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/linestrip.c b/progs/trivial/linestrip.c deleted file mode 100644 index 0219b1ab70e..00000000000 --- a/progs/trivial/linestrip.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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_LINE_STRIP); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/long-fixed-func.c b/progs/trivial/long-fixed-func.c deleted file mode 100644 index 4b6c412f9e8..00000000000 --- a/progs/trivial/long-fixed-func.c +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Enable as much fixed-function vertex processing state as possible - * to test fixed-function -> program code generation. - */ - - - -#include <GL/glew.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <GL/glut.h> - - -static void -Reshape(int width, int height) -{ - glViewport(0, 0, (GLint)width, (GLint)height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); - glMatrixMode(GL_MODELVIEW); -} - - -static void -Draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glBegin(GL_TRIANGLES); - glColor3f(.8,0,0); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.0, 0.9, -30.0); - glEnd(); - - glFlush(); - - glutSwapBuffers(); -} - - -static void -Init(void) -{ - GLubyte tex[16][16][4]; - GLfloat pos[4] = {5, 10, 3, 1.0}; - int i, j; - - fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); - fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); - fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); - fflush(stderr); - - glClearColor(0.3, 0.1, 0.3, 0.0); - - for (i = 0; i < 16; i++) { - for (j = 0; j < 16; j++) { - if ((i+j) & 1) { - tex[i][j][0] = 100; - tex[i][j][1] = 100; - tex[i][j][2] = 100; - tex[i][j][3] = 255; - } - else { - tex[i][j][0] = 200; - tex[i][j][1] = 200; - tex[i][j][2] = 200; - tex[i][j][3] = 255; - } - } - } - - - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); - glFogi(GL_FOG_MODE, GL_LINEAR); - glEnable(GL_FOG); - - glPointParameterfv(GL_DISTANCE_ATTENUATION_EXT, pos); - - for (i = 0; i < 8; i++) { - GLuint texObj; - - glEnable(GL_LIGHT0 + i); - glLightf(GL_LIGHT0 + i, GL_SPOT_EXPONENT, 3.5); - glLightf(GL_LIGHT0 + i, GL_SPOT_CUTOFF, 30.); - glLightf(GL_LIGHT0 + i, GL_CONSTANT_ATTENUATION, 3.); - glLightf(GL_LIGHT0 + i, GL_LINEAR_ATTENUATION, 3.); - glLightf(GL_LIGHT0 + i, GL_QUADRATIC_ATTENUATION, 3.); - glLightfv(GL_LIGHT0 + i, GL_POSITION, pos); - - glActiveTexture(GL_TEXTURE0 + i); - glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); - glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); - glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); - glEnable(GL_TEXTURE_GEN_R); - glEnable(GL_TEXTURE_GEN_Q); - glEnable(GL_TEXTURE_2D); - - glMatrixMode(GL_TEXTURE); - glScalef(2.0, 1.0, 3.0); - - glGenTextures(1, &texObj); - glBindTexture(GL_TEXTURE_2D, texObj); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, - GL_RGBA, GL_UNSIGNED_BYTE, tex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - - glEnable(GL_LIGHTING); - glActiveTexture(GL_TEXTURE0); - glMatrixMode(GL_MODELVIEW); -} - - -static void -Key(unsigned char key, int x, int y) -{ - if (key == 27) { - exit(0); - } - glutPostRedisplay(); -} - - -int -main(int argc, char **argv) -{ - GLenum type = GLUT_RGB | GLUT_DOUBLE; - - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); - glutInitWindowSize( 250, 250); - glutInitDisplayMode(type); - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - glewInit(); - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - Init(); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/pgon-mode.c b/progs/trivial/pgon-mode.c deleted file mode 100644 index db586386196..00000000000 --- a/progs/trivial/pgon-mode.c +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Test glPolygonMode. - * A tri-strip w/ two tris is drawn so that the first tri is front-facing - * but the second tri is back-facing. - * Set glPolygonMode differently for the front/back faces - * - */ - - -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glut.h> - -static int Win; -static GLfloat Zrot = 0; -static GLboolean FrontFillBackUnfilled = GL_TRUE; -static GLboolean Lines = GL_TRUE; - - -static void -Draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if (FrontFillBackUnfilled) { - if (Lines) { - printf("FrontMode = FILL, BackMode = LINE\n"); - glPolygonMode(GL_BACK, GL_LINE); - } - else { - printf("FrontMode = FILL, BackMode = POINT\n"); - glPolygonMode(GL_BACK, GL_POINT); - } - glPolygonMode(GL_FRONT, GL_FILL); - } - else { - if (Lines) { - printf("FrontMode = LINE, BackMode = FILL\n"); - glPolygonMode(GL_FRONT, GL_LINE); - } - else { - printf("FrontMode = POINT, BackMode = FILL\n"); - glPolygonMode(GL_FRONT, GL_POINT); - } - glPolygonMode(GL_BACK, GL_FILL); - } - - glPushMatrix(); - glRotatef(Zrot, 0, 0, 1); - - glBegin(GL_TRIANGLE_STRIP); - glVertex2f(-1, 0); - glVertex2f( 1, 0); - glVertex2f(0, 1); - glVertex2f(0, -1); - glEnd(); - - 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, 25.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -15.0); -} - - -static void -Key(unsigned char key, int x, int y) -{ - const GLfloat step = 3.0; - (void) x; - (void) y; - switch (key) { - case 'p': - FrontFillBackUnfilled = !FrontFillBackUnfilled; - break; - case 'l': - Lines = !Lines; - break; - case 'z': - Zrot -= step; - break; - case 'Z': - Zrot += step; - break; - case 27: - glutDestroyWindow(Win); - exit(0); - break; - } - glutPostRedisplay(); -} - - -static void -Init(void) -{ - printf("GL_RENDERER = %s\n", (char*) glGetString(GL_RENDERER)); - - glLineWidth(3.0); - glPointSize(3.0); - - glColor4f(1, 1, 1, 0.8); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - printf("Press 'p' to toggle polygon mode\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); - glutDisplayFunc(Draw); - Init(); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/point-sprite.c b/progs/trivial/point-sprite.c deleted file mode 100644 index 5d29a6a3cf9..00000000000 --- a/progs/trivial/point-sprite.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - -#define SIZE 16 - { - GLubyte tex2d[SIZE][SIZE][3]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { -#if 1 - tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; - tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; - tex2d[t][s][2] = 0; -#else - tex2d[t][s][0] = s*255/(SIZE-1); - tex2d[t][s][1] = t*255/(SIZE-1); - tex2d[t][s][2] = 0; -#endif - } - } - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glEnable(GL_TEXTURE_2D); - } - - glEnable(GL_POINT_SPRITE); - - 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); -} - -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); - - glPointSize(16.0); - - glBegin(GL_POINTS); - glColor3f(1,0,0); - glVertex3f( 0.6, -0.6, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.6, 0.6, -30.0); - glColor3f(1,0,1); - glVertex3f(-0.6, 0.6, -30.0); - glColor3f(0,1,1); - glVertex3f(-0.6, -0.6, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/point-wide-smooth.c b/progs/trivial/point-wide-smooth.c deleted file mode 100644 index f6e9b8df5f9..00000000000 --- a/progs/trivial/point-wide-smooth.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glPointSize(8.0); - - glEnable(GL_POINT_SMOOTH); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glBegin(GL_POINTS); - glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(1,0,1); - glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,1,1); - glVertex3f(-0.9, -0.9, -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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/poly-flat-clip.c b/progs/trivial/poly-flat-clip.c deleted file mode 100644 index 5490068b08e..00000000000 --- a/progs/trivial/poly-flat-clip.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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_POLYGON); - glColor3f(1,0,0); - glVertex3f( 0, 0, -30.0); - glColor3f(1,1,0); - glVertex3f( 1.3, 1.1, -30.0); - glColor3f(1,0,1); - glVertex3f(-.9, .9, -30.0); - glColor3f(0,1,1); - glVertex3f(-1.1, -1.3, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/poly-flat-unfilled-clip.c b/progs/trivial/poly-flat-unfilled-clip.c deleted file mode 100644 index 26b90ef9645..00000000000 --- a/progs/trivial/poly-flat-unfilled-clip.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glPolygonMode(GL_FRONT, GL_LINE); - glPolygonMode(GL_BACK, GL_LINE); - glLineWidth(4.0); - - - glBegin(GL_POLYGON); - glColor3f(1,0,0); - glVertex3f( 0, 0, -30.0); - glColor3f(1,1,0); - glVertex3f( 1.3, 1.1, -30.0); - glColor3f(1,0,1); - glVertex3f(-.9, .9, -30.0); - glColor3f(0,1,1); - glVertex3f(-1.1, -1.3, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/psb_context.c b/progs/trivial/psb_context.c deleted file mode 100644 index e69de29bb2d..00000000000 --- a/progs/trivial/psb_context.c +++ /dev/null diff --git a/progs/trivial/quad-tex-alpha.c b/progs/trivial/quad-tex-alpha.c deleted file mode 100644 index eebaf9170ec..00000000000 --- a/progs/trivial/quad-tex-alpha.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - glClearColor(0.0, 0.0, 1.0, 0.0); - -#define SIZE 16 - { - GLubyte tex2d[SIZE][SIZE][4]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { - tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; - tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; - tex2d[t][s][2] = 0; - tex2d[t][s][3] = ((t^s) & 3) * 63; - } - } - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, 4, SIZE, SIZE, 0, - GL_RGBA, GL_UNSIGNED_BYTE, tex2d); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glEnable(GL_TEXTURE_2D); - } -} - -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); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GEQUAL, 0.5); - - glBegin(GL_QUADS); - glTexCoord2f(1,0); - glVertex3f( 0.9, -0.9, -30.0); - glTexCoord2f(1,1); - glVertex3f( 0.9, 0.9, -30.0); - glTexCoord2f(0,1); - glVertex3f(-0.9, 0.9, -30.0); - glTexCoord2f(0,0); - glVertex3f(-0.9, -0.9, -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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/quad-tex-sub.c b/progs/trivial/quad-tex-sub.c deleted file mode 100644 index 5620dbc6f81..00000000000 --- a/progs/trivial/quad-tex-sub.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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> -#include <GL/glew.h> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - -#define SIZE 16 -GLenum doubleBuffer; -GLint line = 0; - -static void MakeImage() -{ - GLubyte tex2d[SIZE][SIZE][3]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { - tex2d[t][s][0] = s*255/(SIZE-1); - tex2d[t][s][1] = t*255/(SIZE-1); - tex2d[t][s][2] = 0*255/(SIZE-1); - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, - SIZE, SIZE, - 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glEnable(GL_TEXTURE_2D); -} - -static void UpdateLine() -{ - GLubyte tex[SIZE][3]; - GLubyte b = 0; - GLint s, t; - - t = line % SIZE; - if (line % (SIZE * 2) < SIZE) - b = 255; - else - b = 0; - - for (s = 0; s < SIZE; s++) { - tex[s][0] = s*255/(SIZE-1); - tex[s][1] = t*255/(SIZE-1); - tex[s][2] = b; - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexSubImage2D(GL_TEXTURE_2D, 0, - 0, t, - SIZE, 1, - GL_RGB, GL_UNSIGNED_BYTE, tex); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); -} - -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); - - glClearColor(0.0, 0.0, 1.0, 0.0); - - 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); - - MakeImage(); - UpdateLine(); - line++; -} - -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: - UpdateLine(); - line++; - break; - } - - glutPostRedisplay(); -} - -static void Draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glBegin(GL_QUADS); - glTexCoord2f(1,0); - glVertex3f( 0.9, -0.9, -30.0); - glTexCoord2f(1,1); - glVertex3f( 0.9, 0.9, -30.0); - glTexCoord2f(0,1); - glVertex3f(-0.9, 0.9, -30.0); - glTexCoord2f(0,0); - glVertex3f(-0.9, -0.9, -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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/quad-unfilled-clip.c b/progs/trivial/quad-unfilled-clip.c deleted file mode 100644 index 761878bd4b6..00000000000 --- a/progs/trivial/quad-unfilled-clip.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - - glBegin(GL_QUADS); - glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(1,0,1); - glVertex3f(-1.9, 0.9, -30.0); - glColor3f(0,1,1); - glVertex3f(-0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/quad-unfilled-stipple.c b/progs/trivial/quad-unfilled-stipple.c deleted file mode 100644 index cd7d2769284..00000000000 --- a/progs/trivial/quad-unfilled-stipple.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - - glEnable(GL_LINE_STIPPLE); - glLineStipple( 5, 0xfffe ); - - glBegin(GL_QUADS); - glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(1,1,1); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,1,0); - glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,0,0); - glVertex3f(-0.9, -0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/quadstrip-clip.c b/progs/trivial/quadstrip-clip.c deleted file mode 100644 index 4cea81a45d7..00000000000 --- a/progs/trivial/quadstrip-clip.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - -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)); - fflush(stderr); - - 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); -} - -static void Key(unsigned char key, int x, int y) -{ - - switch (key) { - case 27: - exit(1); - } - - glutPostRedisplay(); -} - -static void Draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glBegin(GL_QUAD_STRIP); - glColor3f(1,1,1); - glVertex3f( 1.9, -0.9, -30.0); - glVertex3f( 0.9, 0.9, -30.0); - - glColor3f(1,0,0); - glVertex3f( 0.1, -0.8, -30.0); - glVertex3f( 0.1, 0.8, -30.0); - - glColor3f(0,1,0); - glVertex3f(-0.1, -0.9, -30.0); - glVertex3f(-0.1, 0.9, -30.0); - - glColor3f(0,0,0); - glVertex3f(-0.9, -0.8, -30.0); - glVertex3f(-0.9, 0.8, -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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/quadstrip-cont.c b/progs/trivial/quadstrip-cont.c deleted file mode 100644 index 329523531aa..00000000000 --- a/progs/trivial/quadstrip-cont.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - -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)); - fflush(stderr); - - 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); -} - -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_QUAD_STRIP); - glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.9, 0.9, -30.0); - - glColor3f(1,0,0); - glVertex3f( 0.1, -0.8, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.1, 0.8, -30.0); - - glColor3f(0,1,1); - glVertex3f(-0.1, -0.9, -30.0); - glColor3f(1,0,1); - glVertex3f(-0.1, 0.9, -30.0); - - glColor3f(0,1,1); - glVertex3f(-0.9, -0.8, -30.0); - glColor3f(1,0,1); - glVertex3f(-0.9, 0.8, -30.0); - glEnd(); - - glFlush(); - - if (doubleBuffer) { - glutSwapBuffers(); - } -} - -static void -idle(void) -{ - glutPostRedisplay(); -} - - -static void -visible(int vis) -{ - if (vis == GLUT_VISIBLE) - glutIdleFunc(idle); - else - glutIdleFunc(NULL); -} - - -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutVisibilityFunc(visible); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/readpixels.c b/progs/trivial/readpixels.c deleted file mode 100644 index 5671618446a..00000000000 --- a/progs/trivial/readpixels.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * glRead/DrawPixels test - */ - - -#include <GL/glew.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <GL/glut.h> - -static int Width = 250, Height = 250; -static GLfloat Zoom = 1.0; - -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); - glClearColor(0.3, 0.1, 0.3, 0.0); -} - -static void Reshape(int width, int height) -{ - Width = width / 2; - Height = height; - /* draw on left half (we'll read that area) */ - 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); -} - -static void Key(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - default: - return; - } - glutPostRedisplay(); -} - -static void Draw(void) -{ - GLfloat *image = (GLfloat *) malloc(Width * Height * 4 * sizeof(GLfloat)); - - glClear(GL_COLOR_BUFFER_BIT); - - glBegin(GL_TRIANGLES); - glColor3f(.8,0,0); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.0, 0.9, -30.0); - glEnd(); - - glBegin(GL_QUADS); - glColor3f(1, 1, 1); - glVertex2f(-1.0, -1.0); - glVertex2f(-0.9, -1.0); - glVertex2f(-0.9, -0.9); - glVertex2f(-1.0, -0.9); - glEnd(); - - glReadPixels(0, 0, Width, Height, GL_RGBA, GL_FLOAT, image); - printf("Pixel(0,0) = %f, %f, %f, %f\n", - image[0], image[1], image[2], image[3]); - /* draw to right half of window */ - glWindowPos2iARB(Width, 0); - glPixelZoom(Zoom, Zoom); - glDrawPixels(Width, Height, GL_RGBA, GL_FLOAT, image); - free(image); - - glutSwapBuffers(); -} - -int main(int argc, char **argv) -{ - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); - glutInitWindowSize(Width*2, Height); - glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE); - if (glutCreateWindow(argv[0]) == GL_FALSE) { - exit(1); - } - - if (argc > 1) - Zoom = atof(argv[1]); - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-alpha-tex.c b/progs/trivial/tri-alpha-tex.c deleted file mode 100644 index 780ebe6be5b..00000000000 --- a/progs/trivial/tri-alpha-tex.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - glClearColor(0.0, 0.0, 1.0, 0.0); - -#define SIZE 16 - { - GLubyte tex2d[SIZE][SIZE][4]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { - tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; - tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; - tex2d[t][s][2] = 0; - tex2d[t][s][3] = ((t^s) & 3) * 63; - } - } - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, 4, SIZE, SIZE, 0, - GL_RGBA, GL_UNSIGNED_BYTE, tex2d); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glEnable(GL_TEXTURE_2D); - } -} - -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); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GEQUAL, 0.5); - - glBegin(GL_QUADS); - glTexCoord2f(1,0); - glVertex3f( 0.9, -0.9, -30.0); - glTexCoord2f(1,1); - glVertex3f( 0.9, 0.9, -30.0); - glTexCoord2f(0,1); - glVertex3f(-0.9, 0.9, -30.0); - glTexCoord2f(0,0); - glVertex3f(-0.9, -0.9, -30.0); - glEnd(); -#if 0 - glBegin(GL_TRIANGLES); - glColor4f(0,0,.7,1); - glVertex3f( 0.9, -0.9, -30.0); - glColor4f(.8,0,0,.5); - glVertex3f( 0.9, 0.9, -30.0); - glColor4f(0,.9,0,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); -#endif - - 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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-alpha.c b/progs/trivial/tri-alpha.c deleted file mode 100644 index aec1cbb3772..00000000000 --- a/progs/trivial/tri-alpha.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GEQUAL, 0.5); - - glBegin(GL_TRIANGLES); - glColor4f(0,0,.7,1); - glVertex3f( 0.9, -0.9, -30.0); - glColor4f(.8,0,0,.5); - glVertex3f( 0.9, 0.9, -30.0); - glColor4f(0,.9,0,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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-array-interleaved.c b/progs/trivial/tri-array-interleaved.c deleted file mode 100644 index 95de2056cf1..00000000000 --- a/progs/trivial/tri-array-interleaved.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Test rebasing */ - -#include <assert.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glew.h> -#include <GL/glut.h> - -struct { - GLubyte color[4]; - GLfloat vert[3]; -} verts[] = { - - { { 0x00, 0x00, 0xff, 0x00 }, - { 0.9, -0.9, 0.0 } }, - - { { 0x00, 0xff, 0x00, 0x00 }, - { 0.9, 0.9, 0.0 } }, - - { { 0xff, 0x00, 0x00, 0x00 }, - { -0.9, 0.9, 0.0 } }, - - { { 0xff, 0xff, 0xff, 0x00 }, - { -0.9, -0.9, 0.0 } }, -}; - -GLuint indices[] = { 1, 2, 3 }; - -static void Init( void ) -{ - GLint errno; - GLuint prognum; - - static const char *prog1 = - "!!ARBvp1.0\n" - "MOV result.color, vertex.color;\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)); - } - - glInterleavedArrays( GL_C4UB_V3F, sizeof(verts[0]), verts ); -} - - - -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); - - /* Should have min_index == 1, maybe force a rebase: - */ - 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; -} diff --git a/progs/trivial/tri-blend-color.c b/progs/trivial/tri-blend-color.c deleted file mode 100644 index 92f019259ec..00000000000 --- a/progs/trivial/tri-blend-color.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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> -#include <GL/glew.h> -#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)); - fflush(stderr); - -} - -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) -{ - glClearColor(0.0, 0.0, 1.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendColor(1.0, 0, 0, 0); - glBlendFunc(GL_CONSTANT_COLOR, GL_SRC_COLOR); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-blend-max.c b/progs/trivial/tri-blend-max.c deleted file mode 100644 index b39f8f3f12a..00000000000 --- a/progs/trivial/tri-blend-max.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * ALL RIGHTS RESERVED - * Permission to use, copy, modify, and distribute this software for - * any purpose and without fee is hereby granted, provided that the above - * copyright notice appear in all copies and that both the copyright notice - * and this permission notice appear in supporting documentation, and that - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. - * - * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "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, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE - * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. - * - * US Government Users Restricted Rights - * Use, duplication, or disclosure by the Government is subject to - * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph - * (c)(1)(ii) of the Rights in Technical Data and Computer Software - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * alpha.c - * This program draws several overlapping filled polygons - * to demonstrate the effect order has on alpha blending results. - * Use the 't' key to toggle the order of drawing polygons. - */ -#include <stdlib.h> -#include <GL/glew.h> -#include <GL/glut.h> - -static int leftFirst = GL_TRUE; - -/* Initialize alpha blending function. - */ -static void init(void) -{ - glBlendEquation (GL_MAX); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glShadeModel (GL_FLAT); - glClearColor (1.0, 0.0, 0.0, 0.0); -} - -static void drawLeftTriangle(void) -{ - /* draw yellow triangle on LHS of screen */ - - glBegin (GL_TRIANGLES); - glColor4f(1.0, 1.0, 0.0, 0.75); - glVertex3f(0.1, 0.9, 0.0); - glVertex3f(0.1, 0.1, 0.0); - glVertex3f(0.7, 0.5, 0.0); - glEnd(); -} - -static void drawRightTriangle(void) -{ - /* draw cyan triangle on RHS of screen */ - - glEnable (GL_BLEND); - glBegin (GL_TRIANGLES); - glColor4f(0.0, 1.0, 1.0, 0.75); - glVertex3f(0.9, 0.9, 0.0); - glVertex3f(0.3, 0.5, 0.0); - glVertex3f(0.9, 0.1, 0.0); - glEnd(); - glDisable (GL_BLEND); -} - -void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - if (leftFirst) { - drawLeftTriangle(); - drawRightTriangle(); - } - else { - drawRightTriangle(); - drawLeftTriangle(); - } - - glFlush(); -} - -void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); -} - -/* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 't': - case 'T': - leftFirst = !leftFirst; - glutPostRedisplay(); - break; - case 27: /* Escape key */ - exit(0); - break; - default: - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (200, 200); - glutCreateWindow (argv[0]); - glewInit(); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-blend-min.c b/progs/trivial/tri-blend-min.c deleted file mode 100644 index 656297c0ce0..00000000000 --- a/progs/trivial/tri-blend-min.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * ALL RIGHTS RESERVED - * Permission to use, copy, modify, and distribute this software for - * any purpose and without fee is hereby granted, provided that the above - * copyright notice appear in all copies and that both the copyright notice - * and this permission notice appear in supporting documentation, and that - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. - * - * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "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, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE - * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. - * - * US Government Users Restricted Rights - * Use, duplication, or disclosure by the Government is subject to - * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph - * (c)(1)(ii) of the Rights in Technical Data and Computer Software - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * alpha.c - * This program draws several overlapping filled polygons - * to demonstrate the effect order has on alpha blending results. - * Use the 't' key to toggle the order of drawing polygons. - */ -#include <stdlib.h> -#include <GL/glew.h> -#include <GL/glut.h> - -static int leftFirst = GL_TRUE; - -/* Initialize alpha blending function. - */ -static void init(void) -{ - glBlendEquation (GL_MIN); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glShadeModel (GL_FLAT); - glClearColor (1.0, 0.0, 0.0, 0.0); -} - -static void drawLeftTriangle(void) -{ - /* draw yellow triangle on LHS of screen */ - - glBegin (GL_TRIANGLES); - glColor4f(1.0, 1.0, 0.0, 0.75); - glVertex3f(0.1, 0.9, 0.0); - glVertex3f(0.1, 0.1, 0.0); - glVertex3f(0.7, 0.5, 0.0); - glEnd(); -} - -static void drawRightTriangle(void) -{ - /* draw cyan triangle on RHS of screen */ - - glEnable (GL_BLEND); - glBegin (GL_TRIANGLES); - glColor4f(0.0, 1.0, 1.0, 0.75); - glVertex3f(0.9, 0.9, 0.0); - glVertex3f(0.3, 0.5, 0.0); - glVertex3f(0.9, 0.1, 0.0); - glEnd(); - glDisable (GL_BLEND); -} - -void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - if (leftFirst) { - drawLeftTriangle(); - drawRightTriangle(); - } - else { - drawRightTriangle(); - drawLeftTriangle(); - } - - glFlush(); -} - -void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); -} - -/* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 't': - case 'T': - leftFirst = !leftFirst; - glutPostRedisplay(); - break; - case 27: /* Escape key */ - exit(0); - break; - default: - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (200, 200); - glutCreateWindow (argv[0]); - glewInit(); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-blend-revsub.c b/progs/trivial/tri-blend-revsub.c deleted file mode 100644 index fe225f1f4e0..00000000000 --- a/progs/trivial/tri-blend-revsub.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * ALL RIGHTS RESERVED - * Permission to use, copy, modify, and distribute this software for - * any purpose and without fee is hereby granted, provided that the above - * copyright notice appear in all copies and that both the copyright notice - * and this permission notice appear in supporting documentation, and that - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. - * - * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "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, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE - * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. - * - * US Government Users Restricted Rights - * Use, duplication, or disclosure by the Government is subject to - * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph - * (c)(1)(ii) of the Rights in Technical Data and Computer Software - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * alpha.c - * This program draws several overlapping filled polygons - * to demonstrate the effect order has on alpha blending results. - * Use the 't' key to toggle the order of drawing polygons. - */ -#include <stdlib.h> -#include <GL/glew.h> -#include <GL/glut.h> - -static int leftFirst = GL_TRUE; - -/* Initialize alpha blending function. - */ -static void init(void) -{ - glBlendEquation (GL_FUNC_REVERSE_SUBTRACT); - glBlendFunc (GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); - glShadeModel (GL_FLAT); - glClearColor (1.0, 0.0, 0.0, 0.0); -} - -static void drawLeftTriangle(void) -{ - /* draw yellow triangle on LHS of screen */ - - glBegin (GL_TRIANGLES); - glColor4f(1.0, 1.0, 0.0, 0.75); - glVertex3f(0.1, 0.9, 0.0); - glVertex3f(0.1, 0.1, 0.0); - glVertex3f(0.7, 0.5, 0.0); - glEnd(); -} - -static void drawRightTriangle(void) -{ - /* draw cyan triangle on RHS of screen */ - - glEnable (GL_BLEND); - glBegin (GL_TRIANGLES); - glColor4f(0.0, 1.0, 1.0, 0.75); - glVertex3f(0.9, 0.9, 0.0); - glVertex3f(0.3, 0.5, 0.0); - glVertex3f(0.9, 0.1, 0.0); - glEnd(); - glDisable (GL_BLEND); -} - -void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - if (leftFirst) { - drawLeftTriangle(); - drawRightTriangle(); - } - else { - drawRightTriangle(); - drawLeftTriangle(); - } - - glFlush(); -} - -void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); -} - -/* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 't': - case 'T': - leftFirst = !leftFirst; - glutPostRedisplay(); - break; - case 27: /* Escape key */ - exit(0); - break; - default: - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (200, 200); - glutCreateWindow (argv[0]); - glewInit(); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-blend-sub.c b/progs/trivial/tri-blend-sub.c deleted file mode 100644 index cc1aeaf4a48..00000000000 --- a/progs/trivial/tri-blend-sub.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * ALL RIGHTS RESERVED - * Permission to use, copy, modify, and distribute this software for - * any purpose and without fee is hereby granted, provided that the above - * copyright notice appear in all copies and that both the copyright notice - * and this permission notice appear in supporting documentation, and that - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. - * - * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "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, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE - * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. - * - * US Government Users Restricted Rights - * Use, duplication, or disclosure by the Government is subject to - * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph - * (c)(1)(ii) of the Rights in Technical Data and Computer Software - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -/* - * alpha.c - * This program draws several overlapping filled polygons - * to demonstrate the effect order has on alpha blending results. - * Use the 't' key to toggle the order of drawing polygons. - */ -#include <stdlib.h> -#include <GL/glew.h> -#include <GL/glut.h> - -static int leftFirst = GL_TRUE; - -/* Initialize alpha blending function. - */ -static void init(void) -{ - glBlendEquation (GL_FUNC_SUBTRACT); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glShadeModel (GL_FLAT); - glClearColor (1.0, 0.0, 0.0, 0.0); -} - -static void drawLeftTriangle(void) -{ - /* draw yellow triangle on LHS of screen */ - - glBegin (GL_TRIANGLES); - glColor4f(1.0, 1.0, 0.0, 0.75); - glVertex3f(0.1, 0.9, 0.0); - glVertex3f(0.1, 0.1, 0.0); - glVertex3f(0.7, 0.5, 0.0); - glEnd(); -} - -static void drawRightTriangle(void) -{ - /* draw cyan triangle on RHS of screen */ - - glEnable (GL_BLEND); - glBegin (GL_TRIANGLES); - glColor4f(0.0, 1.0, 1.0, 0.75); - glVertex3f(0.9, 0.9, 0.0); - glVertex3f(0.3, 0.5, 0.0); - glVertex3f(0.9, 0.1, 0.0); - glEnd(); - glDisable (GL_BLEND); -} - -void display(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - if (leftFirst) { - drawLeftTriangle(); - drawRightTriangle(); - } - else { - drawRightTriangle(); - drawLeftTriangle(); - } - - glFlush(); -} - -void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); -} - -/* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 't': - case 'T': - leftFirst = !leftFirst; - glutPostRedisplay(); - break; - case 27: /* Escape key */ - exit(0); - break; - default: - break; - } -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize (200, 200); - glutCreateWindow (argv[0]); - glewInit(); - init(); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-clear.c b/progs/trivial/tri-clear.c deleted file mode 100644 index f49186bd8ae..00000000000 --- a/progs/trivial/tri-clear.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - -GLint Width = 250, Height = 250; - -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)); - fflush(stderr); - - 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); -} - -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,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - - glEnable(GL_SCISSOR_TEST); - glClearColor(1, 0, 1, 0); - glScissor(Width / 2, Height / 2, Width - Width / 2, Height - Height / 2); - glClear(GL_COLOR_BUFFER_BIT); - glDisable(GL_SCISSOR_TEST); - - 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(100, 0); glutInitWindowSize( Width, Height); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-cull-both.c b/progs/trivial/tri-cull-both.c deleted file mode 100644 index 864be710c2a..00000000000 --- a/progs/trivial/tri-cull-both.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - glClearColor(0.0, 0.0, 1.0, 0.0); - glCullFace(GL_FRONT_AND_BACK); - glEnable(GL_CULL_FACE); - -} - -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(.8,0,0); - glVertex3f( 0.93, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.93, 0.0, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.93, -0.8, -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(*argv) == GL_FALSE) { - exit(1); - } - - 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 deleted file mode 100644 index 07443695011..00000000000 --- a/progs/trivial/tri-fbo-tex-mip.c +++ /dev/null @@ -1,261 +0,0 @@ -/* Framebuffer object test */ - - -#include <GL/glew.h> -#include <GL/glut.h> -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -/* For debug */ - - -static int Win = 0; -static int Width = 512, Height = 512; - -static GLenum TexTarget = GL_TEXTURE_2D; -static int TexWidth = 512, TexHeight = 512; - -static GLuint MyFB; -static GLuint TexObj; -static GLboolean Anim = GL_FALSE; -static GLfloat Rot = 0.0; -static GLuint TextureLevel = 4; /* which texture level to render to */ -static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */ - - -static void -CheckError(int line) -{ - GLenum err = glGetError(); - if (err) { - printf("GL Error 0x%x at line %d\n", (int) err, line); - } -} - - -static void -Idle(void) -{ - Rot = glutGet(GLUT_ELAPSED_TIME) * 0.1; - glutPostRedisplay(); -} - - -static void -RenderTexture(void) -{ - GLenum status; - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -15.0); - - if (1) { - /* draw to texture image */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - - status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { - printf("Framebuffer incomplete!!!\n"); - } - - glViewport(0, 0, - TexWidth / (1 << TextureLevel), - TexHeight / (1 << TextureLevel)); - glClearColor(0.5, 0.5, 1.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - CheckError(__LINE__); - - glBegin(GL_POLYGON); - glColor3f(1, 0, 0); - glVertex2f(-1, -1); - glColor3f(0, 1, 0); - glVertex2f(1, -1); - glColor3f(0, 0, 1); - glVertex2f(0, 1); - glEnd(); - - /* Bind normal framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } - else { - } - - CheckError(__LINE__); -} - - - -static void -Display(void) -{ - float ar = (float) Width / (float) Height; - - RenderTexture(); - - /* draw textured quad in the window */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -7.0); - - glViewport(0, 0, Width, Height); - - glClearColor(0.25, 0.25, 0.25, 0); - glClear(GL_COLOR_BUFFER_BIT); - - glPushMatrix(); - glRotatef(Rot, 0, 1, 0); - glEnable(TexTarget); - glBindTexture(TexTarget, TexObj); - - { - glBegin(GL_POLYGON); - glColor3f(0.25, 0.25, 0.25); - glTexCoord2f(0, 0); - glVertex2f(-1, -1); - glTexCoord2f(1, 0); - glVertex2f(1, -1); - glColor3f(1.0, 1.0, 1.0); - glTexCoord2f(1, 1); - glVertex2f(1, 1); - glTexCoord2f(0, 1); - glVertex2f(-1, 1); - glEnd(); - } - - glPopMatrix(); - glDisable(TexTarget); - - glutSwapBuffers(); - CheckError(__LINE__); -} - - -static void -Reshape(int width, int height) -{ - glViewport(0, 0, width, height); - Width = width; - Height = height; -} - - -static void -CleanUp(void) -{ - glDeleteFramebuffersEXT(1, &MyFB); - - glDeleteTextures(1, &TexObj); - - glutDestroyWindow(Win); - - exit(0); -} - - -static void -Key(unsigned char key, int x, int y) -{ - (void) x; - (void) y; - switch (key) { - case 'a': - Anim = !Anim; - if (Anim) - glutIdleFunc(Idle); - else - glutIdleFunc(NULL); - break; - case 's': - Rot += 2.0; - break; - case 27: - CleanUp(); - break; - } - glutPostRedisplay(); -} - - -static void -Init(int argc, char *argv[]) -{ - if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { - printf("GL_EXT_framebuffer_object not found!\n"); - exit(0); - } - - printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); - - - /* Make texture object/image */ - glGenTextures(1, &TexObj); - glBindTexture(TexTarget, TexObj); - glTexParameteri(TexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(TexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(TexTarget, GL_TEXTURE_BASE_LEVEL, TextureLevel); - glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel); - - glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glTexImage2D(TexTarget, TextureLevel, TexIntFormat, - TexWidth / (1 << TextureLevel), TexHeight / (1 << TextureLevel), 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - - - - /* gen framebuffer id, delete it, do some assertions, just for testing */ - glGenFramebuffersEXT(1, &MyFB); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - assert(glIsFramebufferEXT(MyFB)); - - - CheckError(__LINE__); - - /* Render color to texture */ - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - TexTarget, TexObj, TextureLevel); - - - - CheckError(__LINE__); - - /* bind regular framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - - -} - - -int -main(int argc, char *argv[]) -{ - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); - glutInitWindowSize(Width, Height); - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); - Win = glutCreateWindow(argv[0]); - glewInit(); - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Display); - if (Anim) - glutIdleFunc(Idle); - Init(argc, argv); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-fbo-tex.c b/progs/trivial/tri-fbo-tex.c deleted file mode 100644 index 72b4cf3683d..00000000000 --- a/progs/trivial/tri-fbo-tex.c +++ /dev/null @@ -1,260 +0,0 @@ -/* Framebuffer object test */ - - -#include <GL/glew.h> -#include <GL/glut.h> -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -/* For debug */ - - -static int Win = 0; -static int Width = 512, Height = 512; - -static GLenum TexTarget = GL_TEXTURE_2D; -static int TexWidth = 512, TexHeight = 512; - -static GLuint MyFB; -static GLuint TexObj; -static GLboolean Anim = GL_FALSE; -static GLfloat Rot = 0.0; -static GLuint TextureLevel = 0; /* which texture level to render to */ -static GLenum TexIntFormat = GL_RGB; /* either GL_RGB or GL_RGBA */ - - -static void -CheckError(int line) -{ - GLenum err = glGetError(); - if (err) { - printf("GL Error 0x%x at line %d\n", (int) err, line); - } -} - - -static void -Idle(void) -{ - Rot = glutGet(GLUT_ELAPSED_TIME) * 0.1; - glutPostRedisplay(); -} - - -static void -RenderTexture(void) -{ - GLenum status; - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -15.0); - - if (1) { - /* draw to texture image */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - - status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); - if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { - printf("Framebuffer incomplete!!!\n"); - } - - glViewport(0, 0, TexWidth, TexHeight); - - glClearColor(0.5, 0.5, 1.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - CheckError(__LINE__); - - glBegin(GL_POLYGON); - glColor3f(1, 0, 0); - glVertex2f(-1, -1); - glColor3f(0, 1, 0); - glVertex2f(1, -1); - glColor3f(0, 0, 1); - glVertex2f(0, 1); - glEnd(); - - /* Bind normal framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } - else { - } - - CheckError(__LINE__); -} - - - -static void -Display(void) -{ - float ar = (float) Width / (float) Height; - - RenderTexture(); - - /* draw textured quad in the window */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -7.0); - - glViewport(0, 0, Width, Height); - - glClearColor(0.25, 0.25, 0.25, 0); - glClear(GL_COLOR_BUFFER_BIT); - - glPushMatrix(); - glRotatef(Rot, 0, 1, 0); - glEnable(TexTarget); - glBindTexture(TexTarget, TexObj); - - { - glBegin(GL_POLYGON); - glColor3f(0.25, 0.25, 0.25); - glTexCoord2f(0, 0); - glVertex2f(-1, -1); - glTexCoord2f(1, 0); - glVertex2f(1, -1); - glColor3f(1.0, 1.0, 1.0); - glTexCoord2f(1, 1); - glVertex2f(1, 1); - glTexCoord2f(0, 1); - glVertex2f(-1, 1); - glEnd(); - } - - glPopMatrix(); - glDisable(TexTarget); - - glutSwapBuffers(); - CheckError(__LINE__); -} - - -static void -Reshape(int width, int height) -{ - glViewport(0, 0, width, height); - Width = width; - Height = height; -} - - -static void -CleanUp(void) -{ - glDeleteFramebuffersEXT(1, &MyFB); - - glDeleteTextures(1, &TexObj); - - glutDestroyWindow(Win); - - exit(0); -} - - -static void -Key(unsigned char key, int x, int y) -{ - (void) x; - (void) y; - switch (key) { - case 'a': - Anim = !Anim; - if (Anim) - glutIdleFunc(Idle); - else - glutIdleFunc(NULL); - break; - case 's': - Rot += 2.0; - break; - case 27: - CleanUp(); - break; - } - glutPostRedisplay(); -} - - -static void -Init(int argc, char *argv[]) -{ - static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 }; - GLint i; - - if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { - printf("GL_EXT_framebuffer_object not found!\n"); - exit(0); - } - - printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); - - - /* Make texture object/image */ - glGenTextures(1, &TexObj); - glBindTexture(TexTarget, TexObj); - glTexParameteri(TexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(TexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(TexTarget, GL_TEXTURE_BASE_LEVEL, TextureLevel); - glTexParameteri(TexTarget, GL_TEXTURE_MAX_LEVEL, TextureLevel); - - glTexImage2D(TexTarget, 0, TexIntFormat, TexWidth, TexHeight, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - - - - /* gen framebuffer id, delete it, do some assertions, just for testing */ - glGenFramebuffersEXT(1, &MyFB); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - assert(glIsFramebufferEXT(MyFB)); - - - CheckError(__LINE__); - - /* Render color to texture */ - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - TexTarget, TexObj, TextureLevel); - - - - CheckError(__LINE__); - - /* bind regular framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - - -} - - -int -main(int argc, char *argv[]) -{ - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); - glutInitWindowSize(Width, Height); - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); - Win = glutCreateWindow(argv[0]); - glewInit(); - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Display); - if (Anim) - glutIdleFunc(Idle); - Init(argc, argv); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-fbo.c b/progs/trivial/tri-fbo.c deleted file mode 100644 index 1ed177ffdfb..00000000000 --- a/progs/trivial/tri-fbo.c +++ /dev/null @@ -1,203 +0,0 @@ - -#include <assert.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> - -#include <GL/glew.h> -#include <GL/glut.h> - - - -static int Width = 400, Height = 400; -static GLuint MyFB, MyRB; - - -#define CheckError() assert(glGetError() == 0) - -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)); - fflush(stderr); - - - if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { - printf("GL_EXT_framebuffer_object not found!\n"); - exit(0); - } - - - glGenFramebuffersEXT(1, &MyFB); - glGenRenderbuffersEXT(1, &MyRB); - - { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, MyRB); - - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, - GL_RENDERBUFFER_EXT, MyRB); - - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - } - - glClearColor(0.0, 0.0, 1.0, 0.0); -} - - - -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 ); - - Width = width; - Height = height; - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); -} - - -static void Key(unsigned char key, int x, int y) -{ - - switch (key) { - case 27: - exit(1); - default: - return; - } - - glutPostRedisplay(); -} - - - -static void Draw( void ) -{ - - /* draw to user framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); - glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); - glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); - - glClearColor(0.5, 0.5, 1.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - CheckError(); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - - - { - GLubyte *buffer = malloc(Width * Height * 4); - - /* read from user framebuffer */ - glReadPixels(0, 0, Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - CheckError(); - - /* draw to window */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - /* Try to clear the window, but will overwrite: - */ - glClearColor(0.8, 0.8, 0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - glWindowPos2iARB(30, 30); - glDrawPixels(Width-60, Height-60, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - - - free(buffer); - } - - /* Bind normal framebuffer */ - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - - if (1) { - glBegin(GL_TRIANGLES); - glColor3f(0,.7,0); - glVertex3f( 0.5, -0.5, -30.0); - glColor3f(0,0,.8); - glVertex3f( 0.5, 0.5, -30.0); - glColor3f(.9,0,0); - glVertex3f(-0.5, 0.0, -30.0); - glEnd(); - } - - if (doubleBuffer) - glutSwapBuffers(); - else - glFinish(); - - CheckError(); -} - - -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(100, 0); glutInitWindowSize( Width, Height ); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(argv[0]) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-fog.c b/progs/trivial/tri-fog.c deleted file mode 100644 index 0cea3d32582..00000000000 --- a/progs/trivial/tri-fog.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - -GLint Width = 250, Height = 250; - -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)); - fflush(stderr); - - glClearColor(0.0, 0.0, 1.0, 0.0); - - glEnable(GL_FOG); - glFogi(GL_FOG_MODE, GL_LINEAR); - glFogf(GL_FOG_START, 25); - glFogf(GL_FOG_END, 35); -#if 0 - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable (GL_BLEND); -#endif -} - -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); - - glEnable(GL_FOG); - - glBegin(GL_TRIANGLES); - glColor3f(1,1,1); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(1,1,1); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(1,1,1); - glVertex3f(-0.9, 0.0, -40.0); - glEnd(); - -#if 0 - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f( 0.9, 0.0, -30.0); - glEnd(); -#endif - - glDisable(GL_FOG); - - 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(100, 0); glutInitWindowSize(Width, Height); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-fp-const-imm.c b/progs/trivial/tri-fp-const-imm.c deleted file mode 100644 index d2df442abfc..00000000000 --- a/progs/trivial/tri-fp-const-imm.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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> -#include <GL/glew.h> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -GLenum doubleBuffer; - -static void Init(void) -{ - GLint errno; - GLuint prognum; - static const char *prog1 = - "!!ARBfp1.0\n" - "TEMP R1;\n" - "MOV R1, state.material.emission;\n" - "MUL R1, R1, {0.9}.x;\n" - "MOV result.color, R1;\n" - "END\n"; - - - 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); - - /* Setup the fragment program */ - glGenProgramsARB(1, &prognum); - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum); - glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - strlen(prog1), (const GLubyte *)prog1); - - errno = glGetError(); - printf("glGetError = 0x%x\n", errno); - if (errno != GL_NO_ERROR) { - GLint errorpos; - - glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); - printf("errorpos: %d\n", errorpos); - printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", - (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); - } - glEnable(GL_FRAGMENT_PROGRAM_ARB); - - 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); -} - -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,.7); - glTexCoord3f(0,0,.7); - glVertex3f( 0.9, -0.9, -0.0); - glColor3f(.8,0,0); - glTexCoord3f(.8,0,0); - glVertex3f( 0.9, 0.9, -0.0); - glColor3f(0,.9,0); - glTexCoord3f(0,.9,0); - glVertex3f(-0.9, 0.0, -0.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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-fp.c b/progs/trivial/tri-fp.c deleted file mode 100644 index 4d1508120ea..00000000000 --- a/progs/trivial/tri-fp.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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> -#include <GL/glew.h> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -GLenum doubleBuffer; - -static void Init(void) -{ - GLint errno; - GLuint prognum; - static const char *prog1 = - "!!ARBfp1.0\n" - "MOV result.color, fragment.texcoord[1];\n" -// "MOV result.color, fragment.color;\n" - "END\n"; - - - 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); - - /* Setup the fragment program */ - glGenProgramsARB(1, &prognum); - glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum); - glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - strlen(prog1), (const GLubyte *)prog1); - - errno = glGetError(); - printf("glGetError = 0x%x\n", errno); - if (errno != GL_NO_ERROR) { - GLint errorpos; - - glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); - printf("errorpos: %d\n", errorpos); - printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", - (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); - } - glEnable(GL_FRAGMENT_PROGRAM_ARB); - - 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); -} - -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,.7); - glTexCoord3f(0,0,.7); - glVertex3f( 0.9, -0.9, -0.0); - glColor3f(.8,0,0); - glTexCoord3f(.8,0,0); - glVertex3f( 0.9, 0.9, -0.0); - glColor3f(0,.9,0); - glTexCoord3f(0,.9,0); - glVertex3f(-0.9, 0.0, -0.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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-lit.c b/progs/trivial/tri-lit.c deleted file mode 100644 index 15a7ad24c51..00000000000 --- a/progs/trivial/tri-lit.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - 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); -} - -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); - glNormal3f(0,0,.7); - glVertex3f( 0.9, -0.9, -0.0); - glNormal3f(.8,0,0); - glVertex3f( 0.9, 0.9, -0.0); - glNormal3f(0,.9,0); - glVertex3f(-0.9, 0.0, -0.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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-logicop-none.c b/progs/trivial/tri-logicop-none.c deleted file mode 100644 index 53c2614ac32..00000000000 --- a/progs/trivial/tri-logicop-none.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -GLenum doubleBuffer = 1; -int win; - -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); - - glClearColor(0.3, 0.1, 0.3, 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(0); - default: - glutPostRedisplay(); - return; - } -} - -static void Draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glBegin(GL_TRIANGLES); - glColor3f(.8,0,0); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.0, 0.9, -30.0); - glEnd(); - - - glLineWidth(4.0); - - glBegin(GL_LINES); - glColor3f(.1,.7,.1); - glVertex3f( 0.5, -0.5, -30.0); - glVertex3f( 0.5, 0.5, -30.0); - - glColor3f(.1,.1,.8); - glVertex3f( 0.5, 0.5, -30.0); - glVertex3f(-0.5, 0.5, -30.0); - - glColor3f(.5,.1,.1); - glVertex3f(-0.5, 0.5, -30.0); - glVertex3f(-0.5, -0.5, -30.0); - - glColor3f(.8,.8,.8); - glVertex3f(-0.5, -0.5, -30.0); - glVertex3f( 0.5, -0.5, -30.0); - glEnd(); - -// glLineWidth(12.0); - - /* Redraw parts of the lines: - */ - glBegin(GL_LINES); - glColor3f(.1,.7,.1); - glVertex3f( 0.5, -0.2, -30.0); - glVertex3f( 0.5, 0.2, -30.0); - - glColor3f(.1,.1,.8); - glVertex3f( 0.2, 0.5, -30.0); - glVertex3f(-0.2, 0.5, -30.0); - - glColor3f(.5,.1,.1); - glVertex3f(-0.5, 0.2, -30.0); - glVertex3f(-0.5, -0.2, -30.0); - - glColor3f(.8,.8,.8); - glVertex3f(-0.2, -0.5, -30.0); - glVertex3f( 0.2, -0.5, -30.0); - glEnd(); - - - glFlush(); - - if (doubleBuffer) { - glutSwapBuffers(); - } -} - -static GLenum Args(int argc, char **argv) -{ - GLint i; - - 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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - win = glutCreateWindow(*argv); - if (!win) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-logicop-xor.c b/progs/trivial/tri-logicop-xor.c deleted file mode 100644 index f018a851ace..00000000000 --- a/progs/trivial/tri-logicop-xor.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -GLenum doubleBuffer = 1; -int win; - -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); - - glClearColor(0.3, 0.1, 0.3, 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(0); - default: - glutPostRedisplay(); - return; - } -} - -static void Draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glBegin(GL_TRIANGLES); - glColor3f(.8,0,0); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.0, 0.9, -30.0); - glEnd(); - - - glLineWidth(4.0); - - glEnable(GL_BLEND); - glEnable(GL_COLOR_LOGIC_OP); - glLogicOp(GL_XOR); - - glBegin(GL_LINES); - glColor3f(.1,.7,.1); - glVertex3f( 0.5, -0.5, -30.0); - glVertex3f( 0.5, 0.5, -30.0); - - glColor3f(.1,.1,.8); - glVertex3f( 0.5, 0.5, -30.0); - glVertex3f(-0.5, 0.5, -30.0); - - glColor3f(.5,.1,.1); - glVertex3f(-0.5, 0.5, -30.0); - glVertex3f(-0.5, -0.5, -30.0); - - glColor3f(.8,.8,.8); - glVertex3f(-0.5, -0.5, -30.0); - glVertex3f( 0.5, -0.5, -30.0); - glEnd(); - -// glLineWidth(12.0); - - /* Redraw parts of the lines to remove them: - */ - glBegin(GL_LINES); - glColor3f(.1,.7,.1); - glVertex3f( 0.5, -0.2, -30.0); - glVertex3f( 0.5, 0.2, -30.0); - - glColor3f(.1,.1,.8); - glVertex3f( 0.2, 0.5, -30.0); - glVertex3f(-0.2, 0.5, -30.0); - - glColor3f(.5,.1,.1); - glVertex3f(-0.5, 0.2, -30.0); - glVertex3f(-0.5, -0.2, -30.0); - - glColor3f(.8,.8,.8); - glVertex3f(-0.2, -0.5, -30.0); - glVertex3f( 0.2, -0.5, -30.0); - glEnd(); - - - - glDisable(GL_COLOR_LOGIC_OP); - glDisable(GL_BLEND); - - glFlush(); - - if (doubleBuffer) { - glutSwapBuffers(); - } -} - -static GLenum Args(int argc, char **argv) -{ - GLint i; - - 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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - win = glutCreateWindow(*argv); - if (!win) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-mask-tri.c b/progs/trivial/tri-mask-tri.c deleted file mode 100644 index d62620905dd..00000000000 --- a/progs/trivial/tri-mask-tri.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -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)); - fflush(stderr); - 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); -} - -static void Key(unsigned char key, int x, int y) -{ - 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); - - /* right triangle: green */ - glBegin(GL_TRIANGLES); - glColor3f(0,1,0); - glVertex3f( 0.9, -0.9, -30.0); - glVertex3f( 0.9, 0.9, -30.0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - - glColorMask(Rmask, Gmask, Bmask, 0); - - /* left triangle: white&mask: purple middle region: white */ - glBegin(GL_TRIANGLES); - glColor3f(1,1,1); - glVertex3f(-0.9, -0.9, -30.0); - glVertex3f(-0.9, 0.9, -30.0); - glVertex3f( 0.9, 0.0, -30.0); - glEnd(); - - glDisable(GL_SCISSOR_TEST); - - 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); - } - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - - glutInitWindowPosition(100, 0); glutInitWindowSize(Width, Height); - glutInitDisplayMode(type); - Win = glutCreateWindow(*argv); - Init(); - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-multitex-vbo.c b/progs/trivial/tri-multitex-vbo.c deleted file mode 100644 index e319447ac15..00000000000 --- a/progs/trivial/tri-multitex-vbo.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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> -#include <GL/glew.h> -#include <GL/glut.h> - -#define NR_VERTS 4 - -struct { - GLfloat position[NR_VERTS][4]; - GLubyte color[NR_VERTS][4]; - GLfloat tex0[NR_VERTS][2]; - GLfloat tex1[NR_VERTS][2]; -} verts = { - - { { 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 } }, - - { { 0x00, 0x00, 0xff, 0x00 }, - { 0x00, 0xff, 0x00, 0x00 }, - { 0xff, 0x00, 0x00, 0x00 }, - { 0xff, 0xff, 0xff, 0x00 } - }, - - { { 1, -1 }, - { 1, 1 }, - { -1, 1 }, - { -1, -1 } }, - - { { 3, 0 }, - { 0, 3 }, - { -3, 0 }, - { 0, -3} }, - -}; - -GLuint indices[] = { 0, 1, 2, 3 }; - -GLuint arrayObj, elementObj; - - -GLenum doubleBuffer; - - -#define Offset(ptr, member) (void *)((const char *)&((ptr)->member) - (const char *)(ptr)) - -static void Init(void) -{ - GLuint texObj[2]; - - 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); - - glClearColor(0.0, 0.0, 1.0, 0.0); - - glGenTextures(2, texObj); - -#define SIZE 32 - { - GLubyte tex2d[SIZE][SIZE][3]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { - tex2d[t][s][0] = s*255/(SIZE-1); - tex2d[t][s][1] = t*255/(SIZE-1); - tex2d[t][s][2] = 0; - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glActiveTextureARB(GL_TEXTURE0_ARB); - glBindTexture(GL_TEXTURE_2D, texObj[0]); - - - glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); - - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - } - - { - GLubyte tex2d[SIZE][SIZE][3]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { - GLboolean on = ((s/4) ^ (t/4)) & 1; - tex2d[t][s][0] = on ? 128 : 0; - tex2d[t][s][1] = on ? 128 : 0; - tex2d[t][s][2] = on ? 128 : 0; - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glActiveTextureARB(GL_TEXTURE1_ARB); - glBindTexture(GL_TEXTURE_2D, texObj[1]); - - glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); - - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - } - - glActiveTextureARB( GL_TEXTURE0_ARB ); - - - { - - glGenBuffersARB(1, &arrayObj); - glGenBuffersARB(1, &elementObj); - - glBindBufferARB(GL_ARRAY_BUFFER_ARB, arrayObj); - glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, elementObj); - - glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), &verts, GL_STATIC_DRAW_ARB); - glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(indices), indices, GL_STATIC_DRAW_ARB); - - glEnableClientState( GL_VERTEX_ARRAY ); - glVertexPointer( 4, GL_FLOAT, 0, Offset(&verts, position) ); - - glEnableClientState( GL_COLOR_ARRAY ); - glColorPointer( 4, GL_UNSIGNED_BYTE, 0, Offset(&verts, color) ); - - glClientActiveTextureARB( GL_TEXTURE0_ARB ); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer( 2, GL_FLOAT, 0, Offset(&verts, tex0) ); - - glClientActiveTextureARB( GL_TEXTURE1_ARB ); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - glTexCoordPointer( 2, GL_FLOAT, 0, Offset(&verts, tex1) ); - - glClientActiveTextureARB( GL_TEXTURE0_ARB ); - } -} - -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); - - glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL ); - - 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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-orig.c b/progs/trivial/tri-orig.c deleted file mode 100644 index e7cfee3a367..00000000000 --- a/progs/trivial/tri-orig.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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,.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(); - - 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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-query.c b/progs/trivial/tri-query.c deleted file mode 100644 index 85e39df2dfa..00000000000 --- a/progs/trivial/tri-query.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * 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> -#include <GL/glew.h> -#include <GL/glut.h> - - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - -static GLuint OccQuery; - -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)); - fflush(stderr); - - glClearColor(0.0, 0.0, 1.0, 0.0); - - glGenQueriesARB(1, &OccQuery); -} - -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) -{ - GLuint passed; - GLint ready; - - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); - - glEnable(GL_DEPTH_TEST); - - glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - - glEndQueryARB(GL_SAMPLES_PASSED_ARB); - - do { - /* do useful work here, if any */ - glGetQueryObjectivARB(OccQuery, GL_QUERY_RESULT_AVAILABLE_ARB, &ready); - } while (!ready); - glGetQueryObjectuivARB(OccQuery, GL_QUERY_RESULT_ARB, &passed); - - fprintf(stderr, " %d Fragments Visible\n", passed); - - 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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB | GLUT_DEPTH; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-repeat.c b/progs/trivial/tri-repeat.c deleted file mode 100644 index 91e355c71f3..00000000000 --- a/progs/trivial/tri-repeat.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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> -#include <math.h> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -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); - - glClearColor(0.3, 0.1, 0.3, 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(0); - default: - glutPostRedisplay(); - return; - } -} - -static void Draw(void) -{ - static float f = 0; - f += .1; - glClear(GL_COLOR_BUFFER_BIT); - - glBegin(GL_TRIANGLES); - glColor3f((sin(f)+1)/2.0,0,0); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(0,(cos(f)+1)/2.0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(0,0,.7); - glVertex3f( 0.0, 0.9, -30.0); - glEnd(); - - glutSwapBuffers(); - glutPostRedisplay(); -} - -static GLenum Args(int argc, char **argv) -{ - 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 | GLUT_ALPHA; - type |= GLUT_DOUBLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(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 deleted file mode 100644 index 608ebf29cff..00000000000 --- a/progs/trivial/tri-scissor-tri.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - -GLint Width = 250, Height = 250; - -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)); - fflush(stderr); - - 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); -} - -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,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - - glScissor(Width / 4, Height / 4, Width / 2, Height / 2); - glEnable(GL_SCISSOR_TEST); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f( 0.9, 0.0, -30.0); - glEnd(); - - glDisable(GL_SCISSOR_TEST); - - 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(100, 0); glutInitWindowSize(Width, Height); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-square.c b/progs/trivial/tri-square.c deleted file mode 100644 index 0b82a1dd8e3..00000000000 --- a/progs/trivial/tri-square.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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(); - gluOrtho2D(0, (GLdouble)width, 0, (GLdouble)height); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -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); - - glColor3f(1,1,1); - - glBegin(GL_TRIANGLES); - glVertex3f( 10, 10, -30.0); - glVertex3f( 200, 150, -30.0); - glVertex3f( 10, 200, -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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-stencil.c b/progs/trivial/tri-stencil.c deleted file mode 100644 index 9f68bca9149..00000000000 --- a/progs/trivial/tri-stencil.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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 <stdlib.h> -#include <string.h> -#include <math.h> -#include <GL/glut.h> - - -static void Init(void) -{ -} - -static void Reshape(int width, int height) -{ - - glViewport(0, 0, (GLint)width, (GLint)height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); - glMatrixMode(GL_MODELVIEW); -} - -static void Key(unsigned char key, int x, int y) -{ - - switch (key) { - case 27: - printf("Exiting...\n"); - exit(1); - case 'r': - printf("Redisplaying...\n"); - glutPostRedisplay(); - break; - default: - printf("No such key '%c'...\n", key); - break; - } -} - -static void Draw(void) -{ - glShadeModel(GL_FLAT); - - { - glClearColor(0.0, 0.0, 0.0, 0.0); - glClearStencil(0); - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); - } - - - glStencilMask(1); - glEnable(GL_STENCIL_TEST); - glStencilFunc(GL_ALWAYS, 1, 1); - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - - glColor3ub(200, 0, 0); - glBegin(GL_POLYGON); - glVertex3i(-4, -4, 0); - glVertex3i( 4, -4, 0); - glVertex3i( 0, 4, 0); - glEnd(); - -#if 1 - glStencilFunc(GL_EQUAL, 1, 1); - glStencilOp(GL_INCR, GL_KEEP, GL_DECR); - - glColor3ub(0, 200, 0); - glBegin(GL_POLYGON); - glVertex3i(3, 3, 0); - glVertex3i(-3, 3, 0); - glVertex3i(-3, -3, 0); - glVertex3i(3, -3, 0); - glEnd(); -#endif - -#if 1 - glStencilFunc(GL_EQUAL, 1, 1); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - - glColor3ub(0, 0, 200); - glBegin(GL_POLYGON); - glVertex3f(2.5, 2.5, 0); - glVertex3f(-2.5, 2.5, 0); - glVertex3f(-2.5, -2.5, 0); - glVertex3f(2.5, -2.5, 0); - glEnd(); -#endif - - glFlush(); -} - -static GLenum Args(int argc, char **argv) -{ - GLint i; - - - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-dr") == 0) { - } else { - printf("%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( 300, 300); - - type = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH | GLUT_STENCIL; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-stipple.c b/progs/trivial/tri-stipple.c deleted file mode 100644 index aa94fa224b7..00000000000 --- a/progs/trivial/tri-stipple.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - -static GLubyte fly[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x03, 0x80, 0x01, 0xC0, 0x06, 0xC0, 0x03, 0x60, 0x04, 0x60, 0x06, 0x20, -0x04, 0x30, 0x0C, 0x20, 0x04, 0x18, 0x18, 0x20, 0x04, 0x0C, 0x30, 0x20, -0x04, 0x06, 0x60, 0x20, 0x44, 0x03, 0xC0, 0x22, 0x44, 0x01, 0x80, 0x22, -0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, -0x44, 0x01, 0x80, 0x22, 0x44, 0x01, 0x80, 0x22, 0x66, 0x01, 0x80, 0x66, -0x33, 0x01, 0x80, 0xCC, 0x19, 0x81, 0x81, 0x98, 0x0C, 0xC1, 0x83, 0x30, -0x07, 0xe1, 0x87, 0xe0, 0x03, 0x3f, 0xfc, 0xc0, 0x03, 0x31, 0x8c, 0xc0, -0x03, 0x33, 0xcc, 0xc0, 0x06, 0x64, 0x26, 0x60, 0x0c, 0xcc, 0x33, 0x30, -0x18, 0xcc, 0x33, 0x18, 0x10, 0xc4, 0x23, 0x08, 0x10, 0x63, 0xC6, 0x08, -0x10, 0x30, 0x0c, 0x08, 0x10, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x08}; - - -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)); - fflush(stderr); - - glEnable (GL_POLYGON_STIPPLE); - glPolygonStipple (fly); - - 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); -} - -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,.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(); - - 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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-tex.c b/progs/trivial/tri-tex.c deleted file mode 100644 index 56afb4748d7..00000000000 --- a/progs/trivial/tri-tex.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - - -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)); - fflush(stderr); - - glClearColor(0.0, 0.0, 1.0, 0.0); - - -#define SIZE 32 - { - GLubyte tex2d[SIZE][SIZE][3]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { -#if 0 - tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; - tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; - tex2d[t][s][2] = 0; -#else - tex2d[t][s][0] = s*255/(SIZE-1); - tex2d[t][s][1] = t*255/(SIZE-1); - tex2d[t][s][2] = 0; -#endif - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); - - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - } - -} - -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); - glTexCoord2f(1,-1); - glVertex3f( 0.9, -0.9, -0.0); - glTexCoord2f(1,1); - glVertex3f( 0.9, 0.9, -0.0); - glTexCoord2f(-1,0); - glVertex3f(-0.9, 0.0, -0.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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-tri.c b/progs/trivial/tri-tri.c deleted file mode 100644 index f996bd01a16..00000000000 --- a/progs/trivial/tri-tri.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,.9,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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-unfilled-edgeflag.c b/progs/trivial/tri-unfilled-edgeflag.c deleted file mode 100644 index 11c21d1bf68..00000000000 --- a/progs/trivial/tri-unfilled-edgeflag.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - glPolygonMode(GL_FRONT, GL_LINE); - glPolygonMode(GL_BACK, GL_LINE); - - glBegin(GL_TRIANGLES); - glEdgeFlag(1); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -0.0); - glEdgeFlag(0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -0.0); - glEdgeFlag(1); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -0.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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-unfilled-fog.c b/progs/trivial/tri-unfilled-fog.c deleted file mode 100644 index c6ecc705b37..00000000000 --- a/progs/trivial/tri-unfilled-fog.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - -GLint Width = 250, Height = 250; - -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)); - fflush(stderr); - - 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); -} - -static void Key(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(1); - } - - glutPostRedisplay(); -} - -static void Draw(void) -{ - glClear(GL_COLOR_BUFFER_BIT); - - glEnable(GL_FOG); - - glPolygonMode(GL_FRONT, GL_FILL); - glPolygonMode(GL_BACK, GL_FILL); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.7, -0.7, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.7, 0.7, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.7, 0.0, -30.0); - glEnd(); - - glPolygonMode(GL_FRONT, GL_LINE); - glPolygonMode(GL_BACK, GL_LINE); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -30.0); - glEnd(); - - glDisable(GL_FOG); - - 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(100, 0); glutInitWindowSize(Width, Height); - - type = GLUT_RGB; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-unfilled-point.c b/progs/trivial/tri-unfilled-point.c deleted file mode 100644 index 750a254669a..00000000000 --- a/progs/trivial/tri-unfilled-point.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - glPolygonMode(GL_FRONT, GL_POINT); - glPolygonMode(GL_BACK, GL_POINT); - - 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(); - - 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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-unfilled-tri-lit.c b/progs/trivial/tri-unfilled-tri-lit.c deleted file mode 100644 index 1d42b40b713..00000000000 --- a/progs/trivial/tri-unfilled-tri-lit.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - - 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); -} - -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); - - glPolygonMode(GL_FRONT, GL_LINE); - glPolygonMode(GL_BACK, GL_LINE); - - glBegin(GL_TRIANGLES); - glNormal3f(0,0,.7); - glVertex3f( 0.9, -0.9, -0.0); - glNormal3f(.8,0,0); - glVertex3f( 0.9, 0.9, -0.0); - glNormal3f(0,.9,0); - glVertex3f(-0.9, 0.0, -0.0); - glEnd(); - - glPolygonMode(GL_FRONT, GL_FILL); - glPolygonMode(GL_BACK, GL_FILL); - - glBegin(GL_TRIANGLES); - glNormal3f(0,0,.7); - glVertex3f( 0.8, -0.8, -0.0); - glNormal3f(.8,0,0); - glVertex3f( 0.8, 0.8, -0.0); - glNormal3f(0,.9,0); - glVertex3f(-0.8, 0.0, -0.0); - glEnd(); - - glPolygonMode(GL_FRONT, GL_LINE); - glPolygonMode(GL_BACK, GL_LINE); - - glBegin(GL_TRIANGLES); - glNormal3f(.8,0,0); - glVertex3f( -0.9, 0.9, -0.0); - glNormal3f(0,0,.7); - glVertex3f( -0.9, -0.9, -0.0); - glNormal3f(0,.9,0); - glVertex3f( 0.9, 0.0, -0.0); - glEnd(); - - glPolygonMode(GL_FRONT, GL_FILL); - glPolygonMode(GL_BACK, GL_FILL); - - glBegin(GL_TRIANGLES); - glNormal3f(.8,0,0); - glVertex3f( -0.8, 0.8, -0.0); - glNormal3f(0,0,.7); - glVertex3f( -0.8, -0.8, -0.0); - glNormal3f(0,.9,0); - glVertex3f( 0.8, 0.0, -0.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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-unfilled-tri.c b/progs/trivial/tri-unfilled-tri.c deleted file mode 100644 index 695cc890955..00000000000 --- a/progs/trivial/tri-unfilled-tri.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glPolygonMode(GL_FRONT, GL_LINE); - glPolygonMode(GL_BACK, GL_LINE); - - 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(); - - glPolygonMode(GL_FRONT, GL_FILL); - glPolygonMode(GL_BACK, GL_FILL); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.8, -0.8, -0.0); - glColor3f(.8,0,0); - glVertex3f( 0.8, 0.8, -0.0); - glColor3f(0,.9,0); - glVertex3f(-0.8, 0.0, -0.0); - glEnd(); - - glPolygonMode(GL_FRONT, GL_LINE); - glPolygonMode(GL_BACK, GL_LINE); - - glBegin(GL_TRIANGLES); - glColor3f(.8,0,0); - glVertex3f( -0.9, 0.9, -0.0); - glColor3f(0,0,.7); - glVertex3f( -0.9, -0.9, -0.0); - glColor3f(0,.9,0); - glVertex3f( 0.9, 0.0, -0.0); - glEnd(); - - glPolygonMode(GL_FRONT, GL_FILL); - glPolygonMode(GL_BACK, GL_FILL); - - glBegin(GL_TRIANGLES); - glColor3f(.8,0,0); - glVertex3f( -0.8, 0.8, -0.0); - glColor3f(0,0,.7); - glVertex3f( -0.8, -0.8, -0.0); - glColor3f(0,.9,0); - glVertex3f( 0.8, 0.0, -0.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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-unfilled-userclip-stip.c b/progs/trivial/tri-unfilled-userclip-stip.c deleted file mode 100644 index ddc0dffd4f4..00000000000 --- a/progs/trivial/tri-unfilled-userclip-stip.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -GLenum doubleBuffer; - -static void Init(void) -{ - static GLdouble plane[4] = { -.5, 0, 1, 0 }; - - 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); - - glClearColor(0.0, 0.0, 1.0, 0.0); - glClipPlane(GL_CLIP_PLANE0, plane); - glEnable(GL_CLIP_PLANE0); - glLineWidth( 4 ); -} - -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); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - - glEnable(GL_LINE_STIPPLE); - glLineStipple( 5, 0xfffe ); - - - - 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(); - - 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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-viewport.c b/progs/trivial/tri-viewport.c deleted file mode 100644 index 3e52449b470..00000000000 --- a/progs/trivial/tri-viewport.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - * 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> -#include <GL/glut.h> - -GLenum doubleBuffer = 1; -int win; -static float tx = 0; -static float ty = 0; -static float tw = 0; -static float th = 0; -static float z = -5; - - -static float win_width = 250; -static float win_height = 250; -static enum { - ORTHO, - FRUSTUM, - MODE_MAX -} mode = ORTHO; - -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); - - glClearColor(0, 0, 0, 0.0); -} - -static void Reshape(int width, int height) -{ - win_width = width; - win_height = height; - glutPostRedisplay(); -} - - -static void Key(unsigned char key, int x, int y) -{ - switch (key) { - case 27: - exit(0); - case 'w': - tw += 1.0; - break; - case 'W': - tw -= 1.0; - break; - case 'h': - th += 1.0; - break; - case 'H': - th -= 1.0; - break; - - case 'z': - z += 1.0; - break; - case 'Z': - z -= 1.0; - break; - case 'm': - mode++; - mode %= MODE_MAX; - break; - case ' ': - tw = th = tx = ty = 0; - z = -5; - mode = ORTHO; - break; - default: - break; - } - glutPostRedisplay(); -} - - -static void Draw(void) -{ - int i; - float w = tw + win_width; - float h = th + win_height; - - fprintf(stderr, "glViewport(%f %f %f %f)\n", tx, ty, w, h); - fprintf(stderr, "mode: %s\n", mode == FRUSTUM ? "FRUSTUM" : "ORTHO"); - fprintf(stderr, "z: %f\n", z); - fflush(stderr); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - switch (mode) { - case FRUSTUM: - glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); - break; - case ORTHO: - default: - glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); - break; - } - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - - glClear(GL_COLOR_BUFFER_BIT); - - - /*********************************************************************** - * Should be clipped to be no larger than the triangles: - */ - glViewport(tx, ty, w, h); - - glBegin(GL_POLYGON); - glColor3f(1,1,0); - glVertex3f(-100, -100, z); - glVertex3f(-100, 100, z); - glVertex3f(100, 100, z); - glVertex3f(100, -100, z); - glEnd(); - - glBegin(GL_POLYGON); - glColor3f(0,1,1); - glVertex3f(-10, -10, z); - glVertex3f(-10, 10, z); - glVertex3f(10, 10, z); - glVertex3f(10, -10, z); - glEnd(); - - glBegin(GL_POLYGON); - glColor3f(1,0,0); - glVertex3f(-2, -2, z); - glVertex3f(-2, 2, z); - glVertex3f(2, 2, z); - glVertex3f(2, -2, z); - glEnd(); - - - glBegin(GL_POLYGON); - glColor3f(.5,.5,1); - glVertex3f(-1, -1, z); - glVertex3f(-1, 1, z); - glVertex3f(1, 1, z); - glVertex3f(1, -1, z); - glEnd(); - - /*********************************************************************** - */ - glViewport(0, 0, win_width, win_height); - glBegin(GL_LINES); - glColor3f(1,1,0); - glVertex3f(-1, 0, z); - glVertex3f(1, 0, z); - - glVertex3f(0, -1, z); - glVertex3f(0, 1, z); - glEnd(); - - - /*********************************************************************** - */ - glViewport(tx, ty, w, h); - glBegin(GL_TRIANGLES); - glColor3f(1,0,0); - glVertex3f(-1, -1, z); - glVertex3f(0, -1, z); - glVertex3f(-.5, -.5, z); - - glColor3f(1,1,1); - glVertex3f(0, -1, z); - glVertex3f(1, -1, z); - glVertex3f(.5, -.5, z); - - glVertex3f(-.5, -.5, z); - glVertex3f(.5, -.5, z); - glVertex3f(0, 0, z); - - - glColor3f(0,1,0); - glVertex3f(1, 1, z); - glVertex3f(0, 1, z); - glVertex3f(.5, .5, z); - - glColor3f(1,1,1); - glVertex3f(0, 1, z); - glVertex3f(-1, 1, z); - glVertex3f(-.5, .5, z); - - glVertex3f(.5, .5, z); - glVertex3f(-.5, .5, z); - glVertex3f( 0, 0, z); - - glEnd(); - - - glViewport(0, 0, win_width, win_height); - - glBegin(GL_LINES); - glColor3f(.5,.5,0); - for (i = -10; i < 10; i++) { - float f = i / 10.0; - - if (i == 0) - continue; - - glVertex3f(-1, f, z); - glVertex3f(1, f, z); - - glVertex3f(f, -1, z); - glVertex3f(f, 1, z); - } - glEnd(); - - - - glFlush(); - - if (doubleBuffer) { - glutSwapBuffers(); - } -} - -static GLenum Args(int argc, char **argv) -{ - GLint i; - - if (getenv("VPX")) - tx = atof(getenv("VPX")); - - if (getenv("VPY")) - ty = atof(getenv("VPY")); - - - 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; -} - - -static void -special(int k, int x, int y) -{ - switch (k) { - case GLUT_KEY_UP: - ty += 1.0; - break; - case GLUT_KEY_DOWN: - ty -= 1.0; - break; - case GLUT_KEY_LEFT: - tx -= 1.0; - break; - case GLUT_KEY_RIGHT: - tx += 1.0; - break; - default: - break; - } - glutPostRedisplay(); -} - - -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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - win = glutCreateWindow(*argv); - if (!win) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutSpecialFunc(special); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-z-9.c b/progs/trivial/tri-z-9.c deleted file mode 100644 index 099e89f6f4a..00000000000 --- a/progs/trivial/tri-z-9.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - -} - -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, -1); - 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) -{ - glClearColor(0.0, 0.0, 1.0, 0.0); - glClearDepth(1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glDepthFunc(GL_EQUAL); - glEnable(GL_DEPTH_TEST); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, .5); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, .5); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, .5); - 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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB | GLUT_DEPTH; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-z-eq.c b/progs/trivial/tri-z-eq.c deleted file mode 100644 index b81c992f7d1..00000000000 --- a/progs/trivial/tri-z-eq.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - -} - -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, -1); - 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) -{ - glClearColor(0.0, 0.0, 1.0, 0.0); - glClearDepth(1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glDepthFunc(GL_EQUAL); - glEnable(GL_DEPTH_TEST); - - glBegin(GL_TRIANGLES); - glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, 1.0); - glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, 1.0); - glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, 1.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(100, 0); glutInitWindowSize( 250, 250); - - type = GLUT_RGB | GLUT_DEPTH; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tri-z.c b/progs/trivial/tri-z.c deleted file mode 100644 index 014aaa071a5..00000000000 --- a/progs/trivial/tri-z.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 1993-1997, Silicon Graphics, Inc. - * ALL RIGHTS RESERVED - * Permission to use, copy, modify, and distribute this software for - * any purpose and without fee is hereby granted, provided that the above - * copyright notice appear in all copies and that both the copyright notice - * and this permission notice appear in supporting documentation, and that - * the name of Silicon Graphics, Inc. not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. - * - * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "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, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, - * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY - * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, - * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF - * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN - * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE - * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. - * - * US Government Users Restricted Rights - * Use, duplication, or disclosure by the Government is subject to - * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph - * (c)(1)(ii) of the Rights in Technical Data and Computer Software - * clause at DFARS 252.227-7013 and/or in similar or successor - * clauses in the FAR or the DOD or NASA FAR Supplement. - * Unpublished-- rights reserved under the copyright laws of the - * United States. Contractor/manufacturer is Silicon Graphics, - * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. - * - * OpenGL(R) is a registered trademark of Silicon Graphics, Inc. - */ - -#include <GL/glut.h> -#include <stdlib.h> -#include <stdio.h> - -static int leftFirst = GL_TRUE; - -static struct { GLenum func; const char *str; } funcs[] = - { - { GL_LESS, "GL_LESS" }, - { GL_LEQUAL, "GL_LEQUAL" }, - { GL_GREATER, "GL_GREATER" }, - { GL_GEQUAL, "GL_GEQUAL" }, - { GL_EQUAL, "GL_EQUAL" }, - { GL_NOTEQUAL, "GL_NOTEQUAL" }, - { GL_ALWAYS, "GL_ALWAYS" }, - { GL_NEVER, "GL_NEVER" }, - }; - -#define NUM_FUNCS (sizeof(funcs) / sizeof(funcs[0])) - -static int curFunc = 0; -static double clearVal = 1.0; -static float minZ = 0.0; -static float maxZ = 1.0; - -static void usage(void) -{ - printf("t - toggle rendering order of triangles\n"); - printf("c - toggle Z clear value between 0, 1\n"); - printf("f - cycle through depth test functions\n"); - printf("n/N - decrease/increase depthrange minZ\n"); - printf("x/X - decrease/increase depthrange maxZ\n"); - printf("spc - reset\n"); - printf("z - set to reverse-direction (ztrick) mode\n"); - fflush(stdout); -} - - -static void init(void) -{ - glEnable(GL_DEPTH_TEST); - glClearColor (1.0, 0.0, 0.0, 0.0); -} - -static void drawLeftTriangle(void) -{ - /* draw yellow triangle on LHS of screen */ - glBegin (GL_TRIANGLES); - glColor4f(1.0, 1.0, 0.0, 0.75); - glVertex3f(0.1, 0.9, -1.0); - glVertex3f(0.1, 0.1, -1.0); - glVertex3f(0.8, 0.5, 1.0); - glEnd(); -} - -static void drawRightTriangle(void) -{ - /* draw cyan triangle on RHS of screen */ - glBegin (GL_TRIANGLES); - glColor4f(0.0, 1.0, 1.0, 0.75); - glVertex3f(0.9, 0.9, 0.0); - glVertex3f(0.2, 0.5, 0.0); - glVertex3f(0.9, 0.1, 0.0); - glEnd(); -} - -void display(void) -{ - printf("GL_CLEAR_DEPTH = %.2f, GL_DEPTH_FUNC = %s, DepthRange(%.1f, %.1f)\n", - clearVal, funcs[curFunc].str, minZ, maxZ); - fflush(stdout); - glClearDepth(clearVal); - glDepthRange(minZ, maxZ); - glDepthFunc(funcs[curFunc].func); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if (leftFirst) { - drawLeftTriangle(); - drawRightTriangle(); - } - else { - drawRightTriangle(); - drawLeftTriangle(); - } - - glFlush(); -} - -void reshape(int w, int h) -{ - glViewport(0, 0, (GLsizei) w, (GLsizei) h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (w <= h) - gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w); - else - gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0); -} - -/* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) -{ - switch (key) { - case 'n': - minZ -= .1; - break; - case 'N': - minZ += .1; - break; - case 'x': - maxZ -= .1; - break; - case 'X': - maxZ += .1; - break; - case 'c': - case 'C': - clearVal = 1.0 - clearVal; - break; - case 'f': - case 'F': - curFunc = (curFunc + 1) % NUM_FUNCS; - break; - case 't': - case 'T': - leftFirst = !leftFirst; - break; - case ' ': - curFunc = 0; - clearVal = 1.0; - minZ = 0.0; - maxZ = 1.0; - break; - case 'z': - curFunc = 2; - clearVal = 0.0; - minZ = 1.0; - maxZ = 0.0; - break; - case 27: /* Escape key */ - exit(0); - break; - default: - return; - } - glutPostRedisplay(); -} - -/* Main Loop - * Open window with initial window size, title bar, - * RGBA display mode, and handle input events. - */ -int main(int argc, char** argv) -{ - glutInit(&argc, argv); - glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowSize (200, 200); - glutCreateWindow (argv[0]); - glutReshapeFunc (reshape); - glutKeyboardFunc (keyboard); - glutDisplayFunc (display); - init(); - usage(); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/trifan-flat-clip.c b/progs/trivial/trifan-flat-clip.c deleted file mode 100644 index 199f91a637e..00000000000 --- a/progs/trivial/trifan-flat-clip.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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_TRIANGLE_FAN); - glColor3f(1,0,0); - glVertex3f( 0, 0, -30.0); - glColor3f(1,1,0); - glVertex3f( 1.3, 1.1, -30.0); - glColor3f(1,0,1); - glVertex3f(-.9, .9, -30.0); - glColor3f(0,1,1); - glVertex3f(-1.1, -1.3, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/trifan-flat-unfilled-clip.c b/progs/trivial/trifan-flat-unfilled-clip.c deleted file mode 100644 index ea3e1553872..00000000000 --- a/progs/trivial/trifan-flat-unfilled-clip.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - glPolygonMode(GL_FRONT, GL_LINE); - glPolygonMode(GL_BACK, GL_LINE); - glLineWidth(4.0); - - - glBegin(GL_TRIANGLE_FAN); - glColor3f(1,0,0); - glVertex3f( 0, 0, -30.0); - glColor3f(1,1,0); - glVertex3f( 1.3, 1.1, -30.0); - glColor3f(1,0,1); - glVertex3f(-.9, .9, -30.0); - glColor3f(0,1,1); - glVertex3f(-1.1, -1.3, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/trifan-flat.c b/progs/trivial/trifan-flat.c deleted file mode 100644 index d69b4887e39..00000000000 --- a/progs/trivial/trifan-flat.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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_TRIANGLE_FAN); - glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(1,0,1); - glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,1,1); - glVertex3f(-0.9, -0.9, -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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/trifan-unfilled.c b/progs/trivial/trifan-unfilled.c deleted file mode 100644 index 91447e4e44d..00000000000 --- a/progs/trivial/trifan-unfilled.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - - glBegin(GL_TRIANGLE_FAN); - glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(1,0,1); - glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,1,1); - glVertex3f(-0.9, -0.9, -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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/trifan.c b/progs/trivial/trifan.c deleted file mode 100644 index 84eb4172de1..00000000000 --- a/progs/trivial/trifan.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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_TRIANGLE_FAN); - glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(1,0,1); - glVertex3f(-0.9, 0.9, -30.0); - glColor3f(0,1,1); - glVertex3f(-0.9, -0.9, -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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/tristrip-flat.c b/progs/trivial/tristrip-flat.c deleted file mode 100644 index 02da97efcea..00000000000 --- a/progs/trivial/tristrip-flat.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * 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> -#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)); - fflush(stderr); - - 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); -} - -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); - - if (0) { - glBegin(GL_LINES); - glColor3f(1,0,0); - glVertex3f( 0.95, -0.9, -30.0); - glColor3f(1,1,0); - glVertex3f( 0.95, 0.9, -30.0); - glEnd(); - } - - glBegin(GL_TRIANGLE_STRIP); - glColor3f(1,0,0); - glVertex3f( 0.9, -0.9, -30.0); - glColor3f(0,1,0); - glVertex3f( 0.9, 0.9, -30.0); - glColor3f(0,0,.5); - glVertex3f(-0.9, -0.9, -30.0); - glColor3f(1,1,1); - glVertex3f(-0.9, 0.9, -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(*argv) == GL_FALSE) { - exit(1); - } - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/vbo-noninterleaved.c b/progs/trivial/vbo-noninterleaved.c deleted file mode 100644 index 0672ca50ff1..00000000000 --- a/progs/trivial/vbo-noninterleaved.c +++ /dev/null @@ -1,139 +0,0 @@ -/* Basic VBO */ - -#include <assert.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glew.h> -#include <GL/glut.h> - - -struct { - GLfloat pos[4][4]; - GLfloat col[4][4]; -} verts = -{ - /* Position: a quad - */ - { - { 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 }, - }, - - /* Color: all red - */ - { - { 1.0, 0.0, 0.0, 1.0 }, - { 1.0, 0.0, 0.0, 1.0 }, - { 1.0, 0.0, 0.0, 1.0 }, - { 1.0, 0.0, 0.0, 1.0 }, - }, - - -}; - -GLuint arrayObj, elementObj; - -static void Init( void ) -{ - GLint errno; - GLuint prognum; - - static const char *prog1 = - "!!ARBvp1.0\n" - "MOV result.color, vertex.color;\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)); - } - - - glEnableClientState( GL_VERTEX_ARRAY ); - glEnableClientState( GL_COLOR_ARRAY ); - - glGenBuffersARB(1, &arrayObj); - glBindBufferARB(GL_ARRAY_BUFFER_ARB, arrayObj); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), &verts, GL_STATIC_DRAW_ARB); - - glVertexPointer( 4, GL_FLOAT, sizeof(verts.pos[0]), 0 ); - glColorPointer( 4, GL_FLOAT, sizeof(verts.col[0]), (void *)(4*4*sizeof(float)) ); - -} - - - -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_ARB); - -// glDrawArrays( GL_TRIANGLES, 0, 3 ); -// glDrawArrays( GL_TRIANGLES, 1, 3 ); - glDrawArrays( GL_QUADS, 0, 4 ); - - 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; -} diff --git a/progs/trivial/vp-array-int.c b/progs/trivial/vp-array-int.c deleted file mode 100644 index 2e1ac1374d7..00000000000 --- a/progs/trivial/vp-array-int.c +++ /dev/null @@ -1,118 +0,0 @@ -/* 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> - -GLint verts[][4] = { - { 1, -1, 0, 1 }, - { 1, 1, 0, 1 }, - { -1, 1, 0, 1 }, - { -1, -1, 0, 1 }, -}; - -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; - - static const char *prog1 = - "!!ARBvp1.0\n" - "MOV result.color, vertex.color;\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)); - } - - - glEnableClientState( GL_VERTEX_ARRAY ); - glEnableClientState( GL_COLOR_ARRAY ); - glVertexPointer( 3, GL_INT, sizeof(verts[0]), verts ); - 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; -} diff --git a/progs/trivial/vp-tri-cb-pos.c b/progs/trivial/vp-tri-cb-pos.c deleted file mode 100644 index 42bf9806b19..00000000000 --- a/progs/trivial/vp-tri-cb-pos.c +++ /dev/null @@ -1,158 +0,0 @@ -/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ - -#include <stdio.h> -#include <assert.h> -#include <string.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glew.h> -#include <GL/glut.h> - - - -GLenum doubleBuffer; - -static void Init(void) -{ - GLint errno; - GLuint prognum; - - static const char *prog1 = - "!!ARBvp1.0\n" - "PARAM Emission = state.material.emission; \n" - "PARAM Ambient = state.material.ambient; \n" - "PARAM Diffuse = state.material.diffuse; \n" - "PARAM Specular = state.material.specular; \n" - "DP4 result.position.x, Ambient, vertex.position;\n" - "DP4 result.position.y, Diffuse, vertex.position;\n" - "DP4 result.position.z, Specular, vertex.position;\n" - "DP4 result.position.w, Emission, vertex.position;\n" - "MOV result.color, vertex.color;\n" - "END\n"; - - const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 }; - const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 }; - const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 }; - const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 }; - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient); - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); - glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission); - - - 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)); - } - - glEnable(GL_VERTEX_PROGRAM_NV); - -} - - -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,.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(); - - 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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/vp-tri-cb-tex.c b/progs/trivial/vp-tri-cb-tex.c deleted file mode 100644 index 8290226675e..00000000000 --- a/progs/trivial/vp-tri-cb-tex.c +++ /dev/null @@ -1,191 +0,0 @@ -/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ - -#include <stdio.h> -#include <assert.h> -#include <string.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glew.h> -#include <GL/glut.h> - - - -GLenum doubleBuffer; - -static void Init(void) -{ - GLint errno; - GLuint prognum; - - static const char *prog1 = - "!!ARBvp1.0\n" - "PARAM Emission = state.material.emission; \n" - "PARAM Ambient = state.material.ambient; \n" - "PARAM Diffuse = state.material.diffuse; \n" - "PARAM Specular = state.material.specular; \n" - "DP4 result.position.x, Ambient, vertex.position;\n" - "DP4 result.position.y, Diffuse, vertex.position;\n" - "DP4 result.position.z, Specular, vertex.position;\n" - "DP4 result.position.w, Emission, vertex.position;\n" - "MOV result.texcoord[0], vertex.texcoord[0];\n" - "END\n"; - - const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 }; - const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 }; - const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 }; - const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 }; - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient); - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); - glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission); - - - 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)); - } - - glEnable(GL_VERTEX_PROGRAM_NV); - -#define SIZE 32 - { - GLubyte tex2d[SIZE][SIZE][3]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { -#if 0 - tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; - tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; - tex2d[t][s][2] = 0; -#else - tex2d[t][s][0] = s*255/(SIZE-1); - tex2d[t][s][1] = t*255/(SIZE-1); - tex2d[t][s][2] = 0; -#endif - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); - - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - } - -} - - -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); - glTexCoord2f(1,-1); - glVertex3f( 0.9, -0.9, -0.0); - glTexCoord2f(1,1); - glVertex3f( 0.9, 0.9, -0.0); - glTexCoord2f(-1,0); - glVertex3f(-0.9, 0.0, -0.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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - - 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 deleted file mode 100644 index 1f12a2c297a..00000000000 --- a/progs/trivial/vp-tri-cb.c +++ /dev/null @@ -1,108 +0,0 @@ -/* 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> - -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]); - glewInit(); - 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 deleted file mode 100644 index f2549f3697f..00000000000 --- a/progs/trivial/vp-tri-imm.c +++ /dev/null @@ -1,102 +0,0 @@ -/* 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> - -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]); - glewInit(); - glutReshapeFunc( Reshape ); - glutKeyboardFunc( Key ); - glutDisplayFunc( Display ); - Init(); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/vp-tri-invariant.c b/progs/trivial/vp-tri-invariant.c deleted file mode 100644 index ff241393659..00000000000 --- a/progs/trivial/vp-tri-invariant.c +++ /dev/null @@ -1,147 +0,0 @@ -/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <math.h> -#include <GL/glew.h> -#include <GL/glut.h> - - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -GLenum doubleBuffer; - -static void Init(void) -{ - GLint errno; - GLuint prognum; - - static const char *prog1 = - "!!ARBvp1.0\n" - "OPTION ARB_position_invariant ;" - "MOV result.color, vertex.color;\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); - - 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)); - } - - 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); - - 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); -} - -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); - - glEnable(GL_VERTEX_PROGRAM_ARB); - - 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(); - - 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 | GLUT_ALPHA; - type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; - glutInitDisplayMode(type); - - if (glutCreateWindow(*argv) == GL_FALSE) { - exit(1); - } - - glewInit(); - Init(); - - glutReshapeFunc(Reshape); - glutKeyboardFunc(Key); - glutDisplayFunc(Draw); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/vp-tri-swap.c b/progs/trivial/vp-tri-swap.c deleted file mode 100644 index a3ab1206fdf..00000000000 --- a/progs/trivial/vp-tri-swap.c +++ /dev/null @@ -1,104 +0,0 @@ -/* 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> - -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]); - glewInit(); - glutReshapeFunc( Reshape ); - glutKeyboardFunc( Key ); - glutDisplayFunc( Display ); - Init(); - glutMainLoop(); - return 0; -} diff --git a/progs/trivial/vp-tri-tex.c b/progs/trivial/vp-tri-tex.c deleted file mode 100644 index bd2b5e59f9d..00000000000 --- a/progs/trivial/vp-tri-tex.c +++ /dev/null @@ -1,138 +0,0 @@ -/* 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> - -static void Init( void ) -{ - GLint errno; - GLuint prognum; - - static const char *prog1 = - "!!ARBvp1.0\n" - "MOV result.texcoord[0], vertex.texcoord[0];\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)); - } - -#define SIZE 32 - { - GLubyte tex2d[SIZE][SIZE][3]; - GLint s, t; - - for (s = 0; s < SIZE; s++) { - for (t = 0; t < SIZE; t++) { -#if 0 - tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255; - tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255; - tex2d[t][s][2] = 0; -#else - tex2d[t][s][0] = s*255/(SIZE-1); - tex2d[t][s][1] = t*255/(SIZE-1); - tex2d[t][s][2] = 0; -#endif - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); - - glEnable(GL_TEXTURE_2D); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - } - -} - -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); - glTexCoord2f(1,-1); - glVertex3f( 0.9, -0.9, -0.0); - glTexCoord2f(1,1); - glVertex3f( 0.9, 0.9, -0.0); - glTexCoord2f(-1,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]); - glewInit(); - glutReshapeFunc( Reshape ); - glutKeyboardFunc( Key ); - glutDisplayFunc( Display ); - Init(); - glutMainLoop(); - return 0; -} diff --git a/progs/vp/SConscript b/progs/vp/SConscript deleted file mode 100644 index 640c5dd8470..00000000000 --- a/progs/vp/SConscript +++ /dev/null @@ -1,13 +0,0 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) - -env.Program( - target = 'vp-tris', - source = ['vp-tris.c'], - ) diff --git a/progs/vp/addimm.txt b/progs/vp/addimm.txt deleted file mode 100644 index f5796d78100..00000000000 --- a/progs/vp/addimm.txt +++ /dev/null @@ -1,5 +0,0 @@ -!!ARBvp1.0 -TEMP R0; -ADD result.color, vertex.color, {.5}.x; -MOV result.position, vertex.position; -END diff --git a/progs/vp/arl-static.txt b/progs/vp/arl-static.txt deleted file mode 100644 index aea87b79a49..00000000000 --- a/progs/vp/arl-static.txt +++ /dev/null @@ -1,7 +0,0 @@ -!!ARBvp1.0 -PARAM arr[5] = { {.0,.1,.2,.3}, {.4,.5,.6,.7}, {.8,.9,.10,.1}, {.12,.3,.4,.14}, {.5,.8,.1,.9}, {.2,0,.4,.1}, {.6,.1,.8,.9}}; -ADDRESS addr; -ARL addr.x, {3}.x; -MOV result.color, arr[addr.x]; -MOV result.position, vertex.position; -END diff --git a/progs/vp/arl-unused.txt b/progs/vp/arl-unused.txt deleted file mode 100644 index 7bdbb8e86c7..00000000000 --- a/progs/vp/arl-unused.txt +++ /dev/null @@ -1,7 +0,0 @@ -!!ARBvp1.0 -PARAM arr[5] = { {.0,.1,.2,.3}, {.4,.5,.6,.7}, {.8,.9,.10,.1}, {.12,.3,.4,.14}, {.5,.8,.1,.9}, {.2,0,.4,.1}, {.6,.1,.8,.9}}; -ADDRESS addr; -ARL addr.x, {3}.x; # not actually used -MOV result.color, arr[3]; -MOV result.position, vertex.position; -END diff --git a/progs/vp/exp-no-w.txt b/progs/vp/exp-no-w.txt deleted file mode 100644 index 98ed4b7a981..00000000000 --- a/progs/vp/exp-no-w.txt +++ /dev/null @@ -1,6 +0,0 @@ -!!ARBvp1.0 -TEMP R0; -EXP R0, vertex.color.x; -SUB result.color, R0.z, {1.0}.x; -MOV result.position, vertex.position; -END diff --git a/progs/vp/exp.txt b/progs/vp/exp.txt deleted file mode 100644 index 53ce71db965..00000000000 --- a/progs/vp/exp.txt +++ /dev/null @@ -1,6 +0,0 @@ -!!ARBvp1.0 -TEMP R0; -EXP R0, vertex.color.x; -SUB result.color, R0.z, R0.w; -MOV result.position, vertex.position; -END diff --git a/progs/vp/log.txt b/progs/vp/log.txt deleted file mode 100644 index 6b4e94ed0ed..00000000000 --- a/progs/vp/log.txt +++ /dev/null @@ -1,7 +0,0 @@ -!!ARBvp1.0 -TEMP R0; -ADD R0, vertex.color, vertex.color; -ADD R0, R0, R0; -LOG result.color, R0.x; -MOV result.position, vertex.position; -END diff --git a/progs/vp/msk.txt b/progs/vp/msk.txt deleted file mode 100644 index 9e925aca11e..00000000000 --- a/progs/vp/msk.txt +++ /dev/null @@ -1,7 +0,0 @@ -!!ARBvp1.0 -TEMP R0; -MOV R0.xz, vertex.color; -MOV R0.yw, {0.5}.x; -MOV result.color, R0; -MOV result.position, vertex.position; -END diff --git a/progs/vp/psiz-imm.txt b/progs/vp/psiz-imm.txt deleted file mode 100644 index 18de2498d67..00000000000 --- a/progs/vp/psiz-imm.txt +++ /dev/null @@ -1,5 +0,0 @@ -!!ARBvp1.0 -MOV result.color, vertex.color; -MOV result.pointsize, {2.0, 0, 0, 1}; -MOV result.position, vertex.position; -END diff --git a/progs/vp/psiz-mul-clamp.txt b/progs/vp/psiz-mul-clamp.txt deleted file mode 100644 index 284c032d790..00000000000 --- a/progs/vp/psiz-mul-clamp.txt +++ /dev/null @@ -1,9 +0,0 @@ -!!ARBvp1.0 -TEMP R0; -MOV result.color, vertex.color; -MUL R0.x, vertex.color.x, {10.0}.x; -MAX R0.x, R0.x, {2.0}.x; -MIN result.pointsize.x, R0.x, {4.0}.x; -MOV result.position, vertex.position; -END - diff --git a/progs/vp/psiz-mul.txt b/progs/vp/psiz-mul.txt deleted file mode 100644 index a74df66de29..00000000000 --- a/progs/vp/psiz-mul.txt +++ /dev/null @@ -1,6 +0,0 @@ -!!ARBvp1.0 -MOV result.color, vertex.color; -MUL result.pointsize, vertex.color.x, {10.0}.x; -MOV result.position, vertex.position; -END - diff --git a/progs/vp/psiz-param-clamp.txt b/progs/vp/psiz-param-clamp.txt deleted file mode 100644 index 7f83fc45165..00000000000 --- a/progs/vp/psiz-param-clamp.txt +++ /dev/null @@ -1,10 +0,0 @@ -!!ARBvp1.0 -TEMP R0; -TEMP R1; -MOV result.color, vertex.color; -MUL R0.x, vertex.color.x, {10.0}.x; -MAX R0.x, R0.x, {2.0}.x; -MIN result.pointsize.x, R0.x, {4.0}.x; -MOV result.position, vertex.position; -END - diff --git a/progs/vp/run.sh b/progs/vp/run.sh deleted file mode 100755 index fdd43d4a52b..00000000000 --- a/progs/vp/run.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -for i in *.txt ; do -echo $i -./vp-tris $i -done - diff --git a/progs/vp/windows/vp2003.sln b/progs/vp/windows/vp2003.sln deleted file mode 100644 index 76de5cfd7ff..00000000000 --- a/progs/vp/windows/vp2003.sln +++ /dev/null @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vp2003", "vp2003.vcproj", "{E1C70416-98E7-4282-B6B2-6C9CF90B12C0}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Debug.ActiveCfg = Debug|Win32 - {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Debug.Build.0 = Debug|Win32 - {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Release.ActiveCfg = Release|Win32 - {E1C70416-98E7-4282-B6B2-6C9CF90B12C0}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/progs/vp/windows/vp2003.vcproj b/progs/vp/windows/vp2003.vcproj deleted file mode 100644 index adca2c50731..00000000000 --- a/progs/vp/windows/vp2003.vcproj +++ /dev/null @@ -1,121 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="7.10" - Name="vp2003" - ProjectGUID="{E1C70416-98E7-4282-B6B2-6C9CF90B12C0}" - Keyword="Win32Proj"> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="Debug" - IntermediateDirectory="Debug" - ConfigurationType="1" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" - MinimalRebuild="TRUE" - BasicRuntimeChecks="3" - RuntimeLibrary="5" - UsePrecompiledHeader="0" - WarningLevel="3" - Detect64BitPortabilityProblems="TRUE" - DebugInformationFormat="4"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="glut32.lib" - OutputFile="$(OutDir)/vp2003.exe" - LinkIncremental="2" - GenerateDebugInformation="TRUE" - ProgramDatabaseFile="$(OutDir)/vp2003.pdb" - SubSystem="1" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="Release" - IntermediateDirectory="Release" - ConfigurationType="1" - CharacterSet="2"> - <Tool - Name="VCCLCompilerTool" - AdditionalIncludeDirectories="" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" - RuntimeLibrary="4" - UsePrecompiledHeader="0" - WarningLevel="3" - Detect64BitPortabilityProblems="TRUE" - DebugInformationFormat="3"/> - <Tool - Name="VCCustomBuildTool"/> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="glut32.lib" - OutputFile="$(OutDir)/vp2003.exe" - LinkIncremental="1" - GenerateDebugInformation="TRUE" - SubSystem="1" - OptimizeReferences="2" - EnableCOMDATFolding="2" - TargetMachine="1"/> - <Tool - Name="VCMIDLTool"/> - <Tool - Name="VCPostBuildEventTool"/> - <Tool - Name="VCPreBuildEventTool"/> - <Tool - Name="VCPreLinkEventTool"/> - <Tool - Name="VCResourceCompilerTool"/> - <Tool - Name="VCWebServiceProxyGeneratorTool"/> - <Tool - Name="VCXMLDataGeneratorTool"/> - <Tool - Name="VCWebDeploymentTool"/> - <Tool - Name="VCManagedWrapperGeneratorTool"/> - <Tool - Name="VCAuxiliaryManagedWrapperGeneratorTool"/> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <File - RelativePath="..\vp-tris.c"> - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/progs/vp/xform.txt b/progs/vp/xform.txt deleted file mode 100644 index d1548f1f10d..00000000000 --- a/progs/vp/xform.txt +++ /dev/null @@ -1,11 +0,0 @@ -!!ARBvp1.0 -PARAM Emission = state.material.emission; -PARAM Ambient = state.material.ambient; -PARAM Diffuse = state.material.diffuse; -PARAM Specular = state.material.specular; -DP4 result.position.x, Ambient, vertex.position; -DP4 result.position.y, Diffuse, vertex.position; -DP4 result.position.z, Specular, vertex.position; -DP4 result.position.w, Emission, vertex.position; -MOV result.color, vertex.color; -END diff --git a/progs/vpglsl/.gitignore b/progs/vpglsl/.gitignore deleted file mode 100644 index a5ff9935254..00000000000 --- a/progs/vpglsl/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vp-tris diff --git a/progs/vpglsl/Makefile b/progs/vpglsl/Makefile deleted file mode 100644 index 3982aca5650..00000000000 --- a/progs/vpglsl/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# 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 = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) - -SOURCES = \ - vp-tris.c - - - -PROGS = $(SOURCES:%.c=%) - -INCLUDES = -I. -I$(TOP)/include -I../samples - - -##### 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: $(PROGS) - -clean: - rm -f $(PROGS) - rm -f *.o - rm -f getproclist.h - - - - - -# Emacs tags -tags: - etags `find . -name \*.[ch]` `find ../include` diff --git a/progs/vpglsl/SConscript b/progs/vpglsl/SConscript deleted file mode 100644 index 640c5dd8470..00000000000 --- a/progs/vpglsl/SConscript +++ /dev/null @@ -1,13 +0,0 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) - -env.Program( - target = 'vp-tris', - source = ['vp-tris.c'], - ) diff --git a/progs/vpglsl/for.glsl b/progs/vpglsl/for.glsl deleted file mode 100644 index 45d6845dacc..00000000000 --- a/progs/vpglsl/for.glsl +++ /dev/null @@ -1,7 +0,0 @@ - -void main() { - gl_Position = gl_Vertex; - gl_FrontColor = vec4(0); - for (int i = 0; i < 4; ++i) - gl_FrontColor += gl_Color; -} diff --git a/progs/vpglsl/if.glsl b/progs/vpglsl/if.glsl deleted file mode 100644 index 174f69c19c9..00000000000 --- a/progs/vpglsl/if.glsl +++ /dev/null @@ -1,7 +0,0 @@ - -void main() { - gl_FrontColor = gl_Color; - gl_Position = gl_Vertex; - if (gl_Position.x < 0.5) - gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0); -} diff --git a/progs/vpglsl/ifelse.glsl b/progs/vpglsl/ifelse.glsl deleted file mode 100644 index 645b2117a17..00000000000 --- a/progs/vpglsl/ifelse.glsl +++ /dev/null @@ -1,8 +0,0 @@ - -void main() { - gl_Position = gl_Vertex; - if (gl_Position.x < 0.5) - gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0); - else - gl_FrontColor = gl_Color; -} diff --git a/progs/vpglsl/mov.glsl b/progs/vpglsl/mov.glsl deleted file mode 100644 index 63b16f4754b..00000000000 --- a/progs/vpglsl/mov.glsl +++ /dev/null @@ -1,5 +0,0 @@ - -void main() { - gl_FrontColor = gl_Color; - gl_Position = gl_Vertex; -} diff --git a/progs/vpglsl/nestedifs.glsl b/progs/vpglsl/nestedifs.glsl deleted file mode 100644 index abb235cd65b..00000000000 --- a/progs/vpglsl/nestedifs.glsl +++ /dev/null @@ -1,13 +0,0 @@ - -void main() { - gl_Position = gl_Vertex; - if (gl_Position.x < 0.5) { - if (gl_Position.y < 0.20) { - gl_FrontColor = vec4(1.0, 0.0, 0.0, 1.0); - } else { - gl_FrontColor = vec4(0.0, 1.0, 0.0, 1.0); - } - gl_FrontColor.y = 1.0; - } else - gl_FrontColor = gl_Color; -} diff --git a/progs/vpglsl/nestedswizzle.glsl b/progs/vpglsl/nestedswizzle.glsl deleted file mode 100644 index a3adb3dfeb2..00000000000 --- a/progs/vpglsl/nestedswizzle.glsl +++ /dev/null @@ -1,9 +0,0 @@ - -void main() { - gl_Position = gl_Vertex; - gl_FrontColor = gl_Color; - if (gl_Position.x < 0.5) { - gl_FrontColor.y = 1.0; - } - gl_FrontColor.xzw = vec3(0, 0, 1); -} diff --git a/progs/vpglsl/off2f.glsl b/progs/vpglsl/off2f.glsl deleted file mode 100644 index e06cb42a0ed..00000000000 --- a/progs/vpglsl/off2f.glsl +++ /dev/null @@ -1,18 +0,0 @@ -const int KernelSize = 8; -uniform vec2 Offset2f[KernelSize]; -uniform vec4 KernelValue4f[KernelSize]; - -void main(void) -{ - int i; - vec4 sum = vec4(0.0); - vec4 tmp = gl_Color; - vec2 rg, ba; - gl_Position = gl_Vertex; - - rg = Offset2f[4]; - ba = Offset2f[5]; - - - gl_FrontColor = KernelValue4f[0] * vec4(rg, ba); -} diff --git a/progs/vpglsl/psiz-imm.glsl b/progs/vpglsl/psiz-imm.glsl deleted file mode 100644 index 101d314d584..00000000000 --- a/progs/vpglsl/psiz-imm.glsl +++ /dev/null @@ -1,6 +0,0 @@ - -void main() { - gl_FrontColor = gl_Color; - gl_PointSize = 2.0; - gl_Position = gl_Vertex; -} diff --git a/progs/vpglsl/psiz-mul.glsl b/progs/vpglsl/psiz-mul.glsl deleted file mode 100644 index 77f4a46b520..00000000000 --- a/progs/vpglsl/psiz-mul.glsl +++ /dev/null @@ -1,6 +0,0 @@ - -void main() { - gl_FrontColor = gl_Color; - gl_PointSize = 10 * gl_Color.x; - gl_Position = gl_Vertex; -} diff --git a/progs/vpglsl/varfor1f.glsl b/progs/vpglsl/varfor1f.glsl deleted file mode 100644 index 9c3e8f2a238..00000000000 --- a/progs/vpglsl/varfor1f.glsl +++ /dev/null @@ -1,22 +0,0 @@ -const int KernelSize = 16; -uniform float KernelValue1f[KernelSize]; - -void main(void) -{ - int i; - vec4 sum = vec4(0.0); - vec4 tmp = gl_Color; - gl_Position = gl_Vertex; - - for (i = 0; i < KernelSize; ++i) { - float x, y, z, w; - - x = KernelValue1f[i]; ++i; - y = KernelValue1f[i]; ++i; - z = KernelValue1f[i]; ++i; - w = KernelValue1f[i]; - - sum += tmp * vec4(x, y, z, w); - } - gl_FrontColor = sum; -} diff --git a/progs/vpglsl/varfor2f.glsl b/progs/vpglsl/varfor2f.glsl deleted file mode 100644 index d98a1100458..00000000000 --- a/progs/vpglsl/varfor2f.glsl +++ /dev/null @@ -1,24 +0,0 @@ -const int KernelSize = 9; -uniform vec2 KernelValue2f[KernelSize]; - -void main(void) -{ - int i; - vec4 sum = vec4(0.0); - vec4 tmp = gl_Color; - gl_Position = gl_Vertex; - - for (i = 0; i < KernelSize; ++i) { - vec2 rg, ba; - - rg = KernelValue2f[i]; - ++i; - if (i < KernelSize) - ba = KernelValue2f[i]; - else - ba = vec2(0, 0); - - sum += tmp * vec4(rg, ba); - } - gl_FrontColor = sum; -} diff --git a/progs/vpglsl/varfor4f.glsl b/progs/vpglsl/varfor4f.glsl deleted file mode 100644 index c70ba0356fd..00000000000 --- a/progs/vpglsl/varfor4f.glsl +++ /dev/null @@ -1,19 +0,0 @@ -const int KernelSize = 4; -uniform vec4 KernelValue4f[KernelSize]; - -void main(void) -{ - int i; - vec4 sum = vec4(0.0); - vec4 tmp = gl_Color; - gl_Position = gl_Vertex; - - for (i = 0; i < KernelSize; ++i) { - vec4 rgba; - - rgba = KernelValue4f[i]; - - sum += tmp * rgba; - } - gl_FrontColor = sum; -} diff --git a/progs/vpglsl/vp-tris.c b/progs/vpglsl/vp-tris.c deleted file mode 100644 index b2b05080910..00000000000 --- a/progs/vpglsl/vp-tris.c +++ /dev/null @@ -1,363 +0,0 @@ - -#include <assert.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - -#include <GL/glew.h> -#include <GL/glut.h> - -static const char *filename = NULL; -static GLuint nr_steps = 4; -static GLuint prim = GL_TRIANGLES; -static GLfloat psz = 1.0; -static GLboolean pointsmooth = 0; -static GLboolean program_point_size = 0; - -static GLuint fragShader; -static GLuint vertShader; -static GLuint program; - -static void usage( char *name ) -{ - fprintf( stderr, "usage: %s [ options ] shader_filename\n", name ); - fprintf( stderr, "\n" ); - fprintf( stderr, "options:\n" ); - fprintf( stderr, " -f flat shaded\n" ); - fprintf( stderr, " -nNr subdivision steps\n" ); -} - - -static void load_and_compile_shader(GLuint shader, const char *text) -{ - GLint stat; - - glShaderSource(shader, 1, (const GLchar **) &text, NULL); - - glCompileShader(shader); - - glGetShaderiv(shader, GL_COMPILE_STATUS, &stat); - if (!stat) { - GLchar log[1000]; - GLsizei len; - glGetShaderInfoLog(shader, 1000, &len, log); - fprintf(stderr, "vp-tris: problem compiling shader:\n%s\n", log); - exit(1); - } -} - -static void read_shader(GLuint shader, const char *filename) -{ - const int max = 100*1000; - int n; - char *buffer = (char*) malloc(max); - FILE *f = fopen(filename, "r"); - if (!f) { - fprintf(stderr, "vp-tris: Unable to open shader file %s\n", filename); - exit(1); - } - - n = fread(buffer, 1, max, f); - printf("vp-tris: read %d bytes from shader file %s\n", n, filename); - if (n > 0) { - buffer[n] = 0; - load_and_compile_shader(shader, buffer); - } - - fclose(f); - free(buffer); -} - -static void check_link(GLuint prog) -{ - GLint stat; - glGetProgramiv(prog, GL_LINK_STATUS, &stat); - if (!stat) { - GLchar log[1000]; - GLsizei len; - glGetProgramInfoLog(prog, 1000, &len, log); - fprintf(stderr, "Linker error:\n%s\n", log); - } -} - -static void setup_uniforms() -{ - { - GLuint loc1f = glGetUniformLocationARB(program, "Offset1f"); - GLuint loc2f = glGetUniformLocationARB(program, "Offset2f"); - GLuint loc4f = glGetUniformLocationARB(program, "Offset4f"); - GLfloat vecKer[] = - { 1.0, 0.0, 0.0, 1.0, - 0.0, 1.0, 0.0, 1.0, - 1.0, 0.0, 0.0, 1.0, - 0.0, 0.0, 0.0, 1.0 - }; - if (loc1f >= 0) - glUniform1fv(loc1f, 16, vecKer); - - if (loc2f >= 0) - glUniform2fv(loc2f, 8, vecKer); - - if (loc4f >= 0) - glUniform4fv(loc4f, 4, vecKer); - - } - - { - GLuint loc1f = glGetUniformLocationARB(program, "KernelValue1f"); - GLuint loc2f = glGetUniformLocationARB(program, "KernelValue2f"); - GLuint loc4f = glGetUniformLocationARB(program, "KernelValue4f"); - GLfloat vecKer[] = - { 1.0, 0.0, 0.0, 0.25, - 0.0, 1.0, 0.0, 0.25, - 0.0, 0.0, 1.0, 0.25, - 0.0, 0.0, 0.0, 0.25, - 0.5, 0.0, 0.0, 0.35, - 0.0, 0.5, 0.0, 0.35, - 0.0, 0.0, 0.5, 0.35, - 0.0, 0.0, 0.0, 0.35 - }; - if (loc1f >= 0) - glUniform1fv(loc1f, 16, vecKer); - - if (loc2f >= 0) - glUniform2fv(loc2f, 8, vecKer); - - if (loc4f >= 0) - glUniform4fv(loc4f, 4, vecKer); - } -} - -static void prepare_shaders() -{ - static const char *fragShaderText = - "void main() {\n" - " gl_FragColor = gl_Color;\n" - "}\n"; - static const char *vertShaderText = - "void main() {\n" - " gl_FrontColor = gl_Color;\n" - " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" - "}\n"; - fragShader = glCreateShader(GL_FRAGMENT_SHADER); - load_and_compile_shader(fragShader, fragShaderText); - - - vertShader = glCreateShader(GL_VERTEX_SHADER); - if (filename) - read_shader(vertShader, filename); - else - load_and_compile_shader(vertShader, vertShaderText); - - program = glCreateProgram(); - glAttachShader(program, fragShader); - glAttachShader(program, vertShader); - glLinkProgram(program); - check_link(program); - glUseProgram(program); - - setup_uniforms(); -} - -static void args(int argc, char *argv[]) -{ - GLint i; - - for (i = 1; i < argc; i++) { - if (strncmp(argv[i], "-n", 2) == 0) { - nr_steps = atoi((argv[i]) + 2); - } - else if (strcmp(argv[i], "-f") == 0) { - glShadeModel(GL_FLAT); - } - else if (i == argc - 1) { - filename = argv[i]; - } - else { - usage(argv[0]); - exit(1); - } - } - - if (!filename) { - usage(argv[0]); - exit(1); - } -} - - - - -union vert { - struct { - GLfloat color[3]; - GLfloat pos[3]; - } v; - GLfloat f[6]; -}; - -static void make_midpoint( union vert *out, - const union vert *v0, - const union vert *v1) -{ - int i; - for (i = 0; i < 6; i++) - out->f[i] = v0->f[i] + .5 * (v1->f[i] - v0->f[i]); -} - -static void subdiv( union vert *v0, - union vert *v1, - union vert *v2, - GLuint depth ) -{ - if (depth == 0) { - glColor3fv(v0->v.color); - glVertex3fv(v0->v.pos); - glColor3fv(v1->v.color); - glVertex3fv(v1->v.pos); - glColor3fv(v2->v.color); - glVertex3fv(v2->v.pos); - } - else { - union vert m[3]; - - make_midpoint(&m[0], v0, v1); - make_midpoint(&m[1], v1, v2); - make_midpoint(&m[2], v2, v0); - - subdiv(&m[0], &m[2], v0, depth-1); - subdiv(&m[1], &m[0], v1, depth-1); - subdiv(&m[2], &m[1], v2, depth-1); - subdiv(&m[0], &m[1], &m[2], depth-1); - } -} - -static void enable( GLenum value, GLboolean flag ) -{ - if (flag) - glEnable(value); - else - glDisable(value); -} - -/** Assignment */ -#define ASSIGN_3V( V, V0, V1, V2 ) \ -do { \ - V[0] = V0; \ - V[1] = V1; \ - V[2] = V2; \ -} while(0) - -static void Display( void ) -{ - glClearColor(0.3, 0.3, 0.3, 1); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glPointSize(psz); - - glUseProgram(program); - enable( GL_POINT_SMOOTH, pointsmooth ); - enable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB, program_point_size ); - - glBegin(prim); - - - { - union vert v[3]; - - ASSIGN_3V(v[0].v.color, 0,0,1); - ASSIGN_3V(v[0].v.pos, 0.9, -0.9, 0.0); - ASSIGN_3V(v[1].v.color, 1,0,0); - ASSIGN_3V(v[1].v.pos, 0.9, 0.9, 0.0); - ASSIGN_3V(v[2].v.color, 0,1,0); - ASSIGN_3V(v[2].v.pos, -0.9, 0, 0.0); - - subdiv(&v[0], &v[1], &v[2], nr_steps); - } - - 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 CleanUp(void) -{ - glDeleteShader(fragShader); - glDeleteShader(vertShader); - glDeleteProgram(program); -} - -static void Key( unsigned char key, int x, int y ) -{ - (void) x; - (void) y; - switch (key) { - case 'p': - prim = GL_POINTS; - break; - case 't': - prim = GL_TRIANGLES; - break; - case 's': - psz += .5; - break; - case 'S': - if (psz > .5) - psz -= .5; - break; - case 'm': - pointsmooth = !pointsmooth; - break; - case 'z': - program_point_size = !program_point_size; - break; - case '+': - nr_steps++; - break; - case '-': - if (nr_steps) - nr_steps--; - break; - case ' ': - psz = 1.0; - prim = GL_TRIANGLES; - nr_steps = 4; - break; - case 27: - CleanUp(); - 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[argc-1]); - glewInit(); - glutReshapeFunc( Reshape ); - glutKeyboardFunc( Key ); - glutDisplayFunc( Display ); - args( argc, argv ); - prepare_shaders(); - glutMainLoop(); - return 0; -} diff --git a/progs/wgl/SConscript b/progs/wgl/SConscript deleted file mode 100644 index 31f61676dec..00000000000 --- a/progs/wgl/SConscript +++ /dev/null @@ -1,25 +0,0 @@ -Import('*') - -if env['platform'] != 'windows': - Return() - -env = env.Clone() - -env.Append(LIBS = [ - 'kernel32', - 'user32', - 'gdi32', -]) - -progs = [ - 'sharedtex_mt', - 'wglthreads', -] - -for prog in progs: - env.Program( - target = prog, - source = prog + '/' + prog + '.c', - ) - -env.Program('wglinfo', ['wglinfo.c']) diff --git a/progs/wgl/sharedtex_mt/sharedtex_mt.c b/progs/wgl/sharedtex_mt/sharedtex_mt.c deleted file mode 100644 index 779e15001db..00000000000 --- a/progs/wgl/sharedtex_mt/sharedtex_mt.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - * Test sharing of display lists and texture objects between GLX contests. - * Brian Paul - * Summer 2000 - * - * - * Copyright (C) 2000 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * Modified 2009 for multithreading by Thomas Hellstrom. - * - * Port to windows by Michal Krol. - */ - - -#include <windows.h> -#include <GL/gl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#pragma comment(lib, "opengl32.lib") - -struct thread_init_arg { - int id; -}; - -struct window { - CRITICAL_SECTION drawMutex; - HDC hDC; - HWND Win; - HGLRC Context; - float Angle; - int Id; - HGLRC sharedContext; - HANDLE hEventInitialised; -}; - - -#define MAX_WINDOWS 20 -static struct window Windows[MAX_WINDOWS]; -static int NumWindows = 0; -static HANDLE terminate = NULL; -static HGLRC gCtx = NULL; -static HDC gHDC = NULL; -static GLuint Textures[3]; - - - -static void -Error(const char *msg) -{ - fprintf(stderr, "Error - %s\n", msg); - exit(1); -} - -static void -Resize(struct window *h, unsigned int width, unsigned int height); - -static LRESULT CALLBACK -WndProc(HWND hWnd, - UINT uMsg, - WPARAM wParam, - LPARAM lParam ) -{ - switch (uMsg) { - case WM_KEYDOWN: - SetEvent(terminate); - break; - case WM_SIZE: - { - LONG index = GetWindowLong(hWnd, GWL_USERDATA); - - if (index >= 0 && index < MAX_WINDOWS) { - RECT r; - - GetClientRect(hWnd, &r); - Resize(&Windows[index], r.right, r.bottom); - } - } - break; - case WM_CREATE: - { - CREATESTRUCT *pcs = (CREATESTRUCT *) lParam; - - SetWindowLong(hWnd, GWL_USERDATA, (LONG) pcs->lpCreateParams); - } - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hWnd, uMsg, wParam, lParam); - } - - return 0; -} - -static int -initMainthread(void) -{ - WNDCLASS wc = {0}; - HWND win; - PIXELFORMATDESCRIPTOR pfd = {0}; - int visinfo; - - wc.lpfnWndProc = WndProc; - wc.lpszClassName = "sharedtex_mt.hidden"; - wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - RegisterClass(&wc); - - win = CreateWindowEx(0, - wc.lpszClassName, - "sharedtex_mt.hidden", - WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - NULL, - NULL, - wc.hInstance, - (LPVOID) -1); - if (!win) { - Error("Couldn't create window"); - } - - gHDC = GetDC(win); - if (!gHDC) { - Error("Couldn't obtain HDC"); - } - - pfd.cColorBits = 24; - pfd.cDepthBits = 24; - pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - pfd.iLayerType = PFD_MAIN_PLANE; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - - visinfo = ChoosePixelFormat(gHDC, &pfd); - if (!visinfo) { - Error("Unable to find RGB, Z, double-buffered visual"); - } - - SetPixelFormat(gHDC, visinfo, &pfd); - gCtx = wglCreateContext(gHDC); - if (!gCtx) { - Error("Couldn't create WGL context"); - } - - return 0; -} - -static struct window * -AddWindow(int xpos, int ypos, HGLRC sCtx) -{ - struct window *win = &Windows[NumWindows]; - WNDCLASS wc = {0}; - int width = 300, height = 300; - - if (NumWindows >= MAX_WINDOWS) - return NULL; - - memset(win, 0, sizeof(*win)); - InitializeCriticalSection(&win->drawMutex); - win->Angle = 0.0; - win->Id = NumWindows++; - - wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.lpfnWndProc = WndProc; - wc.lpszClassName = "sharedtex_mt"; - wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - RegisterClass(&wc); - - win->Win = CreateWindowEx(0, - wc.lpszClassName, - "sharedtex_mt", - WS_SIZEBOX | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - xpos, - ypos, - width, - height, - NULL, - NULL, - wc.hInstance, - (LPVOID) win->Id); - if (!win->Win) { - Error("Couldn't create window"); - } - - win->sharedContext = sCtx; - - ShowWindow(win->Win, SW_SHOW); - - return win; -} - - -static void -InitGLstuff(void) -{ - glGenTextures(3, Textures); - - /* setup first texture object */ - { - GLubyte image[16][16][4]; - GLint i, j; - glBindTexture(GL_TEXTURE_2D, Textures[0]); - - /* red/white checkerboard */ - for (i = 0; i < 16; i++) { - for (j = 0; j < 16; j++) { - if ((i ^ j) & 1) { - image[i][j][0] = 255; - image[i][j][1] = 255; - image[i][j][2] = 255; - image[i][j][3] = 255; - } - else { - image[i][j][0] = 255; - image[i][j][1] = 0; - image[i][j][2] = 0; - image[i][j][3] = 255; - } - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, - GL_UNSIGNED_BYTE, image); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - } - - /* setup second texture object */ - { - GLubyte image[8][8][3]; - GLint i, j; - glBindTexture(GL_TEXTURE_2D, Textures[1]); - - /* green/yellow checkerboard */ - for (i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) { - if ((i ^ j) & 1) { - image[i][j][0] = 0; - image[i][j][1] = 255; - image[i][j][2] = 0; - } - else { - image[i][j][0] = 255; - image[i][j][1] = 255; - image[i][j][2] = 0; - } - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 2); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 8, 8, 0, GL_RGB, - GL_UNSIGNED_BYTE, image); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - } - - /* setup second texture object */ - { - GLubyte image[4][4][3]; - GLint i, j; - glBindTexture(GL_TEXTURE_2D, Textures[2]); - - /* blue/gray checkerboard */ - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - if ((i ^ j) & 1) { - image[i][j][0] = 0; - image[i][j][1] = 0; - image[i][j][2] = 255; - } - else { - image[i][j][0] = 200; - image[i][j][1] = 200; - image[i][j][2] = 200; - } - } - } - - glPixelStorei(GL_UNPACK_ALIGNMENT, 2); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, - GL_UNSIGNED_BYTE, image); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - } - - /* Now make the cube object display list */ - - printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); - printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION)); - printf("GL_VENDOR: %s\n", (char *) glGetString(GL_VENDOR)); -} - -static void -Redraw(struct window *h) -{ - EnterCriticalSection(&h->drawMutex); - if (!wglMakeCurrent(h->hDC, h->Context)) { - LeaveCriticalSection(&h->drawMutex); - Error("wglMakeCurrent failed in Redraw"); - return; - } - - h->Angle += 1.0; - - glShadeModel(GL_FLAT); - glClearColor(0.25, 0.25, 0.25, 1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glEnable(GL_TEXTURE_2D); - glEnable(GL_DEPTH_TEST); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - glColor3f(1, 1, 1); - - glPushMatrix(); - if (h->Id == 0) - glRotatef(h->Angle, 0, 1, -1); - else if (h->Id == 1) - glRotatef(-(h->Angle), 0, 1, -1); - else if (h->Id == 2) - glRotatef(h->Angle, 0, 1, 1); - else if (h->Id == 3) - glRotatef(-(h->Angle), 0, 1, 1); - glBindTexture(GL_TEXTURE_2D, Textures[0]); - glBegin(GL_POLYGON); - glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); - glTexCoord2f(1, 0); glVertex3f(-1, 1, -1); - glTexCoord2f(1, 1); glVertex3f(-1, 1, 1); - glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); - glEnd(); - glBegin(GL_POLYGON); - glTexCoord2f(0, 0); glVertex3f(1, -1, -1); - glTexCoord2f(1, 0); glVertex3f(1, 1, -1); - glTexCoord2f(1, 1); glVertex3f(1, 1, 1); - glTexCoord2f(0, 1); glVertex3f(1, -1, 1); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, Textures[1]); - glBegin(GL_POLYGON); - glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); - glTexCoord2f(1, 0); glVertex3f( 1, -1, -1); - glTexCoord2f(1, 1); glVertex3f( 1, -1, 1); - glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); - glEnd(); - glBegin(GL_POLYGON); - glTexCoord2f(0, 0); glVertex3f(-1, 1, -1); - glTexCoord2f(1, 0); glVertex3f( 1, 1, -1); - glTexCoord2f(1, 1); glVertex3f( 1, 1, 1); - glTexCoord2f(0, 1); glVertex3f(-1, 1, 1); - glEnd(); - - glBindTexture(GL_TEXTURE_2D, Textures[2]); - glBegin(GL_POLYGON); - glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); - glTexCoord2f(1, 0); glVertex3f( 1, -1, -1); - glTexCoord2f(1, 1); glVertex3f( 1, 1, -1); - glTexCoord2f(0, 1); glVertex3f(-1, 1, -1); - glEnd(); - glBegin(GL_POLYGON); - glTexCoord2f(0, 0); glVertex3f(-1, -1, 1); - glTexCoord2f(1, 0); glVertex3f( 1, -1, 1); - glTexCoord2f(1, 1); glVertex3f( 1, 1, 1); - glTexCoord2f(0, 1); glVertex3f(-1, 1, 1); - glEnd(); - - glPopMatrix(); - - SwapBuffers(h->hDC); - - if (!wglMakeCurrent(NULL, NULL)) { - Error("wglMakeCurrent failed in Redraw"); - } - LeaveCriticalSection(&h->drawMutex); -} - -static DWORD WINAPI -threadRunner (void *arg) -{ - struct thread_init_arg *tia = (struct thread_init_arg *) arg; - struct window *win; - PIXELFORMATDESCRIPTOR pfd = {0}; - int visinfo; - - win = &Windows[tia->id]; - - win->hDC = GetDC(win->Win); - if (!win->hDC) { - Error("Couldn't obtain HDC"); - } - - /* Wait for the previous thread */ - if(tia->id > 0) - WaitForSingleObject(Windows[tia->id - 1].hEventInitialised, INFINITE); - - pfd.cColorBits = 24; - pfd.cDepthBits = 24; - pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - pfd.iLayerType = PFD_MAIN_PLANE; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - - visinfo = ChoosePixelFormat(win->hDC, &pfd); - if (!visinfo) { - Error("Unable to find RGB, Z, double-buffered visual"); - } - - SetPixelFormat(win->hDC, visinfo, &pfd); - win->Context = wglCreateContext(win->hDC); - if (!win->Context) { - Error("Couldn't create WGL context"); - } - - if (win->sharedContext) { - if(!wglShareLists(win->sharedContext, win->Context)) - Error("Couldn't share WGL context lists"); - } - - SetEvent(win->hEventInitialised); - - /* Wait for all threads to initialize otherwise wglShareLists will fail */ - if(tia->id < NumWindows - 1) - WaitForSingleObject(Windows[NumWindows - 1].hEventInitialised, INFINITE); - - SendMessage(win->Win, WM_SIZE, 0, 0); - - while (1) { - MSG msg; - - /* wait 1 ms for signal either to exit or process messages */ - switch (MsgWaitForMultipleObjects(1, &terminate, FALSE, 1, QS_ALLINPUT)) { - case WAIT_OBJECT_0: - SendMessage(win->Win, WM_CLOSE, 0, 0); - break; - case WAIT_OBJECT_0 + 1: - break; - } - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) { - return 0; - } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - Redraw(win); - } - - return 0; -} - -static void -Resize(struct window *h, unsigned int width, unsigned int height) -{ - if (!h->Context) - return; - - EnterCriticalSection(&h->drawMutex); - - if (!wglMakeCurrent(h->hDC, h->Context)) { - LeaveCriticalSection(&h->drawMutex); - Error("wglMakeCurrent failed in Resize()"); - return; - } - - glViewport(0, 0, width, height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-1, 1, -1, 1, 2, 10); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0, 0, -4.5); - if (!wglMakeCurrent(NULL, NULL)) { - Error("wglMakeCurrent failed in Resize()"); - } - LeaveCriticalSection(&h->drawMutex); -} - -int -main(int argc, char *argv[]) -{ - struct thread_init_arg tia[MAX_WINDOWS]; - struct window *h[MAX_WINDOWS]; - HANDLE threads[MAX_WINDOWS]; - int i; - - terminate = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (initMainthread()) - return -1; - - /* four windows and contexts sharing display lists and texture objects */ - h[0] = AddWindow( 10, 10, gCtx); - h[1] = AddWindow(330, 10, gCtx); - h[2] = AddWindow( 10, 350, gCtx); - h[3] = AddWindow(330, 350, gCtx); - - for (i = 0; i < NumWindows; i++) { - Windows[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL); - } - - for (i = 0; i < NumWindows; i++) { - DWORD id; - - tia[i].id = i; - threads[i] = CreateThread(NULL, 0, threadRunner, &tia[i], 0, &id); - - WaitForSingleObject(Windows[i].hEventInitialised, INFINITE); - } - - if (!wglMakeCurrent(gHDC, gCtx)) { - Error("wglMakeCurrent failed for init thread."); - return -1; - } - - InitGLstuff(); - - while (1) { - MSG msg; - - /* wait 1 ms for signal either to exit or process messages */ - switch (MsgWaitForMultipleObjects(NumWindows, threads, TRUE, 1, QS_ALLINPUT)) { - case WAIT_OBJECT_0: - return 0; - } - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) { - return 0; - } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - return 0; -} diff --git a/progs/wgl/wglinfo.c b/progs/wgl/wglinfo.c deleted file mode 100644 index 864372c2f94..00000000000 --- a/progs/wgl/wglinfo.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Copyright (C) 2009 VMware, Inc. - * Copyright (C) 1999-2006 Brian Paul - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -/* - * This program is a work-alike of the GLX glxinfo program. - * Command line options: - * -t print wide table - * -v print verbose information - * -b only print ID of "best" visual on screen 0 - * -l print interesting OpenGL limits (added 5 Sep 2002) - */ - -#include <windows.h> - -#include <GL/gl.h> -#include <GL/glext.h> -#include <GL/wglext.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - - -typedef enum -{ - Normal, - Wide, - Verbose -} InfoMode; - - -/* - * Print a list of extensions, with word-wrapping. - */ -static void -print_extension_list(const char *ext) -{ - const char *indentString = " "; - const int indent = 4; - const int max = 79; - int width, i, j; - - if (!ext || !ext[0]) - return; - - width = indent; - printf(indentString); - i = j = 0; - while (1) { - if (ext[j] == ' ' || ext[j] == 0) { - /* found end of an extension name */ - const int len = j - i; - if (width + len > max) { - /* start a new line */ - printf("\n"); - width = indent; - printf(indentString); - } - /* print the extension name between ext[i] and ext[j] */ - while (i < j) { - printf("%c", ext[i]); - i++; - } - /* either we're all done, or we'll continue with next extension */ - width += len + 1; - if (ext[j] == 0) { - break; - } - else { - i++; - j++; - if (ext[j] == 0) - break; - printf(", "); - width += 2; - } - } - j++; - } - printf("\n"); -} - - -/** - * Print interesting limits for vertex/fragment programs. - */ -static void -print_program_limits(GLenum target) -{ -#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program) - struct token_name { - GLenum token; - const char *name; - }; - static const struct token_name limits[] = { - { GL_MAX_PROGRAM_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" }, - { GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" }, - { GL_MAX_PROGRAM_TEMPORARIES_ARB, "GL_MAX_PROGRAM_TEMPORARIES_ARB" }, - { GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" }, - { GL_MAX_PROGRAM_PARAMETERS_ARB, "GL_MAX_PROGRAM_PARAMETERS_ARB" }, - { GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" }, - { GL_MAX_PROGRAM_ATTRIBS_ARB, "GL_MAX_PROGRAM_ATTRIBS_ARB" }, - { GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" }, - { GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" }, - { GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" }, - { GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" }, - { GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" }, - { GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" }, - { GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" }, - { GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" }, - { GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" }, - { GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" }, - { GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" }, - { (GLenum) 0, NULL } - }; - PFNGLGETPROGRAMIVARBPROC GetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC) - wglGetProcAddress("glGetProgramivARB"); - GLint max[1]; - int i; - - if (target == GL_VERTEX_PROGRAM_ARB) { - printf(" GL_VERTEX_PROGRAM_ARB:\n"); - } - else if (target == GL_FRAGMENT_PROGRAM_ARB) { - printf(" GL_FRAGMENT_PROGRAM_ARB:\n"); - } - else { - return; /* something's wrong */ - } - - for (i = 0; limits[i].token; i++) { - GetProgramivARB_func(target, limits[i].token, max); - if (glGetError() == GL_NO_ERROR) { - printf(" %s = %d\n", limits[i].name, max[0]); - } - } -#endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */ -} - - -/** - * Print interesting limits for vertex/fragment shaders. - */ -static void -print_shader_limits(GLenum target) -{ - struct token_name { - GLenum token; - const char *name; - }; -#if defined(GL_ARB_vertex_shader) - static const struct token_name vertex_limits[] = { - { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" }, - { GL_MAX_VARYING_FLOATS_ARB, "GL_MAX_VARYING_FLOATS_ARB" }, - { GL_MAX_VERTEX_ATTRIBS_ARB, "GL_MAX_VERTEX_ATTRIBS_ARB" }, - { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, - { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" }, - { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" }, - { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" }, - { (GLenum) 0, NULL } - }; -#endif -#if defined(GL_ARB_fragment_shader) - static const struct token_name fragment_limits[] = { - { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" }, - { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" }, - { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, - { (GLenum) 0, NULL } - }; -#endif - GLint max[1]; - int i; - -#if defined(GL_ARB_vertex_shader) - if (target == GL_VERTEX_SHADER_ARB) { - printf(" GL_VERTEX_SHADER_ARB:\n"); - for (i = 0; vertex_limits[i].token; i++) { - glGetIntegerv(vertex_limits[i].token, max); - if (glGetError() == GL_NO_ERROR) { - printf(" %s = %d\n", vertex_limits[i].name, max[0]); - } - } - } -#endif -#if defined(GL_ARB_fragment_shader) - if (target == GL_FRAGMENT_SHADER_ARB) { - printf(" GL_FRAGMENT_SHADER_ARB:\n"); - for (i = 0; fragment_limits[i].token; i++) { - glGetIntegerv(fragment_limits[i].token, max); - if (glGetError() == GL_NO_ERROR) { - printf(" %s = %d\n", fragment_limits[i].name, max[0]); - } - } - } -#endif -} - - -/** - * Print interesting OpenGL implementation limits. - */ -static void -print_limits(const char *extensions) -{ - struct token_name { - GLuint count; - GLenum token; - const char *name; - }; - static const struct token_name limits[] = { - { 1, GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH" }, - { 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH" }, - { 1, GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES" }, - { 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH, "GL_MAX_COLOR_MATRIX_STACK_DEPTH" }, - { 1, GL_MAX_ELEMENTS_VERTICES, "GL_MAX_ELEMENTS_VERTICES" }, - { 1, GL_MAX_ELEMENTS_INDICES, "GL_MAX_ELEMENTS_INDICES" }, - { 1, GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER" }, - { 1, GL_MAX_LIGHTS, "GL_MAX_LIGHTS" }, - { 1, GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING" }, - { 1, GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH" }, - { 1, GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH" }, - { 1, GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE" }, - { 1, GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH" }, - { 1, GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH" }, - { 1, GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE" }, - { 1, GL_MAX_3D_TEXTURE_SIZE, "GL_MAX_3D_TEXTURE_SIZE" }, - { 2, GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS" }, - { 2, GL_ALIASED_LINE_WIDTH_RANGE, "GL_ALIASED_LINE_WIDTH_RANGE" }, - { 2, GL_SMOOTH_LINE_WIDTH_RANGE, "GL_SMOOTH_LINE_WIDTH_RANGE" }, - { 2, GL_ALIASED_POINT_SIZE_RANGE, "GL_ALIASED_POINT_SIZE_RANGE" }, - { 2, GL_SMOOTH_POINT_SIZE_RANGE, "GL_SMOOTH_POINT_SIZE_RANGE" }, -#if defined(GL_ARB_texture_cube_map) - { 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB" }, -#endif -#if defined(GLX_NV_texture_rectangle) - { 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV" }, -#endif -#if defined(GL_ARB_texture_compression) - { 1, GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB" }, -#endif -#if defined(GL_ARB_multitexture) - { 1, GL_MAX_TEXTURE_UNITS_ARB, "GL_MAX_TEXTURE_UNITS_ARB" }, -#endif -#if defined(GL_EXT_texture_lod_bias) - { 1, GL_MAX_TEXTURE_LOD_BIAS_EXT, "GL_MAX_TEXTURE_LOD_BIAS_EXT" }, -#endif -#if defined(GL_EXT_texture_filter_anisotropic) - { 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT" }, -#endif -#if defined(GL_ARB_draw_buffers) - { 1, GL_MAX_DRAW_BUFFERS_ARB, "GL_MAX_DRAW_BUFFERS_ARB" }, -#endif - { 0, (GLenum) 0, NULL } - }; - GLint i, max[2]; - - printf("OpenGL limits:\n"); - for (i = 0; limits[i].count; i++) { - glGetIntegerv(limits[i].token, max); - if (glGetError() == GL_NO_ERROR) { - if (limits[i].count == 1) - printf(" %s = %d\n", limits[i].name, max[0]); - else /* XXX fix if we ever query something with more than 2 values */ - printf(" %s = %d, %d\n", limits[i].name, max[0], max[1]); - } - } - -#if defined(GL_EXT_convolution) - { - PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC glGetConvolutionParameterivEXT_func = - (PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC)wglGetProcAddress("glGetConvolutionParameterivEXT"); - if(glGetConvolutionParameterivEXT_func) { - /* these don't fit into the above mechanism, unfortunately */ - glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_WIDTH, max); - glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_HEIGHT, max+1); - if (glGetError() == GL_NONE) { - printf(" GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max[0], max[1]); - } - } - } -#endif - -#if defined(GL_ARB_vertex_program) - if (strstr(extensions, "GL_ARB_vertex_program")) { - print_program_limits(GL_VERTEX_PROGRAM_ARB); - } -#endif -#if defined(GL_ARB_fragment_program) - if (strstr(extensions, "GL_ARB_fragment_program")) { - print_program_limits(GL_FRAGMENT_PROGRAM_ARB); - } -#endif -#if defined(GL_ARB_vertex_shader) - if (strstr(extensions, "GL_ARB_vertex_shader")) { - print_shader_limits(GL_VERTEX_SHADER_ARB); - } -#endif -#if defined(GL_ARB_fragment_shader) - if (strstr(extensions, "GL_ARB_fragment_shader")) { - print_shader_limits(GL_FRAGMENT_SHADER_ARB); - } -#endif -} - - -static LRESULT CALLBACK -WndProc(HWND hWnd, - UINT uMsg, - WPARAM wParam, - LPARAM lParam ) -{ - switch (uMsg) { - case WM_DESTROY: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hWnd, uMsg, wParam, lParam); - } - - return 0; -} - - -static void -print_screen_info(HDC _hdc, GLboolean limits) -{ - WNDCLASS wc; - HWND win; - HGLRC ctx; - int visinfo; - HDC hdc; - PIXELFORMATDESCRIPTOR pfd; - - memset(&wc, 0, sizeof wc); - wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.lpfnWndProc = WndProc; - wc.lpszClassName = "wglinfo"; - wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - RegisterClass(&wc); - - win = CreateWindowEx(0, - wc.lpszClassName, - "wglinfo", - WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - NULL, - NULL, - wc.hInstance, - NULL); - if (!win) { - fprintf(stderr, "Couldn't create window"); - return; - } - - hdc = GetDC(win); - if (!hdc) { - fprintf(stderr, "Couldn't obtain HDC"); - return; - } - - pfd.cColorBits = 3; - pfd.cRedBits = 1; - pfd.cGreenBits = 1; - pfd.cBlueBits = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - pfd.iLayerType = PFD_MAIN_PLANE; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - - visinfo = ChoosePixelFormat(hdc, &pfd); - if (!visinfo) { - pfd.dwFlags |= PFD_DOUBLEBUFFER; - visinfo = ChoosePixelFormat(hdc, &pfd); - } - - if (!visinfo) { - fprintf(stderr, "Error: couldn't find RGB WGL visual\n"); - return; - } - - SetPixelFormat(hdc, visinfo, &pfd); - ctx = wglCreateContext(hdc); - if (!ctx) { - fprintf(stderr, "Error: wglCreateContext failed\n"); - return; - } - - if (wglMakeCurrent(hdc, ctx)) { -#if defined(WGL_ARB_extensions_string) - PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB_func = - (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); -#endif - const char *glVendor = (const char *) glGetString(GL_VENDOR); - const char *glRenderer = (const char *) glGetString(GL_RENDERER); - const char *glVersion = (const char *) glGetString(GL_VERSION); - const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS); - -#if defined(WGL_ARB_extensions_string) - if(wglGetExtensionsStringARB_func) { - const char *wglExtensions = wglGetExtensionsStringARB_func(hdc); - if(wglExtensions) { - printf("WGL extensions:\n"); - print_extension_list(wglExtensions); - } - } -#endif - printf("OpenGL vendor string: %s\n", glVendor); - printf("OpenGL renderer string: %s\n", glRenderer); - printf("OpenGL version string: %s\n", glVersion); -#ifdef GL_VERSION_2_0 - if (glVersion[0] >= '2' && glVersion[1] == '.') { - char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); - printf("OpenGL shading language version string: %s\n", v); - } -#endif - - printf("OpenGL extensions:\n"); - print_extension_list(glExtensions); - if (limits) - print_limits(glExtensions); - } - else { - fprintf(stderr, "Error: wglMakeCurrent failed\n"); - } - - DestroyWindow(win); -} - - -static const char * -visual_render_type_name(BYTE iPixelType) -{ - switch (iPixelType) { - case PFD_TYPE_RGBA: - return "rgba"; - case PFD_TYPE_COLORINDEX: - return "ci"; - default: - return ""; - } -} - -static void -print_visual_attribs_verbose(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd) -{ - printf("Visual ID: %x generic=%d native=%d\n", - iPixelFormat, - ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0, - ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0); - printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n", - 0 /* ppfd->bufferSize */, 0 /* ppfd->level */, - visual_render_type_name(ppfd->iPixelType), - ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0, - ppfd->dwFlags & PFD_STEREO ? 1 : 0); - printf(" rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n", - ppfd->cRedBits, ppfd->cGreenBits, - ppfd->cBlueBits, ppfd->cAlphaBits); - printf(" cAuxBuffers=%d cDepthBits=%d cStencilBits=%d\n", - ppfd->cAuxBuffers, ppfd->cDepthBits, ppfd->cStencilBits); - printf(" accum: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n", - ppfd->cAccumRedBits, ppfd->cAccumGreenBits, - ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits); - printf(" multiSample=%d multiSampleBuffers=%d\n", - 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */); -} - - -static void -print_visual_attribs_short_header(void) -{ - printf(" visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav\n"); - printf(" id gen nat sp sz l ci b ro r g b a bf th cl r g b a ns b eat\n"); - printf("-----------------------------------------------------------------------\n"); -} - - -static void -print_visual_attribs_short(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd) -{ - char *caveat = "None"; - - printf("0x%02x %2d %2d %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d", - iPixelFormat, - ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0, - ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0, - 0, - 0 /* ppfd->bufferSize */, - 0 /* ppfd->level */, - ppfd->iPixelType == PFD_TYPE_RGBA ? 'r' : ' ', - ppfd->iPixelType == PFD_TYPE_COLORINDEX ? 'c' : ' ', - ppfd->dwFlags & PFD_DOUBLEBUFFER ? 'y' : '.', - ppfd->dwFlags & PFD_STEREO ? 'y' : '.', - ppfd->cRedBits, ppfd->cGreenBits, - ppfd->cBlueBits, ppfd->cAlphaBits, - ppfd->cAuxBuffers, - ppfd->cDepthBits, - ppfd->cStencilBits - ); - - printf(" %2d %2d %2d %2d %2d %1d %s\n", - ppfd->cAccumRedBits, ppfd->cAccumGreenBits, - ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits, - 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */, - caveat - ); -} - - -static void -print_visual_attribs_long_header(void) -{ - printf("Vis Vis Visual Trans buff lev render DB ste r g b a aux dep ste accum buffers MS MS\n"); - printf(" ID Depth Type parent size el type reo sz sz sz sz buf th ncl r g b a num bufs\n"); - printf("----------------------------------------------------------------------------------------------------\n"); -} - - -static void -print_visual_attribs_long(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd) -{ - printf("0x%2x %2d %11d %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d", - iPixelFormat, - ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0, - ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0, - 0, - 0 /* ppfd->bufferSize */, - 0 /* ppfd->level */, - visual_render_type_name(ppfd->iPixelType), - ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0, - ppfd->dwFlags & PFD_STEREO ? 1 : 0, - ppfd->cRedBits, ppfd->cGreenBits, - ppfd->cBlueBits, ppfd->cAlphaBits - ); - - printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n", - ppfd->cAuxBuffers, - ppfd->cDepthBits, - ppfd->cStencilBits, - ppfd->cAccumRedBits, ppfd->cAccumGreenBits, - ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits, - 0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */ - ); -} - - -static void -print_visual_info(HDC hdc, InfoMode mode) -{ - PIXELFORMATDESCRIPTOR pfd; - int numVisuals, numWglVisuals; - int i; - - numVisuals = DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL); - if (numVisuals == 0) - return; - - numWglVisuals = 0; - for (i = 0; i < numVisuals; i++) { - if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd)) - continue; - - //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL)) - // continue; - - ++numWglVisuals; - } - - printf("%d WGL Visuals\n", numWglVisuals); - - if (mode == Normal) - print_visual_attribs_short_header(); - else if (mode == Wide) - print_visual_attribs_long_header(); - - for (i = 0; i < numVisuals; i++) { - if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd)) - continue; - - //if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL)) - // continue; - - if (mode == Verbose) - print_visual_attribs_verbose(i, &pfd); - else if (mode == Normal) - print_visual_attribs_short(i, &pfd); - else if (mode == Wide) - print_visual_attribs_long(i, &pfd); - } - printf("\n"); -} - - -/* - * Examine all visuals to find the so-called best one. - * We prefer deepest RGBA buffer with depth, stencil and accum - * that has no caveats. - */ -static int -find_best_visual(HDC hdc) -{ -#if 0 - XVisualInfo theTemplate; - XVisualInfo *visuals; - int numVisuals; - long mask; - int i; - struct visual_attribs bestVis; - - /* get list of all visuals on this screen */ - theTemplate.screen = scrnum; - mask = VisualScreenMask; - visuals = XGetVisualInfo(hdc, mask, &theTemplate, &numVisuals); - - /* init bestVis with first visual info */ - get_visual_attribs(hdc, &visuals[0], &bestVis); - - /* try to find a "better" visual */ - for (i = 1; i < numVisuals; i++) { - struct visual_attribs vis; - - get_visual_attribs(hdc, &visuals[i], &vis); - - /* always skip visuals with caveats */ - if (vis.visualCaveat != GLX_NONE_EXT) - continue; - - /* see if this vis is better than bestVis */ - if ((!bestVis.supportsGL && vis.supportsGL) || - (bestVis.visualCaveat != GLX_NONE_EXT) || - (bestVis.iPixelType != vis.iPixelType) || - (!bestVis.doubleBuffer && vis.doubleBuffer) || - (bestVis.cRedBits < vis.cRedBits) || - (bestVis.cGreenBits < vis.cGreenBits) || - (bestVis.cBlueBits < vis.cBlueBits) || - (bestVis.cAlphaBits < vis.cAlphaBits) || - (bestVis.cDepthBits < vis.cDepthBits) || - (bestVis.cStencilBits < vis.cStencilBits) || - (bestVis.cAccumRedBits < vis.cAccumRedBits)) { - /* found a better visual */ - bestVis = vis; - } - } - - return bestVis.id; -#else - return 0; -#endif -} - - -static void -usage(void) -{ - printf("Usage: glxinfo [-v] [-t] [-h] [-i] [-b] [-display <dname>]\n"); - printf("\t-v: Print visuals info in verbose form.\n"); - printf("\t-t: Print verbose table.\n"); - printf("\t-h: This information.\n"); - printf("\t-b: Find the 'best' visual and print it's number.\n"); - printf("\t-l: Print interesting OpenGL limits.\n"); -} - - -int -main(int argc, char *argv[]) -{ - HDC hdc; - InfoMode mode = Normal; - GLboolean findBest = GL_FALSE; - GLboolean limits = GL_FALSE; - int i; - - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-t") == 0) { - mode = Wide; - } - else if (strcmp(argv[i], "-v") == 0) { - mode = Verbose; - } - else if (strcmp(argv[i], "-b") == 0) { - findBest = GL_TRUE; - } - else if (strcmp(argv[i], "-l") == 0) { - limits = GL_TRUE; - } - else if (strcmp(argv[i], "-h") == 0) { - usage(); - return 0; - } - else { - printf("Unknown option `%s'\n", argv[i]); - usage(); - return 0; - } - } - - hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); - - if (findBest) { - int b; - b = find_best_visual(hdc); - printf("%d\n", b); - } - else { - print_screen_info(hdc, limits); - printf("\n"); - print_visual_info(hdc, mode); - } - - return 0; -} diff --git a/progs/wgl/wglthreads/wglthreads.c b/progs/wgl/wglthreads/wglthreads.c deleted file mode 100644 index 27dca10f2a0..00000000000 --- a/progs/wgl/wglthreads/wglthreads.c +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Copyright (C) 2000 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * Port to windows done by Michal Krol. - */ - - -/* - * This program tests WGL thread safety. - * Command line options: - * -h Print usage - * -l Enable application-side locking - * -n <num threads> Number of threads to create (default is 2) - * -t Use texture mapping - * -s Force single-threaded. - * - * Brian Paul 20 July 2000 - */ - - -/* - * Notes: - * - Each thread gets its own WGL context. - * - * - The WGL contexts share texture objects. - * - * - When 't' is pressed to update the texture image, the window/thread which - * has input focus is signalled to change the texture. The other threads - * should see the updated texture the next time they call glBindTexture. - */ - - -#include <assert.h> -#include <windows.h> -#include <GL/gl.h> -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#pragma comment(lib, "opengl32.lib") - - -/* - * Each window/thread/context: - */ -struct winthread { - int Index; - HANDLE Thread; - HWND Win; - HDC hDC; - HGLRC Context; - float Angle; - int WinWidth, WinHeight; - GLboolean NewSize; - HANDLE hEventInitialised; - GLboolean Initialized; - GLboolean MakeNewTexture; - HANDLE hEventRedraw; -}; - - -#define MAX_WINTHREADS 100 -static struct winthread WinThreads[MAX_WINTHREADS]; -static int NumWinThreads = 2; -static HANDLE ExitEvent = NULL; - -static GLboolean Locking = 0; -static GLboolean Texture = GL_FALSE; -static GLboolean SingleThreaded = GL_FALSE; -static GLuint TexObj = 12; -static GLboolean Animate = GL_TRUE; - -static CRITICAL_SECTION Mutex; - - -static void -Error(const char *msg) -{ - fprintf(stderr, "Error: %s\n", msg); - exit(1); -} - - -static void -signal_redraw(void) -{ - int i; - - for (i = 0; i < NumWinThreads; i++) { - SetEvent(WinThreads[i].hEventRedraw); - } -} - - -static void -MakeNewTexture(struct winthread *wt) -{ -#define TEX_SIZE 128 - static float step = 0.0f; - GLfloat image[TEX_SIZE][TEX_SIZE][4]; - GLint width; - int i, j; - - for (j = 0; j < TEX_SIZE; j++) { - for (i = 0; i < TEX_SIZE; i++) { - float dt = 5.0f * (j - 0.5f * TEX_SIZE) / TEX_SIZE; - float ds = 5.0f * (i - 0.5f * TEX_SIZE) / TEX_SIZE; - float r = dt * dt + ds * ds + step; - image[j][i][0] = - image[j][i][1] = - image[j][i][2] = 0.75f + 0.25f * (float) cos(r); - image[j][i][3] = 1.0f; - } - } - - step += 0.5; - - glBindTexture(GL_TEXTURE_2D, TexObj); - - glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); - if (width) { - assert(width == TEX_SIZE); - /* sub-tex replace */ - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEX_SIZE, TEX_SIZE, - GL_RGBA, GL_FLOAT, image); - } - else { - /* create new */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0, - GL_RGBA, GL_FLOAT, image); - } -} - - - -/* draw a colored cube */ -static void -draw_object(void) -{ - glPushMatrix(); - glScalef(0.75f, 0.75f, 0.75f); - - glColor3f(1, 0, 0); - - if (Texture) { - glBindTexture(GL_TEXTURE_2D, TexObj); - glEnable(GL_TEXTURE_2D); - } - else { - glDisable(GL_TEXTURE_2D); - } - - glBegin(GL_QUADS); - - /* -X */ - glColor3f(0, 1, 1); - glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); - glTexCoord2f(1, 0); glVertex3f(-1, 1, -1); - glTexCoord2f(1, 1); glVertex3f(-1, 1, 1); - glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); - - /* +X */ - glColor3f(1, 0, 0); - glTexCoord2f(0, 0); glVertex3f(1, -1, -1); - glTexCoord2f(1, 0); glVertex3f(1, 1, -1); - glTexCoord2f(1, 1); glVertex3f(1, 1, 1); - glTexCoord2f(0, 1); glVertex3f(1, -1, 1); - - /* -Y */ - glColor3f(1, 0, 1); - glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); - glTexCoord2f(1, 0); glVertex3f( 1, -1, -1); - glTexCoord2f(1, 1); glVertex3f( 1, -1, 1); - glTexCoord2f(0, 1); glVertex3f(-1, -1, 1); - - /* +Y */ - glColor3f(0, 1, 0); - glTexCoord2f(0, 0); glVertex3f(-1, 1, -1); - glTexCoord2f(1, 0); glVertex3f( 1, 1, -1); - glTexCoord2f(1, 1); glVertex3f( 1, 1, 1); - glTexCoord2f(0, 1); glVertex3f(-1, 1, 1); - - /* -Z */ - glColor3f(1, 1, 0); - glTexCoord2f(0, 0); glVertex3f(-1, -1, -1); - glTexCoord2f(1, 0); glVertex3f( 1, -1, -1); - glTexCoord2f(1, 1); glVertex3f( 1, 1, -1); - glTexCoord2f(0, 1); glVertex3f(-1, 1, -1); - - /* +Y */ - glColor3f(0, 0, 1); - glTexCoord2f(0, 0); glVertex3f(-1, -1, 1); - glTexCoord2f(1, 0); glVertex3f( 1, -1, 1); - glTexCoord2f(1, 1); glVertex3f( 1, 1, 1); - glTexCoord2f(0, 1); glVertex3f(-1, 1, 1); - - glEnd(); - - glPopMatrix(); -} - - -/* signal resize of given window */ -static void -resize(struct winthread *wt, int w, int h) -{ - wt->NewSize = GL_TRUE; - wt->WinWidth = w; - wt->WinHeight = h; - if (!Animate) - SetEvent(wt->hEventRedraw); -} - - -/* - * We have an instance of this for each thread. - */ -static void -draw_loop(struct winthread *wt) -{ - while (1) { - GLboolean draw = Animate; - MSG msg; - - if (Animate) { - /* wait 5 ms for signal either to exit or process messages */ - switch (MsgWaitForMultipleObjects(1, &ExitEvent, FALSE, 5, QS_ALLINPUT)) { - case WAIT_OBJECT_0: - SendMessage(wt->Win, WM_CLOSE, 0, 0); - break; - case WAIT_OBJECT_0 + 1: - break; - } - } - else { - HANDLE events[2]; - - events[0] = wt->hEventRedraw; - events[1] = ExitEvent; - - /* wait for signal either to draw, exit or process messages */ - switch (MsgWaitForMultipleObjects(2, events, FALSE, INFINITE, QS_ALLINPUT)) { - case WAIT_OBJECT_0: - draw = GL_TRUE; - break; - case WAIT_OBJECT_0 + 1: - SendMessage(wt->Win, WM_CLOSE, 0, 0); - break; - case WAIT_OBJECT_0 + 2: - break; - } - } - - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) { - return; - } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - if (!draw) - continue; - - if (Locking) - EnterCriticalSection(&Mutex); - - wglMakeCurrent(wt->hDC, wt->Context); - - if (!wt->Initialized) { - printf("wglthreads: %d: GL_RENDERER = %s\n", wt->Index, - (char *) glGetString(GL_RENDERER)); - if (Texture /*&& wt->Index == 0*/) { - MakeNewTexture(wt); - } - wt->Initialized = GL_TRUE; - } - - if (Locking) - LeaveCriticalSection(&Mutex); - - glEnable(GL_DEPTH_TEST); - - if (wt->NewSize) { - GLfloat w = (float) wt->WinWidth / (float) wt->WinHeight; - glViewport(0, 0, wt->WinWidth, wt->WinHeight); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-w, w, -1.0, 1.0, 1.5, 10); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0, 0, -2.5); - wt->NewSize = GL_FALSE; - } - - if (wt->MakeNewTexture) { - MakeNewTexture(wt); - wt->MakeNewTexture = GL_FALSE; - } - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glPushMatrix(); - glRotatef(wt->Angle, 0, 1, 0); - glRotatef(wt->Angle, 1, 0, 0); - glScalef(0.7f, 0.7f, 0.7f); - draw_object(); - glPopMatrix(); - - if (Locking) - EnterCriticalSection(&Mutex); - - SwapBuffers(wt->hDC); - - if (Locking) - LeaveCriticalSection(&Mutex); - - wt->Angle += 1.0; - } -} - - -static void -keypress(WPARAM keySym, struct winthread *wt) -{ - switch (keySym) { - case VK_ESCAPE: - /* tell all threads to exit */ - SetEvent(ExitEvent); - /*printf("exit draw_loop %d\n", wt->Index);*/ - return; - case 't': - case 'T': - if (Texture) { - wt->MakeNewTexture = GL_TRUE; - if (!Animate) - signal_redraw(); - } - break; - case 'a': - case 'A': - Animate = !Animate; - if (Animate) - signal_redraw(); - break; - case 's': - case 'S': - if (!Animate) - signal_redraw(); - break; - default: - ; /* nop */ - } -} - - -static LRESULT CALLBACK -WndProc(HWND hWnd, - UINT uMsg, - WPARAM wParam, - LPARAM lParam ) -{ - int i; - - switch (uMsg) { - case WM_KEYDOWN: - for (i = 0; i < NumWinThreads; i++) { - struct winthread *wt = &WinThreads[i]; - - if (hWnd == wt->Win) { - keypress(wParam, wt); - break; - } - } - break; - case WM_SIZE: - for (i = 0; i < NumWinThreads; i++) { - struct winthread *wt = &WinThreads[i]; - - if (hWnd == wt->Win) { - RECT r; - - GetClientRect(hWnd, &r); - resize(wt, r.right, r.bottom); - break; - } - } - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hWnd, uMsg, wParam, lParam); - } - - return 0; -} - -/* - * we'll call this once for each thread, before the threads are created. - */ -static void -create_window(struct winthread *wt, HGLRC shareCtx) -{ - WNDCLASS wc = {0}; - int width = 160, height = 160; - int xpos = (wt->Index % 8) * (width + 10); - int ypos = (wt->Index / 8) * (width + 20); - HWND win; - HDC hdc; - PIXELFORMATDESCRIPTOR pfd = {0}; - int visinfo; - HGLRC ctx; - - wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wc.lpfnWndProc = WndProc; - wc.lpszClassName = "wglthreads"; - wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - RegisterClass(&wc); - - win = CreateWindowEx(0, - wc.lpszClassName, - "wglthreads", - WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TILEDWINDOW, - xpos, - ypos, - width, - height, - NULL, - NULL, - wc.hInstance, - (LPVOID) wt); - if (!win) { - Error("Couldn't create window"); - } - - hdc = GetDC(win); - if (!hdc) { - Error("Couldn't obtain HDC"); - } - - pfd.cColorBits = 24; - pfd.cDepthBits = 24; - pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - pfd.iLayerType = PFD_MAIN_PLANE; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - - visinfo = ChoosePixelFormat(hdc, &pfd); - if (!visinfo) { - Error("Unable to find RGB, Z, double-buffered visual"); - } - - SetPixelFormat(hdc, visinfo, &pfd); - ctx = wglCreateContext(hdc); - if (!ctx) { - Error("Couldn't create WGL context"); - } - - if (shareCtx) { - if(!wglShareLists(shareCtx, ctx)) - Error("Couldn't share WGL context lists"); - } - - /* save the info for this window/context */ - wt->Win = win; - wt->hDC = hdc; - wt->Context = ctx; - wt->Angle = 0.0; - wt->WinWidth = width; - wt->WinHeight = height; - wt->NewSize = GL_TRUE; -} - - -/* - * Called by pthread_create() - */ -static DWORD WINAPI -ThreadProc(void *p) -{ - struct winthread *wt = (struct winthread *) p; - HGLRC share; - - /* Wait for the previous thread */ - if(Texture && wt->Index > 0) { - WaitForSingleObject(WinThreads[wt->Index - 1].hEventInitialised, INFINITE); - share = WinThreads[0].Context; - } - else - share = 0; - - share = (Texture && wt->Index > 0) ? WinThreads[0].Context : 0; - create_window(wt, share); - SetEvent(wt->hEventInitialised); - - /* Wait for all threads to initialize otherwise wglShareLists will fail */ - if(wt->Index < NumWinThreads - 1) - WaitForSingleObject(WinThreads[NumWinThreads - 1].hEventInitialised, INFINITE); - - draw_loop(wt); - return 0; -} - - -static void -usage(void) -{ - printf("wglthreads: test of GL thread safety (any key = exit)\n"); - printf("Usage:\n"); - printf(" wglthreads [options]\n"); - printf("Options:\n"); - printf(" -h Show this usage screen\n"); - printf(" -n NUMTHREADS Number of threads to create\n"); - printf(" -l Use application-side locking\n"); - printf(" -t Enable texturing\n"); - printf(" -s Force single-threaded\n"); - printf("Keyboard:\n"); - printf(" Esc Exit\n"); - printf(" t Change texture image (requires -t option)\n"); - printf(" a Toggle animation\n"); - printf(" s Step rotation (when not animating)\n"); -} - - -int -main(int argc, char *argv[]) -{ - int i; - - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-h") == 0) { - usage(); - exit(0); - } - else if (strcmp(argv[i], "-l") == 0) { - Locking = 1; - } - else if (strcmp(argv[i], "-t") == 0) { - Texture = 1; - } - else if (strcmp(argv[i], "-n") == 0 && i + 1 < argc) { - NumWinThreads = atoi(argv[i + 1]); - if (NumWinThreads < 1) - NumWinThreads = 1; - else if (NumWinThreads > MAX_WINTHREADS) - NumWinThreads = MAX_WINTHREADS; - i++; - } - else if (strcmp(argv[i], "-s") == 0) { - SingleThreaded = GL_TRUE; - } - else { - usage(); - exit(1); - } - } - - if (SingleThreaded) - printf("wglthreads: Forcing single-threaded, no other threads will be created.\n"); - - if (Locking) - printf("wglthreads: Using explicit locks around WGL calls.\n"); - else - printf("wglthreads: No explict locking.\n"); - - InitializeCriticalSection(&Mutex); - ExitEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - - if (SingleThreaded) { - NumWinThreads = 1; - - WinThreads[0].Index = 0; - WinThreads[0].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL); - WinThreads[0].hEventRedraw = CreateEvent(NULL, FALSE, FALSE, NULL); - - ThreadProc((void*) &WinThreads[0]); - } - else { - HANDLE threads[MAX_WINTHREADS]; - - printf("wglthreads: creating threads\n"); - - /* Create the events */ - for (i = 0; i < NumWinThreads; i++) { - WinThreads[i].Index = i; - WinThreads[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL); - WinThreads[i].hEventRedraw = CreateEvent(NULL, FALSE, FALSE, NULL); - } - - /* Create the threads */ - for (i = 0; i < NumWinThreads; i++) { - DWORD id; - - WinThreads[i].Thread = CreateThread(NULL, - 0, - ThreadProc, - (void*) &WinThreads[i], - 0, - &id); - printf("wglthreads: Created thread %p\n", (void *) WinThreads[i].Thread); - - threads[i] = WinThreads[i].Thread; - } - - /* Wait for all threads to finish. */ - WaitForMultipleObjects(NumWinThreads, threads, TRUE, INFINITE); - } - - return 0; -} |