summaryrefslogtreecommitdiff
path: root/progs/trivial
diff options
context:
space:
mode:
Diffstat (limited to 'progs/trivial')
-rw-r--r--progs/trivial/.gitignore16
-rw-r--r--progs/trivial/Makefile17
-rw-r--r--progs/trivial/SConscript163
-rw-r--r--progs/trivial/dlist-degenerate.c153
-rw-r--r--progs/trivial/point-param.c57
-rw-r--r--progs/trivial/quad-clip-nearplane.c43
-rw-r--r--progs/trivial/tri-mask-tri.c123
-rw-r--r--progs/trivial/tri-stencil.c13
-rw-r--r--progs/trivial/tri.c4
9 files changed, 480 insertions, 109 deletions
diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore
index a6629446d1..4789cf8475 100644
--- a/progs/trivial/.gitignore
+++ b/progs/trivial/.gitignore
@@ -1,9 +1,11 @@
clear
clear-fbo
clear-fbo-tex
+clear-repeat
clear-scissor
clear-undefined
dlist-dangling
+dlist-degenerate
dlist-edgeflag
dlist-edgeflag-dangling
drawarrays
@@ -29,6 +31,7 @@ linestrip
linestrip-flat-stipple
linestrip-stipple
linestrip-stipple-wide
+long-fixed-func
pgon-mode
point
point-clip
@@ -86,17 +89,24 @@ tri-fbo-tex
tri-flat
tri-flat-clip
tri-fog
+tri-fp
+tri-fp-const-imm
+tri-lit
tri-mask-tri
tri-orig
tri-query
+tri-repeat
tri-scissor-tri
tri-stencil
+tri-tex
tri-tex-3d
tri-tri
tri-unfilled
tri-unfilled-clip
tri-unfilled-edgeflag
tri-unfilled-smooth
+tri-unfilled-tri
+tri-unfilled-tri-lit
tri-unfilled-userclip
tri-unfilled-userclip-stip
tri-userclip
@@ -113,4 +123,10 @@ vp-array-int
vp-clip
vp-line-clip
vp-tri
+vp-tri-cb
+vp-tri-cb-pos
+vp-tri-cb-tex
+vp-tri-imm
+vp-tri-swap
+vp-tri-tex
vp-unfilled
diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile
index cfe7fe6f31..f7bfd1f039 100644
--- a/progs/trivial/Makefile
+++ b/progs/trivial/Makefile
@@ -8,7 +8,7 @@ TOP = ../..
include $(TOP)/configs/current
-LIBS = $(APP_LIB_DEPS)
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
SOURCES = \
clear-fbo-tex.c \
@@ -20,6 +20,7 @@ SOURCES = \
dlist-dangling.c \
dlist-edgeflag-dangling.c \
dlist-edgeflag.c \
+ dlist-degenerate.c \
drawarrays.c \
drawelements.c \
drawrange.c \
@@ -75,7 +76,6 @@ SOURCES = \
quadstrip-cont.c \
quadstrip-flat.c \
quadstrip.c \
- tri-orig.c \
tri-alpha.c \
tri-array-interleaved.c \
tri-blend-color.c \
@@ -98,6 +98,7 @@ SOURCES = \
tri-fp-const-imm.c \
tri-lit.c \
tri-mask-tri.c \
+ tri-orig.c \
tri-query.c \
tri-repeat.c \
tri-scissor-tri.c \
@@ -155,7 +156,7 @@ UTIL_FILES = readtex.h readtex.c
.SUFFIXES: .c
.c:
- $(APP_CC) $(INCLUDES) $(CFLAGS) $< $(LIBS) -o $@
+ $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
.c.o:
$(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
@@ -169,9 +170,9 @@ UTIL_FILES = readtex.h readtex.c
default: $(UTIL_FILES) $(PROGS)
clean:
- rm -f $(PROGS)
- rm -f *.o
- rm -f getproclist.h
+ -rm -f $(PROGS)
+ -rm -f *.o
+ -rm -f getproclist.h
# auto code generation
@@ -182,13 +183,13 @@ getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.
texrect: texrect.o readtex.o
- $(APP_CC) texrect.o readtex.o $(LIBS) -o $@
+ $(APP_CC) $(CFLAGS) $(LDFLAGS) texrect.o readtex.o $(LIBS) -o $@
texrect.o: texrect.c readtex.h
$(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
invert: invert.o readtex.o
- $(APP_CC) invert.o readtex.o $(LIBS) -o $@
+ $(APP_CC) $(CFLAGS) $(LDFLAGS) invert.o readtex.o $(LIBS) -o $@
invert.o: invert.c readtex.h
$(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript
new file mode 100644
index 0000000000..edb8386c5b
--- /dev/null
+++ b/progs/trivial/SConscript
@@ -0,0 +1,163 @@
+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',
+ 'drawelements',
+ 'drawrange',
+ 'flat-clip',
+ 'fs-tri',
+ 'line-clip',
+ 'line-cull',
+ '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-unfilled-clip',
+ 'quad-unfilled-stipple',
+ 'quad-unfilled',
+ 'quad',
+ 'quads',
+ '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-cull-both',
+ 'tri-cull',
+ 'tri-dlist',
+ 'tri-edgeflag',
+ 'tri-fbo-tex',
+ 'tri-fbo',
+ 'tri-flat-clip',
+ 'tri-flat',
+ 'tri-fog',
+ 'tri-fp',
+ 'tri-fp-const-imm',
+ 'tri-lit',
+ 'tri-mask-tri',
+ 'tri-orig',
+ 'tri-query',
+ 'tri-repeat',
+ 'tri-scissor-tri',
+ 'tri-stencil',
+ 'tri-tex',
+ 'tri-tex-3d',
+ 'tri-tri',
+ '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-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-drawelements',
+ 'vbo-drawrange',
+ 'vp-array',
+ 'vp-array-int',
+ 'vp-clip',
+ 'vp-line-clip',
+ 'vp-tri',
+ '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/dlist-degenerate.c b/progs/trivial/dlist-degenerate.c
new file mode 100644
index 0000000000..c7f2d2a6e9
--- /dev/null
+++ b/progs/trivial/dlist-degenerate.c
@@ -0,0 +1,153 @@
+/**
+ * Test display list corner cases.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <GL/glut.h>
+
+
+static int Win;
+static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
+static GLboolean Anim = GL_FALSE;
+static GLuint List1 = 0, List2 = 0;
+
+
+static void
+Idle(void)
+{
+ Xrot += 3.0;
+ Yrot += 4.0;
+ Zrot += 2.0;
+ glutPostRedisplay();
+}
+
+
+static void
+Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glPushMatrix();
+ glRotatef(Xrot, 1, 0, 0);
+ glRotatef(Yrot, 0, 1, 0);
+ glRotatef(Zrot, 0, 0, 1);
+
+ glCallList(List1);
+ glCallList(List2);
+
+ 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 'a':
+ Anim = !Anim;
+ if (Anim)
+ glutIdleFunc(Idle);
+ else
+ glutIdleFunc(NULL);
+ break;
+ case 'z':
+ Zrot -= step;
+ break;
+ case 'Z':
+ Zrot += step;
+ break;
+ case 27:
+ glutDestroyWindow(Win);
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+SpecialKey(int key, int x, int y)
+{
+ const GLfloat step = 3.0;
+ (void) x;
+ (void) y;
+ switch (key) {
+ case GLUT_KEY_UP:
+ Xrot -= step;
+ break;
+ case GLUT_KEY_DOWN:
+ Xrot += step;
+ break;
+ case GLUT_KEY_LEFT:
+ Yrot -= step;
+ break;
+ case GLUT_KEY_RIGHT:
+ Yrot += step;
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+ /* List1: start of primitive */
+ List1 = glGenLists(1);
+ glNewList(List1, GL_COMPILE);
+ glBegin(GL_POLYGON);
+ glVertex2f(-1, -1);
+ glVertex2f( 1, -1);
+ glEndList();
+
+ /* List2: end of primitive */
+ List2 = glGenLists(1);
+ glNewList(List2, GL_COMPILE);
+ glVertex2f( 1, 1);
+ glVertex2f(-1, 1);
+ glEnd();
+ glEndList();
+
+ glEnable(GL_DEPTH_TEST);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(400, 400);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ Win = glutCreateWindow(argv[0]);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutSpecialFunc(SpecialKey);
+ glutDisplayFunc(Draw);
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/point-param.c b/progs/trivial/point-param.c
index be4328d999..96544a0525 100644
--- a/progs/trivial/point-param.c
+++ b/progs/trivial/point-param.c
@@ -22,15 +22,14 @@
* OF THIS SOFTWARE.
*/
+#define GL_GLEXT_PROTOTYPES
+#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;
@@ -40,53 +39,63 @@ static void Init(void)
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
- glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClearColor(0.0, 0.0, 1.0, 0.0);
}
static void Reshape(int width, int height)
{
-
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glOrtho(-1.0, 1.0, -1.0, 1.0, 0, 100.0);
glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
-
switch (key) {
- case 27:
+ case 27:
exit(1);
- default:
+ default:
return;
}
-
glutPostRedisplay();
}
+
+static float
+expected(float z, float size, const float atten[3])
+{
+ float dist = fabs(z);
+ const GLfloat q = atten[0] + dist * (atten[1] + dist * atten[2]);
+ const GLfloat a = sqrt(1.0 / q);
+ return size * a;
+}
+
+
static void Draw(void)
{
- static GLfloat theQuad[3] = { 0.25, 0.0, 1/60.0 };
+ static GLfloat atten[3] = { 0.0, 0.1, .01 };
+ float size = 40.0;
+ int i;
glClear(GL_COLOR_BUFFER_BIT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glPointSize(8.0);
- glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
+ glPointSize(size);
+ glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, atten);
+ glColor3f(1,0,0);
+ printf("Expected point sizes:\n");
glBegin(GL_POINTS);
- glColor3f(1,0,0);
- glVertex3f( 0.9, -0.9, -10.0);
- glColor3f(1,1,0);
- glVertex3f( 0.9, 0.9, -5.0);
- glColor3f(1,0,1);
- glVertex3f(-0.9, 0.9, -30.0);
- glColor3f(0,1,1);
- glVertex3f(-0.9, -0.9, -20.0);
+ for (i = 0; i < 5; i++) {
+ float x = -0.8 + i * 0.4;
+ float z = -i * 20 - 10;
+ glVertex3f( x, 0.0, z);
+ printf(" %f\n", expected(z, size, atten));
+ }
glEnd();
glFlush();
@@ -96,6 +105,7 @@ static void Draw(void)
}
}
+
static GLenum Args(int argc, char **argv)
{
GLint i;
@@ -115,6 +125,7 @@ static GLenum Args(int argc, char **argv)
return GL_TRUE;
}
+
int main(int argc, char **argv)
{
GLenum type;
@@ -131,7 +142,7 @@ int main(int argc, char **argv)
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
glutInitDisplayMode(type);
- if (glutCreateWindow("First Tri") == GL_FALSE) {
+ if (glutCreateWindow(argv[0]) == GL_FALSE) {
exit(1);
}
@@ -141,5 +152,5 @@ int main(int argc, char **argv)
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
glutMainLoop();
- return 0;
+ return 0;
}
diff --git a/progs/trivial/quad-clip-nearplane.c b/progs/trivial/quad-clip-nearplane.c
index e76eb29f89..1e8056c474 100644
--- a/progs/trivial/quad-clip-nearplane.c
+++ b/progs/trivial/quad-clip-nearplane.c
@@ -33,6 +33,7 @@
GLenum doubleBuffer;
+float Z = -6;
static void Init(void)
{
@@ -40,30 +41,36 @@ static void Init(void)
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);
+ fprintf(stderr, "Press z/Z to translate quad\n");
+
+ 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);
+ glFrustum(-1.0, 1.0, -1.0, 1.0, 5, 100.0);
glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
-
switch (key) {
- case 27:
- exit(1);
- default:
- return;
+ case 'z':
+ Z += 0.5;
+ break;
+ case 'Z':
+ Z -= 0.5;
+ break;
+ case 27:
+ exit(1);
+ default:
+ return;
}
-
+ printf("Z = %f\n", Z);
glutPostRedisplay();
}
@@ -71,17 +78,22 @@ static void Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT);
+ glPushMatrix();
+ glTranslatef(0, -0.5, Z);
+
glBegin(GL_QUADS);
glColor3f(1,0,0);
- glVertex3f( 0.9, -0.9, 30.0);
+ glVertex3f( -0.8, 0, -4.0);
glColor3f(1,1,0);
- glVertex3f( 0.9, 0.9, 30.0);
+ glVertex3f( 0.8, 0, -4.0);
glColor3f(1,0,1);
- glVertex3f(-1.9, 0.9, 30.0);
+ glVertex3f( 0.8, 0, 4.0);
glColor3f(0,1,1);
- glVertex3f(-1.9, -0.9, -30.0);
+ glVertex3f( -0.8, 0, 4.0);
glEnd();
+ glPopMatrix();
+
glFlush();
if (doubleBuffer) {
@@ -118,7 +130,8 @@ int main(int argc, char **argv)
exit(1);
}
- glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize( 250, 250);
type = GLUT_RGB | GLUT_ALPHA;
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
@@ -134,5 +147,5 @@ int main(int argc, char **argv)
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
glutMainLoop();
- return 0;
+ return 0;
}
diff --git a/progs/trivial/tri-mask-tri.c b/progs/trivial/tri-mask-tri.c
index 38ecd20a73..8333f7ed8a 100644
--- a/progs/trivial/tri-mask-tri.c
+++ b/progs/trivial/tri-mask-tri.c
@@ -28,48 +28,53 @@
#include <GL/glut.h>
-#define CI_OFFSET_1 16
-#define CI_OFFSET_2 32
-
GLint Width = 250, Height = 250;
-
GLenum doubleBuffer;
+GLint Win;
+GLboolean Rmask = GL_TRUE, Gmask = GL_FALSE, Bmask = GL_TRUE;
+
static void Init(void)
{
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
-
- glClearColor(0.0, 0.0, 1.0, 0.0);
+ glClearColor(0.0, 0.0, 1.0, 0.0);
}
static void Reshape(int width, int height)
{
-
- glViewport(0, 0, (GLint)width, (GLint)height);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
- glMatrixMode(GL_MODELVIEW);
+ glViewport(0, 0, (GLint)width, (GLint)height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
-
- switch (key) {
- case 27:
- exit(1);
- default:
- return;
- }
-
- glutPostRedisplay();
+ switch (key) {
+ case 'r':
+ Rmask = !Rmask;
+ break;
+ case 'g':
+ Gmask = !Gmask;
+ break;
+ case 'b':
+ Bmask = !Bmask;
+ break;
+ case 27:
+ glutDestroyWindow(Win);
+ exit(1);
+ default:
+ return;
+ }
+ glutPostRedisplay();
}
static void Draw(void)
{
+ printf("ColorMask = %d, %d, %d\n", Rmask, Gmask, Bmask);
glColorMask(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
@@ -82,7 +87,7 @@ static void Draw(void)
glVertex3f(-0.9, 0.0, -30.0);
glEnd();
- glColorMask(1,0,1,0);
+ glColorMask(Rmask, Gmask, Bmask, 0);
/* left triangle: white&mask: purple middle region: white */
glBegin(GL_TRIANGLES);
@@ -103,48 +108,46 @@ static void Draw(void)
static GLenum Args(int argc, char **argv)
{
- GLint i;
-
- doubleBuffer = GL_FALSE;
-
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-sb") == 0) {
- doubleBuffer = GL_FALSE;
- } else if (strcmp(argv[i], "-db") == 0) {
- doubleBuffer = GL_TRUE;
- } else {
- fprintf(stderr, "%s (Bad option).\n", argv[i]);
- return GL_FALSE;
- }
- }
- return GL_TRUE;
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ }
+ else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ }
+ else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
}
+
int main(int argc, char **argv)
{
- GLenum type;
-
- glutInit(&argc, argv);
+ GLenum type;
- if (Args(argc, argv) == GL_FALSE) {
- exit(1);
- }
+ glutInit(&argc, argv);
- glutInitWindowPosition(100, 0); glutInitWindowSize(Width, Height);
-
- type = GLUT_RGB;
- type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
- glutInitDisplayMode(type);
-
- if (glutCreateWindow("First Tri") == GL_FALSE) {
- exit(1);
- }
-
- Init();
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Draw);
- glutMainLoop();
- return 0;
+ type = GLUT_RGB;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+
+ glutInitWindowPosition(100, 0); glutInitWindowSize(Width, Height);
+ glutInitDisplayMode(type);
+ Win = glutCreateWindow("First Tri");
+ Init();
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
}
diff --git a/progs/trivial/tri-stencil.c b/progs/trivial/tri-stencil.c
index 5edbef26ce..7686e16aef 100644
--- a/progs/trivial/tri-stencil.c
+++ b/progs/trivial/tri-stencil.c
@@ -49,7 +49,15 @@ 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;
}
}
@@ -89,7 +97,7 @@ static void Draw(void)
glEnd();
#endif
-#if 0
+#if 1
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
@@ -130,7 +138,8 @@ int main(int argc, char **argv)
exit(1);
}
- glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize( 300, 300);
type = GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH | GLUT_STENCIL;
glutInitDisplayMode(type);
diff --git a/progs/trivial/tri.c b/progs/trivial/tri.c
index 64c529415c..d3c6b59ea5 100644
--- a/progs/trivial/tri.c
+++ b/progs/trivial/tri.c
@@ -33,6 +33,7 @@
GLenum doubleBuffer = 1;
+int win;
static void Init(void)
{
@@ -118,7 +119,8 @@ int main(int argc, char **argv)
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
glutInitDisplayMode(type);
- if (glutCreateWindow("First Tri") == GL_FALSE) {
+ win = glutCreateWindow("First Tri");
+ if (!win) {
exit(1);
}