summaryrefslogtreecommitdiff
path: root/progs
diff options
context:
space:
mode:
Diffstat (limited to 'progs')
-rw-r--r--progs/demos/isosurf.c14
-rw-r--r--progs/trivial/.gitignore1
-rw-r--r--progs/trivial/Makefile1
-rw-r--r--progs/trivial/SConscript1
-rw-r--r--progs/trivial/tri-unfilled-fog.c152
5 files changed, 165 insertions, 4 deletions
diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c
index 393741cc9d..e280d8f507 100644
--- a/progs/demos/isosurf.c
+++ b/progs/demos/isosurf.c
@@ -69,6 +69,7 @@
#define NO_STIPPLE 0x08000000
#define POLYGON_FILL 0x10000000
#define POLYGON_LINE 0x20000000
+#define POLYGON_POINT 0x40000000
#define LIGHT_MASK (LIT|UNLIT|REFLECT)
#define FILTER_MASK (POINT_FILTER|LINEAR_FILTER)
@@ -81,7 +82,7 @@
#define SHADE_MASK (SHADE_SMOOTH|SHADE_FLAT)
#define FOG_MASK (FOG|NO_FOG)
#define STIPPLE_MASK (STIPPLE|NO_STIPPLE)
-#define POLYGON_MASK (POLYGON_FILL|POLYGON_LINE)
+#define POLYGON_MASK (POLYGON_FILL|POLYGON_LINE|POLYGON_POINT)
#define MAXVERTS 10000
static GLint maxverts = MAXVERTS;
@@ -147,7 +148,7 @@ static void read_surface( char *filename )
static void print_flags( const char *msg, GLuint flags )
{
fprintf(stderr,
- "%s (0x%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ "%s (0x%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
msg, flags,
(flags & GLVERTEX) ? "glVertex, " : "",
(flags & DRAW_ARRAYS) ? "glDrawArrays, " : "",
@@ -166,7 +167,8 @@ static void print_flags( const char *msg, GLuint flags )
(flags & MATERIALS) ? "materials, " : "",
(flags & FOG) ? "fog, " : "",
(flags & STIPPLE) ? "stipple, " : "",
- (flags & POLYGON_LINE) ? "polygon mode line, " : "");
+ (flags & POLYGON_LINE) ? "polygon mode line, " : "",
+ (flags & POLYGON_POINT) ? "polygon mode point, " : "");
}
@@ -711,9 +713,12 @@ static void ModeMenu(int m)
if (m & POLYGON_FILL) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
- else {
+ else if (m & POLYGON_LINE) {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
+ else {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+ }
}
#ifdef GL_EXT_vertex_array
@@ -1089,6 +1094,7 @@ int main(int argc, char **argv)
glutAddMenuEntry("", 0);
glutAddMenuEntry("Polygon Mode Fill", POLYGON_FILL);
glutAddMenuEntry("Polygon Mode Line", POLYGON_LINE);
+ glutAddMenuEntry("Polygon Mode Points", POLYGON_POINT);
glutAddMenuEntry("", 0);
glutAddMenuEntry("Point Filtered", POINT_FILTER);
glutAddMenuEntry("Linear Filtered", LINEAR_FILTER);
diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore
index d77f120b96..f58345ce3b 100644
--- a/progs/trivial/.gitignore
+++ b/progs/trivial/.gitignore
@@ -102,6 +102,7 @@ tri-tri
tri-unfilled
tri-unfilled-clip
tri-unfilled-edgeflag
+tri-unfilled-fog
tri-unfilled-smooth
tri-unfilled-tri
tri-unfilled-tri-lit
diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile
index dce96f6bc8..2800f3ef82 100644
--- a/progs/trivial/Makefile
+++ b/progs/trivial/Makefile
@@ -108,6 +108,7 @@ SOURCES = \
tri-tex.c \
tri-tex-3d.c \
tri-tri.c \
+ tri-unfilled-fog.c \
tri-unfilled-edgeflag.c \
tri-unfilled-clip.c \
tri-unfilled-smooth.c \
diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript
index 76826d9be0..d699e2b46b 100644
--- a/progs/trivial/SConscript
+++ b/progs/trivial/SConscript
@@ -103,6 +103,7 @@ progs = [
'tri-tex',
'tri-tex-3d',
'tri-tri',
+ 'tri-unfilled-fog',
'tri-unfilled-edgeflag',
'tri-unfilled-clip',
'tri-unfilled-smooth',
diff --git a/progs/trivial/tri-unfilled-fog.c b/progs/trivial/tri-unfilled-fog.c
new file mode 100644
index 0000000000..90444aecdf
--- /dev/null
+++ b/progs/trivial/tri-unfilled-fog.c
@@ -0,0 +1,152 @@
+/*
+ * 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));
+
+ 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("Filled and unfilled fog tri") == GL_FALSE) {
+ exit(1);
+ }
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}