Ejemplo n.º 1
0
int main(
  int argc,
  char *argv[])
  {
   mainEnv = CreateEnvironment();
   RerouteStdin(mainEnv,argc,argv);

#if UNIX_V || LINUX || DARWIN || UNIX_7 || WIN_GCC || WIN_MVC
   signal(SIGINT,CatchCtrlC);
#endif

   CommandLoop(mainEnv);

#if UNIX_V || LINUX || DARWIN || UNIX_7 || WIN_GCC || WIN_MVC
   signal(SIGINT,CatchCtrlC);
#endif

   /*==================================================================*/
   /* Control does not normally return from the CommandLoop function.  */
   /* However if you are embedding CLIPS, have replaced CommandLoop    */
   /* with your own embedded calls that will return to this point, and */
   /* are running software that helps detect memory leaks, you need to */
   /* add function calls here to deallocate memory still being used by */
   /* CLIPS. If you have a multi-threaded application, no environments */
   /* can be currently executing.                                      */
   /*==================================================================*/
   
   DestroyEnvironment(mainEnv);
   
   return(-1);
  }
Ejemplo n.º 2
0
AdventureEngineEngine::AdventureEngineEngine(OSystem *syst) 
: Engine(syst) {
   _previousMouseCommand = 0;
   _expertSystemStalled = false;
  clipsEnv = CreateEnvironment();
  debug("AdventureEngineEngine::AdventureEngineEngine: Created CLIPS Environment");
  // Put your engine in a sane state, but do nothing big yet;
  // in particular, do not load data from files; rather, if you
  // need to do such things, do them from run().
  SetEnvironmentContext(clipsEnv, (void*)this);
  //for now I just want to see if this works
  EnvBatchStar(clipsEnv, "Run.clp");
  //TODO: Define default directories once we have a successful compile
  //TODO: Save engine context within the clips environment (pointer)
  //TODO: Add the ability to register applications from CLIPS with SCUMMVM

  // However this is the place to specify all default directories
  //const Common::FSNode gameDataDir(ConfMan.get("path"));
  //SearchMan.addSubDirectoryMatching(gameDataDir, "sound");

  // Here is the right place to set up the engine specific debug channels
  //DebugMan.addDebugChannel(kAdventureEngineDebugExample, "example", "this is just an example for a engine specific debug channel");
  //DebugMan.addDebugChannel(kAdventureEngineDebugExample2, "example2", "also an example");

  // Don't forget to register your random source
  _rnd = new Common::RandomSource("AdventureEngine");

  debug("AdventureEngineEngine::AdventureEngineEngine");
}
Ejemplo n.º 3
0
int main(
  int argc,
  char *argv[])
  {
   void *theEnv;

   theEnv = CreateEnvironment();
   RerouteStdin(theEnv,argc,argv);
   CommandLoop(theEnv);

   /*==================================================================*/
   /* Control does not normally return from the CommandLoop function.  */
   /* However if you are embedding CLIPS, have replaced CommandLoop    */
   /* with your own embedded calls that will return to this point, and */
   /* are running software that helps detect memory leaks, you need to */
   /* add function calls here to deallocate memory still being used by */
   /* CLIPS. If you have a multi-threaded application, no environments */
   /* can be currently executing. If the ALLOW_ENVIRONMENT_GLOBALS     */
   /* flag in setup.h has been set to TRUE (the default value), you    */
   /* call the DeallocateEnvironmentData function which will call      */
   /* DestroyEnvironment for each existing environment and then        */
   /* deallocate the remaining data used to keep track of allocated    */
   /* environments. Otherwise, you must explicitly call                */
   /* DestroyEnvironment for each environment you create.              */
   /*==================================================================*/

   /* DeallocateEnvironmentData(); */
   /* DestroyEnvironment(theEnv); */

   return(-1);
  }
Ejemplo n.º 4
0
int main(int argc,char **argv)
{
	int i;


   /* The camera attributes are passed from server to client as necessary */
   CameraHome();
	camera.stereo       = NOSTEREO;
   camera.cursordepth  = camera.focallength;
   camera.screenwidth  = 400;
   camera.screenheight = 300;

	options.fullscreen   = FALSE;


	/* Parse the command line arguments */
   for (i=1;i<argc;i++) {
      if (strcmp(argv[i],"-h") == 0)
         fprintf(stderr,"%s -f (for fullscreen) -s (for active stereo) -ss (for passive stereo)\n",argv[0]);
      if (strcmp(argv[i],"-f") == 0)
         options.fullscreen = !options.fullscreen;
      if (strcmp(argv[i],"-s") == 0)
         camera.stereo = ACTIVESTEREO;
		if (strcmp(argv[i],"-ss") == 0) {
         camera.stereo = DUALSTEREO;
			camera.screenwidth *= 2;
		}
   }

   /* Set things up and go */
   glutInit(&argc,argv);
   if (camera.stereo == ACTIVESTEREO)
		glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO);
	else
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

	/* Create the window and handlers */
   glutCreateWindow("triangle");
	glutReshapeWindow(camera.screenwidth,camera.screenheight);
   if (options.fullscreen)
      glutFullScreen();
   glutDisplayFunc(HandleDisplay);
	glutReshapeFunc(HandleReshape);

	/*
		The client doesn't deal with user input
		Turn of the mouse since it is a killer in passive stereo
		to have a mouse on only one screen.
	*/
   glutKeyboardFunc(HandleKeyboard);
   glutMotionFunc(HandleMouseMotion);
	glutSetCursor(GLUT_CURSOR_NONE);
   CreateEnvironment();

	/* Ready to go! */
   glutMainLoop();
   return(0);
}
Ejemplo n.º 5
0
void ClipsSession::initialize(int argc,char *argv, string sessionID, RouterInterface *router)
#endif
{
	cout<<"ClipsSession::initialize 0 sessionID:"<<sessionID<<endl;
	m_sessionID = sessionID;
		cout<<"ClipsSession::initialize 1"<<endl;
	m_theEnv = CreateEnvironment();
	cout<<"ClipsSession::initialize 2"<<endl;
#ifdef _DEBUG_CLIPS_
    cout<<"ClipsSession::initialize 3"<<endl;

	if (ConfigUtil::GetInstance()->GetConfigStr("CLIPSログ出力パス").length() > 0)
	{
		fw.open(ConfigUtil::GetInstance()->GetConfigStr("CLIPSログ出力パス").c_str(), ios::out);
#if 1
		EnvWatch(m_theEnv,"globals");
		EnvWatch(m_theEnv, "rules");
		EnvWatch(m_theEnv, "facts");
		EnvWatch(m_theEnv,"activations");
		EnvWatch(m_theEnv,"focus");
		EnvWatch(m_theEnv,"deffunctions");
		EnvWatch(m_theEnv,"compilations");
#endif
		EnvAddRouter(m_theEnv,"DEBUG",999,queryFunction,printFunction,NULL,NULL,NULL);
		//EnvAddRouter(m_theEnv,"wtrace",1000,queryFunction,printFunction,NULL,NULL,NULL);
		//EnvActivateRouter(m_theEnv,"wdialog");
		EnvActivateRouter(m_theEnv,"DEBUG");
#endif
#ifdef _PERFORMANCE_
		//for performance
		//EnvWatch(m_theEnv,"statistics");
#endif
	}

 #if 0
	char *tmp[1];
	tmp[0] = argv;
	RerouteStdin(m_theEnv,1,tmp);
#else
    if (router != NULL)
    {
        m_router = router;
        //const char *routerName=m_router->getRouterName().c_str();
        string routerName = m_router->getRouterName();
		EnvAddRouter(m_theEnv,routerName.c_str(),30,queryFunction,printFunction,NULL,NULL,NULL);
		EnvActivateRouter(m_theEnv, routerName.c_str());
    }
#endif	
	cout<<"ClipsSession::initialize 4"<<endl;	
	EnvReset(m_theEnv);

	
	cout<<"ClipsSession::initialize 5"<<endl;
	m_ruleMgr = new ClipsRuleMgr();
	if (m_ruleMgr != NULL) 
		m_ruleMgr->initialize(m_theEnv, m_sessionID);
}
Ejemplo n.º 6
0
int main(int argc, char **argv)
{
	pthread_t thread1;
	
	/* Parse the command line arguments */
	std::string *projectordata;
	Projector *projector;
	for (int i=1; i < argc; i++) {
		if (strstr(argv[i],"-p") != NULL) {
			projectordata = new std::string(argv[i+1]);
			projector = new Projector(*projectordata);
			projectors.push_back(projector);
		}
	}
	fprintf(stderr, "Done initializing projectors.\n");

	/* Set things up and go */
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

	glutCreateWindow("Pre-Distorted Scene");
	camera.aperture = aperture;
	camera.screenwidth = screenSize[0];
	camera.screenheight = screenSize[1];
	reshape(camera.screenwidth, camera.screenheight);
	glutReshapeWindow(camera.screenwidth,camera.screenheight);
	glutDisplayFunc(HandleDisplay);
	glutVisibilityFunc(HandleVisibility);
	glutKeyboardFunc(HandleKeyboard);
	glutSetCursor(GLUT_CURSOR_NONE);
	CreateEnvironment();

	/* Load the edge blending image */
	
	edgeBlending = SOIL_load_OGL_texture(
				"blending.png",
				SOIL_LOAD_AUTO,
				SOIL_CREATE_NEW_ID,
				SOIL_FLAG_INVERT_Y
			);
	if(edgeBlending == 0) {
		fprintf(stderr, "ERROR : Failed to load texture %s.\n", "blending.png");
	}

	glutFullScreen();
	if(	initExperiment(argc-1, argv+1) ) {
		/* Ready to go! */
		glutMainLoop();
		return(0);
	} else {
		fprintf(stderr, "Could not initialize experiment code.");
		return(-1);
	}
}
Ejemplo n.º 7
0
TEST(StdDuck, print_value_function)
{
    CreateEnvironment();
    testing::internal::CaptureStdout();

    VALUE func = CreateFunction(TestStdDuck::DummyFunc);
    AddParameter(func, "arg0");

    PrintValue(func);
    ASSERT_STREQ("function(arg0)", testing::internal::GetCapturedStdout().c_str());

    FreeEnvironment();
}
Ejemplo n.º 8
0
TEST(StdDuck, print_value_string)
{
    CreateEnvironment();
    testing::internal::CaptureStdout();

    VALUE val;
    val.type = VAL_STRING;
    val.data.string = "1";

    PrintValue(val);
    ASSERT_STREQ("1", testing::internal::GetCapturedStdout().c_str());

    FreeEnvironment();
}
int main(int argc,char **argv)
{
   int i,j,depth;
   int mainmenu,speedmenu;

   for (i=1;i<argc;i++) {
      if (strstr(argv[i],"-h") != NULL)
         GiveUsage(argv[0]);
      if (strstr(argv[i],"-q") != NULL) {
         if (i+1 >= argc)
            GiveUsage(argv[0]);
         drawquality = atoi(argv[i+1]);
         if (drawquality < DRAFT)
            drawquality = DRAFT;
         if (drawquality > BEST)
            drawquality = BEST;
         i++;
      }
   }

   /* Set things up and go */
   glutInit(&argc,argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
   glutCreateWindow("Micro CT Simulations Version 0.1 HL");
   glutDisplayFunc(Display);
   glutVisibilityFunc(HandleVisibility);
   glutKeyboardFunc(HandleKeyboard);
   glutSpecialFunc(HandleSpecialKeyboard);
   glutMouseFunc(HandleMouse);

   CreateEnvironment();

   /* Set up some menus */
   speedmenu = glutCreateMenu(HandleSpeedMenu);
   glutAddMenuEntry("Slow",1);
   glutAddMenuEntry("Medium",2);
   glutAddMenuEntry("fast",3);
   mainmenu = glutCreateMenu(HandleMainMenu);
   glutAddMenuEntry("Toggle camera spin",1);
   glutAddMenuEntry("Change Eye Location rho",2);    //HL: change the Eye Location
   glutAddSubMenu("Speed",speedmenu);
   glutAddMenuEntry("Quit",100);
   glutAttachMenu(GLUT_RIGHT_BUTTON);

   glutMainLoop();
   return(0);
}
Ejemplo n.º 10
0
    bool EnvironmentModule::HandleEvent(event_category_id_t category_id, event_id_t event_id, Foundation::EventDataInterface* data)
    {
        if(category_id == framework_event_category_)
        {
            HandleFrameworkEvent(event_id, data);
        }
        else if(category_id == resource_event_category_)
        {
            HandleResouceEvent(event_id, data);
        }
        else if(category_id == network_in_event_category_)
        {
            HandleNetworkEvent(event_id, data);
        }
        else if (category_id == network_state_event_category_)
        {
            if (event_id == ProtocolUtilities::Events::EVENT_SERVER_CONNECTED)
            {
                if (GetFramework()->GetDefaultWorldScene().get())
                {
                    CreateEnvironment();
                    CreateTerrain();
                    CreateWater();
                    //CreateEnvironment();
                    CreateSky();
                }
            }

            if (event_id == ProtocolUtilities::Events::EVENT_SERVER_DISCONNECTED)
            {
                if(postprocess_dialog_)
                    postprocess_dialog_->DisableAllEffects();
                ReleaseTerrain();
                ReleaseWater();
                ReleaseEnvironment();
                ReleaseSky();
                firstTime_ = true;
               
            }
        }
        else if(category_id == input_event_category_)
        {
            HandleInputEvent(event_id, data);
        }
        return false;
    }
Ejemplo n.º 11
0
func Initialize()
{
	CreateEnvironment();

	var goal = CreateObject(Goal_Parkour, 0, 0, NO_OWNER);
	var mode = PARKOUR_CP_Respawn | PARKOUR_CP_Check | PARKOUR_CP_Ordered;
	// goal->SetStartpoint(90, 1510);
	// goal->AddCheckpoint(520, 1510, mode);
	// goal->AddCheckpoint(1420, 1510, mode);
	// goal->AddCheckpoint(1460, 1175, mode);
	// goal->AddCheckpoint(535, 1175, mode);
	// goal->AddCheckpoint(570, 985, mode);
	// goal->AddCheckpoint(1160, 950, mode);
	// goal->AddCheckpoint(1850, 950, mode);
	// goal->AddCheckpoint(2165, 1395, mode);
	// goal->SetFinishpoint(3820, 1515);
	
	goal->SetStartpoint(3190, 1521);
	goal->AddCheckpoint(2165, 1395, mode);
	goal->AddCheckpoint(1850, 950, mode);
	goal->AddCheckpoint(1160, 950, mode);
	goal->AddCheckpoint(570, 985, mode);
	goal->AddCheckpoint(535, 1175, mode);
	goal->AddCheckpoint(1460, 1175, mode);
	goal->AddCheckpoint(1420, 1510, mode);
	goal->AddCheckpoint(520, 1510, mode);
	goal->SetFinishpoint(90, 1510);
	
	
	Grass->Place(100, nil);
	Tree_Coniferous->Place(5);
	Tree_Coniferous2->Place(5);
	Tree_Deciduous->Place(5);
	Mushroom->Place(20);
	Flower->Place(30);
	Fern->Place(15);
}
Ejemplo n.º 12
0
globle void InitializeEnvironment()
   {
    if (GetCurrentEnvironment() == NULL)
      { CreateEnvironment(); }
   }
Ejemplo n.º 13
0
void __declspec(dllexport) * CALL_CONV __CreateEnvironment()
  {
   return CreateEnvironment();
  }
int main(int argc,char **argv)
{

   int i,j,depth,l=0, m=0;
   int mainmenu,speedmenu;

   rd = fopen("read_dda.txt", "r");
   if (rd < 0)
   {
      perror("unable to read from file");
      return 1;
   }
   while(!feof(rd))
   {
      fscanf(rd, "%f", &x_buffer[l]);
      fscanf(rd, "%f", &y_buffer[l]);
      printf("x = %f, y = %f\n", x_buffer[l], y_buffer[l]);
      l++;
   }
   fclose(rd);
   buffer_index = l;
   printf("buffer_index = %d\n", buffer_index);

   rdp = fopen("read_bresenham.txt", "r");
   if (rdp < 0)
   {
      perror("unable to read from file");
      return 1;
   }
   // read the value of radius from file, first value in file
   fscanf(rdp, "%d", &radius_file);
   while(!feof(rdp))
   {
      fscanf(rdp, "%d", &x_bresenham[m]);
      fscanf(rdp, "%d", &y_bresenham[m]);
      printf("x_bresenham = %d, y_bresenham = %d\n", x_bresenham[m], y_bresenham[m]);
      m++;
   }
   fclose(rdp);
   buffer_bresenham = m;
   printf("buffer_bresenham = %d\n", buffer_bresenham);

   printf("radius = %d\n\n\n", radius_file);

   for (i=1;i<argc;i++) {
      if (strstr(argv[i],"-h") != NULL)
         GiveUsage(argv[0]);
      if (strstr(argv[i],"-q") != NULL) {
         if (i+1 >= argc)
            GiveUsage(argv[0]);
         drawquality = atoi(argv[i+1]);
         if (drawquality < DRAFT)
            drawquality = DRAFT;
         if (drawquality > BEST)
            drawquality = BEST;
         i++;
      }
   }

   /* Set things up and go */
   glutInit(&argc,argv);
   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
   glutCreateWindow("Micro CT Simulations Version 0.1 HL");
   glutDisplayFunc(Display);
   //glutDisplayFunc(display);
   glutVisibilityFunc(HandleVisibility);
   glutKeyboardFunc(HandleKeyboard);
   glutSpecialFunc(HandleSpecialKeyboard);
   glutMouseFunc(HandleMouse);

   CreateEnvironment();

   /* Set up some menus */
   speedmenu = glutCreateMenu(HandleSpeedMenu);
   glutAddMenuEntry("Slow",1);
   glutAddMenuEntry("Medium",2);
   glutAddMenuEntry("fast",3);
   mainmenu = glutCreateMenu(HandleMainMenu);
   glutAddMenuEntry("Toggle camera spin",1);
   glutAddMenuEntry("Change Eye Location rho",2);    //HL: change the Eye Location
   glutAddSubMenu("Speed",speedmenu);
   glutAddMenuEntry("Quit",100);
   glutAttachMenu(GLUT_RIGHT_BUTTON);

   glutMainLoop();
   return(0);
}
Ejemplo n.º 15
0
STDMETHODIMP PartCoverConnector2::StartTarget(
    BSTR p_targetPath, 
    BSTR p_targetWorkingDir, 
    BSTR p_targetArguments,
    VARIANT_BOOL redirectOutput,
	IConnectorActionCallback* callback)
{
    HRESULT hr;
    _bstr_t targetPath(p_targetPath);
    _bstr_t targetWorkingDir(p_targetWorkingDir);
    _bstr_t targetArguments(p_targetArguments);

    if (targetWorkingDir.length() == 0 || targetPath.length() == 0 )
        return E_INVALIDARG;

	if(callback != 0 ) callback->OpenMessagePipe();

    // init message center 
    if(FAILED(hr = m_center.Open()))
        return hr;

	if(callback != 0 ) callback->TargetSetEnvironmentVars();

    targetArguments = _bstr_t("\"") + targetPath + _bstr_t("\" ") + targetArguments;

    // get current working dir and settings
    StringMap env = ParseEnvironment();
    env[_T("Cor_Enable_Profiling")] = _T("1");
    env[_T("Cor_Profiler")] = _T("{") _T(DRIVER_CORPROFILER_GUID) _T("}");
    env[OPTION_MESSOPT] = m_center.getId();

    if (m_driverLogging > 0)
	{
		DynamicArray<TCHAR> curBuffer(5);
        _stprintf_s(curBuffer, curBuffer.size(), _T("%d"), m_driverLogging);
        env[OPTION_VERBOSE] = curBuffer;
	}

	if (m_useFileLogging) {
        DWORD curLength = ::GetCurrentDirectory(0, NULL);
        DynamicArray<TCHAR> curBuffer(curLength + 25);
        if (curLength = ::GetCurrentDirectory(curLength + 1, curBuffer)) 
		{
            _stprintf_s(curBuffer + curLength, 25, DRIVER_LOG_FILENAME);
            env[OPTION_LOGFILE] = curBuffer;

			m_logFile = curBuffer;
        }
    }

	if (m_usePipeLogging) {
        env[OPTION_LOGPIPE] = _T("1");
    }

    // copy old and new env settings
    LPTSTR new_env = CreateEnvironment(env);

	if(callback != 0 ) callback->TargetCreateProcess();

    // extract 
    STARTUPINFO si;
    ZeroMemory(&si, sizeof(si));
    si.cb = sizeof(si);

    if (redirectOutput == VARIANT_TRUE) {
        si.dwFlags = STARTF_USESTDHANDLES;
        si.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);
        si.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
        si.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);
    }

    ZeroMemory(&pi, sizeof(pi));

    DynamicArray<TCHAR> args(targetArguments.length() + 1);
    _tcscpy_s(args, targetArguments.length() + 1, targetArguments);

    BOOL created = ::CreateProcess(
                        NULL, // Application
                        args, // command line
                        NULL, // lpProcessAttributes,
                        NULL, // lpThreadAttributes,
                        redirectOutput == VARIANT_TRUE ? TRUE : FALSE, // bInheritHandles,
#ifdef _UNICODE
                        CREATE_UNICODE_ENVIRONMENT |
#endif
                        (redirectOutput == VARIANT_TRUE ? 0 : CREATE_NEW_CONSOLE),
                        new_env,
                        targetWorkingDir,
                        &si,
                        &pi );

    // clear environment
    FreeEnvironment(new_env);
    
    if (!created)
        return HRESULT_FROM_WIN32( ::GetLastError() );

	if(callback != 0 ) callback->TargetWaitDriver();

    if (FAILED(hr = m_center.WaitForClient()))
        return hr;

	if(callback != 0 ) callback->DriverConnected();

	struct Starter : ITransferrableVisitor {
		IConnectorActionCallback* m_callback;
	public:
		bool readyToGo;
		Starter(IConnectorActionCallback* callback) : m_callback(callback), readyToGo(false) {}

		void on(MessageType type) { if (Messages::C_RequestStart == type) readyToGo = true; }
		void on(FunctionMap& value) {}
		void on(Rules& value) {}
		void on(InstrumentResults& value) {}
		void on(LogMessage& value) { if (m_callback != 0) m_callback->LogMessage(value.getThreadId(), value.getTicks(), _bstr_t(value.getMessage().c_str())); }
	} messageVisitor(callback);

	ITransferrable* message;
	while(SUCCEEDED(m_center.Wait(message)))
	{
		message->visit(messageVisitor);
		destroy(message);
		if (messageVisitor.readyToGo) break;
	}

	if (!messageVisitor.readyToGo)
	{
		ATLTRACE("PartCoverConnector2::StartTarget - C_RequestStart wait error");
		return E_ABORT;
	}

	if(callback != 0 ) callback->DriverSendRules();

	m_center.Send(m_rules);
	m_center.Send(Messages::Message<Messages::C_EndOfInputs>());

	if(callback != 0 ) callback->DriverWaitEoIConfirm();

	messageVisitor.readyToGo = false;
	while(SUCCEEDED(m_center.Wait(message)))
	{
		message->visit(messageVisitor);
		destroy(message);

		if (messageVisitor.readyToGo) break;
	}

	return true;
}
Ejemplo n.º 16
0
int main(int argc,char **argv)
{
   int i;
   int mainmenu,itermenu,heightmenu,resolmenu;
   int methodmenu,colourmenu;

   camera.screenwidth = 800;
   camera.screenheight = 600;

   /* Parse the command line arguments */
   for (i=1;i<argc;i++) {
      if (strstr(argv[i],"-h") != NULL) 
         GiveUsage(argv[0]);
      if (strstr(argv[i],"-f") != NULL)
         fullscreen = TRUE;
      if (strstr(argv[i],"-s") != NULL)
         stereo = TRUE;
      if (strstr(argv[i],"-d") != NULL)
         debug = TRUE;
      if (strstr(argv[i],"-D") != NULL)
         demomode = TRUE;
      if (strstr(argv[i],"-S") != NULL)
          sscanf( argv[++i], "%i", &seedvalue );
      if (strstr(argv[i],"-F") != NULL)
          sscanf( argv[++i], "%i", &spheredepth );
      if (strstr(argv[i],"--origin") != NULL)
          whichmethod = 1;
      if (strstr(argv[i],"--notorigin") != NULL)
          whichmethod = 2;
   }

   /* Set things up and go */
   glutInit(&argc,argv);
   if (!stereo)
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
   else
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO);

   glutCreateWindow("Planet creation example");
   glutReshapeWindow(camera.screenwidth,camera.screenheight);
   if (fullscreen)
      glutFullScreen();
   glutDisplayFunc(Display);
   glutReshapeFunc(HandleReshape);
   glutVisibilityFunc(HandleVisibility);
   glutKeyboardFunc(HandleKeyboard);
   glutSpecialFunc(HandleSpecialKeyboard);
   glutMouseFunc(HandleMouse);
   glutMotionFunc(HandleMouseMotion);

   nface = FormSphere(spheredepth);
   CreateEnvironment();
   CameraHome(0);

   /* Iteration menu */
   itermenu = glutCreateMenu(HandleIterMenu);
   glutAddMenuEntry("Decrease iteration depth",1);
   glutAddMenuEntry("Increase iteration depth",2);
   glutAddMenuEntry("Do 100 more",3);
   glutAddMenuEntry("Do 1000 more",4);
   glutAddMenuEntry("Reset",5);

   /* Height menu */
   heightmenu = glutCreateMenu(HandleHeightMenu);
   glutAddMenuEntry("Low",1);
   glutAddMenuEntry("Average",2);
   glutAddMenuEntry("High",3);

   /* Sphere resolution menu */
   resolmenu = glutCreateMenu(HandleResolMenu);
   glutAddMenuEntry("Low (8192 facets)",5);
   glutAddMenuEntry("Average (32768 facets)",6);
   glutAddMenuEntry("High (131072 facets)",7);
   glutAddMenuEntry("Extreme (524288 facets)",8);

   /* Colour map menu */
   colourmenu = glutCreateMenu(HandleColourMenu);
   glutAddMenuEntry("Mars 1",11);
   glutAddMenuEntry("Mars 2",12);
   glutAddMenuEntry("Earth (Sea to snow)",15);
   glutAddMenuEntry("Extreme earth",10);
   glutAddMenuEntry("Land to snow",13);
   glutAddMenuEntry("Grey Scale",3);
   glutAddMenuEntry("Hot to cold",1);

   /* Algorithm menu */
   methodmenu = glutCreateMenu(HandleMethodMenu);
   glutAddMenuEntry("Plane through origin",1);
   glutAddMenuEntry("Plane not through origin",2);

   /* Set up the main menu */
   mainmenu = glutCreateMenu(HandleMainMenu);
   glutAddSubMenu("Iteration depth",itermenu);
   glutAddSubMenu("Height control",heightmenu);
   glutAddSubMenu("Sphere resolution",resolmenu);
   glutAddSubMenu("Colour map",colourmenu);
   glutAddSubMenu("Algorithm",methodmenu);
   glutAddMenuEntry("Toggle lights on/off",1);
   glutAddMenuEntry("Toggle wireframe/solid",2);
   glutAddMenuEntry("Toggle construction on/off",3);
   glutAddMenuEntry("Toggle smooth shading on/off",4);
   glutAddMenuEntry("Toggle ocean on/off",5);
   glutAddMenuEntry("Change seed",9);
   glutAddMenuEntry("Quit",10);
   glutAttachMenu(GLUT_RIGHT_BUTTON);

   /* Ready to go! */
   glutMainLoop();
   return(0);
}
Ejemplo n.º 17
0
/*
int Interpret(SYNTAX_TREE* tree)
    ---------------------------------------------------------
    Run a duck program from the command console by parsing it
    into a syntax tree and then interating over the program
    definitions.
*/
int Interpret(SYNTAX_TREE* tree)
{
    CreateEnvironment();

    gc_inst_count = 0;
    gc_collect_count = 0;

    test_inst_count = 0;

    /* global NameSpace */
    gCurrentContext = gGlobalContext = (CLOSURE*)ALLOC(sizeof(CLOSURE));
    gCurrentContext->parent = NULL;
    gCurrentContext->list = NULL;
    gCurrentContext->ref_count = -1;
    GCAddContext(gGlobalContext, &gGCManager);

    /* current expression */
    gLastExpression.type = VAL_NIL;
    gLastExpression.data.primitive = 0;

    /* global variables */
    gParameterListing = NULL;
    gDictionaryInit = NULL;
    gArrayIndex = 0;
    gArgumentEvaluation = NULL;

    /* l-value bound context */
    gLValueIdentifier = NULL;
    gLValueContext = NULL;
    gLValueIndex.type = VAL_NIL;
    gLValueIndex.data.primitive = 0;
    gLValueDictionary = NULL;
    array_indexing = 0;

    /* libraries */
    BindStandardLibrary();
    BindMathLibrary();
    BindAdditionalLibraries();
    BindRandLibrary();

    /* function definition */
    gParameterListing = NULL;

    /* program control */
    returning = 0;
    breaking = 0;
    continuing = 0;
    halting = 0;

    /* profiling */
    greatest_stack_depth;
    stack_depth;

    /* clear call stack */
    ClearCallStack(&gStackTrace);
    line_error = 0;
    failed_production = NULL;
    
    /* run */
    int error = InterpretNode(tree);
    while (PopExecutionStack());
    //ForceFreeContext(gGlobalContext);
    return error;
}
Ejemplo n.º 18
0
func Initialize()
{
	CreateEnvironment();
}