bigtest.c
上传用户:xk288cn
上传日期:2007-05-28
资源大小:4876k
文件大小:59k
- /**
- * My first GLUT prog.
- * Uses most GLUT calls to prove it all works.
- * G Edwards, 30 Aug 95.
- *
- * Notes:
- * Display lists are not shared between windows, and there doesn't seem to be
- * any provision for this in GLUT. See glxCreateContext.
- *
- * The windows are internally indexed 0,1,2,3,4,5,6. The actual window ids
- * returned by glut are held in winId[0], ...
- *
- * Todo:
- *
- * Could reorder the windows so 0,1,2,3,4,5,6 are the gfx, 7,8 text.
- *
- * 30 Aug 95 GJE Created. Version 1.00
- * 05 Sep 95 GJE Version 1.01.
- * 07 Sep 95 GJE Version 1.02. More or less complete. All possible GLUT
- * calls used, except dials/buttons/tablet/spaceball stuff.
- * 15 Sep 95 GJE Add "trackball" code.
- *
- * Calls not used yet: these callbacks are registered but inactive.
- *
- * glutSpaceball<xxx>Func
- * glutButtonBoxFunc
- * glutDialsFunc
- * glutTabletMotionFunc
- * glutTabletButtonFunc
- *
- * Tested on:
- * R3K Indigo Starter
- * R4K Indigo Elan
- * R4K Indy XZ
- * R4K Indy XL
- * R4K Indigo2 Extreme
- */
- #include <GL/glut.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- /* Controls */
- #define VERSION "1.00"
- #define DATE "16Sep95"
- #define DELAY 1000 /* delay for timer test */
- #define MENUDELAY 200 /* hack to fix glutMenuStateFunc bug */
- #define MAXWIN 9 /* max no. of windows */
- unsigned int AUTODELAY = 1500; /* delay in demo mode */
- #define VERSIONLONG "Version " VERSION "/" DATE ", compiled " __DATE__ ", " __TIME__ ", file " __FILE__
- int pos[MAXWIN][2] =
- {
- {50, 150}, /* win 0 */
- {450, 150}, /* win 1 */
- {50, 600}, /* win 2 */
- {450, 600}, /* win 3 */
- {10, 10}, /* subwin 4 (relative to parent win 0) */
- {300, 400}, /* help win 5 */
- {850, 150}, /* cmap win 6 */
- {850, 600}, /* cmap win 7 */
- {250, 450} /* text win 8 */
- };
- int size[MAXWIN][2] =
- {
- {350, 350}, /* win 0 */
- {350, 350}, /* win 1 */
- {350, 350}, /* win 2 */
- {350, 350}, /* win 3 */
- {200, 200}, /* subwin 4 */
- {700, 300}, /* help win 5 */
- {350, 350}, /* cmap win 6 */
- {350, 350}, /* cmap win 7 */
- {800, 450} /* text win 8 */
- };
- /* Macros */
- #define PR if(debug)printf
- /* #define GLNEWLIST(a, b) glNewList(a, b), fprintf(stderr,
- "creating list %d n", a); */
- /* #define GLCALLLIST(a) glCallList(a), fprintf(stderr,
- "calling list %d n", a); */
- /* #define GLUTSETWINDOW(x) glutSetWindow(x), fprintf(stderr,
- "gsw at %dn", __LINE__) */
- /* Globals */
- int winId[MAXWIN] =
- {0}; /* table of glut window id's */
- GLboolean winVis[MAXWIN] =
- {GL_FALSE}; /* is window visible */
- GLboolean text[MAXWIN] =
- {GL_FALSE}; /* is text on */
- GLboolean winFreeze[MAXWIN] =
- {GL_FALSE}; /* user requested menuFreeze */
- GLboolean menuFreeze = GL_FALSE; /* menuFreeze while menus posted */
- GLboolean timerOn = GL_FALSE; /* timer active */
- GLboolean animation = GL_TRUE; /* idle func animation on */
- GLboolean debug = GL_FALSE; /* dump all events */
- GLboolean showKeys = GL_FALSE; /* dump key events */
- GLboolean demoMode = GL_FALSE; /* run automatic demo */
- GLboolean backdrop = GL_FALSE; /* use backdrop polygon */
- GLboolean passive = GL_FALSE; /* report passive motions */
- GLboolean leftDown = GL_FALSE; /* left button down ? */
- GLboolean middleDown = GL_FALSE; /* middle button down ? */
- int displayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
- int currentShape = 0; /* current glut shape */
- int scrollLine = 0, scrollCol = 0; /* help scrolling params */
- int lineWidth = 1; /* line width */
- int angle = 0; /* global rotation angle */
- char *textPtr[1000] =
- {0}; /* pointers to text window text */
- int textCount = 0, helpCount = 0; /* text list indexes */
- float scaleFactor = 0.0; /* window size scale factor */
- #ifdef ALPHA
- #undef ALPHA /* Avoid problems with DEC's ALPHA machines. */
- #endif
- int menu1, menu2, menu3, menu4, menu5, menu6 = 0, menu7, menu8;
- enum {
- RGBA, INDEX, SINGLE, DOUBLEBUFFER, DEPTH, ACCUM, ALPHA, STENCIL, MULTISAMPLE,
- STEREO, MODES
- };
- char *modeNames[] =
- {"RGBA", "INDEX", "SINGLE", "DOUBLE", "DEPTH", "ACCUM",
- "ALPHA", "STENCIL", "MULTISAMPLE", "STEREO"};
- int glutMode[] =
- {GLUT_RGBA, GLUT_INDEX, GLUT_SINGLE, GLUT_DOUBLE, GLUT_DEPTH,
- GLUT_ACCUM, GLUT_ALPHA, GLUT_STENCIL, GLUT_MULTISAMPLE, GLUT_STEREO};
- int modes[MODES] =
- {0};
- GLboolean menuButton[3] =
- {0, 0, 1};
- enum {
- MOUSEBUTTON, MOUSEMOTION, APPLY, RESET
- };
- /* Prototypes */
- void gfxInit(int);
- void drawScene(void);
- void idleFunc(void);
- void reshapeFunc(int width, int height);
- void visible(int state);
- void keyFunc(unsigned char key, int x, int y);
- void mouseFunc(int button, int state, int x, int y);
- void motionFunc(int x, int y);
- void passiveMotionFunc(int x, int y);
- void entryFunc(int state);
- void specialFunc(int key, int x, int y);
- void menuStateFunc(int state);
- void timerFunc(int value);
- #if 0
- void delayedReinstateMenuStateCallback(int value);
- #endif
- void menuFunc(int value);
- void showText(void);
- void textString(int x, int y, char *str, void *font);
- void strokeString(int x, int y, char *str, void *font);
- void makeMenus(void);
- int idToIndex(int id);
- void setInitDisplayMode(void);
- void createMenu6(void);
- void removeCallbacks(void);
- void addCallbacks(void);
- void dumpIds(void);
- void updateHelp(void);
- void updateAll(void);
- void killWindow(int index);
- void makeWindow(int index);
- void warning(char *msg);
- void autoDemo(int);
- void positionWindow(int index);
- void reshapeWindow(int index);
- void iconifyWindow(int index);
- void showWindow(int index);
- void hideWindow(int index);
- void pushWindow(int index);
- void popWindow(int index);
- void attachMenus(void);
- void killAllWindows(void);
- void makeAllWindows(void);
- void updateText(void);
- void updateScrollWindow(int index, char **ptr);
- void redefineShapes(int shape);
- GLboolean match(char *, char *);
- void checkArgs(int argc, char *argv[]);
- void scaleWindows(float);
- void commandLineHelp(void);
- void trackBall(int mode, int button, int state, int x, int y);
- void spaceballMotionCB(int, int, int);
- void spaceballRotateCB(int, int, int);
- void spaceballButtonCB(int, int);
- void buttonBoxCB(int, int);
- void dialsCB(int, int);
- void tabletMotionCB(int, int);
- void tabletButtonCB(int, int, int, int);
- /* strdup is actually not a standard ANSI C or POSIX routine
- so implement a private one. OpenVMS does not have a strdup; Linux's
- standard libc doesn't declare strdup by default (unless BSD or SVID
- interfaces are requested). */
- static char *
- stralloc(const char *string)
- {
- char *copy;
- copy = malloc(strlen(string) + 1);
- if (copy == NULL)
- return NULL;
- strcpy(copy, string);
- return copy;
- }
- /* main */
- int
- main(int argc, char **argv)
- {
- /* General init */
- glutInit(&argc, argv);
- /* Check args */
- checkArgs(argc, argv);
- /* Scale window position/size if needed. Ignore aspect ratios. */
- if (scaleFactor > 0.0)
- scaleWindows(scaleFactor);
- else
- scaleWindows(glutGet(GLUT_SCREEN_WIDTH) / 1280.0);
- /* Set initial display mode */
- modes[RGBA] = 1;
- modes[DOUBLEBUFFER] = 1;
- modes[DEPTH] = 1;
- setInitDisplayMode();
- /* Set up menus */
- makeMenus();
- /* Make some windows */
- makeWindow(0);
- makeWindow(1);
- /* Global callbacks */
- glutIdleFunc(idleFunc);
- glutMenuStateFunc(menuStateFunc);
- /* Start demo if needed */
- if (demoMode)
- autoDemo(-2);
- /* Fall into event loop */
- glutMainLoop();
- return 0; /* ANSI C requires main to return int. */
- }
- /* gfxInit - Init opengl for each window */
- void
- gfxInit(int index)
- {
- GLfloat grey10[] =
- {0.10, 0.10, 0.10, 1.0};
- GLfloat grey20[] =
- {0.2, 0.2, 0.2, 1.0};
- GLfloat black[] =
- {0.0, 0.0, 0.0, 0.0};
- GLfloat diffuse0[] =
- {1.0, 0.0, 0.0, 1.0};
- GLfloat diffuse1[] =
- {0.0, 1.0, 0.0, 1.0};
- GLfloat diffuse2[] =
- {1.0, 1.0, 0.0, 1.0};
- GLfloat diffuse3[] =
- {0.0, 1.0, 1.0, 1.0};
- GLfloat diffuse4[] =
- {1.0, 0.0, 1.0, 1.0};
- #define XX 3
- #define YY 3
- #define ZZ -2.5
- float vertex[][3] =
- {
- {-XX, -YY, ZZ},
- {+XX, -YY, ZZ},
- {+XX, +YY, ZZ},
- {-XX, +YY, ZZ}
- };
- /* warning: This func mixes RGBA and CMAP calls in an ugly
- fashion */
- redefineShapes(currentShape); /* set up display lists */
- glutSetWindow(winId[index]); /* hack - redefineShapes
- changes glut win */
- /* Shaded backdrop square (RGB or CMAP) */
- glNewList(100, GL_COMPILE);
- glPushAttrib(GL_LIGHTING);
- glDisable(GL_LIGHTING);
- glBegin(GL_POLYGON);
- glColor4fv(black);
- glIndexi(0);
- glVertex3fv(vertex[0]);
- glColor4fv(grey10);
- glIndexi(3);
- glVertex3fv(vertex[1]);
- glColor4fv(grey20);
- glIndexi(4);
- glVertex3fv(vertex[2]);
- glColor4fv(grey10);
- glIndexi(7);
- glVertex3fv(vertex[3]);
- glEnd();
- glPopAttrib();
- glIndexi(9);
- glEndList();
- /* Set proj+view */
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(40.0, 1.0, 1.0, 20.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.);
- glTranslatef(0.0, 0.0, -1.0);
- if (index == 6 || index == 7)
- goto colorindex;
- /* Set basic material, lighting for RGB windows */
- if (index == 0)
- glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse0);
- else if (index == 1)
- glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse1);
- else if (index == 2)
- glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse2);
- else if (index == 3)
- glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse3);
- else if (index == 4)
- glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse4);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glEnable(GL_DEPTH_TEST);
- if (index == 4)
- glClearColor(0.15, 0.15, 0.15, 1);
- else
- glClearColor(0.1, 0.1, 0.1, 1.0);
- return;
- /* Set GL basics for CMAP windows 6,7 */
- colorindex:
- glEnable(GL_DEPTH_TEST);
- if (glutGet(GLUT_WINDOW_COLORMAP_SIZE) < 16)
- warning("Color map size too small for color index window");
- /* Try to reuse an existing color map */
- if ((index == 6) && (winId[7] != 0)) {
- glutCopyColormap(winId[7]);
- } else if ((index == 7) && (winId[6] != 0)) {
- glutCopyColormap(winId[6]);
- } else {
- glutSetColor(8, 0.1, 0.1, 0.1);
- glutSetColor(9, 1.0, 0.5, 0.0);
- glutSetColor(10, 1.0, 0.6, 0.8);
- }
- glClearIndex(8);
- glIndexi(index + 3);
- }
- /* makeMenus - Create popup menus */
- void
- makeMenus(void)
- {
- /* General control / debug */
- menu2 = glutCreateMenu(menuFunc);
- glutAddMenuEntry("toggle auto demo mode (a)", 312);
- glutAddMenuEntry("toggle freezing in menus", 300);
- glutAddMenuEntry("toggle text per window (t)", 301);
- glutAddMenuEntry("toggle global timer", 302);
- glutAddMenuEntry("toggle global animation", 303);
- glutAddMenuEntry("toggle per window animation", 304);
- glutAddMenuEntry("toggle debug prints (D)", 305);
- glutAddMenuEntry("toggle shaded backdrop", 307);
- glutAddMenuEntry("toggle passive motion callback", 308);
- glutAddMenuEntry("increase line width (l)", 310);
- glutAddMenuEntry("decrease line width (L)", 311);
- /* Shapes */
- menu3 = glutCreateMenu(menuFunc);
- glutAddMenuEntry("sphere", 200);
- glutAddMenuEntry("cube", 201);
- glutAddMenuEntry("cone", 202);
- glutAddMenuEntry("torus", 203);
- glutAddMenuEntry("dodecahedron", 204);
- glutAddMenuEntry("octahedron", 205);
- glutAddMenuEntry("tetrahedron", 206);
- glutAddMenuEntry("icosahedron", 207);
- glutAddMenuEntry("teapot", 208);
- /* Open/close windows */
- menu4 = glutCreateMenu(menuFunc);
- glutAddMenuEntry("open all windows", 450);
- glutAddMenuEntry("close all windows", 451);
- glutAddMenuEntry(" ", 9999);
- glutAddMenuEntry("create win 0", 400);
- glutAddMenuEntry("create win 1", 401);
- glutAddMenuEntry("create win 2", 402);
- glutAddMenuEntry("create win 3", 403);
- glutAddMenuEntry("create sub window", 404);
- glutAddMenuEntry("create color index win 6", 406);
- glutAddMenuEntry("create color index win 7", 407);
- glutAddMenuEntry(" ", 9999);
- glutAddMenuEntry("destroy win 0", 410);
- glutAddMenuEntry("destroy win 1", 411);
- glutAddMenuEntry("destroy win 2", 412);
- glutAddMenuEntry("destroy win 3", 413);
- glutAddMenuEntry("destroy sub window", 414);
- glutAddMenuEntry("destroy color index win 6", 416);
- glutAddMenuEntry("destroy color index win 7", 417);
- /* Window manager stuff */
- menu5 = glutCreateMenu(menuFunc);
- glutAddMenuEntry("move current win", 430);
- glutAddMenuEntry("resize current win", 431);
- glutAddMenuEntry("iconify current win", 432);
- glutAddMenuEntry("show current win", 433);
- glutAddMenuEntry("hide current win", 434);
- glutAddMenuEntry("push current win", 435);
- glutAddMenuEntry("pop current win", 436);
- glutAddMenuEntry(" ", 9999);
- glutAddMenuEntry("move win 1", 420);
- glutAddMenuEntry("resize win 1", 421);
- glutAddMenuEntry("iconify win 1", 422);
- glutAddMenuEntry("show win 1", 423);
- glutAddMenuEntry("hide win 1", 424);
- glutAddMenuEntry("push win 1", 425);
- glutAddMenuEntry("pop win 1", 426);
- /* Gfx modes */
- createMenu6(); /* build dynamically */
- /* Texty reports */
- menu7 = glutCreateMenu(menuFunc);
- glutAddMenuEntry("report current win modes", 700);
- glutAddMenuEntry("report current device data", 701);
- glutAddMenuEntry("check OpenGL extensions", 702);
- glutAddMenuEntry("dump internal data (d)", 703);
- /* Play with menus */
- menu8 = glutCreateMenu(menuFunc);
- glutAddMenuEntry("toggle menus on left button", 805);
- glutAddMenuEntry("toggle menus on middle button", 806);
- glutAddMenuEntry("toggle menus on right button", 807);
- glutAddMenuEntry("---------------------------", 9999);
- glutAddMenuEntry("add plain items", 800);
- glutAddMenuEntry("add submenu items", 801);
- glutAddMenuEntry("change new entries to plain items", 802);
- glutAddMenuEntry("change new entries to submenus", 803);
- glutAddMenuEntry("remove all new items", 804);
- glutAddMenuEntry("---------------------------", 9999);
- /* Main menu */
- menu1 = glutCreateMenu(menuFunc);
- glutAddSubMenu("control", menu2);
- glutAddSubMenu("shapes", menu3);
- glutAddSubMenu("windows", menu4);
- glutAddSubMenu("window ops", menu5);
- glutAddSubMenu("gfx modes", menu6);
- glutAddSubMenu("reports", menu7);
- glutAddSubMenu("menus", menu8);
- glutAddMenuEntry("help (h)", 101);
- glutAddMenuEntry("quit (esc)", 100);
- }
- /* createMenu6 - Dynamically rebuild menu of display modes to
- show current choices */
- void
- createMenu6(void)
- {
- char str[100];
- int i;
- if (menu6 != 0)
- glutDestroyMenu(menu6);
- menu6 = glutCreateMenu(menuFunc);
- for (i = 0; i < MODES; i++) {
- sprintf(str, "%srequest %s", (modes[i] ? "+ " : " "), modeNames[i]);
- glutAddMenuEntry(str, 602 + i);
- }
- }
- /* menuFunc - Process return codes from popup menus */
- void
- menuFunc(int value)
- {
- static int initItems = 10;
- int items, m;
- if (initItems == 0) {
- glutSetMenu(menu8);
- initItems = glutGet(GLUT_MENU_NUM_ITEMS);
- }
- PR("Menu returned value %d n", value);
- switch (value) {
- /* GLUT shapes */
- case 200:
- case 201:
- case 202:
- case 203:
- case 204:
- case 205:
- case 206:
- case 207:
- case 208:
- redefineShapes(value - 200);
- break;
- /* Overall controls */
- case 300:
- menuFreeze = !menuFreeze;
- break;
- case 301:
- text[idToIndex(glutGetWindow())] = !(text[idToIndex(glutGetWindow())]);
- break;
- case 302:
- timerOn = !timerOn;
- if (timerOn)
- glutTimerFunc(DELAY, timerFunc, 1);
- break;
- case 303:
- animation = !animation;
- if (animation)
- glutIdleFunc(idleFunc);
- else
- glutIdleFunc(NULL);
- break;
- case 304:
- winFreeze[idToIndex(glutGetWindow())] = !(winFreeze[idToIndex(
- glutGetWindow())]);
- break;
- case 305:
- debug = !debug;
- break;
- case 307:
- backdrop = !backdrop;
- break;
- case 308:
- passive = !passive;
- if (passive)
- glutPassiveMotionFunc(passiveMotionFunc);
- else
- glutPassiveMotionFunc(NULL);
- break;
- case 310:
- lineWidth += 1;
- updateAll();
- break;
- case 311:
- lineWidth -= 1;
- if (lineWidth < 1)
- lineWidth = 1;
- updateAll();
- break;
- case 312:
- demoMode = !demoMode;
- if (demoMode)
- autoDemo(-2);
- break;
- /* Window create/destroy. */
- /* Creates */
- case 400:
- makeWindow(0);
- break;
- case 401:
- makeWindow(1);
- break;
- case 402:
- makeWindow(2);
- break;
- case 403:
- makeWindow(3);
- break;
- case 404:
- makeWindow(4);
- break;
- case 406:
- makeWindow(6);
- break;
- case 407:
- makeWindow(7);
- break;
- /* Destroys */
- case 410:
- killWindow(0);
- break;
- case 411:
- killWindow(1);
- break;
- case 412:
- killWindow(2);
- break;
- case 413:
- killWindow(3);
- break;
- case 414:
- killWindow(4);
- break;
- case 416:
- killWindow(6);
- break;
- case 417:
- killWindow(7);
- break;
- case 450:
- makeAllWindows();
- break;
- case 451:
- killAllWindows();
- break;
- /* Window movements etc. */
- case 420:
- positionWindow(1);
- break;
- case 421:
- reshapeWindow(1);
- break;
- case 422:
- iconifyWindow(1);
- break;
- case 423:
- showWindow(1);
- break;
- case 424:
- hideWindow(1);
- break;
- case 425:
- pushWindow(1);
- break;
- case 426:
- popWindow(1);
- break;
- case 430:
- positionWindow(idToIndex(glutGetWindow()));
- break;
- case 431:
- reshapeWindow(idToIndex(glutGetWindow()));
- break;
- case 432:
- iconifyWindow(idToIndex(glutGetWindow()));
- break;
- case 433:
- showWindow(idToIndex(glutGetWindow()));
- break;
- case 434:
- hideWindow(idToIndex(glutGetWindow()));
- break;
- case 435:
- pushWindow(idToIndex(glutGetWindow()));
- break;
- case 436:
- popWindow(idToIndex(glutGetWindow()));
- break;
- /* Test gfx modes. */
- case 600:
- makeWindow(3);
- break;
- case 601:
- killWindow(3);
- break;
- case 602:
- case 603:
- case 604:
- case 605:
- case 606:
- case 607:
- case 608:
- case 609:
- case 610:
- case 611:
- modes[value - 602] = !modes[value - 602];
- setInitDisplayMode();
- break;
- /* Text reports */
- /* This is pretty ugly. */
- #define INDENT 30
- #define REPORTSTART(text)
- printf("n" text "n");
- textPtr[0] = (char *)malloc(strlen(text)+1);
- strcpy(textPtr[0], text);
- textCount = 1;
- #define REPORTEND
- scrollLine = 0;
- textPtr[textCount] = NULL;
- makeWindow(8);
- updateText();
- #define GLUTGET(name)
- {
- char str[100], str2[100];
- int s, len;
- sprintf(str, # name);
- len = (int) strlen(# name);
- for(s = 0 ; s < INDENT-len; s++)
- strcat(str, " ");
- sprintf(str2, ": %dn",glutGet(name));
- strcat(str, str2);
- printf(str);
- textPtr[textCount] = stralloc(str);
- textCount++;
- }
- case 700:
- printf("XXXXXX glutGetWindow = %dn", glutGetWindow());
- REPORTSTART("glutGet():");
- GLUTGET(GLUT_WINDOW_X);
- GLUTGET(GLUT_WINDOW_Y);
- GLUTGET(GLUT_WINDOW_WIDTH);
- GLUTGET(GLUT_WINDOW_HEIGHT);
- GLUTGET(GLUT_WINDOW_BUFFER_SIZE);
- GLUTGET(GLUT_WINDOW_STENCIL_SIZE);
- GLUTGET(GLUT_WINDOW_DEPTH_SIZE);
- GLUTGET(GLUT_WINDOW_RED_SIZE);
- GLUTGET(GLUT_WINDOW_GREEN_SIZE);
- GLUTGET(GLUT_WINDOW_BLUE_SIZE);
- GLUTGET(GLUT_WINDOW_ALPHA_SIZE);
- GLUTGET(GLUT_WINDOW_ACCUM_RED_SIZE);
- GLUTGET(GLUT_WINDOW_ACCUM_GREEN_SIZE);
- GLUTGET(GLUT_WINDOW_ACCUM_BLUE_SIZE);
- GLUTGET(GLUT_WINDOW_ACCUM_ALPHA_SIZE);
- GLUTGET(GLUT_WINDOW_DOUBLEBUFFER);
- GLUTGET(GLUT_WINDOW_RGBA);
- GLUTGET(GLUT_WINDOW_PARENT);
- GLUTGET(GLUT_WINDOW_NUM_CHILDREN);
- GLUTGET(GLUT_WINDOW_COLORMAP_SIZE);
- GLUTGET(GLUT_WINDOW_NUM_SAMPLES);
- GLUTGET(GLUT_STEREO);
- GLUTGET(GLUT_SCREEN_WIDTH);
- GLUTGET(GLUT_SCREEN_HEIGHT);
- GLUTGET(GLUT_SCREEN_HEIGHT_MM);
- GLUTGET(GLUT_SCREEN_WIDTH_MM);
- GLUTGET(GLUT_MENU_NUM_ITEMS);
- GLUTGET(GLUT_DISPLAY_MODE_POSSIBLE);
- GLUTGET(GLUT_INIT_DISPLAY_MODE);
- GLUTGET(GLUT_INIT_WINDOW_X);
- GLUTGET(GLUT_INIT_WINDOW_Y);
- GLUTGET(GLUT_INIT_WINDOW_WIDTH);
- GLUTGET(GLUT_INIT_WINDOW_HEIGHT);
- GLUTGET(GLUT_ELAPSED_TIME);
- REPORTEND;
- break;
- #define GLUTDEVGET(name)
- {
- char str[100], str2[100];
- int len, s;
- sprintf(str, # name);
- len = (int) strlen(# name);
- for(s = 0 ; s < INDENT-len; s++)
- strcat(str, " ");
- sprintf(str2, ": %dn",
- glutDeviceGet(name));
- strcat(str, str2);
- printf(str);
- textPtr[textCount] = stralloc(str);
- textCount++;
- }
- case 701:
- REPORTSTART("glutDeviceGet():");
- GLUTDEVGET(GLUT_HAS_KEYBOARD);
- GLUTDEVGET(GLUT_HAS_MOUSE);
- GLUTDEVGET(GLUT_HAS_SPACEBALL);
- GLUTDEVGET(GLUT_HAS_DIAL_AND_BUTTON_BOX);
- GLUTDEVGET(GLUT_HAS_TABLET);
- GLUTDEVGET(GLUT_NUM_MOUSE_BUTTONS);
- GLUTDEVGET(GLUT_NUM_SPACEBALL_BUTTONS);
- GLUTDEVGET(GLUT_NUM_BUTTON_BOX_BUTTONS);
- GLUTDEVGET(GLUT_NUM_DIALS);
- GLUTDEVGET(GLUT_NUM_TABLET_BUTTONS);
- REPORTEND;
- break;
- #define EXTCHECK(name)
- {
- char str[100], str2[100];
- int len, s;
- sprintf(str, # name);
- len = (int) strlen(# name);
- for(s = 0 ; s < INDENT-len; s++)
- strcat(str, " ");
- sprintf(str2, ": %sn",
- glutExtensionSupported(# name)?
- "yes": "no");
- strcat(str, str2);
- printf(str);
- textPtr[textCount] = stralloc(str);
- textCount++;
- }
- case 702:
- REPORTSTART("glutExtensionSupported():");
- EXTCHECK(GL_EXT_abgr);
- EXTCHECK(GL_EXT_blend_color);
- EXTCHECK(GL_EXT_blend_minmax);
- EXTCHECK(GL_EXT_blend_logic_op);
- EXTCHECK(GL_EXT_blend_subtract);
- EXTCHECK(GL_EXT_polygon_offset);
- EXTCHECK(GL_EXT_texture);
- EXTCHECK(GL_EXT_guaranteed_to_fail);
- EXTCHECK(GLX_SGI_swap_control);
- EXTCHECK(GLX_SGI_video_sync);
- EXTCHECK(GLX_SGIS_multi_sample);
- REPORTEND;
- break;
- case 703:
- dumpIds();
- break;
- /* Mess around with menus */
- case 800:
- if (glutGetMenu() != menu8) /* just a test */
- printf("glutGetMenu() returned unexpected valuen");
- glutAddMenuEntry("help", 101);
- glutAddMenuEntry("help", 101);
- glutAddMenuEntry("help", 101);
- glutAddMenuEntry("help", 101);
- glutAddMenuEntry("help", 101);
- break;
- case 801:
- glutAddSubMenu("shapes", menu3);
- glutAddSubMenu("shapes", menu3);
- glutAddSubMenu("shapes (a long string to break menus with)", menu3);
- glutAddSubMenu("shapes", menu3);
- glutAddSubMenu("shapes", menu3);
- break;
- case 802:
- items = glutGet(GLUT_MENU_NUM_ITEMS);
- for (m = initItems + 1; m <= items; m++) {
- glutChangeToMenuEntry(m, "help", 101);
- }
- break;
- case 803:
- items = glutGet(GLUT_MENU_NUM_ITEMS);
- for (m = initItems + 1; m <= items; m++) {
- glutChangeToSubMenu(m, "shapes", menu3);
- }
- break;
- case 804:
- items = glutGet(GLUT_MENU_NUM_ITEMS);
- /* reverse order so renumbering not aproblem */
- for (m = items; m >= initItems + 1; m--) {
- glutRemoveMenuItem(m);
- }
- break;
- case 805:
- menuButton[0] = !menuButton[0];
- attachMenus();
- break;
- case 806:
- menuButton[1] = !menuButton[1];
- attachMenus();
- break;
- case 807:
- menuButton[2] = !menuButton[2];
- attachMenus();
- break;
- /* Direct menu items. */
- case 100:
- exit(0);
- break;
- case 101:
- if (winId[5] == 0)
- makeWindow(5);
- else
- killWindow(5);
- break;
- case 9999:
- break;
- default:
- fprintf(stderr, "