Пример #1
0
uint32_t ReadPref(const char* pref_key, int default_value)
{
	LoadConfigFile();
	std::string pref = "preferences:";
	pref.append(pref_key);
	return iniparser_getint(preferences, pref.c_str(), default_value);
}
Пример #2
0
int CSummerApp_1::InitialApp(HINSTANCE hInstance, int nCmdShow)
{

	TCHAR curpath[MAX_PATH];
	////::GetCurrentDirectoryW(MAX_PATH, curpath);	////something is wired
	GetModuleFileNameW(NULL, curpath, MAX_PATH);
	curpath[_tcslen(curpath) - 3] = L'\0';
	_tcscat_s(curpath, MAX_PATH, L"xml");
    if (!LoadConfigFile(curpath))
		return (-1);

    if (WARMGUI::CWndApp::InitialApp(hInstance, nCmdShow))
		return (-2);

	WARMGUI::CDxFactorys* factorys = WARMGUI::CDxFactorys::GetInstance();
	if (!factorys)
		return (-3);

    dispatcher_1 = new CTestDispatcher_summer("ok1", 1);
    dispatcher_2 = new CTestDispatcher_summer("ok2", 2);
    dispatcher_3 = new CTestDispatcher_summer("ok3", 3);
    dispatcher_4 = new CTestDispatcher_summer("ok4", 4);

	return (0);
}
Пример #3
0
const char* ReadPrefString(const char* pref_key, const char* default_value)
{
	LoadConfigFile();
	std::string pref = "preferences:";
	pref.append(pref_key);
	return iniparser_getstring(preferences, pref.c_str(), default_value);
}
Пример #4
0
uint32_t ReadPrefHex(const char* pref_key)
{
	LoadConfigFile();
	std::string pref = "preferences:";
	pref.append(pref_key);
	return fromHex(iniparser_getstring(preferences, pref.c_str(), 0));
}
Пример #5
0
void	LoadNetFeatureTables(void)
{
	gNetFeatures.clear();
	gNetReps.clear();
	gFeature2Rep.clear();
	gBridgeInfo.clear();
	gTwinRules.clear();
	gForkRules.clear();
	gChangeRules.clear();
	gZonePromote.clear();
	gPromotedZoningSet.clear();
	gLevelCrossings.clear();

	RegisterLineHandler("ROAD_GENERAL", RoadGeneralProps, NULL);
	RegisterLineHandler("ROAD_PROP", ReadRoadSpecificProps, NULL);
	RegisterLineHandler("ROAD_PICK", ReadRoadPick, NULL);
	RegisterLineHandler("FORK_RULE",ReadForkRule,NULL);
	RegisterLineHandler("CHANGE_RULE",ReadChangeRule,NULL);
	RegisterLineHandler("ROAD_BRIDGE", ReadRoadBridge, NULL);
	RegisterLineHandler("ROAD_TWIN", ReadTwinRule, NULL);
	RegisterLineHandler("ROAD_PROMOTE_ZONING", ReadRoadPromoteZoning, NULL);
	RegisterLineHandler("ROAD_PROMOTE", ReadRoadPromote, NULL);
	RegisterLineHandler("LEVEL_CROSSING", ReadLevelCrossing, NULL);
	LoadConfigFile("road_properties.txt");
}
Пример #6
0
void InitConfig (char *arg0) {
#if defined (OS_WIN32_MINGW)
	// the progdir is always the current dir
	param.config_dir = "config";
	param.data_dir = "data";
	param.configfile = param.config_dir + SEP + "options.txt";
#else
	char buff[256];
	if (strcmp (arg0, "./etr") == 0) { 		// start from work directory
		char *s = getcwd (buff, 256);
		if (s==NULL) {};
	} else {								// start with full path
		strcpy (buff, arg0);		
		if (strlen (buff) > 5) buff[strlen(buff)-3] = 0;
	} 
	param.prog_dir = buff;
	struct passwd *pwent = getpwuid (getuid ());
	param.config_dir = pwent->pw_dir;
	param.config_dir += SEP;
	param.config_dir += CONFIG_DIR;
	// or: param.config_dir = param.prog_dir + SEP + "config";
    if (!DirExists (param.config_dir.c_str()))
		mkdir (param.config_dir.c_str(), 0775); 
	param.data_dir = param.prog_dir + SEP + "data";
	param.configfile = param.config_dir + SEP + "options";
#endif

	param.screenshot_dir = param.data_dir + SEP + "screenshots";
	param.obj_dir = param.data_dir + SEP + "objects";
	param.env_dir2 = param.data_dir + SEP + "env";
	param.char_dir = param.data_dir + SEP + "char";
	param.keyframe_dir = param.char_dir + SEP + "keyframes";
	param.terr_dir = param.data_dir + SEP + "terrains";
	param.tex_dir = param.data_dir + SEP + "textures";
	param.common_course_dir = param.data_dir + SEP + "courses";
	param.common_cup_dir = param.data_dir + SEP + "cups";
	param.sounds_dir = param.data_dir + SEP + "sounds";
	param.music_dir = param.data_dir + SEP + "music";
	param.font_dir = param.data_dir + SEP + "fonts";
	param.trans_dir = param.data_dir + SEP + "translations";
	param.player_dir = param.data_dir + SEP + "players";

	param.ui_snow = true;
	param.view_mode = 1;
	param.display_fps = false;
	param.show_hud = true;

	if (FileExists (param.configfile.c_str())) {
//		SetConfigDefaults ();
		LoadConfigFile ();
	} else {
		SetConfigDefaults ();
		SaveConfigFile ();
	}
	string playerfile = param.config_dir + SEP + PLAYER_FILE;
	if (FileExists (playerfile.c_str())) {
	} else {
	}
}
Пример #7
0
FConfigFile::FConfigFile (const char *pathname,
	void (*nosechandler)(const char *pathname, FConfigFile *config, void *userdata),
	void *userdata)
{
	Sections = CurrentSection = NULL;
	LastSectionPtr = &Sections;
	CurrentEntry = NULL;
	ChangePathName (pathname);
	LoadConfigFile (nosechandler, userdata);
	OkayToWrite = true;
	FileExisted = true;
}
Пример #8
0
uint32_t ReadPrefHex(const char* pref_key, int default_value)
{
    std::stringstream ss;
    std::string default_string;
    ss.setf(std::ios::hex|std::ios::showbase, std::ios::basefield);
    ss << default_value;
    ss >> default_string;
    LoadConfigFile();
    std::string pref = "preferences:";
    pref.append(pref_key);
    return fromHex(iniparser_getstring(preferences, pref.c_str(), default_string.c_str()));
}
Пример #9
0
HH_Runtime::HH_Runtime( const std::string& iniFile, const std::string& configFile, HH_Notifier& notifier )
    : m_iniFile( iniFile ),
      m_configFile( configFile ),
      m_notifier( notifier )
{
    LoadConfigFile( configFile );

    m_dotInputFileName =  std::string( ".\\" ) + m_name + ".in";
    m_dotPreprocessedFileName = std::string( ".\\" ) + m_name + ".tmp";
    m_dotOutputFileName = std::string( ".\\" ) + m_name + ".out";
    m_dotKnownGoodFileName = std::string( ".\\" ) + m_name + ".good";

}
Population::Population(char* iniFile)
{
	std::cout << "Starting " << fileOnly(iniFile) << "...\n";
	std::cout << LINE;
	// Gets the config file information
	LoadConfigFile(iniFile);
	// LoadSettings
	LoadSettings();
	// Creates the populations and its aspects
	CreateSubPopulations();
	// Initializes aspects
	Initialize();
	// Create output objects
	CreateOutputs();

}
    Configuration::Configuration(const string& modelName, char* arguments[]) {
        DebugLevel = 0;
        TraceLevel = 0;
        BinarySerialize = false;
        RunDiagnostics = false;
        EpochCount = 0;
        ArchivePath = NULL;
        ConfigFile = NULL;
        PathPrefix = NULL;
        PlatoPrefix = NULL;
        ModelParameters = NULL;
        CheckOptionValues(true);
        ModelParameters = new CommandLine(arguments);

        // Work out a config file to open.
        const string* newConfigFile = ModelParameters->GetOptionValue("ConfigFile");
        try {
            // Initialise the name of the config file to load.
            if (newConfigFile==NULL || newConfigFile->empty()) {
                string* tmp = new string(GetExecutableDirectory());
                *tmp += PlatformDirectorySeparator + modelName + ".config";
                newConfigFile = tmp;
            }
        } catch (...) {
            Trace::WriteLine(1, "Configuration: Configuration: setting ConfigFile exception.");
            string* tmp = new string(modelName);
            *tmp += ".config";
            newConfigFile =  tmp;
        }
        // Find an appropriate config file that exists.
        ifstream* textFile = new ifstream(newConfigFile->c_str());
        if(textFile->fail()) {
            delete textFile;
            textFile = new ifstream(ConfigFile->c_str());
            if(textFile->fail()) {
                delete ConfigFile;
                ConfigFile = newConfigFile;
            } else {
                delete newConfigFile;
            }
        } else {
            delete ConfigFile;
            ConfigFile = newConfigFile;
        }
        delete textFile;
        LoadConfigFile();
    }
Пример #12
0
bool Genesis::Init()
{
    if (!m_initialized)
    {
        m_initialized = m_g59cmd.Init(m_vendorid, m_productid);
    }

    LoadConfigFile();
    bool hasmultiple = false;
    m_hasGPA10 = m_ini.GetBoolValue("g59","hasGPA10", true, &hasmultiple);
    m_hasMicPreamp = m_ini.GetBoolValue("g59","hasMicPreamp", true, &hasmultiple);
    fprintf(stderr,"%s:%d m_hasGPA10=%d, m_hasMicPreamp=%d\n",__FUNCTION__,__LINE__,m_hasGPA10,m_hasMicPreamp);

    //enable the GPA10 if it is available
    m_g59cmd.pa10(m_hasGPA10);

    return m_initialized;
}
Пример #13
0
void ServerConfig::Load(const std::string & _config_file)
{
  if (config_file != "") {
        DPRINTMSG(stderr,
		  "Config file %s is already loaded. %s will not be loaded",
		  config_file.c_str(), _config_file.c_str());
	exit(EXIT_FAILURE);
  }

  // Get its full pathname to allow "automatic" reloading
  char *config_path = realpath(_config_file.c_str(), NULL);
  if (!config_path) {
    DPRINTMSG(stderr, "Unable to open config file %s: %s", _config_file.c_str(), strerror(errno));
    exit(EXIT_FAILURE);
  }

  config_file = config_path;
  free(config_path);

  LoadConfigFile();
}
Пример #14
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
    XInitXCGUI(); // 初始化
    extern char ConfigFile[MAX_PATH];
    GetAppDir(ConfigFile);
    strcat(ConfigFile, "/GuiDF.ini");
    if (IsFileExist(ConfigFile))
        LoadConfigFile();

    HWINDOW hWindow = XWnd_CreateWindow(0, 0, 380, 282, L"检测打包Adobe文档字体(C)2012.05 蘭公子"); // 创建窗口
    if (hWindow) {
        // 设置图标
        HICON logo_hIcon = LoadIcon(hInstance, (LPCTSTR)LOGO_ICON);
        XWnd_SetIcon(hWindow, logo_hIcon, false);
        InitXC_Window(hWindow); // 窗口布局

        XWnd_ShowWindow(hWindow, SW_SHOW); //显示窗口
        XRunXCGUI(); //运行
    }
    return 0;
}
Пример #15
0
//--------------------------------------------------------------------------------------------
bool_t setup_read_vfs()
{
    /// @details BB@> read the setup file

    // Read the local setup.txt
    fs_ensureUserFile( "setup.txt", btrue );
    snprintf( _config_filename, SDL_arraysize( _config_filename ), "%s" SLASH_STR "setup.txt", fs_getUserDirectory() );

    // do NOT force the file to open in a read directory if it doesn't exist. this will cause a failure in
    // linux if the directory is read-only
    lConfigSetup = LoadConfigFile( _config_filename, bfalse );

    //Did something go wrong?
    if ( NULL == lConfigSetup )
    {
        log_error( "Could not load setup settings: \"%s\"\n", _config_filename );
        return bfalse;
    }

    log_info( "Loaded setup file - \"%s\".\n", _config_filename );
    return btrue;
}
Пример #16
0
int main(int argc, char **argv)
{
	unsigned char Message[257];
	int Bytes, ch;
	uint32_t LoopCount[2];
	pthread_t SSDVThread, FTPThread, NetworkThread, HabitatThread, ServerThread;
	WINDOW * mainwin;
	int LEDCounts[2];
	
	if (prog_count("gateway") > 1)
	{
		printf("\nThe gateway program is already running!\n\n");
		exit(1);
	}

	mainwin = InitDisplay();
	
	// Settings for character input
	noecho();
	cbreak();
	nodelay(stdscr, TRUE);
	keypad(stdscr, TRUE);
		
	Config.LoRaDevices[0].InUse = 0;
	Config.LoRaDevices[1].InUse = 0;
	
	LEDCounts[0] = 0;
	LEDCounts[1] = 0;	
	
	// Remove any old SSDV files
	// system("rm -f /tmp/*.bin");	
	
	// Default pin allocations

	Config.LoRaDevices[0].DIO0 = 6;
	Config.LoRaDevices[0].DIO5 = 5;
	
	Config.LoRaDevices[1].DIO0 = 27;
	Config.LoRaDevices[1].DIO5 = 26;
	
	LoadConfigFile();
	LoadPayloadFiles();
	
	if (wiringPiSetup() < 0)
	{
		fprintf(stderr, "Failed to open wiringPi\n");
		exit(1);
	}
	
	if (Config.LoRaDevices[0].ActivityLED >= 0) pinMode(Config.LoRaDevices[0].ActivityLED, OUTPUT);
	if (Config.LoRaDevices[1].ActivityLED >= 0) pinMode(Config.LoRaDevices[1].ActivityLED, OUTPUT);
	if (Config.InternetLED >= 0) pinMode(Config.InternetLED, OUTPUT);
	if (Config.NetworkLED >= 0) pinMode(Config.NetworkLED, OUTPUT);
	
	setupRFM98(0);
	setupRFM98(1);
	
	ShowPacketCounts(0);
	ShowPacketCounts(1);

	LoopCount[0] = 0;
	LoopCount[1] = 0;
	
	if (pthread_create(&SSDVThread, NULL, SSDVLoop, NULL))
	{
		fprintf(stderr, "Error creating SSDV thread\n");
		return 1;
	}

	if (pthread_create(&FTPThread, NULL, FTPLoop, NULL))
	{
		fprintf(stderr, "Error creating FTP thread\n");
		return 1;
	}

	if (pthread_create(&HabitatThread, NULL, HabitatLoop, NULL))
	{
		fprintf(stderr, "Error creating Habitat thread\n");
		return 1;
	}
	
	if (Config.ServerPort > 0)
	{
		if (pthread_create(&ServerThread, NULL, ServerLoop, NULL))
		{
			fprintf(stderr, "Error creating server thread\n");
			return 1;
		}
	}

	if ((Config.NetworkLED >= 0) && (Config.InternetLED >= 0))
	{
		if (pthread_create(&NetworkThread, NULL, NetworkLoop, NULL))
		{
			fprintf(stderr, "Error creating Network thread\n");
			return 1;
		}
	}

	while (run)
	{
		int Channel;
		
		for (Channel=0; Channel<=1; Channel++)
		{
			if (Config.LoRaDevices[Channel].InUse)
			{
				if (digitalRead(Config.LoRaDevices[Channel].DIO0))
				{
					Bytes = receiveMessage(Channel, Message+1);
					
					if (Bytes > 0)
					{
						if (Config.LoRaDevices[Channel].ActivityLED >= 0)
						{
							digitalWrite(Config.LoRaDevices[Channel].ActivityLED, 1);
							LEDCounts[Channel] = 5;
						}
						// LogMessage("Channel %d data available - %d bytes\n", Channel, Bytes);
						// LogMessage("Line = '%s'\n", Message);

						if (Message[1] == '!')
						{
							ProcessUploadMessage(Channel, (char *) Message+1);
						}
						else if (Message[1] == '^')
						{
							ProcessCallingMessage(Channel, (char *) Message+1);
						}
						else if (Message[1] == '$')
						{
							ProcessTelemetryMessage(Channel, (char *) Message+1);
						}
						else if (Message[1] == 0x66)
						{
							ProcessSSDVMessage(Channel, Message);
						}
						else
						{
							LogMessage("Unknown packet type is %02Xh, RSSI %d\n", Message[1], readRegister(Channel, REG_PACKET_RSSI) - 157);
							ChannelPrintf(Channel, 4, 1, "Unknown Packet %d, %d bytes", Message[0], Bytes);
							Config.LoRaDevices[Channel].UnknownCount++;
						}
						
						Config.LoRaDevices[Channel].LastPacketAt = time(NULL);
						
						if (Config.LoRaDevices[Channel].InCallingMode && (Config.CallingTimeout > 0))
						{
							Config.LoRaDevices[Channel].ReturnToCallingModeAt = time(NULL) + Config.CallingTimeout;
						}
						

						ShowPacketCounts(Channel);
					}
				}
				
				if (++LoopCount[Channel] > 1000000)
				{
					LoopCount[Channel] = 0;
					ShowPacketCounts(Channel);
					ChannelPrintf(Channel, 12, 1, "Current RSSI = %4d   ", readRegister(Channel, REG_CURRENT_RSSI) - 157);
					
					if (Config.LoRaDevices[Channel].LastPacketAt > 0)
					{
						ChannelPrintf(Channel, 6, 1, "%us since last packet   ", (unsigned int)(time(NULL) - Config.LoRaDevices[Channel].LastPacketAt));
					}
					
					if (Config.LoRaDevices[Channel].InCallingMode && (Config.CallingTimeout > 0) && (Config.LoRaDevices[Channel].ReturnToCallingModeAt > 0) && (time(NULL) > Config.LoRaDevices[Channel].ReturnToCallingModeAt))
					{
						Config.LoRaDevices[Channel].InCallingMode = 0;
						Config.LoRaDevices[Channel].ReturnToCallingModeAt = 0;
						
						LogMessage("Return to calling mode\n");
						// setMode(Channel, RF96_MODE_SLEEP);
						
						// setFrequency(Channel, Frequency);

						// SetLoRaParameters(Channel, ImplicitOrExplicit, ErrorCoding, Bandwidth, SpreadingFactor, LowDataRateOptimize);
						
						// setMode(Channel, RF96_MODE_RX_CONTINUOUS); 
					
						setLoRaMode(Channel);

						SetDefaultLoRaParameters(Channel);
		
						setMode(Channel, RF96_MODE_RX_CONTINUOUS); 
						
						ChannelPrintf(Channel, 1, 1, "Channel %d %sMHz  %s mode", Channel, Config.LoRaDevices[Channel].Frequency, Modes[Config.LoRaDevices[Channel].SpeedMode]);
					}
						 
					if ((ch = getch()) != ERR)
					{
						ProcessKeyPress(ch);
					}
					
					if (LEDCounts[Channel] && (Config.LoRaDevices[Channel].ActivityLED >= 0))
					{
						if (--LEDCounts[Channel] == 0)
						{
							digitalWrite(Config.LoRaDevices[Channel].ActivityLED, 0);
						}
					}
				}
			}
		}
		// delay(5);
 	}

	CloseDisplay(mainwin);
	
	if (Config.NetworkLED >= 0) digitalWrite(Config.NetworkLED, 0);
	if (Config.InternetLED >= 0) digitalWrite(Config.InternetLED, 0);
	if (Config.LoRaDevices[0].ActivityLED >= 0) digitalWrite(Config.LoRaDevices[0].ActivityLED, 0);
	if (Config.LoRaDevices[1].ActivityLED >= 0) digitalWrite(Config.LoRaDevices[1].ActivityLED, 0);	
	
	return 0;
}
Пример #17
0
CConfigData::CConfigData(std::string configFilename){
  Initialize();
  LoadConfigFile(configFilename);
}
Пример #18
0
bool CaMuleExternalConnector::OnCmdLineParsed(wxCmdLineParser& parser)
{
	if (parser.Found(wxT("version"))) {
		printf("%s %s\n", m_appname, (const char *)unicode2char(GetMuleVersion()));
		return false;
	}

	if (!parser.Found(wxT("config-file"), &m_configFileName)) {
		m_configFileName = GetConfigDir() + wxT("remote.conf");
	}

	wxString aMuleConfigFile;
	if (parser.Found(wxT("create-config-from"), &aMuleConfigFile)) {
		aMuleConfigFile = FinalizeFilename(aMuleConfigFile);
		if (!::wxFileExists(aMuleConfigFile)) {
			fprintf(stderr, "%s\n", (const char *)unicode2char(wxT("FATAL ERROR: File does not exist: ") + aMuleConfigFile));
			exit(1);
		}
		CECFileConfig aMuleConfig(aMuleConfigFile);
		LoadAmuleConfig(aMuleConfig);
		SaveConfigFile();
		m_configFile->Flush();
		exit(0);
	}

	LoadConfigFile();

	if ( !parser.Found(wxT("host"), &m_host) ) {
		if ( m_host.IsEmpty() ) {
			m_host = wxT("localhost");
		}
	}

	long port;
	if (parser.Found(wxT("port"), &port)) {
		m_port = port;
	}

	wxString pass_plain;
	if (parser.Found(wxT("password"), &pass_plain)) {
		if (!pass_plain.IsEmpty()) {
			m_password.Decode(MD5Sum(pass_plain).GetHash());
		} else {
			m_password.Clear();
		}
	}

	if (parser.Found(wxT("write-config"))) {
		m_NeedsConfigSave = true;
	}

	parser.Found(wxT("locale"), &m_language);

	if (parser.Found(wxT("help"))) {
		parser.Usage();
		return false;
	}

	m_KeepQuiet = parser.Found(wxT("quiet"));
	m_Verbose = parser.Found(wxT("verbose"));

	return true;
}
Пример #19
0
int main(int argc, char** argv)
{
    LOG_INFO("RiftRay version %s", pRiftRayVersion);
#if defined(_WIN32)
    LOG_INFO("Windows build.");
#elif defined(_LINUX)
    LOG_INFO("Linux build.");
#elif defined(_MACOS)
    LOG_INFO("MacOS build.");
#endif

    bool useOpenGLCoreContext = false;

    g_renderMode.outputType = RenderingMode::OVR_SDK;

#ifdef USE_CORE_CONTEXT
    useOpenGLCoreContext = true;
#endif

#ifdef _LINUX
    // Linux driver seems to be lagging a bit
    useOpenGLCoreContext = false;
#endif

    LOG_INFO("Using GLFW3 backend.");
    LOG_INFO("Compiled against GLFW %i.%i.%i",
        GLFW_VERSION_MAJOR,
        GLFW_VERSION_MINOR,
        GLFW_VERSION_REVISION);
    int major, minor, revision;
    glfwGetVersion(&major, &minor, &revision);
    LOG_INFO("Running against GLFW %i.%i.%i", major, minor, revision);
    LOG_INFO("glfwGetVersionString: %s", glfwGetVersionString());

    // Command line options
    for (int i=0; i<argc; ++i)
    {
        const std::string a = argv[i];
        LOG_INFO("argv[%d]: %s", i, a.c_str());
        if (!a.compare("-sdk"))
        {
            g_renderMode.outputType = RenderingMode::OVR_SDK;
        }
        else if (!a.compare("-client"))
        {
            g_renderMode.outputType = RenderingMode::OVR_Client;
        }
        else if (!a.compare("-core"))
        {
            useOpenGLCoreContext = true;
        }
        else if (!a.compare("-compat"))
        {
            useOpenGLCoreContext = false;
        }
    }

    LoadConfigFile();

    g_app.initHMD();

    GLFWwindow* l_Window = NULL;
    glfwSetErrorCallback(ErrorCallback);
    if (!glfwInit())
    {
        exit(EXIT_FAILURE);
    }

#ifdef __APPLE__
    // Set the working directory to the Resources dir of the .app bundle
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
    char path[PATH_MAX];
    CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX);
    CFRelease(resourcesURL);
    strcat( path, "/shaders" );
    struct stat sb;
    if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode))
        chdir(path);
#endif

#ifndef _LINUX
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
#  if defined(_MACOS)
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
#  else
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
#  endif
#endif //ndef _LINUX
    if (useOpenGLCoreContext)
    {
        LOG_INFO("Using OpenGL core context.");
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
        glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    }
    else
    {
#ifndef _LINUX
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
#endif
    }

    glfwWindowHint(GLFW_SAMPLES, 0);
#ifdef _DEBUG
    glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
#endif

    std::string windowTitle = "RiftRay-v" + std::string(pRiftRayVersion);
#ifdef USE_OCULUSSDK
    const ovrSizei sz = g_app.getHmdResolution();
    const ovrVector2i pos = g_app.getHmdWindowPos();

    if (g_app.UsingDebugHmd() == true)
    {
        // Create a normal, decorated application window
        LOG_INFO("Using Debug HMD mode.");
        windowTitle += "-GLFW-DebugHMD";

        l_Window = glfwCreateWindow(sz.w, sz.h, windowTitle.c_str(), NULL, NULL);
        g_app.m_dashScene.m_bDraw = false;
        g_renderMode.outputType = RenderingMode::Mono_Buffered;
    }
    else if (g_app.UsingDirectMode())
    {
        LOG_INFO("Using Direct to Rift mode.");
        windowTitle += "-GLFW-Direct";

        l_Window = glfwCreateWindow(sz.w, sz.h, windowTitle.c_str(), NULL, NULL);

#if defined(_WIN32)
        g_app.AttachToWindow((void*)glfwGetWin32Window(l_Window));
#endif
    }
    else
    {
        LOG_INFO("Using Extended desktop mode.");
        windowTitle += "-GLFW-Extended";

        glfwWindowHint(GLFW_DECORATED, 0);
        l_Window = glfwCreateWindow(sz.w, sz.h, windowTitle.c_str(), NULL, NULL);
        glfwWindowHint(GLFW_DECORATED, 1);
        glfwSetWindowPos(l_Window, pos.x, pos.y);
    }

    resize(l_Window, sz.w, sz.h); // inform AppSkeleton of window size

#else
    const glm::vec2 sz(800, 600);
    // Create a normal, decorated application window
    LOG_INFO("Using No VR SDK.");
    windowTitle += "-GLFW-NoVRSDK";
    g_renderMode.outputType = RenderingMode::Mono_Buffered;

    l_Window = glfwCreateWindow(sz.x, sz.y, windowTitle.c_str(), NULL, NULL);
    resize(l_Window, sz.x, sz.y); // inform AppSkeleton of window size
#endif //USE_OSVR|USE_OCULUSSDK

    if (!l_Window)
    {
        LOG_INFO("Glfw failed to create a window. Exiting.");
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

#ifdef USE_OCULUSSDK
    // Required for SDK rendering (to do the buffer swap on its own)
#  if defined(_WIN32)
    g_app.setWindow(glfwGetWin32Window(l_Window));
#  elif defined(__linux__)
    g_app.setWindow(glfwGetX11Display());
#  endif
#endif

    glfwMakeContextCurrent(l_Window);
    glfwSetWindowSizeCallback(l_Window, resize);
    glfwSetMouseButtonCallback(l_Window, mouseDown);
    glfwSetCursorPosCallback(l_Window, mouseMove);
    glfwSetScrollCallback(l_Window, mouseWheel);
    glfwSetKeyCallback(l_Window, keyboard);

    memset(m_keyStates, 0, GLFW_KEY_LAST*sizeof(int));

    FindPreferredJoystick();

    // Log system monitor information
    const GLFWmonitor* pPrimary = glfwGetPrimaryMonitor();
    int monitorCount = 0;
    GLFWmonitor** ppMonitors = glfwGetMonitors(&monitorCount);
    for (int i=0; i<monitorCount; ++i)
    {
        GLFWmonitor* pCur = ppMonitors[i];
        const GLFWvidmode* mode = glfwGetVideoMode(pCur);
        if (mode != NULL)
        {
            LOG_INFO("Monitor #%d: %dx%d @ %dHz %s",
                i,
                mode->width,
                mode->height,
                mode->refreshRate,
                pCur==pPrimary ? "Primary":"");
        }
    }

    printGLContextInfo(l_Window);
    glfwMakeContextCurrent(l_Window);
    g_pHMDWindow = l_Window;


    // Don't forget to initialize Glew, turn glewExperimental on to
    // avoid problems fetching function pointers...
    glewExperimental = GL_TRUE;
    const GLenum l_Result = glewInit();
    if (l_Result != GLEW_OK)
    {
        LOG_INFO("glewInit() error.");
        exit(EXIT_FAILURE);
    }

#ifdef _DEBUG
    // Debug callback initialization
    // Must be done *after* glew initialization.
    glDebugMessageCallback(myCallback, NULL);
    glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
    glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
        GL_DEBUG_SEVERITY_NOTIFICATION, -1, "Start debugging");
    glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
#endif

#ifdef USE_ANTTWEAKBAR
    LOG_INFO("Using AntTweakbar.");
    TwInit(useOpenGLCoreContext ? TW_OPENGL_CORE : TW_OPENGL, NULL);
    InitializeBar();
#endif

    LOG_INFO("Calling initGL...");
    g_app.initGL();
    LOG_INFO("Calling initVR...");
    g_app.initVR();
    LOG_INFO("initVR complete.");

    SetVsync(1); // default to vsync on

    StartShaderLoad();

    while (!glfwWindowShouldClose(l_Window))
    {
        const bool tapped = g_app.CheckForTapOnHmd();
        if (tapped && (g_receivedFirstTap == false))
        {
            g_app.RecenterPose();
            g_receivedFirstTap = true;
        }

        glfwPollEvents();
        joystick();
        timestep();
        g_fps.OnFrame();
        if (g_dynamicallyScaleFBO)
        {
            DynamicallyScaleFBO();
        }

#ifdef USE_ANTTWEAKBAR
        TwRefreshBar(g_pTweakbar);
        TwRefreshBar(g_pShaderTweakbar);
#endif

        displayToHMD();

#ifndef _LINUX
        // Indicate FPS in window title
        // This is absolute death for performance in Ubuntu Linux 12.04
        {
            std::ostringstream oss;
            oss << windowTitle
                << " "
                << static_cast<int>(g_fps.GetFPS())
                << " fps";
            glfwSetWindowTitle(l_Window, oss.str().c_str());
            if (g_AuxWindow != NULL)
                glfwSetWindowTitle(g_AuxWindow, oss.str().c_str());
        }
#endif
        const float dumpInterval = 1.f;
        if (g_logDumpTimer.seconds() > dumpInterval)
        {
            LOG_INFO("Frame rate: %d fps", static_cast<int>(g_fps.GetFPS()));
            g_logDumpTimer.reset();
        }

        // Optionally display to auxiliary mono view
        if (g_AuxWindow != NULL)
        {
            glfwMakeContextCurrent(g_AuxWindow);
            glClearColor(0.f, 0.f, 0.f, 0.f);
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

            ///@note VAOs *cannot* be shared between contexts.
            ///@note GLFW windows are inextricably tied to their own unique context.
            /// For these two reasons, calling draw a third time for the auxiliary window
            /// is not possible. Furthermore, it is not strictly desirable for the extra
            /// rendering cost.
            /// Instead, we share the render target texture from the stereo render and present
            /// just the left eye to the aux window.
            if (g_drawToAuxWindow)
            {
                presentSharedFboTexture();
            }

#ifdef USE_ANTTWEAKBAR
            TwDraw(); ///@todo Should this go first? Will it write to a depth buffer?
#endif

            glfwSwapBuffers(g_AuxWindow);

            if (glfwWindowShouldClose(g_AuxWindow))
            {
                destroyAuxiliaryWindow(g_AuxWindow);
            }

            // Set context to Rift window when done
            glfwMakeContextCurrent(l_Window);
        }
    }

    g_app.exitVR();
    glfwDestroyWindow(l_Window);
    glfwTerminate();

    exit(EXIT_SUCCESS);
}
Пример #20
0
void ServerConfig::Reload()
{
  LoadConfigFile();
}
Пример #21
0
int main(void)
{
	int fd, ReturnCode, i;
	unsigned long Sentence_Counter = 0;
	int ImagePacketCount, MaxImagePackets;
	char Sentence[100], Command[100];
	struct stat st = {0};
	struct TGPS GPS;
	pthread_t PredictionThread, LoRaThread, APRSThread, GPSThread, DS18B20Thread, ADCThread, CameraThread, BMP085Thread, BME280Thread, LEDThread, LogThread;
	
	if (prog_count("tracker") > 1)
	{
		printf("\nThe tracker program is already running!\n");
		printf("It is started automatically, with the camera script, when the Pi boots.\n\n");
		printf("If you just want the tracker software to run, it already is,\n");
		printf("and its output can be viewed on a monitor attached to a Pi video socket.\n\n");
		printf("If instead you want to view the tracker output via ssh,\n");
		printf("then you should first stop it by typing the following command:\n");
		printf("	sudo killall tracker\n\n");
		printf("and then restart manually with\n");
		printf("	sudo ./tracker\n\n");
		exit(1);
	}
	
	printf("\n\nRASPBERRY PI-IN-THE-SKY FLIGHT COMPUTER\n");
	printf(    "=======================================\n\n");

	Config.BoardType = GetBoardType();

	if (Config.BoardType)
	{
		if (Config.BoardType == 3)
		{
			printf("RPi Zero\n");
			printf("PITS Zero Board\n");
		}
		else
		{
			if (Config.BoardType == 2)
			{
				printf("RPi 2 B\n");
			}
			else
			{
				printf("RPi Model A+ or B+\n");
			}
			printf("PITS+ Board\n");
		}
				
		Config.LED_OK = 25;
		Config.LED_Warn = 24;
		
		Config.SDA = 2;
		Config.SCL = 3;
	}
	else
	{
		printf("RPi Model A or B\n");
		printf("PITS Board\n");

		Config.LED_OK = 11;
		Config.LED_Warn = 4;
		
		Config.SDA = 5;
		Config.SCL = 6;
	}
	
	printf("Device Tree is %s\n\n", devicetree() ? "enabled" : "disabled");

	LoadConfigFile(&Config);

	if (Config.DisableMonitor)
	{
		system("/opt/vc/bin/tvservice -off");
	}
	
	if (FileExists("/boot/clear.txt"))
	{
		// remove SSDV and other camera images, plus log files

		printf("Removing existing photo files\n");
		remove("gps.txt");
		remove("telemetry.txt");
		remove("/boot/clear.txt");
		system("rm -rf /home/pi/pits/tracker/images/*");
	}
		
	// Remove any old SSDV files
	system("rm -f ssdv*.bin");

	GPS.SecondsInDay = 0;
	GPS.Hours = 0;
	GPS.Minutes = 0;
	GPS.Seconds = 0;
	GPS.Longitude = 0.0;
	GPS.Latitude = 0.0;
	GPS.Altitude = 0;
	GPS.Satellites = 0;
	GPS.Speed = 0.0;
	GPS.Direction = 0.0;
	GPS.DS18B20Temperature[0] = 0.0;
	GPS.DS18B20Temperature[1] = 0.0;
	GPS.BatteryVoltage = 0.0;
	GPS.BMP180Temperature = 0.0;
	GPS.Pressure = 0.0;
	GPS.MaximumAltitude = 0.0;
	GPS.DS18B20Count = 0;

	
	// Set up I/O
	if (wiringPiSetup() == -1)
	{
		exit (1);
	}

	// Switch off the radio till it's configured
	pinMode (NTX2B_ENABLE, OUTPUT);
	digitalWrite (NTX2B_ENABLE, 0);
		
	// Switch on the GPS
	if (Config.BoardType == 0)
	{
		// Only PITS board had this, not PITS+
		pinMode (UBLOX_ENABLE, OUTPUT);
		digitalWrite (UBLOX_ENABLE, 0);
	}

	if (!Config.DisableRTTY)
	{
		if (*Config.Frequency)
		{
			SetFrequency(Config.Frequency);
		}
	
		fd = OpenSerialPort();

		digitalWrite (NTX2B_ENABLE, 1);
	}
	
	// Set up DS18B20
	system("sudo modprobe w1-gpio");
	system("sudo modprobe w1-therm");
	
	if (!devicetree())
	{
		// SPI for ADC (older boards), LoRa add-on board
		system("gpio load spi");
	}

	// SSDV Folders
	sprintf(Config.Channels[0].SSDVFolder, "%s/RTTY", SSDVFolder);
	*Config.Channels[1].SSDVFolder = '\0';										// No folder for APRS images
	sprintf(Config.Channels[2].SSDVFolder, "%s/LORA0", SSDVFolder);
	sprintf(Config.Channels[3].SSDVFolder, "%s/LORA1", SSDVFolder);
	sprintf(Config.Channels[4].SSDVFolder, "%s/FULL", SSDVFolder);
		
	if (Config.Camera)
	{
		// Create SSDV Folders
		if (stat(SSDVFolder, &st) == -1)
		{
			mkdir(SSDVFolder, 0777);
		}	
	
		for (i=0; i<5; i++)
		{
			if (*Config.Channels[i].SSDVFolder)
			{
				if (stat(Config.Channels[i].SSDVFolder, &st) == -1)
				{
					mkdir(Config.Channels[i].SSDVFolder, 0777);
				}
			}
		}

		// Filenames for SSDV
		for (i=0; i<5; i++)
		{
			sprintf(Config.Channels[i].take_pic, "take_pic_%d", i);
			// sprintf(Config.Channels[i].current_ssdv, "ssdv_%d.bin", i);
			// sprintf(Config.Channels[i].next_ssdv, "ssdv_%d.nxt", i);
			sprintf(Config.Channels[i].convert_file, "convert_%d", i);
			sprintf(Config.Channels[i].ssdv_done, "ssdv_done_%d", i);
			
			Config.Channels[i].SSDVImageNumber = -1;
			Config.Channels[i].SSDVPacketNumber = -1;
			
			Config.Channels[i].ImageFP = NULL;
		}
	}
	
	if (pthread_create(&GPSThread, NULL, GPSLoop, &GPS))
	{
		fprintf(stderr, "Error creating GPS thread\n");
		return 1;
	}

	if (*(Config.APRS_Callsign) && Config.APRS_ID && Config.APRS_Period)
	{
		if (pthread_create(&APRSThread, NULL, APRSLoop, &GPS))
		{
			fprintf(stderr, "Error creating APRS thread\n");
			return 1;
		}
	}
	
	if (Config.LoRaDevices[0].InUse || Config.LoRaDevices[1].InUse)
	{
		if (pthread_create(&LoRaThread, NULL, LoRaLoop, &GPS))
		{
			fprintf(stderr, "Error creating LoRa thread\n");
		}
	}
	
	if (pthread_create(&DS18B20Thread, NULL, DS18B20Loop, &GPS))
	{
		fprintf(stderr, "Error creating DS18B20s thread\n");
		return 1;
	}

	if (Config.BoardType != 3)
	{
		// Not a zero, so should have ADC on it
		if (I2CADCExists())
		{
			printf ("V2.4 or later board with I2C ADC\n");
			
			if (pthread_create(&ADCThread, NULL, I2CADCLoop, &GPS))
			{
				fprintf(stderr, "Error creating ADC thread\n");
				return 1;
			}
		}
		else
		{
			printf ("Older board with SPI ADC\n");
			
			if (pthread_create(&ADCThread, NULL, ADCLoop, &GPS))
			{
				fprintf(stderr, "Error creating ADC thread\n");
				return 1;
			}
		}
	}

	if (Config.Camera)
	{
		if (pthread_create(&CameraThread, NULL, CameraLoop, &GPS))
		{
			fprintf(stderr, "Error creating camera thread\n");
			return 1;
		}
	}

	if (pthread_create(&LEDThread, NULL, LEDLoop, &GPS))
	{
		fprintf(stderr, "Error creating LED thread\n");
		return 1;
	}

	if (Config.TelemetryFileUpdate > 0)
	{
		if (pthread_create(&LogThread, NULL, LogLoop, &GPS))
		{
			fprintf(stderr, "Error creating Log thread\n");
			return 1;
		}
	}
	
	if (Config.EnableBMP085)
	{
		if (pthread_create(&BMP085Thread, NULL, BMP085Loop, &GPS))
		{
			fprintf(stderr, "Error creating BMP085 thread\n");
			return 1;
		}
	}

	if (Config.EnableBME280)
	{
		if (pthread_create(&BME280Thread, NULL, BME280Loop, &GPS))
		{
			fprintf(stderr, "Error creating BME280 thread\n");
			return 1;
		}
	}

	if (Config.EnableLandingPrediction)
	{
		if (pthread_create(&PredictionThread, NULL, PredictionLoop, &GPS))
		{
			fprintf(stderr, "Error creating prediction thread\n");
		}
	}	
	
	if (!Config.DisableRTTY)
	{
		if (Config.InfoMessageCount < 0)
		{
			// Default number depends on baud rate
			Config.InfoMessageCount = (Config.TxSpeed < B300) ? 2 : 4;
		}
	
		for (i=0; i<Config.InfoMessageCount; i++)
		{
			SendIPAddress(fd);
			SendFreeSpace(fd);
		}
	}

	ImagePacketCount = 0;
	
	while (1)
	{
		static int CarrierOn=1;
		
		if (Config.DisableRTTY)
		{
			delayMilliseconds (200);
		}
		else if (LoRaUploadNow(&GPS, 10))
		{
			if (CarrierOn)
			{
				digitalWrite (NTX2B_ENABLE, 0);
				CarrierOn = 0;
				printf("Switching RTTY carrier off\n");
			}
			delayMilliseconds (200);
		}
		else
		{
			if (!CarrierOn)
			{
				digitalWrite (NTX2B_ENABLE, 1);
				printf("Switching RTTY carrier on\n");
				CarrierOn = 1;
			}
			
			MaxImagePackets = (GPS.Altitude > Config.SSDVHigh) ? Config.Channels[RTTY_CHANNEL].ImagePackets : 1;
			
			if (ImagePacketCount++ < MaxImagePackets)
			{
				SendRTTYImage(fd);
			}
			else
			{
				ImagePacketCount = 0;
				
				BuildSentence(Sentence, ++Sentence_Counter, &GPS);
			
				SendSentence(fd, Sentence);
			}
		}
	}
}
Пример #22
0
void SkinManager::ExtractSkinInfo(skinitem* Skin)
{
	if (Skin->isCompressed)
	{
		// Check to see if Data Path exists
		string datapath = SETTINGS::getInstance().getDataPath() + "Skins\\";
		HRESULT hr;
		if (!FileExists(datapath)){
			DebugMsg("SkinManager", "Creating %s folder", datapath.c_str());
			_mkdir(datapath.c_str());
		}
		// Check to see if xmlpath exists "skins\\default.xzp\\"
		if (!FileExists(Skin->xmlpath)){
			DebugMsg("SkinManager", "Creating %s folder", Skin->xmlpath.c_str());
			_mkdir(Skin->xmlpath.c_str());
		}
		// Check to see if Settings folder exists
		string tempcfg = Skin->xmlpath + "Settings\\";
		if(!FileExists(tempcfg)){
		DebugMsg("SkinManager", "Creating %s folder", tempcfg.c_str());
		_mkdir(tempcfg.c_str());
		}

		// Check to see if Menu Settings Exists, if not, extract it
		string strbuff = Skin->xmlpath + "Settings\\MenuSettings.xml";
		if (!FileExists(Skin->xmlpath + "Settings\\MenuSettings.xml"))
		{
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "Settings\\MenuSettings.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}

		// Check to see if SkinSettings Exists, if not, extract it
		strbuff = Skin->xmlpath + "Settings\\SkinSettings.xml";
		if (!FileExists(Skin->xmlpath + "Settings\\SkinSettings.xml"))
		{
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "Settings\\SkinSettings.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}

		// Check to verify that XML Folder Exists
		string tempxml = Skin->xmlpath + "XML\\";
		if (!FileExists(tempxml))
		{
			DebugMsg("SkinManager", "Creating %s folder", tempxml.c_str());
			_mkdir(tempxml.c_str());
		}

		// Look for BkgListA and extract that
		strbuff = Skin->xmlpath + "XML\\BkgListA.xml";
		if (!FileExists(Skin->xmlpath + "XML\\BkgListA.xml")){
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "XML\\BkgListA.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}
		// Look for BkgListB and extract that
		strbuff = Skin->xmlpath + "XML\\BkgListB.xml";
		if (!FileExists(Skin->xmlpath + "XML\\BkgListB.xml")){
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "XML\\BkgListB.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}
			// Look for VisualList and extract that
		strbuff = Skin->xmlpath + "XML\\VisualList.xml";
		if (!FileExists(Skin->xmlpath + "XML\\VisualList.xml")){
			DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
			hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, "XML\\VisualList.xml");
			if (hr == S_OK)
			{
				DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
			} else {
				DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
			}
		}
		XMLReader * xml = LoadConfigFile(strbuff);
		// Extract the visual files as well
		DebugMsg("SkinManager","Extracting Visual XML files");
		while (xml && xml->read())
		{
			if(StartAttribute(xml, "visual"))
			{
				DebugMsg("SkinManager", "Reading VisualList.xml");
				strbuff = xml->getAttributeValue("path");
				DebugMsg("SkinManager", "Path: %s", strbuff.c_str());
				tempxml = Skin->xmlpath + strbuff;
				DebugMsg("SkinManager", "TempPath: %s", tempxml.c_str());
				if (!FileExists(tempxml)){
					DebugMsg("SkinManager", "File %s doesn't exist. Extracting", strbuff.c_str());
					hr = XZPManager::getInstance().ExtractXML(Skin->SkinPath, Skin->SkinFileName, strbuff);
					if (hr == S_OK)
					{
						DebugMsg("SkinManager", "Extracted %s Successfully", strbuff.c_str());
					} else {
						DebugMsg("SkinManager", "Failed to extract %s", strbuff.c_str());
					}
				}
			}
		}
	}
}
Пример #23
0
CConfig::CConfig(void)
{
    LoadConfigFile();
}
Пример #24
0
int main(int argc, char** argv)
{
    LoadConfigFile();
    initHMD();

    glfwSetErrorCallback(ErrorCallback);
    if (!glfwInit())
    {
        exit(EXIT_FAILURE);
    }
    glfwWindowHint(GLFW_DEPTH_BITS, 16);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);// : GLFW_OPENGL_COMPAT_PROFILE);
    //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#ifdef _DEBUG
    glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
#endif

    const std::string windowName = "RiftRay v" + std::string(pRiftRayVersion);
    GLFWwindow* l_Window = glfwCreateWindow(g_mirrorWindowSz.x, g_mirrorWindowSz.y, windowName.c_str(), NULL, NULL);
    if (!l_Window)
    {
        LOG_ERROR("Glfw failed to create a window. Exiting.");
        glfwTerminate();
        exit(EXIT_FAILURE);
    }
    glfwMakeContextCurrent(l_Window);
    glfwSetKeyCallback(l_Window, keyboard);
    glfwSetMouseButtonCallback(l_Window, mouseDown);
    glfwSetCursorPosCallback(l_Window, mouseMove);
    glfwSetScrollCallback(l_Window, mouseWheel);
    glfwSetWindowSizeCallback(l_Window, resize);
    glfwSetInputMode(l_Window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
    g_pMirrorWindow = l_Window;

    memset(m_keyStates, 0, GLFW_KEY_LAST*sizeof(int));
    FindPreferredJoystick();

    glewExperimental = GL_TRUE;
    if (glewInit() != GLEW_OK)
    {
        LOG_INFO("glewInit() error.");
        exit(EXIT_FAILURE);
    }

#ifdef _DEBUG
    // Debug callback initialization
    // Must be done *after* glew initialization.
    glDebugMessageCallback(myCallback, NULL);
    glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE);
    glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
        GL_DEBUG_SEVERITY_NOTIFICATION, -1 , "Start debugging");
    glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
#endif

#ifdef USE_ANTTWEAKBAR
    TwInit(TW_OPENGL_CORE, NULL);
    initAnt();
#endif

    g_pScene = &g_gallery;// new ShaderGalleryScene();
    if (g_pScene != NULL)
    {
        g_pScene->initGL();
    }

    g_gallery.SetHmdPositionPointer(&m_hmdRo);
    g_gallery.SetHmdDirectionPointer(&m_hmdRd);
    g_gallery.SetChassisPosPointer(&m_chassisPos);
    g_gallery.SetChassisYawPointer(&m_chassisYaw);
    g_gallery.SetHeadSizePointer(&m_headSize);

    initVR();
    StartShaderLoad();
    glfwSwapInterval(0);
    while (!glfwWindowShouldClose(l_Window))
    {
        glfwPollEvents();
        joystick();
        timestep();

#ifdef USE_ANTTWEAKBAR
        TwRefreshBar(g_pMainTweakbar);
        TwRefreshBar(g_pShaderTweakbar);
#endif
        g_gallery.RenderPrePass();
        displayHMD();
        glfwSwapBuffers(l_Window);
    }
    exitVR();
    g_pScene->exitGL();
    glfwDestroyWindow(l_Window);
    glfwTerminate();
    exit(EXIT_SUCCESS);
}
Пример #25
0
int main( int argc, char **argv )
{
	if( argc < 2 )
	{
		Usage();
	}
	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
	InitDefaultFileSystem();

	int i = 1;
	while( i < argc )
	{
		if( stricmp( argv[i], "-quiet" ) == 0 )
		{
			i++;
			g_Quiet = true;
			g_NoPause = true; // no point in pausing if we aren't going to print anything out.
		}
		if( stricmp( argv[i], "-nopause" ) == 0 )
		{
			i++;
			g_NoPause = true;
		}
		else
		{
			break;
		}
	}

	char pCurrentDirectory[MAX_PATH];
	if ( _getcwd( pCurrentDirectory, sizeof(pCurrentDirectory) ) == NULL )
	{
		fprintf( stderr, "Unable to get the current directory\n" );
		return -1;
	}

	Q_FixSlashes( pCurrentDirectory );
	Q_StripTrailingSlash( pCurrentDirectory );

	for( ; i < argc; i++ )
	{
		static char normalFileNameWithoutExtension[1024];
		char *pFileName;
		if ( !Q_IsAbsolutePath( argv[i] ) )
		{
			Q_snprintf( normalFileNameWithoutExtension, sizeof(normalFileNameWithoutExtension), "%s\\%s", pCurrentDirectory, argv[i] );
			pFileName = normalFileNameWithoutExtension;
		}
		else
		{
			pFileName = argv[i];
		}

		if( !g_Quiet )
		{
			printf( "file: %s\n", pFileName );
		}
		float bumpScale = -1.0f;
		int startFrame = -1;
		int endFrame = -1;
		LoadConfigFile( pFileName, &bumpScale, &startFrame, &endFrame );
		if( bumpScale == -1.0f )
		{
			fprintf( stderr, "Must specify \"bumpscale\" in config file\n" );
			Pause();
			continue;
		}
		if( ( startFrame == -1 && endFrame != -1 ) ||
			( startFrame != -1 && endFrame == -1 ) )
		{
			fprintf( stderr, "ERROR: If you use startframe, you must use endframe, and vice versa.\n" );
			Pause();
			continue;
		}
		if( !g_Quiet )
		{
			printf( "\tbumpscale: %f\n", bumpScale );
		}
		
		Q_StripExtension( pFileName, normalFileNameWithoutExtension, sizeof( normalFileNameWithoutExtension ) );
		ProcessFiles( normalFileNameWithoutExtension,
					  startFrame, endFrame,
					  bumpScale );
	}
	return 0;
}
FGameConfigFile::FGameConfigFile ()
{
#ifdef __APPLE__
	FString user_docs, user_app_support, local_app_support;
#endif
	FString pathname;
	
	bMigrating = false;
	pathname = GetConfigPath (true);
	ChangePathName (pathname);
	LoadConfigFile (MigrateStub, NULL);

	if (!HaveSections ())
	{ // Config file not found; try the old one
		MigrateOldConfig ();
	}

	// If zdoom.ini was read from the program directory, switch
	// to the user directory now. If it was read from the user
	// directory, this effectively does nothing.
	pathname = GetConfigPath (false);
	ChangePathName (pathname);

	// Set default IWAD search paths if none present
	if (!SetSection ("IWADSearch.Directories"))
	{
		SetSection ("IWADSearch.Directories", true);
		SetValueForKey ("Path", ".", true);
		SetValueForKey ("Path", "$DOOMWADDIR", true);
#ifdef __APPLE__
		char cpath[PATH_MAX];
		FSRef folder;
		
		if (noErr == FSFindFolder(kUserDomain, kDocumentsFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			user_docs << cpath << "/" GAME_DIR;
			SetValueForKey("Path", user_docs, true);
		}
		else
		{
			SetValueForKey("Path", "~/" GAME_DIR, true);
		}
		if (noErr == FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			user_app_support << cpath << "/" GAME_DIR;
			SetValueForKey("Path", user_app_support, true);
		}
		SetValueForKey ("Path", "$PROGDIR", true);
		if (noErr == FSFindFolder(kLocalDomain, kApplicationSupportFolderType, kCreateFolder, &folder) &&
			noErr == FSRefMakePath(&folder, (UInt8*)cpath, PATH_MAX))
		{
			local_app_support << cpath << "/" GAME_DIR;
			SetValueForKey("Path", local_app_support, true);
		}
#elif !defined(unix)
		SetValueForKey ("Path", "$HOME", true);
		SetValueForKey ("Path", "$PROGDIR", true);
#else
		SetValueForKey ("Path", "~/" GAME_DIR, true);
		SetValueForKey ("Path", SHARE_DIR, true);
#endif
	}

	// Set default search paths if none present
	if (!SetSection ("FileSearch.Directories"))
	{
		SetSection ("FileSearch.Directories", true);
#ifdef __APPLE__
		SetValueForKey ("Path", user_docs, true);
		SetValueForKey ("Path", user_app_support, true);
		SetValueForKey ("Path", "$PROGDIR", true);
		SetValueForKey ("Path", local_app_support, true);
#elif !defined(unix)
		SetValueForKey ("Path", "$PROGDIR", true);
#else
		SetValueForKey ("Path", SHARE_DIR, true);
#endif
		SetValueForKey ("Path", "$DOOMWADDIR", true);
	}

	// Create auto-load sections, so users know what's available.
	// Note that this totem pole is the reverse of the order that
	// they will appear in the file.
	CreateSectionAtStart("Chex3.Autoload");
	CreateSectionAtStart("Chex.Autoload");
	CreateSectionAtStart("Strife.Autoload");
	CreateSectionAtStart("HexenDemo.Autoload");
	CreateSectionAtStart("HexenDK.Autoload");
	CreateSectionAtStart("Hexen.Autoload");
	CreateSectionAtStart("Heretic.Autoload");
	CreateSectionAtStart("FreeDM.Autoload");
	CreateSectionAtStart("Freedoom1.Autoload");
	CreateSectionAtStart("Freedoom.Autoload");
	CreateSectionAtStart("Plutonia.Autoload");
	CreateSectionAtStart("TNT.Autoload");
	CreateSectionAtStart("Doom2.Autoload");
	CreateSectionAtStart("Doom1.Autoload");
	CreateSectionAtStart("Doom.Autoload");
	CreateSectionAtStart("Global.Autoload");

	// The same goes for auto-exec files.
	CreateStandardAutoExec("Chex.AutoExec", true);
	CreateStandardAutoExec("Strife.AutoExec", true);
	CreateStandardAutoExec("Hexen.AutoExec", true);
	CreateStandardAutoExec("Heretic.AutoExec", true);
	CreateStandardAutoExec("Doom.AutoExec", true);

	// Move search paths back to the top.
	MoveSectionToStart("FileSearch.Directories");
	MoveSectionToStart("IWADSearch.Directories");

	// Add some self-documentation.
	SetSectionNote("IWADSearch.Directories",
		"# These are the directories to automatically search for IWADs.\n"
		"# Each directory should be on a separate line, preceded by Path=\n");
	SetSectionNote("FileSearch.Directories",
		"# These are the directories to search for wads added with the -file\n"
		"# command line parameter, if they cannot be found with the path\n"
		"# as-is. Layout is the same as for IWADSearch.Directories\n");
	SetSectionNote("Doom.AutoExec",
		"# Files to automatically execute when running the corresponding game.\n"
		"# Each file should be on its own line, preceded by Path=\n\n");
	SetSectionNote("Global.Autoload",
		"# WAD files to always load. These are loaded after the IWAD but before\n"
		"# any files added with -file. Place each file on its own line, preceded\n"
		"# by Path=\n");
	SetSectionNote("Doom.Autoload",
		"# Wad files to automatically load depending on the game and IWAD you are\n"
		"# playing.  You may have have files that are loaded for all similar IWADs\n"
		"# (the game) and files that are only loaded for particular IWADs. For example,\n"
		"# any files listed under Doom.Autoload will be loaded for any version of Doom,\n"
		"# but files listed under Doom2.Autoload will only load when you are\n"
		"# playing Doom 2.\n\n");
}
Пример #27
0
FGameConfigFile::FGameConfigFile ()
{
#ifdef __APPLE__
	FString user_docs, user_app_support, local_app_support;
	M_GetMacSearchDirectories(user_docs, user_app_support, local_app_support);
#endif

	FString pathname;

	OkayToWrite = false;	// Do not allow saving of the config before DoGameSetup()
	bModSetup = false;
	pathname = GetConfigPath (true);
	ChangePathName (pathname);
	LoadConfigFile ();

	// If zdoom.ini was read from the program directory, switch
	// to the user directory now. If it was read from the user
	// directory, this effectively does nothing.
	pathname = GetConfigPath (false);
	ChangePathName (pathname);

	// Set default IWAD search paths if none present
	if (!SetSection ("IWADSearch.Directories"))
	{
		SetSection ("IWADSearch.Directories", true);
		SetValueForKey ("Path", ".", true);
		SetValueForKey ("Path", "$DOOMWADDIR", true);
#ifdef __APPLE__
		SetValueForKey ("Path", user_docs, true);
		SetValueForKey ("Path", user_app_support, true);
		SetValueForKey ("Path", "$PROGDIR", true);
		SetValueForKey ("Path", local_app_support, true);
#elif !defined(__unix__)
		SetValueForKey ("Path", "$HOME", true);
		SetValueForKey ("Path", "$PROGDIR", true);
#else
		SetValueForKey ("Path", "$HOME/" GAME_DIR, true);
		// Arch Linux likes them in /usr/share/doom
		// Debian likes them in /usr/share/games/doom
		// I assume other distributions don't do anything radically different
		SetValueForKey ("Path", "/usr/local/share/doom", true);
		SetValueForKey ("Path", "/usr/local/share/games/doom", true);
		SetValueForKey ("Path", "/usr/share/doom", true);
		SetValueForKey ("Path", "/usr/share/games/doom", true);
#endif
	}

	// Set default search paths if none present
	if (!SetSection ("FileSearch.Directories"))
	{
		SetSection ("FileSearch.Directories", true);
#ifdef __APPLE__
		SetValueForKey ("Path", user_docs, true);
		SetValueForKey ("Path", user_app_support, true);
		SetValueForKey ("Path", "$PROGDIR", true);
		SetValueForKey ("Path", local_app_support, true);
#elif !defined(__unix__)
		SetValueForKey ("Path", "$PROGDIR", true);
#else
		SetValueForKey ("Path", "$HOME/" GAME_DIR, true);
		SetValueForKey ("Path", SHARE_DIR, true);
		SetValueForKey ("Path", "/usr/local/share/doom", true);
		SetValueForKey ("Path", "/usr/local/share/games/doom", true);
		SetValueForKey ("Path", "/usr/share/doom", true);
		SetValueForKey ("Path", "/usr/share/games/doom", true);
#endif
		SetValueForKey ("Path", "$DOOMWADDIR", true);
	}

	// Set default search paths if none present
	if (!SetSection("SoundfontSearch.Directories"))
	{
		SetSection("SoundfontSearch.Directories", true);
#ifdef __APPLE__
		SetValueForKey("Path", user_docs + "/soundfonts", true);
		SetValueForKey("Path", user_docs + "/fm_banks", true);
		SetValueForKey("Path", user_app_support + "/soundfonts", true);
		SetValueForKey("Path", user_app_support + "/fm_banks", true);
		SetValueForKey("Path", "$PROGDIR/soundfonts", true);
		SetValueForKey("Path", "$PROGDIR/fm_banks", true);
		SetValueForKey("Path", local_app_support + "/soundfonts", true);
		SetValueForKey("Path", local_app_support + "/fm_banks", true);
#elif !defined(__unix__)
		SetValueForKey("Path", "$PROGDIR/soundfonts", true);
		SetValueForKey("Path", "$PROGDIR/fm_banks", true);
#else
		SetValueForKey("Path", "$HOME/" GAME_DIR "/soundfonts", true);
		SetValueForKey("Path", "$HOME/" GAME_DIR "/fm_banks", true);
		SetValueForKey("Path", "/usr/local/share/doom/soundfonts", true);
		SetValueForKey("Path", "/usr/local/share/doom/fm_banks", true);
		SetValueForKey("Path", "/usr/local/share/games/doom/soundfonts", true);
		SetValueForKey("Path", "/usr/local/share/games/doom/fm_banks", true);
		SetValueForKey("Path", "/usr/share/doom/soundfonts", true);
		SetValueForKey("Path", "/usr/share/doom/fm_banks", true);
		SetValueForKey("Path", "/usr/share/games/doom/soundfonts", true);
		SetValueForKey("Path", "/usr/share/games/doom/fm_banks", true);
#endif
	}

	// Add some self-documentation.
	SetSectionNote("IWADSearch.Directories",
		"# These are the directories to automatically search for IWADs.\n"
		"# Each directory should be on a separate line, preceded by Path=\n");
	SetSectionNote("FileSearch.Directories",
		"# These are the directories to search for wads added with the -file\n"
		"# command line parameter, if they cannot be found with the path\n"
		"# as-is. Layout is the same as for IWADSearch.Directories\n");
	SetSectionNote("SoundfontSearch.Directories",
		"# These are the directories to search for soundfonts that let listed in the menu.\n"
		"# Layout is the same as for IWADSearch.Directories\n");
}