summaryrefslogtreecommitdiff
path: root/progs/xdemos
diff options
context:
space:
mode:
Diffstat (limited to 'progs/xdemos')
-rw-r--r--progs/xdemos/.gitignore1
-rw-r--r--progs/xdemos/Makefile1
-rw-r--r--progs/xdemos/glsync.c11
-rw-r--r--progs/xdemos/glxinfo.c23
-rw-r--r--progs/xdemos/msctest.c13
-rw-r--r--progs/xdemos/omlsync.c267
-rw-r--r--progs/xdemos/vgears.c281
-rw-r--r--progs/xdemos/vindex.c65
-rw-r--r--progs/xdemos/vtest.c82
9 files changed, 292 insertions, 452 deletions
diff --git a/progs/xdemos/.gitignore b/progs/xdemos/.gitignore
index 5ae0f5a062..a65b890d3d 100644
--- a/progs/xdemos/.gitignore
+++ b/progs/xdemos/.gitignore
@@ -27,3 +27,4 @@ xfont
xrotfontdemo
yuvrect_client
msctest
+omlsync
diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile
index f866a32865..9cf984b59e 100644
--- a/progs/xdemos/Makefile
+++ b/progs/xdemos/Makefile
@@ -32,6 +32,7 @@ PROGS = \
msctest \
multictx \
offset \
+ omlsync \
overlay \
pbinfo \
pbdemo \
diff --git a/progs/xdemos/glsync.c b/progs/xdemos/glsync.c
index c00ba9e468..3751373e23 100644
--- a/progs/xdemos/glsync.c
+++ b/progs/xdemos/glsync.c
@@ -63,10 +63,9 @@ void (*swap_interval)();
static int GLXExtensionSupported(Display *dpy, const char *extension)
{
- const char *extensionsString, *client_extensions, *pos;
+ const char *extensionsString, *pos;
extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
- client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
pos = strstr(extensionsString, extension);
@@ -74,12 +73,6 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
return 1;
- pos = strstr(client_extensions, extension);
-
- if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
- (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
- return 1;
-
return 0;
}
@@ -235,7 +228,7 @@ int main(int argc, char *argv[])
XMapWindow(disp, winGL);
ret = glXMakeCurrent(disp, winGL, context);
- if (ret) {
+ if (!ret) {
fprintf(stderr, "failed to make context current: %d\n", ret);
}
diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c
index d871088210..332f5c2f46 100644
--- a/progs/xdemos/glxinfo.c
+++ b/progs/xdemos/glxinfo.c
@@ -171,7 +171,7 @@ print_program_limits(GLenum target)
GLenum token;
const char *name;
};
- static const struct token_name limits[] = {
+ static const struct token_name common_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" },
@@ -184,6 +184,9 @@ print_program_limits(GLenum target)
{ 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" },
+ { (GLenum) 0, NULL }
+ };
+ static const struct token_name fragment_limits[] = {
{ 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" },
@@ -192,8 +195,10 @@ print_program_limits(GLenum target)
{ GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" },
{ (GLenum) 0, NULL }
};
+
PFNGLGETPROGRAMIVARBPROC GetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC)
glXGetProcAddressARB((GLubyte *) "glGetProgramivARB");
+
GLint max[1];
int i;
@@ -207,10 +212,18 @@ print_program_limits(GLenum target)
return; /* something's wrong */
}
- for (i = 0; limits[i].token; i++) {
- GetProgramivARB_func(target, limits[i].token, max);
+ for (i = 0; common_limits[i].token; i++) {
+ GetProgramivARB_func(target, common_limits[i].token, max);
if (glGetError() == GL_NO_ERROR) {
- printf(" %s = %d\n", limits[i].name, max[0]);
+ printf(" %s = %d\n", common_limits[i].name, max[0]);
+ }
+ }
+ if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ for (i = 0; fragment_limits[i].token; i++) {
+ GetProgramivARB_func(target, fragment_limits[i].token, max);
+ if (glGetError() == GL_NO_ERROR) {
+ printf(" %s = %d\n", fragment_limits[i].name, max[0]);
+ }
}
}
#endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */
@@ -1100,7 +1113,7 @@ usage(void)
printf("\t-display <dname>: Print GLX visuals on specified server.\n");
printf("\t-h: This information.\n");
printf("\t-i: Force an indirect rendering context.\n");
- printf("\t-b: Find the 'best' visual and print it's number.\n");
+ printf("\t-b: Find the 'best' visual and print its number.\n");
printf("\t-l: Print interesting OpenGL limits.\n");
}
diff --git a/progs/xdemos/msctest.c b/progs/xdemos/msctest.c
index 001ecf04d6..11b0434442 100644
--- a/progs/xdemos/msctest.c
+++ b/progs/xdemos/msctest.c
@@ -45,10 +45,9 @@ void (*wait_sync)(Display *dpy, Window winGL, int64_t target_msc, int64_t diviso
static int GLXExtensionSupported(Display *dpy, const char *extension)
{
- const char *extensionsString, *client_extensions, *pos;
+ const char *extensionsString, *pos;
extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
- client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
pos = strstr(extensionsString, extension);
@@ -56,12 +55,6 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
return 1;
- pos = strstr(client_extensions, extension);
-
- if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
- (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
- return 1;
-
return 0;
}
@@ -167,8 +160,8 @@ int main(int argc, char *argv[])
glXMakeCurrent(disp, winGL, context);
- get_sync_values = glXGetProcAddress((unsigned char *)"glXGetSyncValuesOML");
- wait_sync = glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
+ get_sync_values = (void *)glXGetProcAddress((unsigned char *)"glXGetSyncValuesOML");
+ wait_sync = (void *)glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
if (!get_sync_values || !wait_sync) {
fprintf(stderr, "failed to get sync values function\n");
diff --git a/progs/xdemos/omlsync.c b/progs/xdemos/omlsync.c
new file mode 100644
index 0000000000..061d6c6861
--- /dev/null
+++ b/progs/xdemos/omlsync.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright © 2007-2010 Intel Corporation
+ *
+ * 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 (including the next
+ * paragraph) 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 OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ * Jesse Barnes <jesse.barnes@intel.com>
+ *
+ */
+
+/** @file omlsync.c
+ * The program is simple: it paints a window alternating colors (red &
+ * white) either as fast as possible or synchronized to vblank events
+ *
+ * If run normally, the program should display a window that exhibits
+ * significant tearing between red and white colors (e.g. you might get
+ * a "waterfall" effect of red and white horizontal bars).
+ *
+ * If run with the '-s b' option, the program should synchronize the
+ * window color changes with the vertical blank period, resulting in a
+ * window that looks orangish with a high frequency flicker (which may
+ * be invisible). If the window is moved to another screen, this
+ * property should be preserved. If the window spans two screens, it
+ * shouldn't tear on whichever screen most of the window is on; the
+ * portion on the other screen may show some tearing (like the
+ * waterfall effect above).
+ *
+ * Other options include '-w <width>' and '-h <height>' to set the
+ * window size.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <GL/glx.h>
+#include <GL/glxext.h>
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+Bool (*glXGetSyncValuesOML)(Display *dpy, GLXDrawable drawable,
+ int64_t *ust, int64_t *msc, int64_t *sbc);
+Bool (*glXGetMscRateOML)(Display *dpy, GLXDrawable drawable, int32_t *numerator,
+ int32_t *denominator);
+int64_t (*glXSwapBuffersMscOML)(Display *dpy, GLXDrawable drawable,
+ int64_t target_msc, int64_t divisor,
+ int64_t remainder);
+Bool (*glXWaitForMscOML)(Display *dpy, GLXDrawable drawable, int64_t target_msc,
+ int64_t divisor, int64_t remainder, int64_t *ust,
+ int64_t *msc, int64_t *sbc);
+Bool (*glXWaitForSbcOML)(Display *dpy, GLXDrawable drawable, int64_t target_sbc,
+ int64_t *ust, int64_t *msc, int64_t *sbc);
+int (*glXSwapInterval)(int interval);
+
+static int GLXExtensionSupported(Display *dpy, const char *extension)
+{
+ const char *extensionsString, *pos;
+
+ extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
+
+ pos = strstr(extensionsString, extension);
+
+ if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
+ (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
+ return 1;
+
+ return 0;
+}
+
+extern char *optarg;
+extern int optind, opterr, optopt;
+static char optstr[] = "w:h:vd:r:n:i:";
+
+static void usage(char *name)
+{
+ printf("usage: %s [-w <width>] [-h <height>] ...\n", name);
+ printf("\t-d<divisor> - divisor for OML swap\n");
+ printf("\t-r<remainder> - remainder for OML swap\n");
+ printf("\t-n<interval> - wait interval for OML WaitMSC\n");
+ printf("\t-i<swap interval> - swap at most once every n frames\n");
+ printf("\t-v: verbose (print count)\n");
+ exit(-1);
+}
+
+int main(int argc, char *argv[])
+{
+ Display *disp;
+ XVisualInfo *pvi;
+ XSetWindowAttributes swa;
+ Window winGL;
+ GLXContext context;
+ int dummy;
+ Atom wmDelete;
+ int64_t ust, msc, sbc;
+ int width = 500, height = 500, verbose = 0, divisor = 0, remainder = 0,
+ wait_interval = 0, swap_interval = 1;
+ int c, i = 1;
+ int ret;
+ int db_attribs[] = { GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ GLX_DOUBLEBUFFER,
+ GLX_DEPTH_SIZE, 1,
+ None };
+ XSizeHints sizehints;
+
+ opterr = 0;
+ while ((c = getopt(argc, argv, optstr)) != -1) {
+ switch (c) {
+ case 'w':
+ width = atoi(optarg);
+ break;
+ case 'h':
+ height = atoi(optarg);
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ case 'd':
+ divisor = atoi(optarg);
+ break;
+ case 'r':
+ remainder = atoi(optarg);
+ break;
+ case 'n':
+ wait_interval = atoi(optarg);
+ break;
+ case 'i':
+ swap_interval = atoi(optarg);
+ break;
+ default:
+ usage(argv[0]);
+ break;
+ }
+ }
+
+ disp = XOpenDisplay(NULL);
+ if (!disp) {
+ fprintf(stderr, "failed to open display\n");
+ return -1;
+ }
+
+ if (!glXQueryExtension(disp, &dummy, &dummy)) {
+ fprintf(stderr, "glXQueryExtension failed\n");
+ return -1;
+ }
+
+ if (!GLXExtensionSupported(disp, "GLX_OML_sync_control")) {
+ fprintf(stderr, "GLX_OML_sync_control not supported\n");
+ return -1;
+ }
+
+ if (!GLXExtensionSupported(disp, "GLX_MESA_swap_control")) {
+ fprintf(stderr, "GLX_MESA_swap_control not supported\n");
+ return -1;
+ }
+
+ pvi = glXChooseVisual(disp, DefaultScreen(disp), db_attribs);
+
+ if (!pvi) {
+ fprintf(stderr, "failed to choose visual, exiting\n");
+ return -1;
+ }
+
+ pvi->screen = DefaultScreen(disp);
+
+ swa.colormap = XCreateColormap(disp, RootWindow(disp, pvi->screen),
+ pvi->visual, AllocNone);
+ swa.border_pixel = 0;
+ swa.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
+ StructureNotifyMask;
+ winGL = XCreateWindow(disp, RootWindow(disp, pvi->screen),
+ 0, 0,
+ width, height,
+ 0, pvi->depth, InputOutput, pvi->visual,
+ CWBorderPixel | CWColormap | CWEventMask, &swa);
+ if (!winGL) {
+ fprintf(stderr, "window creation failed\n");
+ return -1;
+ }
+ wmDelete = XInternAtom(disp, "WM_DELETE_WINDOW", True);
+ XSetWMProtocols(disp, winGL, &wmDelete, 1);
+
+ sizehints.x = 0;
+ sizehints.y = 0;
+ sizehints.width = width;
+ sizehints.height = height;
+ sizehints.flags = USSize | USPosition;
+
+ XSetNormalHints(disp, winGL, &sizehints);
+ XSetStandardProperties(disp, winGL, "glsync test", "glsync text",
+ None, NULL, 0, &sizehints);
+
+ context = glXCreateContext(disp, pvi, NULL, GL_TRUE);
+ if (!context) {
+ fprintf(stderr, "failed to create glx context\n");
+ return -1;
+ }
+
+ XMapWindow(disp, winGL);
+ ret = glXMakeCurrent(disp, winGL, context);
+ if (!ret) {
+ fprintf(stderr, "failed to make context current: %d\n", ret);
+ }
+
+ glXGetSyncValuesOML = (void *)glXGetProcAddress((unsigned char *)"glXGetSyncValuesOML");
+ glXGetMscRateOML = (void *)glXGetProcAddress((unsigned char *)"glXGetMscRateOML");
+ glXSwapBuffersMscOML = (void *)glXGetProcAddress((unsigned char *)"glXSwapBuffersMscOML");
+ glXWaitForMscOML = (void *)glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
+ glXWaitForSbcOML = (void *)glXGetProcAddress((unsigned char *)"glXWaitForSbcOML");
+ glXSwapInterval = (void *)glXGetProcAddress((unsigned char *)"glXSwapIntervalMESA");
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glXSwapInterval(swap_interval);
+ fprintf(stderr, "set swap interval to %d\n", swap_interval);
+
+ glXGetSyncValuesOML(disp, winGL, &ust, &msc, &sbc);
+ while (i++) {
+ /* Alternate colors to make tearing obvious */
+ if (i & 1) {
+ glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+ glColor3f(1.0f, 1.0f, 1.0f);
+ } else {
+ glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
+ glColor3f(1.0f, 0.0f, 0.0f);
+ }
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glRectf(0, 0, width, height);
+
+ if (!wait_interval)
+ glXSwapBuffersMscOML(disp, winGL, 0, divisor,
+ remainder);
+ else {
+ glXWaitForMscOML(disp, winGL, msc + wait_interval,
+ divisor, remainder, &ust, &msc, &sbc);
+ glXSwapBuffersMscOML(disp, winGL, 0, 0, 0);
+ }
+ }
+
+ XDestroyWindow(disp, winGL);
+ glXDestroyContext(disp, context);
+ XCloseDisplay(disp);
+
+ return 0;
+}
diff --git a/progs/xdemos/vgears.c b/progs/xdemos/vgears.c
deleted file mode 100644
index f579e8b421..0000000000
--- a/progs/xdemos/vgears.c
+++ /dev/null
@@ -1,281 +0,0 @@
-
-/*
- * Spinning gears demo for Linux SVGA/Mesa interface in 32K color mode.
- *
- * Compile with: gcc vgears.c -I../include -L../lib -lMesaGL -lX11 -lXext
- * -lvga -lm -o vgears
- *
- * This program is in the public domain.
- * Brian Paul, January 1996
- */
-
-
-#include <vga.h>
-#include <math.h>
-#include "GL/svgamesa.h"
-#include "GL/gl.h"
-
-
-int width = 800, height = 600;
-
-SVGAMesaContext vmc;
-
-
-
-/*
- * Draw a gear wheel. You'll probably want to call this function when
- * building a display list since we do a lot of trig here.
- *
- * Input: inner_radius - radius of hole at center
- * outer_radius - radius at center of teeth
- * width - width of gear
- * teeth - number of teeth
- * tooth_depth - depth of tooth
- */
-static void gear( GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
- GLint teeth, GLfloat tooth_depth )
-{
- GLint i;
- GLfloat r0, r1, r2;
- GLfloat angle, da;
- GLfloat u, v, len;
-
- r0 = inner_radius;
- r1 = outer_radius - tooth_depth/2.0;
- r2 = outer_radius + tooth_depth/2.0;
-
- da = 2.0*M_PI / teeth / 4.0;
-
- glShadeModel( GL_FLAT );
-
- glNormal3f( 0.0, 0.0, 1.0 );
-
- /* draw front face */
- glBegin( GL_QUAD_STRIP );
- for (i=0;i<=teeth;i++) {
- angle = i * 2.0*M_PI / teeth;
- glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 );
- glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 );
- glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 );
- glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 );
- }
- glEnd();
-
- /* draw front sides of teeth */
- glBegin( GL_QUADS );
- da = 2.0*M_PI / teeth / 4.0;
- for (i=0;i<teeth;i++) {
- angle = i * 2.0*M_PI / teeth;
-
- glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 );
- glVertex3f( r2*cos(angle+da), r2*sin(angle+da), width*0.5 );
- glVertex3f( r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5 );
- glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 );
- }
- glEnd();
-
-
- glNormal3f( 0.0, 0.0, -1.0 );
-
- /* draw back face */
- glBegin( GL_QUAD_STRIP );
- for (i=0;i<=teeth;i++) {
- angle = i * 2.0*M_PI / teeth;
- glVertex3f( r1*cos(angle), r1*sin(angle), -width*0.5 );
- glVertex3f( r0*cos(angle), r0*sin(angle), -width*0.5 );
- glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5 );
- glVertex3f( r0*cos(angle), r0*sin(angle), -width*0.5 );
- }
- glEnd();
-
- /* draw back sides of teeth */
- glBegin( GL_QUADS );
- da = 2.0*M_PI / teeth / 4.0;
- for (i=0;i<teeth;i++) {
- angle = i * 2.0*M_PI / teeth;
-
- glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5 );
- glVertex3f( r2*cos(angle+2*da), r2*sin(angle+2*da), -width*0.5 );
- glVertex3f( r2*cos(angle+da), r2*sin(angle+da), -width*0.5 );
- glVertex3f( r1*cos(angle), r1*sin(angle), -width*0.5 );
- }
- glEnd();
-
-
- /* draw outward faces of teeth */
- glBegin( GL_QUAD_STRIP );
- for (i=0;i<teeth;i++) {
- angle = i * 2.0*M_PI / teeth;
-
- glVertex3f( r1*cos(angle), r1*sin(angle), width*0.5 );
- glVertex3f( r1*cos(angle), r1*sin(angle), -width*0.5 );
- u = r2*cos(angle+da) - r1*cos(angle);
- v = r2*sin(angle+da) - r1*sin(angle);
- len = sqrt( u*u + v*v );
- u /= len;
- v /= len;
- glNormal3f( v, -u, 0.0 );
- glVertex3f( r2*cos(angle+da), r2*sin(angle+da), width*0.5 );
- glVertex3f( r2*cos(angle+da), r2*sin(angle+da), -width*0.5 );
- glNormal3f( cos(angle), sin(angle), 0.0 );
- glVertex3f( r2*cos(angle+2*da), r2*sin(angle+2*da), width*0.5 );
- glVertex3f( r2*cos(angle+2*da), r2*sin(angle+2*da), -width*0.5 );
- u = r1*cos(angle+3*da) - r2*cos(angle+2*da);
- v = r1*sin(angle+3*da) - r2*sin(angle+2*da);
- glNormal3f( v, -u, 0.0 );
- glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), width*0.5 );
- glVertex3f( r1*cos(angle+3*da), r1*sin(angle+3*da), -width*0.5 );
- glNormal3f( cos(angle), sin(angle), 0.0 );
- }
-
- glVertex3f( r1*cos(0), r1*sin(0), width*0.5 );
- glVertex3f( r1*cos(0), r1*sin(0), -width*0.5 );
-
- glEnd();
-
-
- glShadeModel( GL_SMOOTH );
-
- /* draw inside radius cylinder */
- glBegin( GL_QUAD_STRIP );
- for (i=0;i<=teeth;i++) {
- angle = i * 2.0*M_PI / teeth;
- glNormal3f( -cos(angle), -sin(angle), 0.0 );
- glVertex3f( r0*cos(angle), r0*sin(angle), -width*0.5 );
- glVertex3f( r0*cos(angle), r0*sin(angle), width*0.5 );
- }
- glEnd();
-
-}
-
-
-static GLfloat view_rotx=20.0, view_roty=30.0, view_rotz=0.0;
-static GLint gear1, gear2, gear3;
-static GLfloat angle = 0.0;
-
-static GLuint limit;
-static GLuint count = 1;
-
-
-static void draw( void )
-{
- angle += 2.0;
-
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
-
- glPushMatrix();
- glRotatef( view_rotx, 1.0, 0.0, 0.0 );
- glRotatef( view_roty, 0.0, 1.0, 0.0 );
- glRotatef( view_rotz, 0.0, 0.0, 1.0 );
-
- glPushMatrix();
- glTranslatef( -3.0, -2.0, 0.0 );
- glRotatef( angle, 0.0, 0.0, 1.0 );
- glCallList(gear1);
- glPopMatrix();
-
- glPushMatrix();
- glTranslatef( 3.1, -2.0, 0.0 );
- glRotatef( -2.0*angle-9.0, 0.0, 0.0, 1.0 );
- glCallList(gear2);
- glPopMatrix();
-
- glPushMatrix();
- glTranslatef( -3.1, 4.2, 0.0 );
- glRotatef( -2.0*angle-25.0, 0.0, 0.0, 1.0 );
- glCallList(gear3);
- glPopMatrix();
-
- glPopMatrix();
-
- SVGAMesaSwapBuffers();
-}
-
-
-static void init( void )
-{
- static GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0 };
- static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0 };
- static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0 };
- static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0 };
-
- GLfloat w = (float) width / (float) height;
- GLfloat h = 1.0;
-
- glLightfv( GL_LIGHT0, GL_POSITION, pos );
- glEnable( GL_CULL_FACE );
- glEnable( GL_LIGHTING );
- glEnable( GL_LIGHT0 );
- glEnable( GL_DEPTH_TEST );
-
- /* make the gears */
- gear1 = glGenLists(1);
- glNewList(gear1, GL_COMPILE);
- glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red );
- gear( 1.0, 4.0, 1.0, 20, 0.7 );
- glEndList();
-
- gear2 = glGenLists(1);
- glNewList(gear2, GL_COMPILE);
- glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green );
- gear( 0.5, 2.0, 2.0, 10, 0.7 );
- glEndList();
-
- gear3 = glGenLists(1);
- glNewList(gear3, GL_COMPILE);
- glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue );
- gear( 1.3, 2.0, 0.5, 10, 0.7 );
- glEndList();
-
- glEnable( GL_NORMALIZE );
-
-
- glViewport( 0, 0, width, height );
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- if (width>height) {
- GLfloat w = (GLfloat) width / (GLfloat) height;
- glFrustum( -w, w, -1.0, 1.0, 5.0, 60.0 );
- }
- else {
- GLfloat h = (GLfloat) height / (GLfloat) width;
- glFrustum( -1.0, 1.0, -h, h, 5.0, 60.0 );
- }
-
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef( 0.0, 0.0, -40.0 );
-}
-
-void setup( void )
-{
- vga_init();
-
- vga_setmode(G800x600x32K);
-/* gl_setcontextvga(G800x600x32K);*/
-
- vmc = SVGAMesaCreateContext(GL_TRUE);
- SVGAMesaMakeCurrent( vmc );
-}
-
-
-void end( void )
-{
- SVGAMesaDestroyContext( vmc );
-
- vga_setmode( TEXT );
-}
-
-
-int main( int argc, char *argv[] )
-{
- int i;
-
- setup();
- init();
- for (i=0;i<4;i++) {
- draw(); /*SVGAMesaSwapBuffers();*/
- }
- end();
- return 0;
-}
diff --git a/progs/xdemos/vindex.c b/progs/xdemos/vindex.c
deleted file mode 100644
index 991fce2a59..0000000000
--- a/progs/xdemos/vindex.c
+++ /dev/null
@@ -1,65 +0,0 @@
-
-/*
- * Test Linux 8-bit SVGA/Mesa color index mode
- *
- * Compile with: gcc vindex.c -I../include -L../lib -lMesaGL -lX11 -lXext
- * -lvga -lm -o vindex
- *
- * This program is in the public domain.
- * Brian Paul, January 1996
- */
-
-
-
-#include <vga.h>
-#include "GL/svgamesa.h"
-#include "GL/gl.h"
-
-
-
-static GLint width = 640, height = 480;
-
-
-
-static void display( void )
-{
- int i, j;
- int w, h;
-
- glViewport( 0, 0, width, height );
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- glOrtho( 0.0, (GLfloat) width, 0.0, (GLfloat) height, -1.0, 1.0 );
-
- glClear( GL_COLOR_BUFFER_BIT );
-
- w = width / 16;
- h = height / 16;
- for (i=0;i<16;i++) {
- for (j=0;j<16;j++) {
- glIndexi( i*16+j );
- glRecti( i*w, j*h, i*w+w, j*h+h );
- }
- }
-}
-
-
-
-int main( int argc, char *argv[] )
-{
- SVGAMesaContext vmc;
- int i;
-
- vga_init();
- vga_setmode( G640x480x256 );
-
- vmc = SVGAMesaCreateContext( GL_FALSE );
- SVGAMesaMakeCurrent( vmc );
-
- display();
- sleep(3);
-
- SVGAMesaDestroyContext( vmc );
- vga_setmode( TEXT );
- return 0;
-}
diff --git a/progs/xdemos/vtest.c b/progs/xdemos/vtest.c
deleted file mode 100644
index e322fbc5c8..0000000000
--- a/progs/xdemos/vtest.c
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/*
- * Test SVGA/Mesa interface in 32K color mode.
- *
- * Compile with: gcc vtest.c -I../include -L../lib -lMesaGL -lX11 -lXext
- * -lvga -lm -o vtest
- *
- * This program is in the public domain.
- * Brian Paul, January 1996
- */
-
-
-
-#include <vga.h>
-#include "GL/svgamesa.h"
-#include "GL/gl.h"
-
-
-SVGAMesaContext vmc;
-
-
-
-void setup( void )
-{
- vga_init();
-
- vga_setmode(G800x600x32K);
-/* gl_setcontextvga(G800x600x32K);*/
-
- vmc = SVGAMesaCreateContext( GL_FALSE ); /* single buffered */
- SVGAMesaMakeCurrent( vmc );
-}
-
-
-void test( void )
-{
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );
- glMatrixMode(GL_MODELVIEW);
-
- glClear( GL_COLOR_BUFFER_BIT );
-
- glBegin( GL_LINES );
- glColor3f( 1.0, 0.0, 0.0 );
- glVertex2f( -0.5, 0.5 );
- glVertex2f( 0.5, 0.5 );
- glColor3f( 0.0, 1.0, 0.0 );
- glVertex2f( -0.5, 0.25 );
- glVertex2f( 0.5, 0.25 );
- glColor3f( 0.0, 0.0, 1.0 );
- glVertex2f( -0.5, 0.0 );
- glVertex2f( 0.5, 0.0 );
- glEnd();
-
- glBegin( GL_POLYGON );
- glColor3f( 1.0, 0.0, 0.0 );
- glVertex2f( 0.0, 0.7 );
- glColor3f( 0.0, 1.0, 0.0 );
- glVertex2f( -0.5, -0.5 );
- glColor3f( 0.0, 0.0, 1.0 );
- glVertex2f( 0.5, -0.5 );
- glEnd();
-
- sleep(3);
-}
-
-void end( void )
-{
- SVGAMesaDestroyContext( vmc );
-
- vga_setmode( TEXT );
-}
-
-
-int main( int argc, char *argv[] )
-{
- setup();
- test();
- end();
- return 0;
-}