Exemplo n.º 1
0
// get megs o' memory from FreeVR, and create the arena
// Warning:  Don't make me do this twice.
void grab_FreeVR_memory(int megs) {
  int size = (megs>1?megs:1) * 1024 * 1024;

  if (vrShmemInit(size) == NULL) 
    msgErr << "Bad juju in the arena.  We're gonna die!" << sendmsg;
  else
    msgInfo <<  "Created arena." << sendmsg;
}
Exemplo n.º 2
0
// get megs o' memory from FreeVR, and create the arena
// Warning:  Don't make me do this twice.
void grab_FreeVR_memory(size_t megs) {
  size_t size = ((megs>1) ? megs : 1) * 1024L * 1024L;
  size_t sz=0;

  while (((sz = vrShmemInit(size)) == 0) && (size > 64*1024*1024)) {
    msgErr << "Failed to create FreeVR arena of size " 
           << (size / (1024*1024)) 
           << ", reducing allocation by half." << sendmsg;
    size >>= 1; // cut allocation in half
  }
 
  if (sz == 0) 
    msgErr << "Failed to create FreeVR arena.  We're gonna die!" << sendmsg;
  else
    msgInfo << "Created arena, size " << (sz / (1024*1024)) 
            << "MB." << sendmsg;
}
Exemplo n.º 3
0
void vrlib_shmem_init (size_t size)
{
    vrShmemInit (size);
    vrConfigure (NULL, NULL, NULL);
    return;
}
Exemplo n.º 4
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);
}