void vrlib_init (void) { vrStart (); vrFunctionSetCallback (VRFUNC_DISPLAY_INIT, vrCallbackCreate (vrlib_init_GL, 0)); vrFunctionSetCallback (VRFUNC_DISPLAY_FRAME, vrCallbackCreate (vrlib_frame, 0)); vrFunctionSetCallback (VRFUNC_DISPLAY, vrCallbackCreate (vrlib_display, 0)); return; }
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[]) { /* 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); }