summaryrefslogtreecommitdiffstats
path: root/progs
diff options
context:
space:
mode:
Diffstat (limited to 'progs')
-rw-r--r--progs/demos/geartrain.c1
-rw-r--r--progs/demos/gltestperf.c1
-rw-r--r--progs/demos/isosurf.c1
-rw-r--r--progs/demos/morph3d.c9
-rw-r--r--progs/demos/spriteblast.c22
-rw-r--r--progs/demos/winpos.c1
-rw-r--r--progs/fbdev/glfbdevtest.c105
-rw-r--r--progs/samples/Makefile.mgw33
-rw-r--r--progs/tests/Makefile1
-rw-r--r--progs/tests/drawbuffers.c21
-rw-r--r--progs/tests/random.c457
-rw-r--r--progs/xdemos/offset.c34
-rw-r--r--progs/xdemos/pbdemo.c9
13 files changed, 633 insertions, 62 deletions
diff --git a/progs/demos/geartrain.c b/progs/demos/geartrain.c
index 3feb2a0524b..8363f2abc6d 100644
--- a/progs/demos/geartrain.c
+++ b/progs/demos/geartrain.c
@@ -1053,6 +1053,7 @@ main (int argc, char *argv[])
else
file = argv[1];
+ glutInit(&argc, argv);
glutInitWindowPosition (0, 0);
glutInitWindowSize(640,480);
glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
diff --git a/progs/demos/gltestperf.c b/progs/demos/gltestperf.c
index be953901014..2188b024192 100644
--- a/progs/demos/gltestperf.c
+++ b/progs/demos/gltestperf.c
@@ -569,6 +569,7 @@ main(int ac, char **av)
if (ac == 2)
frontbuffer = 0;
+ glutInit(&ac, av);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(0, 0);
glutInitWindowSize(640, 480);
diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c
index 0710bc6047b..10f94b6ace2 100644
--- a/progs/demos/isosurf.c
+++ b/progs/demos/isosurf.c
@@ -1042,6 +1042,7 @@ int main(int argc, char **argv)
read_surface( "isosurf.dat" );
+ glutInit( &argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(400, 400);
diff --git a/progs/demos/morph3d.c b/progs/demos/morph3d.c
index 162a6ff847e..6aca8270ff5 100644
--- a/progs/demos/morph3d.c
+++ b/progs/demos/morph3d.c
@@ -826,7 +826,7 @@ static void pinit(void)
}
-static void INIT(void)
+int main(int argc, char **argv)
{
printf("Morph 3D - Shows morphing platonic polyhedra\n");
printf("Author: Marcelo Fernandes Vianna ([email protected])\n\n");
@@ -841,6 +841,7 @@ static void INIT(void)
object=1;
+ glutInit(&argc, argv);
glutInitWindowPosition(0,0);
glutInitWindowSize(640,480);
@@ -888,9 +889,3 @@ static void INIT(void)
glutMainLoop();
}
-
-int main(int argc, char **argv)
-{
- INIT();
- return(0);
-}
diff --git a/progs/demos/spriteblast.c b/progs/demos/spriteblast.c
index f0d3d0dfd41..5ad8e4d9a94 100644
--- a/progs/demos/spriteblast.c
+++ b/progs/demos/spriteblast.c
@@ -333,13 +333,13 @@ menu(int option)
smooth = 0;
break;
case 10:
- glPointSize(4.0);
+ glPointSize(16.0);
break;
case 11:
- glPointSize(8.0);
+ glPointSize(32.0);
break;
case 12:
- glPointSize(16.0);
+ glPointSize(64.0);
break;
case 13:
spin = 1 - spin;
@@ -411,19 +411,19 @@ key(unsigned char c, int x, int y)
glutPostRedisplay();
break;
case '1':
- glPointSize(2.0);
+ glPointSize(16.0);
glutPostRedisplay();
break;
case '2':
- glPointSize(4.0);
+ glPointSize(32.0);
glutPostRedisplay();
break;
case '3':
- glPointSize(8.0);
+ glPointSize(64.0);
glutPostRedisplay();
break;
case '4':
- glPointSize(16.0);
+ glPointSize(128.0);
glutPostRedisplay();
break;
case 27:
@@ -526,9 +526,9 @@ main(int argc, char **argv)
glutAddMenuEntry("Threshold 10", 7);
glutAddMenuEntry("Point smooth on", 8);
glutAddMenuEntry("Point smooth off", 9);
- glutAddMenuEntry("Point size 4", 10);
- glutAddMenuEntry("Point size 8", 11);
- glutAddMenuEntry("Point size 16", 12);
+ glutAddMenuEntry("Point size 16", 10);
+ glutAddMenuEntry("Point size 32", 11);
+ glutAddMenuEntry("Point size 64", 12);
glutAddMenuEntry("Toggle spin", 13);
glutAddMenuEntry("200 points ", 14);
glutAddMenuEntry("500 points ", 15);
@@ -544,7 +544,7 @@ main(int argc, char **argv)
glEnable(GL_DEPTH_TEST);
glEnable(GL_POINT_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glPointSize(16.0);
+ glPointSize(32.0);
#ifdef GL_ARB_point_parameters
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
#endif
diff --git a/progs/demos/winpos.c b/progs/demos/winpos.c
index 3a1a19ecdb9..b58e3308643 100644
--- a/progs/demos/winpos.c
+++ b/progs/demos/winpos.c
@@ -100,6 +100,7 @@ static void init( void )
int main( int argc, char *argv[] )
{
+ glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(500, 500);
glutInitDisplayMode( GLUT_RGB );
diff --git a/progs/fbdev/glfbdevtest.c b/progs/fbdev/glfbdevtest.c
index a461c55e2f8..6d9f8070302 100644
--- a/progs/fbdev/glfbdevtest.c
+++ b/progs/fbdev/glfbdevtest.c
@@ -23,11 +23,21 @@
#include <GL/glfbdev.h>
#include <math.h>
-#define DEFAULT_DEPTH 8
+
+/**
+ * Choose one of these modes
+ */
+/*static const int XRes = 1280, YRes = 1024, Hz = 75;*/
+/*static const int XRes = 1280, YRes = 1024, Hz = 70;*/
+/*static const int XRes = 1280, YRes = 1024, Hz = 60;*/
+static const int XRes = 1024, YRes = 768, Hz = 70;
+
+static int DesiredDepth = 32;
+
+static int NumFrames = 100;
static struct fb_fix_screeninfo FixedInfo;
static struct fb_var_screeninfo VarInfo, OrigVarInfo;
-static int DesiredDepth = 0;
static int OriginalVT = -1;
static int ConsoleFD = -1;
static int FrameBufferFD = -1;
@@ -227,7 +237,6 @@ initialize_fbdev( void )
VarInfo = OrigVarInfo;
/* set the depth, resolution, etc */
- DesiredDepth = 32;
if (DesiredDepth)
VarInfo.bits_per_pixel = DesiredDepth;
@@ -251,16 +260,60 @@ initialize_fbdev( void )
VarInfo.blue.length = 8;
VarInfo.transp.length = 8;
}
- /* timing values taken from /etc/fb.modes (1280x1024 @ 75Hz) */
- VarInfo.xres_virtual = VarInfo.xres = 1280;
- VarInfo.yres_virtual = VarInfo.yres = 1024;
- VarInfo.pixclock = 7408;
- VarInfo.left_margin = 248;
- VarInfo.right_margin = 16;
- VarInfo.upper_margin = 38;
- VarInfo.lower_margin = 1;
- VarInfo.hsync_len = 144;
- VarInfo.vsync_len = 3;
+
+ /* timing values taken from /etc/fb.modes */
+ if (XRes == 1280 && YRes == 1024) {
+ VarInfo.xres_virtual = VarInfo.xres = XRes;
+ VarInfo.yres_virtual = VarInfo.yres = YRes;
+ if (Hz == 75) {
+ VarInfo.pixclock = 7408;
+ VarInfo.left_margin = 248;
+ VarInfo.right_margin = 16;
+ VarInfo.upper_margin = 38;
+ VarInfo.lower_margin = 1;
+ VarInfo.hsync_len = 144;
+ VarInfo.vsync_len = 3;
+ }
+ else if (Hz == 70) {
+ VarInfo.pixclock = 7937;
+ VarInfo.left_margin = 216;
+ VarInfo.right_margin = 80;
+ VarInfo.upper_margin = 36;
+ VarInfo.lower_margin = 1;
+ VarInfo.hsync_len = 112;
+ VarInfo.vsync_len = 5;
+ }
+ else if (Hz == 60) {
+ VarInfo.pixclock = 9260;
+ VarInfo.left_margin = 248;
+ VarInfo.right_margin = 48;
+ VarInfo.upper_margin = 38;
+ VarInfo.lower_margin = 1;
+ VarInfo.hsync_len = 112;
+ VarInfo.vsync_len = 3;
+ }
+ else {
+ fprintf(stderr, "invalid rate for 1280x1024\n");
+ exit(1);
+ }
+ }
+ else if (XRes == 1024 && YRes == 768 && Hz == 70) {
+ VarInfo.xres_virtual = VarInfo.xres = XRes;
+ VarInfo.yres_virtual = VarInfo.yres = YRes;
+ if (Hz == 70) {
+ VarInfo.pixclock = 13334;
+ VarInfo.left_margin = 144;
+ VarInfo.right_margin = 24;
+ VarInfo.upper_margin = 29;
+ VarInfo.lower_margin = 3;
+ VarInfo.hsync_len = 136;
+ VarInfo.vsync_len = 6;
+ }
+ else {
+ fprintf(stderr, "invalid rate for 1024x768\n");
+ exit(1);
+ }
+ }
VarInfo.xoffset = 0;
VarInfo.yoffset = 0;
@@ -338,7 +391,7 @@ initialize_fbdev( void )
printf("MMIOAddress = %p\n", MMIOAddress);
/* try out some simple MMIO register reads */
- if (1)
+ if (0)
{
typedef unsigned int CARD32;
typedef unsigned char CARD8;
@@ -452,6 +505,7 @@ gltest( void )
GLFBDevVisualPtr vis;
int bytes, r, g, b, a;
float ang;
+ int i;
printf("GLFBDEV_VENDOR = %s\n", glFBDevGetString(GLFBDEV_VENDOR));
printf("GLFBDEV_VERSION = %s\n", glFBDevGetString(GLFBDEV_VERSION));
@@ -491,13 +545,17 @@ gltest( void )
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
- for (ang = 0; ang <= 180; ang += 15) {
+ printf("Drawing %d frames...\n", NumFrames);
+
+ ang = 0.0;
+ for (i = 0; i < NumFrames; i++) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(ang, 1, 0, 0);
doughnut(1, 3, 40, 20);
glPopMatrix();
glFBDevSwapBuffers(buf);
+ ang += 15.0;
}
/* clean up */
@@ -510,12 +568,29 @@ gltest( void )
}
+static void
+parse_args(int argc, char *argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-f") == 0) {
+ NumFrames = atoi(argv[i+1]);
+ i++;
+ }
+ }
+}
+
+
int
main( int argc, char *argv[] )
{
signal(SIGUSR1, signal_handler); /* exit if someone tries a vt switch */
signal(SIGSEGV, signal_handler); /* catch segfaults */
+ parse_args(argc, argv);
+
+ printf("Setting mode to %d x %d @ %d Hz, %d bpp\n", XRes, YRes, Hz, DesiredDepth);
initialize_fbdev();
gltest();
shutdown_fbdev();
diff --git a/progs/samples/Makefile.mgw b/progs/samples/Makefile.mgw
index 11935405783..3b2fd785def 100644
--- a/progs/samples/Makefile.mgw
+++ b/progs/samples/Makefile.mgw
@@ -26,6 +26,15 @@
# Web : http://www.geocities.com/dborca
+# MinGW samples makefile updated for Mesa 7.0
+#
+# Updated : by Heromyth, on 2007-7-21
+# Bugs : 1) All the default settings work fine. But the setting X86=1 can't work.
+# The others havn't been tested yet.
+# 2) The generated DLLs are *not* compatible with the ones built
+# with the other compilers like VC8, especially for GLUT.
+# 3) Although more tests are needed, it can be used individually!
#
# Available options:
@@ -44,15 +53,31 @@
TOP = ../..
+include $(TOP)/configs/config.mgw
+ALL_USING_STDCALL ?= 1
+GL_USING_STDCALL ?= 1
+GLUT_USING_STDCALL ?= 1
+
CC = mingw32-gcc
-CFLAGS = -Wall -W -pedantic
+CFLAGS = -Wall -pedantic
CFLAGS += -O2 -ffast-math
CFLAGS += -I$(TOP)/include -I../util
ifeq ($(FX),1)
-CFLAGS += -DFX
+ CFLAGS += -DFX
+endif
+
+CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK
+
+ifeq ($(GL_USING_STDCALL),0)
+ CFLAGS += -DGL_NO_STDCALL
+endif
+
+ifeq ($(GLUT_USING_STDCALL),1)
+ CFLAGS += -D_STDCALL_SUPPORTED
+else
+ CFLAGS += -DGLUT_NO_STDCALL
endif
-CFLAGS += -DGLUT_DISABLE_ATEXIT_HACK -D_STDCALL_SUPPORTED
-CFLAGS += -D_WINDEF_ -D_WINGDI_
+
LD = mingw32-g++
LDFLAGS = -s -L$(TOP)/lib
diff --git a/progs/tests/Makefile b/progs/tests/Makefile
index b506db3e7bf..9016efe9e77 100644
--- a/progs/tests/Makefile
+++ b/progs/tests/Makefile
@@ -55,6 +55,7 @@ SOURCES = \
pbo.c \
prog_parameter.c \
projtex.c \
+ random.c \
readrate.c \
seccolor.c \
sharedtex.c \
diff --git a/progs/tests/drawbuffers.c b/progs/tests/drawbuffers.c
index 8583bac0ddf..5e89569380a 100644
--- a/progs/tests/drawbuffers.c
+++ b/progs/tests/drawbuffers.c
@@ -19,6 +19,7 @@ static int Win;
static int Width = 400, Height = 400;
static GLuint FBobject, RBobjects[3];
static GLfloat Xrot = 0.0, Yrot = 0.0;
+static GLuint Program;
static void
@@ -40,6 +41,8 @@ Display(void)
GL_COLOR_ATTACHMENT1_EXT
};
+ glUseProgram_func(Program);
+
/* draw to user framebuffer */
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
@@ -71,10 +74,12 @@ Display(void)
buffer);
/* top half = colorbuffer 1 */
glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
- glReadPixels(0, Height/2, Width, Height / 2, GL_RGBA, GL_UNSIGNED_BYTE,
- buffer + Width * Height / 2 * 4);
+ glReadPixels(0, Height/2, Width, Height - Height / 2,
+ GL_RGBA, GL_UNSIGNED_BYTE,
+ buffer + Width * (Height / 2) * 4);
/* draw to window */
+ glUseProgram_func(0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glWindowPos2iARB(0, 0);
glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
@@ -243,15 +248,15 @@ SetupShaders(void)
" gl_FragData[1] = vec4(1.0) - gl_Color; \n"
"}\n";
- GLuint fragShader, program;
+ GLuint fragShader;
fragShader = LoadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText);
- program = glCreateProgram_func();
+ Program = glCreateProgram_func();
- glAttachShader_func(program, fragShader);
- glLinkProgram_func(program);
- CheckLink(program);
- glUseProgram_func(program);
+ glAttachShader_func(Program, fragShader);
+ glLinkProgram_func(Program);
+ CheckLink(Program);
+ glUseProgram_func(Program);
}
diff --git a/progs/tests/random.c b/progs/tests/random.c
new file mode 100644
index 00000000000..d52c338e0e1
--- /dev/null
+++ b/progs/tests/random.c
@@ -0,0 +1,457 @@
+/**
+ * Random rendering, to check for crashes, hangs, etc.
+ *
+ * Brian Paul
+ * 21 June 2007
+ */
+
+#define GL_GLEXT_PROTOTYPES
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <GL/glut.h>
+
+static int Win;
+static GLboolean Anim = GL_TRUE;
+static int Width = 200, Height = 200;
+static int DB = 0;
+static int MinVertexCount = 0, MaxVertexCount = 1000;
+static int Count = 0;
+
+struct vertex
+{
+ int type;
+ float v[4];
+};
+
+static int BufferSize = 10000;
+static struct vertex *Vbuffer = NULL;
+static int Vcount, Vprim;
+
+enum {
+ BEGIN,
+ END,
+ VERTEX2,
+ VERTEX3,
+ VERTEX4,
+ COLOR3,
+ COLOR4,
+ TEX2,
+ TEX3,
+ TEX4,
+ SECCOLOR3,
+ NORMAL3
+};
+
+
+
+/**
+ * This can be called from within gdb after a crash:
+ * (gdb) call ReportState()
+ */
+static void
+ReportState(void)
+{
+ static const struct {
+ GLenum token;
+ char *str;
+ GLenum type;
+ } state [] = {
+ { GL_ALPHA_TEST, "GL_ALPHA_TEST", GL_INT },
+ { GL_BLEND, "GL_BLEND", GL_INT },
+ { GL_CLIP_PLANE0, "GL_CLIP_PLANE0", GL_INT },
+ { GL_DEPTH_TEST, "GL_DEPTH_TEST", GL_INT },
+ { GL_LIGHTING, "GL_LIGHTING", GL_INT },
+ { GL_LINE_WIDTH, "GL_LINE_WIDTH", GL_FLOAT },
+ { GL_POINT_SIZE, "GL_POINT_SIZE", GL_FLOAT },
+ { GL_SHADE_MODEL, "GL_SHADE_MODEL", GL_INT },
+ { GL_SCISSOR_TEST, "GL_SCISSOR_TEST", GL_INT },
+ { 0, NULL, 0 }
+ };
+
+ GLint i;
+
+ for (i = 0; state[i].token; i++) {
+ if (state[i].type == GL_INT) {
+ GLint v;
+ glGetIntegerv(state[i].token, &v);
+ printf("%s = %d\n", state[i].str, v);
+ }
+ else {
+ GLfloat v;
+ glGetFloatv(state[i].token, &v);
+ printf("%s = %f\n", state[i].str, v);
+ }
+ }
+}
+
+static void
+PrintVertex(const char *f, const struct vertex *v, int sz)
+{
+ int i;
+ printf("%s(", f);
+ for (i = 0; i < sz; i++) {
+ printf("%g%s", v->v[i], (i == sz-1) ? "" : ", ");
+ }
+ printf(");\n");
+}
+
+/**
+ * This can be called from within gdb after a crash:
+ * (gdb) call ReportState()
+ */
+static void
+LastPrim(void)
+{
+ int i;
+ for (i = 0; i < Vcount; i++) {
+ switch (Vbuffer[i].type) {
+ case BEGIN:
+ printf("glBegin(%d);\n", (int) Vbuffer[i].v[0]);
+ break;
+ case END:
+ printf("glEnd();\n");
+ break;
+ case VERTEX2:
+ PrintVertex("glVertex2f", Vbuffer + i, 2);
+ break;
+ case VERTEX3:
+ PrintVertex("glVertex3f", Vbuffer + i, 3);
+ break;
+ case VERTEX4:
+ PrintVertex("glVertex4f", Vbuffer + i, 4);
+ break;
+ case COLOR3:
+ PrintVertex("glColor3f", Vbuffer + i, 3);
+ break;
+ case COLOR4:
+ PrintVertex("glColor4f", Vbuffer + i, 4);
+ break;
+ case TEX2:
+ PrintVertex("glTexCoord2f", Vbuffer + i, 2);
+ break;
+ case TEX3:
+ PrintVertex("glTexCoord3f", Vbuffer + i, 3);
+ break;
+ case TEX4:
+ PrintVertex("glTexCoord4f", Vbuffer + i, 4);
+ break;
+ case SECCOLOR3:
+ PrintVertex("glSecondaryColor3f", Vbuffer + i, 3);
+ break;
+ case NORMAL3:
+ PrintVertex("glNormal3f", Vbuffer + i, 3);
+ break;
+ default:
+ abort();
+ }
+ }
+}
+
+
+static int
+RandomInt(int max)
+{
+ if (max == 0)
+ return 0;
+ return rand() % max;
+}
+
+static float
+RandomFloat(float min, float max)
+{
+ int k = rand() % 10000;
+ float x = min + (max - min) * k / 10000.0;
+ return x;
+}
+
+/*
+ * Return true if random number in [0,1] is <= percentile.
+ */
+static GLboolean
+RandomChoice(float percentile)
+{
+ return RandomFloat(0.0, 1.0) <= percentile;
+}
+
+static void
+RandomStateChange(void)
+{
+ int k = RandomInt(19);
+ switch (k) {
+ case 0:
+ glEnable(GL_BLEND);
+ break;
+ case 1:
+ glDisable(GL_BLEND);
+ break;
+ case 2:
+ glEnable(GL_ALPHA_TEST);
+ break;
+ case 3:
+ glEnable(GL_ALPHA_TEST);
+ break;
+ case 4:
+ glEnable(GL_DEPTH_TEST);
+ break;
+ case 5:
+ glEnable(GL_DEPTH_TEST);
+ break;
+ case 6:
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ break;
+ case 7:
+ glPointSize(10.0);
+ break;
+ case 8:
+ glPointSize(1.0);
+ break;
+ case 9:
+ glLineWidth(10.0);
+ break;
+ case 10:
+ glLineWidth(1.0);
+ break;
+ case 11:
+ glEnable(GL_LIGHTING);
+ break;
+ case 12:
+ glDisable(GL_LIGHTING);
+ break;
+ case 13:
+ glEnable(GL_SCISSOR_TEST);
+ break;
+ case 14:
+ glDisable(GL_SCISSOR_TEST);
+ break;
+ case 15:
+ glEnable(GL_CLIP_PLANE0);
+ break;
+ case 16:
+ glDisable(GL_CLIP_PLANE0);
+ break;
+ case 17:
+ glShadeModel(GL_FLAT);
+ break;
+ case 18:
+ glShadeModel(GL_SMOOTH);
+ break;
+ }
+}
+
+
+static void
+RandomPrimitive(void)
+{
+ int i;
+ int len = MinVertexCount + RandomInt(MaxVertexCount - MinVertexCount);
+
+ Vprim = RandomInt(10);
+
+ glBegin(Vprim);
+ Vbuffer[Vcount].type = BEGIN;
+ Vbuffer[Vcount].v[0] = Vprim;
+ Vcount++;
+
+ for (i = 0; i < len; i++) {
+ Vbuffer[Vcount].v[0] = RandomFloat(-3, 3);
+ Vbuffer[Vcount].v[1] = RandomFloat(-3, 3);
+ Vbuffer[Vcount].v[2] = RandomFloat(-3, 3);
+ Vbuffer[Vcount].v[3] = RandomFloat(-3, 3);
+ int k = RandomInt(9);
+ switch (k) {
+ case 0:
+ glVertex2fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = VERTEX2;
+ break;
+ case 1:
+ glVertex3fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = VERTEX3;
+ break;
+ case 2:
+ glVertex4fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = VERTEX4;
+ break;
+ case 3:
+ glColor3fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = COLOR3;
+ break;
+ case 4:
+ glColor4fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = COLOR4;
+ break;
+ case 5:
+ glTexCoord2fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = TEX2;
+ break;
+ case 6:
+ glTexCoord3fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = TEX3;
+ break;
+ case 7:
+ glTexCoord4fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = TEX4;
+ break;
+ case 8:
+ glSecondaryColor3fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = SECCOLOR3;
+ break;
+ case 9:
+ glNormal3fv(Vbuffer[Vcount].v);
+ Vbuffer[Vcount].type = NORMAL3;
+ break;
+ default:
+ abort();
+ }
+ Vcount++;
+
+ if (Vcount >= BufferSize - 2) {
+ /* reset */
+ Vcount = 0;
+ }
+ }
+
+ Vbuffer[Vcount++].type = END;
+
+ glEnd();
+}
+
+
+static void
+RandomDraw(void)
+{
+ int i;
+ GLboolean dlist = RandomChoice(0.1);
+ if (dlist)
+ glNewList(1, GL_COMPILE);
+ for (i = 0; i < 3; i++) {
+ RandomStateChange();
+ }
+ RandomPrimitive();
+
+ if (dlist) {
+ glEndList();
+ glCallList(1);
+ }
+}
+
+
+static void
+Idle(void)
+{
+ glutPostRedisplay();
+}
+
+
+static void
+Draw(void)
+{
+#if 1
+ RandomDraw();
+ Count++;
+#else
+ /* cut & paste temp code here */
+#endif
+
+ assert(glGetError() == 0);
+
+ if (DB)
+ glutSwapBuffers();
+ else
+ glFinish();
+}
+
+
+static void
+Reshape(int width, int height)
+{
+ Width = width;
+ Height = height;
+ glViewport(0, 0, width, height);
+ glScissor(20, 20, Width-40, Height-40);
+ 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 27:
+ glutDestroyWindow(Win);
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+static void
+Init(void)
+{
+ static const GLdouble plane[4] = {1, 1, 0, 0};
+ glDrawBuffer(GL_FRONT);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glEnable(GL_LIGHT0);
+ glClipPlane(GL_CLIP_PLANE0, plane);
+
+ Vbuffer = (struct vertex *)
+ malloc(BufferSize * sizeof(struct vertex));
+
+ /* silence warnings */
+ (void) ReportState;
+ (void) LastPrim;
+}
+
+
+static void
+ParseArgs(int argc, char *argv[])
+{
+ int i;
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-s") == 0) {
+ int j = atoi(argv[i + 1]);
+ printf("Random seed value: %d\n", j);
+ srand(j);
+ i++;
+ }
+ else if (strcmp(argv[i], "-a") == 0) {
+ i++;
+ MinVertexCount = atoi(argv[i]);
+ }
+ else if (strcmp(argv[i], "-b") == 0) {
+ i++;
+ MaxVertexCount = atoi(argv[i]);
+ }
+ }
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ glutInit(&argc, argv);
+ glutInitWindowPosition(0, 0);
+ glutInitWindowSize(Width, Height);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ Win = glutCreateWindow(argv[0]);
+ ParseArgs(argc, argv);
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ if (Anim)
+ glutIdleFunc(Idle);
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/xdemos/offset.c b/progs/xdemos/offset.c
index 3e92e68daa7..0ad9147aea6 100644
--- a/progs/xdemos/offset.c
+++ b/progs/xdemos/offset.c
@@ -71,12 +71,12 @@ typedef Vertex Quad[4];
/* data to define the six faces of a unit cube */
Quad quads[MAXQUAD] = {
- { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0} },
- { {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} },
- { {0,0,0}, {1,0,0}, {1,0,1}, {0,0,1} },
- { {0,1,0}, {1,1,0}, {1,1,1}, {0,1,1} },
- { {0,0,0}, {0,0,1}, {0,1,1}, {0,1,0} },
- { {1,0,0}, {1,0,1}, {1,1,1}, {1,1,0} }
+ { {0,0,0}, {0,0,1}, {0,1,1}, {0,1,0} }, /* x = 0 */
+ { {0,0,0}, {1,0,0}, {1,0,1}, {0,0,1} }, /* y = 0 */
+ { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0} }, /* z = 0 */
+ { {1,0,0}, {1,0,1}, {1,1,1}, {1,1,0} }, /* x = 1 */
+ { {0,1,0}, {1,1,0}, {1,1,1}, {0,1,1} }, /* y = 1 */
+ { {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} } /* z = 1 */
};
#define WIREFRAME 0
@@ -86,7 +86,7 @@ static void error(const char* prog, const char* msg);
static void cubes(int mx, int my, int mode);
static void fill(Quad quad);
static void outline(Quad quad);
-static void draw_hidden(Quad quad, int mode);
+static void draw_hidden(Quad quad, int mode, int face);
static void process_input(Display *dpy, Window win);
static int query_extension(char* extName);
@@ -101,6 +101,7 @@ int main(int argc, char** argv) {
XSetWindowAttributes swa;
Window win;
GLXContext cx;
+ GLint z;
dpy = XOpenDisplay(0);
if (!dpy) error(argv[0], "can't open display");
@@ -134,13 +135,16 @@ int main(int argc, char** argv) {
/* set up viewing parameters */
glMatrixMode(GL_PROJECTION);
- gluPerspective(20, 1, 0.1, 20);
+ gluPerspective(20, 1, 10, 20);
glMatrixMode(GL_MODELVIEW);
glTranslatef(0, 0, -15);
/* set other relevant state information */
glEnable(GL_DEPTH_TEST);
+ glGetIntegerv(GL_DEPTH_BITS, &z);
+ printf("GL_DEPTH_BITS = %d\n", z);
+
#ifdef GL_EXT_polygon_offset
printf("using 1.0 offset extension\n");
glPolygonOffsetEXT( 1.0, 0.00001 );
@@ -160,6 +164,7 @@ int main(int argc, char** argv) {
static void
draw_scene(int mx, int my) {
+ glClearColor(0.25, 0.25, 0.25, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
@@ -206,7 +211,7 @@ cubes(int mx, int my, int mode) {
glTranslatef(x, y, z);
glScalef(0.8, 0.8, 0.8);
for (i = 0; i < MAXQUAD; i++)
- draw_hidden(quads[i], mode);
+ draw_hidden(quads[i], mode, i);
glPopMatrix();
}
}
@@ -236,13 +241,18 @@ outline(Quad quad) {
}
static void
-draw_hidden(Quad quad, int mode) {
+draw_hidden(Quad quad, int mode, int face) {
+ static const GLfloat colors[3][3] = {
+ {0.5, 0.5, 0.0},
+ {0.8, 0.5, 0.0},
+ {0.0, 0.5, 0.8}
+ };
if (mode == HIDDEN_LINE) {
- glColor3f(0, 0, 0);
+ glColor3fv(colors[face % 3]);
fill(quad);
}
- /* draw the outline using white, optionally fill the interior with black */
+ /* draw the outline using white */
glColor3f(1, 1, 1);
outline(quad);
}
diff --git a/progs/xdemos/pbdemo.c b/progs/xdemos/pbdemo.c
index efdfdfa4522..7db0017b33e 100644
--- a/progs/xdemos/pbdemo.c
+++ b/progs/xdemos/pbdemo.c
@@ -93,7 +93,7 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
None
},
{
- /* Single bufferd, without depth buffer */
+ /* Single buffered, without depth buffer */
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
@@ -105,7 +105,7 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
None
},
{
- /* Double bufferd, without depth buffer */
+ /* Double buffered, without depth buffer */
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RED_SIZE, 1,
@@ -130,9 +130,8 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
/* Get list of possible frame buffer configurations */
fbConfigs = ChooseFBConfig(dpy, screen, fbAttribs[attempt], &nConfigs);
if (nConfigs==0 || !fbConfigs) {
- printf("Error: glXChooseFBConfig failed\n");
- XCloseDisplay(dpy);
- return 0;
+ printf("Note: glXChooseFBConfig(%s) failed\n", fbString[attempt]);
+ continue;
}
#if 0 /*DEBUG*/