1706f2543Smrg/* 2706f2543Smrg * Copyright (c) 2003 by the XFree86 Project, Inc. 3706f2543Smrg * 4706f2543Smrg * All Rights Reserved. 5706f2543Smrg * 6706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining 7706f2543Smrg * a copy of this software and associated documentation files (the 8706f2543Smrg * "Software"), to deal in the Software without restriction, including 9706f2543Smrg * without limitation on the rights to use, copy, modify, merge, 10706f2543Smrg * publish, distribute, sublicense, and/or sell copies of the Software, 11706f2543Smrg * and to permit persons to whom the Software is furnished to do so, 12706f2543Smrg * subject to the following conditions: 13706f2543Smrg * 14706f2543Smrg * The above copyright notice and this permission notice (including the 15706f2543Smrg * next paragraph) shall be included in all copies or substantial 16706f2543Smrg * portions of the Software. 17706f2543Smrg * 18706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19706f2543Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20706f2543Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21706f2543Smrg * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS 22706f2543Smrg * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 23706f2543Smrg * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24706f2543Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25706f2543Smrg * SOFTWARE. 26706f2543Smrg */ 27706f2543Smrg 28706f2543Smrg/* 29706f2543Smrg * Create a window and use the DMX extension to query the window's 30706f2543Smrg * back-end properties. Display the info inside the window itself. 31706f2543Smrg * 32706f2543Smrg * Brian Paul 33706f2543Smrg * 23 Jan 2003 34706f2543Smrg */ 35706f2543Smrg 36706f2543Smrg#include <assert.h> 37706f2543Smrg#include <stdio.h> 38706f2543Smrg#include <stdlib.h> 39706f2543Smrg#include <string.h> 40706f2543Smrg#include <X11/Xlib.h> 41706f2543Smrg#include <X11/Xutil.h> 42706f2543Smrg#include <X11/Xmu/SysUtil.h> 43706f2543Smrg#include <X11/extensions/dmxext.h> 44706f2543Smrg 45706f2543Smrgstatic const char *FontName = "fixed"; 46706f2543Smrg 47706f2543Smrg 48706f2543Smrgstatic void 49706f2543SmrgEventLoop(Display *dpy, Window win, GC gc) 50706f2543Smrg{ 51706f2543Smrg XEvent ev; 52706f2543Smrg while (1) { 53706f2543Smrg XNextEvent( dpy, &ev ); 54706f2543Smrg switch (ev.type) { 55706f2543Smrg case ReparentNotify: 56706f2543Smrg break; 57706f2543Smrg case MapNotify: 58706f2543Smrg break; 59706f2543Smrg case ConfigureNotify: 60706f2543Smrg case Expose: 61706f2543Smrg { 62706f2543Smrg int numScreens, count, i; 63706f2543Smrg DMXWindowAttributes *winInfo; 64706f2543Smrg int x, y; 65706f2543Smrg const char *msg = "DMX window info:"; 66706f2543Smrg 67706f2543Smrg DMXGetScreenCount(dpy, &numScreens); 68706f2543Smrg winInfo 69706f2543Smrg = (DMXWindowAttributes *) 70706f2543Smrg malloc(numScreens * sizeof(DMXWindowAttributes)); 71706f2543Smrg assert(winInfo); 72706f2543Smrg if (!DMXGetWindowAttributes(dpy, win, &count, 73706f2543Smrg numScreens, winInfo)) { 74706f2543Smrg printf("Could not get window information for 0x%08lx\n", 75706f2543Smrg (long unsigned)win); 76706f2543Smrg } 77706f2543Smrg x = y = 50; 78706f2543Smrg XClearWindow(dpy, win); 79706f2543Smrg XDrawString(dpy, win, gc, x, y, msg, strlen(msg)); 80706f2543Smrg y += 20; 81706f2543Smrg for (i = 0; i < count; i++) { 82706f2543Smrg char str[500]; 83706f2543Smrg XmuSnprintf(str, sizeof(str), 84706f2543Smrg "screen %d: pos: %dx%d+%d+%d visible: %dx%d+%d+%d", 85706f2543Smrg winInfo[i].screen, 86706f2543Smrg winInfo[i].pos.width, winInfo[i].pos.height, 87706f2543Smrg winInfo[i].pos.x, winInfo[i].pos.y, 88706f2543Smrg winInfo[i].vis.width, winInfo[i].vis.height, 89706f2543Smrg winInfo[i].vis.x, winInfo[i].vis.y); 90706f2543Smrg XDrawString(dpy, win, gc, x, y, str, strlen(str)); 91706f2543Smrg y += 20; 92706f2543Smrg } 93706f2543Smrg free(winInfo); 94706f2543Smrg } 95706f2543Smrg break; 96706f2543Smrg default: 97706f2543Smrg printf("Event type 0x%x\n", ev.type); 98706f2543Smrg } 99706f2543Smrg } 100706f2543Smrg} 101706f2543Smrg 102706f2543Smrgint 103706f2543Smrgmain(int argc, char *argv[]) 104706f2543Smrg{ 105706f2543Smrg const char *displayName = NULL; 106706f2543Smrg Display *dpy; 107706f2543Smrg int event_base, error_base; 108706f2543Smrg int scr, n; 109706f2543Smrg long vinfoMask, attrMask; 110706f2543Smrg XVisualInfo vinfoTemp, *visInfo; 111706f2543Smrg Visual *vis; 112706f2543Smrg Window win, root; 113706f2543Smrg XSetWindowAttributes attr; 114706f2543Smrg XFontStruct *fontInfo; 115706f2543Smrg GC gc; 116706f2543Smrg 117706f2543Smrg if (argc > 1) { 118706f2543Smrg displayName = argv[1]; 119706f2543Smrg } 120706f2543Smrg 121706f2543Smrg dpy = XOpenDisplay(displayName); 122706f2543Smrg if (!dpy) { 123706f2543Smrg fprintf(stderr, "Unable to open display %s\n", displayName); 124706f2543Smrg return -1; 125706f2543Smrg } 126706f2543Smrg 127706f2543Smrg if (!DMXQueryExtension(dpy, &event_base, &error_base)) { 128706f2543Smrg fprintf(stderr, "DMX extension not available on this display.\n"); 129706f2543Smrg return -1; 130706f2543Smrg } 131706f2543Smrg 132706f2543Smrg scr = DefaultScreen(dpy); 133706f2543Smrg root = RootWindow(dpy, scr); 134706f2543Smrg vis = DefaultVisual(dpy, scr); 135706f2543Smrg 136706f2543Smrg vinfoMask = VisualIDMask; 137706f2543Smrg vinfoTemp.visualid = vis->visualid; 138706f2543Smrg visInfo = XGetVisualInfo(dpy, vinfoMask, &vinfoTemp, &n); 139706f2543Smrg if (!visInfo || n != 1) { 140706f2543Smrg fprintf(stderr, "Unable to get visual!\n"); 141706f2543Smrg XCloseDisplay(dpy); 142706f2543Smrg return -1; 143706f2543Smrg } 144706f2543Smrg 145706f2543Smrg attr.background_pixel = 0; 146706f2543Smrg attr.border_pixel = 0; 147706f2543Smrg attr.colormap = XCreateColormap(dpy, root, visInfo->visual, AllocNone); 148706f2543Smrg attr.event_mask = StructureNotifyMask | ExposureMask; 149706f2543Smrg attrMask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; 150706f2543Smrg 151706f2543Smrg win = XCreateWindow(dpy, root, 152706f2543Smrg 500, 500, 600, 400, /* x, y, w, h */ 153706f2543Smrg 0, /* border_width */ 154706f2543Smrg visInfo->depth, InputOutput, 155706f2543Smrg visInfo->visual, attrMask, &attr); 156706f2543Smrg 157706f2543Smrg 158706f2543Smrg if (!win) { 159706f2543Smrg fprintf(stderr, "Unable to create window!\n"); 160706f2543Smrg XCloseDisplay(dpy); 161706f2543Smrg return -1; 162706f2543Smrg } 163706f2543Smrg 164706f2543Smrg fontInfo = XLoadQueryFont(dpy, FontName); 165706f2543Smrg if (!fontInfo) { 166706f2543Smrg fprintf(stderr, "Error: font %s not found\n", FontName); 167706f2543Smrg exit(0); 168706f2543Smrg } 169706f2543Smrg 170706f2543Smrg gc = XCreateGC(dpy, win, 0, NULL); 171706f2543Smrg XSetBackground(dpy, gc, BlackPixel(dpy, scr)); 172706f2543Smrg XSetForeground(dpy, gc, WhitePixel(dpy, scr)); 173706f2543Smrg XSetFont(dpy, gc, fontInfo->fid); 174706f2543Smrg 175706f2543Smrg XMapWindow(dpy, win); 176706f2543Smrg 177706f2543Smrg EventLoop(dpy, win, gc); 178706f2543Smrg 179706f2543Smrg XDestroyWindow(dpy, win); 180706f2543Smrg XCloseDisplay(dpy); 181706f2543Smrg return 0; 182706f2543Smrg} 183706f2543Smrg 184706f2543Smrg#if 00 185706f2543Smrg 186706f2543Smrgstatic void make_window( char *title, int color_flag ) 187706f2543Smrg{ 188706f2543Smrg int x = 10, y = 10, width = 400, height = 300; 189706f2543Smrg Display *dpy; 190706f2543Smrg int scr; 191706f2543Smrg Window root, win; 192706f2543Smrg Colormap cmap; 193706f2543Smrg XColor xcolor; 194706f2543Smrg int attr_flags; 195706f2543Smrg XVisualInfo *visinfo; 196706f2543Smrg XSetWindowAttributes attr; 197706f2543Smrg XTextProperty tp; 198706f2543Smrg XSizeHints sh; 199706f2543Smrg XEvent e; 200706f2543Smrg XMesaContext context; 201706f2543Smrg XMesaVisual visual; 202706f2543Smrg XMesaBuffer buffer; 203706f2543Smrg 204706f2543Smrg 205706f2543Smrg /* 206706f2543Smrg * Do the usual X things to make a window. 207706f2543Smrg */ 208706f2543Smrg 209706f2543Smrg dpy = XOpenDisplay(NULL); 210706f2543Smrg if (!dpy) { 211706f2543Smrg printf("Couldn't open default display!\n"); 212706f2543Smrg exit(1); 213706f2543Smrg } 214706f2543Smrg 215706f2543Smrg scr = DefaultScreen(dpy); 216706f2543Smrg root = RootWindow(dpy, scr); 217706f2543Smrg 218706f2543Smrg /* alloc visinfo struct */ 219706f2543Smrg visinfo = (XVisualInfo *) malloc( sizeof(XVisualInfo) ); 220706f2543Smrg 221706f2543Smrg /* Get a visual and colormap */ 222706f2543Smrg if (color_flag) { 223706f2543Smrg /* Open TrueColor window */ 224706f2543Smrg 225706f2543Smrg/* 226706f2543Smrg if (!XMatchVisualInfo( dpy, scr, 24, TrueColor, visinfo )) { 227706f2543Smrg printf("Couldn't get 24-bit TrueColor visual!\n"); 228706f2543Smrg exit(1); 229706f2543Smrg } 230706f2543Smrg*/ 231706f2543Smrg if (!XMatchVisualInfo( dpy, scr, 8, PseudoColor, visinfo )) { 232706f2543Smrg printf("Couldn't get 8-bit PseudoColor visual!\n"); 233706f2543Smrg exit(1); 234706f2543Smrg } 235706f2543Smrg 236706f2543Smrg cmap = XCreateColormap( dpy, root, visinfo->visual, AllocNone ); 237706f2543Smrg Black = Red = Green = Blue = 0; 238706f2543Smrg } 239706f2543Smrg else { 240706f2543Smrg /* Open color index window */ 241706f2543Smrg 242706f2543Smrg if (!XMatchVisualInfo( dpy, scr, 8, PseudoColor, visinfo )) { 243706f2543Smrg printf("Couldn't get 8-bit PseudoColor visual\n"); 244706f2543Smrg exit(1); 245706f2543Smrg } 246706f2543Smrg 247706f2543Smrg cmap = XCreateColormap( dpy, root, visinfo->visual, AllocNone ); 248706f2543Smrg 249706f2543Smrg /* Allocate colors */ 250706f2543Smrg xcolor.red = 0x0; 251706f2543Smrg xcolor.green = 0x0; 252706f2543Smrg xcolor.blue = 0x0; 253706f2543Smrg xcolor.flags = DoRed | DoGreen | DoBlue; 254706f2543Smrg if (!XAllocColor( dpy, cmap, &xcolor )) { 255706f2543Smrg printf("Couldn't allocate black!\n"); 256706f2543Smrg exit(1); 257706f2543Smrg } 258706f2543Smrg Black = xcolor.pixel; 259706f2543Smrg 260706f2543Smrg xcolor.red = 0xffff; 261706f2543Smrg xcolor.green = 0x0; 262706f2543Smrg xcolor.blue = 0x0; 263706f2543Smrg xcolor.flags = DoRed | DoGreen | DoBlue; 264706f2543Smrg if (!XAllocColor( dpy, cmap, &xcolor )) { 265706f2543Smrg printf("Couldn't allocate red!\n"); 266706f2543Smrg exit(1); 267706f2543Smrg } 268706f2543Smrg Red = xcolor.pixel; 269706f2543Smrg 270706f2543Smrg xcolor.red = 0x0; 271706f2543Smrg xcolor.green = 0xffff; 272706f2543Smrg xcolor.blue = 0x0; 273706f2543Smrg xcolor.flags = DoRed | DoGreen | DoBlue; 274706f2543Smrg if (!XAllocColor( dpy, cmap, &xcolor )) { 275706f2543Smrg printf("Couldn't allocate green!\n"); 276706f2543Smrg exit(1); 277706f2543Smrg } 278706f2543Smrg Green = xcolor.pixel; 279706f2543Smrg 280706f2543Smrg xcolor.red = 0x0; 281706f2543Smrg xcolor.green = 0x0; 282706f2543Smrg xcolor.blue = 0xffff; 283706f2543Smrg xcolor.flags = DoRed | DoGreen | DoBlue; 284706f2543Smrg if (!XAllocColor( dpy, cmap, &xcolor )) { 285706f2543Smrg printf("Couldn't allocate blue!\n"); 286706f2543Smrg exit(1); 287706f2543Smrg } 288706f2543Smrg Blue = xcolor.pixel; 289706f2543Smrg } 290706f2543Smrg 291706f2543Smrg /* set window attributes */ 292706f2543Smrg attr.colormap = cmap; 293706f2543Smrg attr.event_mask = ExposureMask | StructureNotifyMask; 294706f2543Smrg attr.border_pixel = BlackPixel( dpy, scr ); 295706f2543Smrg attr.background_pixel = BlackPixel( dpy, scr ); 296706f2543Smrg attr_flags = CWColormap | CWEventMask | CWBorderPixel | CWBackPixel; 297706f2543Smrg 298706f2543Smrg /* Create the window */ 299706f2543Smrg win = XCreateWindow( dpy, root, x,y, width, height, 0, 300706f2543Smrg visinfo->depth, InputOutput, 301706f2543Smrg visinfo->visual, 302706f2543Smrg attr_flags, &attr); 303706f2543Smrg if (!win) { 304706f2543Smrg printf("Couldn't open window!\n"); 305706f2543Smrg exit(1); 306706f2543Smrg } 307706f2543Smrg 308706f2543Smrg XStringListToTextProperty(&title, 1, &tp); 309706f2543Smrg sh.flags = USPosition | USSize; 310706f2543Smrg XSetWMProperties(dpy, win, &tp, &tp, 0, 0, &sh, 0, 0); 311706f2543Smrg XMapWindow(dpy, win); 312706f2543Smrg while (1) { 313706f2543Smrg XNextEvent( dpy, &e ); 314706f2543Smrg if (e.type == MapNotify && e.xmap.window == win) { 315706f2543Smrg break; 316706f2543Smrg } 317706f2543Smrg } 318706f2543Smrg 319706f2543Smrg 320706f2543Smrg /* 321706f2543Smrg * Now do the special Mesa/Xlib stuff! 322706f2543Smrg */ 323706f2543Smrg 324706f2543Smrg visual = XMesaCreateVisual( dpy, visinfo, 325706f2543Smrg (GLboolean) color_flag, 326706f2543Smrg GL_FALSE, /* alpha_flag */ 327706f2543Smrg GL_FALSE, /* db_flag */ 328706f2543Smrg GL_FALSE, /* stereo flag */ 329706f2543Smrg GL_FALSE, /* ximage_flag */ 330706f2543Smrg 0, /* depth size */ 331706f2543Smrg 0, /* stencil size */ 332706f2543Smrg 0,0,0,0, /* accum_size */ 333706f2543Smrg 0, /* num samples */ 334706f2543Smrg 0, /* level */ 335706f2543Smrg 0 /* caveat */ 336706f2543Smrg ); 337706f2543Smrg if (!visual) { 338706f2543Smrg printf("Couldn't create Mesa/X visual!\n"); 339706f2543Smrg exit(1); 340706f2543Smrg } 341706f2543Smrg 342706f2543Smrg /* Create a Mesa rendering context */ 343706f2543Smrg context = XMesaCreateContext( visual, 344706f2543Smrg NULL /* share_list */ 345706f2543Smrg ); 346706f2543Smrg if (!context) { 347706f2543Smrg printf("Couldn't create Mesa/X context!\n"); 348706f2543Smrg exit(1); 349706f2543Smrg } 350706f2543Smrg 351706f2543Smrg buffer = XMesaCreateWindowBuffer( visual, win ); 352706f2543Smrg if (!buffer) { 353706f2543Smrg printf("Couldn't create Mesa/X buffer!\n"); 354706f2543Smrg exit(1); 355706f2543Smrg } 356706f2543Smrg 357706f2543Smrg 358706f2543Smrg XMesaMakeCurrent( context, buffer ); 359706f2543Smrg 360706f2543Smrg /* Ready to render! */ 361706f2543Smrg} 362706f2543Smrg 363706f2543Smrg 364706f2543Smrg 365706f2543Smrgstatic void draw_cube( void ) 366706f2543Smrg{ 367706f2543Smrg /* X faces */ 368706f2543Smrg glIndexi( Red ); 369706f2543Smrg glColor3f( 1.0, 0.0, 0.0 ); 370706f2543Smrg glBegin( GL_POLYGON ); 371706f2543Smrg glVertex3f( 1.0, 1.0, 1.0 ); 372706f2543Smrg glVertex3f( 1.0, -1.0, 1.0 ); 373706f2543Smrg glVertex3f( 1.0, -1.0, -1.0 ); 374706f2543Smrg glVertex3f( 1.0, 1.0, -1.0 ); 375706f2543Smrg glEnd(); 376706f2543Smrg 377706f2543Smrg glBegin( GL_POLYGON ); 378706f2543Smrg glVertex3f( -1.0, 1.0, 1.0 ); 379706f2543Smrg glVertex3f( -1.0, 1.0, -1.0 ); 380706f2543Smrg glVertex3f( -1.0, -1.0, -1.0 ); 381706f2543Smrg glVertex3f( -1.0, -1.0, 1.0 ); 382706f2543Smrg glEnd(); 383706f2543Smrg 384706f2543Smrg /* Y faces */ 385706f2543Smrg glIndexi( Green ); 386706f2543Smrg glColor3f( 0.0, 1.0, 0.0 ); 387706f2543Smrg glBegin( GL_POLYGON ); 388706f2543Smrg glVertex3f( 1.0, 1.0, 1.0 ); 389706f2543Smrg glVertex3f( 1.0, 1.0, -1.0 ); 390706f2543Smrg glVertex3f( -1.0, 1.0, -1.0 ); 391706f2543Smrg glVertex3f( -1.0, 1.0, 1.0 ); 392706f2543Smrg glEnd(); 393706f2543Smrg 394706f2543Smrg glBegin( GL_POLYGON ); 395706f2543Smrg glVertex3f( 1.0, -1.0, 1.0 ); 396706f2543Smrg glVertex3f( -1.0, -1.0, 1.0 ); 397706f2543Smrg glVertex3f( -1.0, -1.0, -1.0 ); 398706f2543Smrg glVertex3f( 1.0, -1.0, -1.0 ); 399706f2543Smrg glEnd(); 400706f2543Smrg 401706f2543Smrg /* Z faces */ 402706f2543Smrg glIndexi( Blue ); 403706f2543Smrg glColor3f( 0.0, 0.0, 1.0 ); 404706f2543Smrg glBegin( GL_POLYGON ); 405706f2543Smrg glVertex3f( 1.0, 1.0, 1.0 ); 406706f2543Smrg glVertex3f( -1.0, 1.0, 1.0 ); 407706f2543Smrg glVertex3f( -1.0, -1.0, 1.0 ); 408706f2543Smrg glVertex3f( 1.0, -1.0, 1.0 ); 409706f2543Smrg glEnd(); 410706f2543Smrg 411706f2543Smrg glBegin( GL_POLYGON ); 412706f2543Smrg glVertex3f( 1.0, 1.0, -1.0 ); 413706f2543Smrg glVertex3f( 1.0,-1.0, -1.0 ); 414706f2543Smrg glVertex3f( -1.0,-1.0, -1.0 ); 415706f2543Smrg glVertex3f( -1.0, 1.0, -1.0 ); 416706f2543Smrg glEnd(); 417706f2543Smrg} 418706f2543Smrg 419706f2543Smrg 420706f2543Smrg 421706f2543Smrg 422706f2543Smrgstatic void display_loop( void ) 423706f2543Smrg{ 424706f2543Smrg GLfloat xrot, yrot, zrot; 425706f2543Smrg 426706f2543Smrg xrot = yrot = zrot = 0.0; 427706f2543Smrg 428706f2543Smrg glClearColor( 0.0, 0.0, 0.0, 0.0 ); 429706f2543Smrg glClearIndex( Black ); 430706f2543Smrg 431706f2543Smrg glMatrixMode( GL_PROJECTION ); 432706f2543Smrg glLoadIdentity(); 433706f2543Smrg glFrustum( -1.0, 1.0, -1.0, 1.0, 1.0, 10.0 ); 434706f2543Smrg glTranslatef( 0.0, 0.0, -5.0 ); 435706f2543Smrg 436706f2543Smrg glMatrixMode( GL_MODELVIEW ); 437706f2543Smrg glLoadIdentity(); 438706f2543Smrg 439706f2543Smrg glCullFace( GL_BACK ); 440706f2543Smrg glEnable( GL_CULL_FACE ); 441706f2543Smrg 442706f2543Smrg glShadeModel( GL_FLAT ); 443706f2543Smrg 444706f2543Smrg while (1) { 445706f2543Smrg glClear( GL_COLOR_BUFFER_BIT ); 446706f2543Smrg glPushMatrix(); 447706f2543Smrg glRotatef( xrot, 1.0, 0.0, 0.0 ); 448706f2543Smrg glRotatef( yrot, 0.0, 1.0, 0.0 ); 449706f2543Smrg glRotatef( zrot, 0.0, 0.0, 1.0 ); 450706f2543Smrg 451706f2543Smrg draw_cube(); 452706f2543Smrg 453706f2543Smrg glPopMatrix(); 454706f2543Smrg glFinish(); 455706f2543Smrg 456706f2543Smrg xrot += 10.0; 457706f2543Smrg yrot += 7.0; 458706f2543Smrg zrot -= 3.0; 459706f2543Smrg } 460706f2543Smrg 461706f2543Smrg} 462706f2543Smrg 463706f2543Smrg 464706f2543Smrg 465706f2543Smrg 466706f2543Smrgint main( int argc, char *argv[] ) 467706f2543Smrg{ 468706f2543Smrg int mode = 0; 469706f2543Smrg 470706f2543Smrg if (argc >= 2) 471706f2543Smrg { 472706f2543Smrg if (strcmp(argv[1],"-ci")==0) 473706f2543Smrg mode = 0; 474706f2543Smrg else if (strcmp(argv[1],"-rgb")==0) 475706f2543Smrg mode = 1; 476706f2543Smrg else 477706f2543Smrg { 478706f2543Smrg printf("Bad flag: %s\n", argv[1]); 479706f2543Smrg printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n"); 480706f2543Smrg exit(1); 481706f2543Smrg } 482706f2543Smrg } 483706f2543Smrg else 484706f2543Smrg { 485706f2543Smrg printf("Specify -ci for 8-bit color index or -rgb for RGB mode\n"); 486706f2543Smrg printf("Defaulting to 8-bit color index\n"); 487706f2543Smrg } 488706f2543Smrg 489706f2543Smrg make_window( argv[0], mode ); 490706f2543Smrg 491706f2543Smrg display_loop(); 492706f2543Smrg return 0; 493706f2543Smrg} 494706f2543Smrg 495706f2543Smrg 496706f2543Smrg#endif 497