void PrintFile2( FILE *OutFile ) { Line_Control *line; if ( !OutFile ) { fprintf( stderr, "Unable to open (%s) for output\n", "stdout" ); exit_application( 1 ); } assert( OutFile ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { fprintf( OutFile, "%s\n", line->Contents ); /* fprintf( OutFile, "(%d,%d)%s\n", line->keyword, line->format, line->Contents ); */ } }
static void init_application( int *argc, char **argv[] ) { DFBResult ret; DFBSurfaceDescription desc; /* Initialize DirectFB including command line parsing. */ ret = DirectFBInit( argc, argv ); if (ret) { DirectFBError( "DirectFBInit() failed", ret ); exit_application( 1 ); } /* Create the super interface. */ ret = DirectFBCreate( &dfb ); if (ret) { DirectFBError( "DirectFBCreate() failed", ret ); exit_application( 2 ); } /* Request fullscreen mode. */ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); /* Fill the surface description. */ desc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT; desc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; desc.pixelformat = DSPF_ARGB; /* Create an 8 bit palette surface. */ ret = dfb->CreateSurface( dfb, &desc, &primary ); if (ret) { DirectFBError( "IDirectFB::CreateSurface() failed", ret ); exit_application( 3 ); } /* Create an event buffer with key capable devices attached. */ ret = dfb->CreateInputEventBuffer( dfb, DICAPS_KEYS, DFB_FALSE, &events ); if (ret) { DirectFBError( "IDirectFB::CreateEventBuffer() failed", ret ); exit_application( 4 ); } /* Clear with black. */ primary->Clear( primary, 0x00, 0x00, 0x00, 0xff ); primary->Flip( primary, NULL, 0 ); }
int main (int argc, char *argv[]) { /* checking for valid argument count and value */ //we should only have 1 argument! //note that the './executable' also counts as an argument itself! if (argc != 2 ){ return exit_application(ERROR_INVALID_ARG_COUNT); } //check for validty of argument (should be 0 t0 255) //TODO this can not tell if the given argument was integer or string(char) //c's atoi() function will case almost anything to integer!!! bad bad bad! int value = atoi(argv[1]); //convert argument 1 to integer if((value > 255 || value < 0)) { return exit_application(ERROR_INVALID_ARG_RANGE); } //correct argument...doing what we supposed to do :) pfffffff...... printf("%d\n", value ^= 0xFF); //XOR with 255 to reverse the bits return 0; //alles klaaaaaaaaar }
int main(int argc, char* argv[]) { char buffer[2048]; /* string buffer for self-control list */ signal(SIGINT, SIG_IGN); vrConfigure(&argc, argv, NULL); vrStart(); signal(SIGINT, exit_application); /* TODO: it would be nice to put these above vrStart(), since */ /* it will block until all input devices are open, and this */ /* way we could be rendering something while waiting. */ /* TODO: actually, we almost *need* to have the init_gfx stuff*/ /* set before vrStart, so the window opening function will */ /* have something to call (other than vrDoNothing()). */ /* In fact, I have no idea how init_gfx() gets called at */ /* all given the current setup. */ vrFunctionSetCallback(VRFUNC_ALL_DISPLAY_INIT, vrCallbackCreate(init_gfx, 0)); vrFunctionSetCallback(VRFUNC_ALL_DISPLAY, vrCallbackCreate(draw_server_world, 0)); vrFunctionSetCallback(VRFUNC_HANDLE_USR2, vrCallbackCreate(vrDbgInfo, 0)); if (vrContext->input->num_input_devices > 0) { vrDbgPrintfN(SELDOM_DBGLVL+1, "input viewer: input device[0] version = '%s'\n", vrContext->input->input_devices[0]->version); } else { vrDbgPrintfN(SELDOM_DBGLVL+1, "input viewer: No input devices defined.\n"); } vrSystemSetName("inputs -- FreeVR inputs display application"); vrSystemSetAuthors("Bill Sherman"); list_self_controls(buffer, vrContext->input, sizeof(buffer), verbose); vrPrintf(buffer); vrSystemSetExtraInfo(buffer); vrDbgPrintf("input viewer: looping\n"); while(vrFrame()) { update_world(); } exit_application(); exit(0); }
int main(int argc, char *argv[]) { int run = 300; width = atoi(argv[1]); height = atoi(argv[2]); fps = atoi(argv[3]); printf("width:%d,%d,fps:%d\n",width,height,fps); init_stglib(); /* Main loop */ update(); // events->WaitForEventWithTimeout(events, 0, 100); exit_stglib(); exit_application(0); return 0; }
static void init_application( int *argc, char **argv[] ) { DFBResult ret; DFBWindowDescription desc; DFBDisplayLayerConfig config; /* Initialize DirectFB including command line parsing. */ ret = DirectFBInit( argc, argv ); if (ret) { DirectFBError( "DirectFBInit() failed", ret ); exit_application( 1 ); } /* Create the super interface. */ ret = DirectFBCreate( &dfb ); if (ret) { DirectFBError( "DirectFBCreate() failed", ret ); exit_application( 2 ); } /* Get the primary display layer. */ ret = dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer ); if (ret) { DirectFBError( "IDirectFB::GetDisplayLayer() failed", ret ); exit_application( 3 ); } /* Get the screen size etc. */ layer->GetConfiguration( layer, &config ); /* Fill the window description. */ desc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS; desc.posx = config.width - 288; desc.posy = 8; desc.width = 64; desc.height = 64; desc.caps = DWCAPS_ALPHACHANNEL | DWCAPS_NODECORATION; /* Create the window. */ ret = layer->CreateWindow( layer, &desc, &window ); if (ret) { DirectFBError( "IDirectFBDisplayLayer::CreateWindow() failed", ret ); exit_application( 4 ); } /* Get the window's surface. */ ret = window->GetSurface( window, &surface ); if (ret) { DirectFBError( "IDirectFBWindow::GetSurface() failed", ret ); exit_application( 5 ); } /* Create an event buffer for all keyboard events. */ ret = window->CreateEventBuffer( window, &events ); if (ret) { DirectFBError( "IDirectFBWindow::CreateEventBuffer() failed", ret ); exit_application( 6 ); } /* Add ghost option (behave like an overlay). */ window->SetOptions( window, DWOP_ALPHACHANNEL | DWOP_GHOST ); /* Move window to upper stacking class. */ window->SetStackingClass( window, DWSC_UPPER ); /* Make it the top most window. */ window->RaiseToTop( window ); }
int main(int argc, char* argv[]) { /* TODO: do I want to ignore interrupts for all of this? or */ /* just during vrStart()? */ //signal(SIGINT, SIG_IGN); vrShmemInit(30 * 1024 * 1024); vrConfigure(&argc, argv, NULL); /* TODO: it would be nice to put these above vrStart(), since */ /* it will block until all input devices are open, and this */ /* way we could be rendering something while waiting. */ /* TODO: actually, we almost *need* to have the init_gfx stuff*/ /* set before vrStart, so the window opening function will */ /* have something to call (other than vrDoNothing()). */ /* In fact, I have no idea how init_gfx() gets called at */ /* all given the current setup. */ /* [5/30/00: I have now moved the function setting routines to*/ /* come before vrStart(). The library needs to be changed */ /* such that the incoming callbacks are stored in a holding */ /* bin, until the render/input/whatever loop is ready to */ /* update them. */ #if 1 /* TODO: unfortunately this shorthand doesn't work when there are extra */ /* arguments but these work okay. */ vrCallbackSet(VRFUNC_DISPLAY_INIT, "init_gfx", init_gfx, 0); vrCallbackSet(VRFUNC_DISPLAY_FRAME, "gfx_frame", gfx_frame, 0); vrCallbackSet(VRFUNC_DISPLAY, "draw_world", draw_world, 0); vrCallbackSet(VRFUNC_DISPLAY_SIM, "my_sim", my_sim, 0); vrCallbackSet(VRFUNC_HANDLE_USR2, "travel:vrDbgInfo", vrDbgInfo, 0); #else # if 1 /* 1/4/2003: test of possible startup race condition */ vrSetFunc(VRFUNC_DISPLAY_INIT, vrCreateNamedCallback("init_gfx", init_gfx, 0)); # endif vrSetFunc(VRFUNC_DISPLAY, vrCreateNamedCallback("draw_world", draw_world, 0)); # ifdef PERSONAL_SIMULATOR vrSetFunc(VRFUNC_DISPLAY_SIM, vrCreateNamedCallback("my_sim", my_sim, 0)); # endif vrSetFunc(VRFUNC_HANDLE_USR2, vrCreateNamedCallback("travel:vrDbgInfo", vrDbgInfo, 0)); #endif vrStart(); signal(SIGINT, exit_application); if (vrContext->input->num_input_devices > 0) { vrDbgPrintfN(SELDOM_DBGLVL+1, "TRAVEL: input device[0] version = '%s'\n", vrContext->input->input_devices[0]->version); } else { vrDbgPrintfN(SELDOM_DBGLVL+1, "TRAVEL: No input devices defined.\n"); } #if 0 if (vrDbgDo(AALWAYS_DBGLVL+1)) { vrFprintContext(stdout, vrContext, verbose); vrFprintConfig(stdout, vrContext->config, verbose); vrFprintInput(stdout, vrContext->input, verbose); } #endif if(vrContext->input->num_input_devices > 0) vrDbgPrintf("TRAVEL: input device[0] version = '%s'\n", vrContext->input->input_devices[0]->version); #if 0 /* NOTE: this isn't really necessary, so don't use for non-test applications */ update_world(); vrInputWaitForAllInputDevicesToBeOpen(); #endif vrSystemSetName("travel -- FreeVR test program"); vrSystemSetAuthors("Bill Sherman"); vrSystemSetExtraInfo("A really good program for testing the FreeVR library"); vrSystemSetStatusDescription("Application running fine"); vrInputSet2switchDescription(0, "Terminate the application"); vrInputSet2switchDescription(1, "Reset User Travel"); vrInputSet2switchDescription(2, "Move User 0.1 to the right"); vrInputSet2switchDescription(3, "Move User 0.1 to the left"); vrInputSetValuatorDescription(0, "Rotate User"); vrInputSetValuatorDescription(1, "Move User in direction of Wand"); #if 0 /* for testing */ vrInputSetNswitchDescription(0, "Do something with a switch"); vrInputSetNsensorDescription(0, "Do something with an N-sensor"); vrInputSet6sensorDescription(0, "Move the Head"); vrInputSet6sensorDescription(1, "Move the Wand"); #endif vrDbgPrintf("TRAVEL: looping\n"); #if 1 while(vrFrame()) { update_world(); } #else /* run for two frames and then quit */ vrFrame(); update_world(); vrFrame(); update_world(); #endif vrPrintf(BOLD_TEXT "TRAVEL: I guess we're all done now.\n" NORM_TEXT); exit_application(); exit(0); }
int main( int argc, char *argv[] ) { int i = 0; int width, height; cairo_matrix_t matrix; /* Initialize application. */ init_application( &argc, &argv ); /* Query size of output surface. */ primary->GetSize( primary, &width, &height ); /* Transform coordinates to have 0,0 in the center. */ cairo_matrix_init_translate( &matrix, width/2, height/2 ); /* Enable coordinate transformation and anti-aliasing for all drawing/blitting, but not Clear(). */ primary->SetRenderOptions( primary, DSRO_MATRIX | DSRO_ANTIALIAS ); /* Main loop. */ while (1) { DFBInputEvent event; /* Convert doubles to DirectFB's fixed point 16.16 and call IDirectFBSurface::SetMatrix(). */ set_cairo_matrix( &matrix ); /* Clear the frame. */ primary->SetDrawingFlags( primary, DSDRAW_NOFX ); primary->Clear( primary, 0x00, 0x00, 0x00, 0x00 ); /* Enable alphablend. */ primary->SetDrawingFlags( primary, DSDRAW_BLEND ); /* Set the blend functions to (SRCALPHASAT, ONE) to * prevent antialiased edges within complex shapes * (e.g. transformed rectangles). */ primary->SetSrcBlendFunction( primary, DSBF_SRCALPHASAT ); primary->SetDstBlendFunction( primary, DSBF_ONE ); /* Fill a small white rectangle in the middle. */ primary->SetColor( primary, 0xff, 0xff, 0xff, 0xff ); primary->FillRectangle( primary, -20, -20, 40, 40 ); /* Fill a small green rectangle on the left. */ primary->SetColor( primary, 0x00, 0xff, 0x00, 0xff ); primary->FillRectangle( primary, -120, -20, 40, 40 ); /* Fill a small blue rectangle at the top. */ primary->SetColor( primary, 0x00, 0x00, 0xff, 0xff ); primary->FillRectangle( primary, -20, -120, 40, 40 ); /* Fill a red rectangle down-right without AA. */ primary->SetColor( primary, 0xff, 0, 0, 0xff ); primary->SetDrawingFlags( primary, DSDRAW_NOFX ); primary->SetRenderOptions( primary, DSRO_MATRIX ); primary->FillRectangle( primary, 100, 100, 100, 100 ); primary->SetRenderOptions( primary, DSRO_MATRIX | DSRO_ANTIALIAS ); primary->SetDrawingFlags( primary, DSDRAW_BLEND ); /* For simpe shapes (lines & triangles) SRCALPHA is good. */ primary->SetSrcBlendFunction( primary, DSBF_SRCALPHA ); /* Draw a white outline around the red rectangle. */ primary->SetColor( primary, 0xcc, 0xcc, 0xcc, 0xff ); primary->DrawRectangle( primary, 100, 100, 100, 100 ); /* Draw a line across the objects. */ primary->SetColor( primary, 0x12, 0x34, 0x56, 0xff ); primary->DrawLine( primary, 0, 0, 300, 300 ); primary->SetColor( primary, 0xff, 0xff, 0xff, 0xff ); primary->DrawLine( primary, -20, -20, -300, -300 ); /* Fill a triangle. */ primary->SetColor( primary, 0x80, 0x90, 0x70, 0xff ); primary->FillTriangle( primary, 0, 0, 200, -210, -200, 190 ); /* Flip the output surface. */ primary->Flip( primary, NULL, DSFLIP_WAITFORSYNC ); // primary->Dump( primary, "/", "df_matrix" ); /* Rotate scene slightly. */ cairo_matrix_rotate( &matrix, 0.1 ); cairo_matrix_scale( &matrix, 0.99, 0.99 ); //cairo_matrix_scale( &matrix, 1.001, 1.001 ); if (++i == 500) { i = 0; cairo_matrix_init_translate( &matrix, width/2, height/2 ); } /* Check for new events. */ while (events->GetEvent( events, DFB_EVENT(&event) ) == DFB_OK) { /* Handle key press events. */ if (event.type == DIET_KEYPRESS) { switch (event.key_symbol) { case DIKS_ESCAPE: case DIKS_POWER: case DIKS_BACK: case DIKS_SMALL_Q: case DIKS_CAPITAL_Q: exit_application( 0 ); break; default: break; } } } } /* Shouldn't reach this. */ return 0; }