void main(int argc, char **argv) { int i,j,k, x_return, y_return; float D; unsigned int width_return, height_return, border_width_return, depth_return; Window root_return; char *display_name; int screen; XSetWindowAttributes winAttributes; char *window_name = "sbXcityfly"; char *icon_name = "sbXcityfly"; static ButtonRec buttonDefs[]={ {&buttonDefs[1], "1", "Translation ON ", 0, SPW_BwFlagRoundButton}, {&buttonDefs[2], "2", "Rotation ON ", 0, SPW_BwFlagRoundButton}, {&buttonDefs[3], "3", "Single Axis Filter OFF", 0, SPW_BwFlagRoundButton}, {&buttonDefs[4], "4", "Roll ON ", 0, SPW_BwFlagRoundButton}, {&buttonDefs[5], "5", "Decrease sensitivity", 0, SPW_BwFlagRoundButton}, {&buttonDefs[6], "Sensi", "Sensitivity: 1 ", 0, SPW_BwFlagNoButton}, {&buttonDefs[7], "6", "Increase sensitivity", 0, SPW_BwFlagRoundButton}, {&buttonDefs[8], "7", " ", 0, SPW_BwFlagRoundButton}, {&buttonDefs[9], "8", "Rezero", 0, SPW_BwFlagRoundButton}, {&buttonDefs[10], "P", "Reset View", 0, SPW_BwFlagRoundButton}, {&buttonDefs[11], NULL, NULL, 0, SPW_BwFlagSeparator}, {&buttonDefs[12], "ESC", "Quit", XK_Escape, SPW_BwFlagKey}, {NULL, NULL, NULL, 0, SPW_BwFlagSeparator}, }; /* * Connect to the X Server */ if ((display_name=getenv("DISPLAY")) == NULL) display_name=":0"; if ((Spw_Dpy=XOpenDisplay(display_name)) == NULL) { fprintf(stderr,"%s: Could not open X Display\n",argv[0]); exit(1); } screen=DefaultScreen(Spw_Dpy); Spw_Gc=DefaultGC(Spw_Dpy,screen); XSetBackground(Spw_Dpy,Spw_Gc,BlackPixel(Spw_Dpy,screen)); XSetForeground(Spw_Dpy,Spw_Gc,WhitePixel(Spw_Dpy,screen)); winAttributes.background_pixel=BlackPixel(Spw_Dpy,screen); /* * Create the main window proportional to the root window */ XGetGeometry(Spw_Dpy, DefaultRootWindow(Spw_Dpy), &root_return, &x_return,&y_return, &width_return, &height_return,& border_width_return, &depth_return); Spw_WindowSize = .8 * MIN(height_return,width_return); Spw_WindowWidth = Spw_WindowSize; Spw_WindowHeight = Spw_WindowSize; Spw_mainWindow = XCreateWindow(Spw_Dpy,DefaultRootWindow(Spw_Dpy), 250, 0, Spw_WindowWidth, Spw_WindowHeight,1, CopyFromParent,CopyFromParent,CopyFromParent, CWBackPixel,&winAttributes); Spw_mainBuffer= XCreatePixmap(Spw_Dpy, Spw_mainWindow, Spw_WindowWidth, Spw_WindowHeight, XDefaultDepthOfScreen(XDefaultScreenOfDisplay(Spw_Dpy))); /* * Select the colors to draw in */ Spw_white = AllocPublicColor(0xffff,0xffff,0xffff); Spw_black = AllocPublicColor(0x0000,0x0000,0x0000); Spw_grey = AllocPublicColor(0xffff,0xffff,0xffff); Spw_green = AllocPublicColor(0x0000,0xffff,0x0000); /* * Set up and map the window */ XStoreName(Spw_Dpy, Spw_mainWindow, argv[0]); setWindowHints(Spw_mainWindow, argv, argc, window_name, icon_name, "sbXcityfly", "SBxcityfly"); XMapWindow(Spw_Dpy, Spw_mainWindow); /* * Initialize the Spaceball and Button Window */ if (!(SPW_InputCheckForSpaceball(Spw_Dpy, Spw_mainWindow, "sbXcityfly")) ) { fprintf (stderr, "Sorry, no Spaceball found!\n"); exit(0); } Spw_ButtonWindow=SPW_BwInit(Spw_Dpy, DefaultScreenOfDisplay(Spw_Dpy), "sbXcityfly", buttonDefs); if(!Spw_ButtonWindow) { fprintf(stderr, "Error: BwInit returned NULL\n"); exit(-1); } SpwUpdateButtons(); /* * Set up the geometry to be displayed */ D = 1.0/tan( (double) ((M_PI/180.0)*(FOV/2.0)) ); SPW_InitializeMatrix(Spw_Persp, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, -1.0/D, 0.0, 0.0, 0.0, 0.0); GetUniqPoints(bldg, buniq, Spw_SizeBldg ); GetUniqPoints(land, luniq, Spw_SizeLand ); /* * Go into main loop, clean up if we ever exit cleanly */ DispatchLoop(); XDestroyWindow(Spw_Dpy, Spw_mainWindow); XCloseDisplay(Spw_Dpy); } /* end of main */
void Initialise() { DispatchLoop(); }