示例#1
0
    void    LogManager::SetLogFile(const sf::String& logFile)
    {
        myLogFile.open(logFile.ToAnsiString().c_str(), std::ios::out | std::ios::trunc);

        if (!myLogFile)
            std::cerr << "Impossible d'ouvrir le fichier " << logFile.ToAnsiString() << std::endl;
    }
示例#2
0
void toDebugLog(const sf::String &pStr)
{
#ifndef DEBUG
	std::ofstream lfile;
	lfile.open(gDebugLog.ToAnsiString(), std::ios::app);
	lfile<<pStr.ToAnsiString()<<std::endl;
	lfile.close();
#else
	//std::cout<<pStr.ToAnsiString()<<std::endl;
#endif
}
示例#3
0
std::vector<std::string> getAllFolders(const sf::String &pFolder)
{
	DIR *lDir;
	struct dirent *ent;

	std::vector<std::string> mReturn;

	// *********** IMAGE LOADING ****/////////////////////////
	lDir = opendir (pFolder.ToAnsiString().c_str());

	if (lDir != NULL) 
	{

	  /* print all the files and directories within directory */
	  while ((ent = readdir (lDir)) != NULL) 
	  {
		  if(ent->d_type == DT_DIR)
		  {
			  sf::String lStr(ent->d_name);
			  if(lStr == "." || lStr == "..")
				  continue;

			  mReturn.push_back(lStr.ToAnsiString());
		  }
	  }
	  closedir (lDir);
	}

	  return mReturn;
}
示例#4
0
std::map<sf::String, sf::String> parseDataFile(const sf::String &pFile)
{
	std::map<sf::String, sf::String> lReturn;

	std::ifstream t(pFile.ToAnsiString());

	if(!t.is_open())
		return lReturn;

	std::string str;

	t.seekg(0, std::ios::end);   
	str.reserve(t.tellg());
	t.seekg(0, std::ios::beg);

	str.assign((std::istreambuf_iterator<char>(t)),
				std::istreambuf_iterator<char>());

	std::string lStrData(str);

	lStrData.erase(std::remove_if(lStrData.begin(), lStrData.end(), ::isspace), lStrData.end());
	
	std::vector<std::string> lLine = split(lStrData, ';');

	for(int i = 0; i < lLine.size(); i++)
	{
		std::vector<std::string> lValue = split(lLine.at(i), '=');

		lReturn[lValue.at(0)] = lValue.at(1);
	}

	return lReturn;
}
示例#5
0
void initDebugLog()
{
#ifndef DEBUG
	std::ofstream lfile;
	lfile.open(gDebugLog.ToAnsiString(), std::ios::out);
	lfile.close();
#endif
}
示例#6
0
文件: Shader.cpp 项目: tsingzhen/sf3d
    void    Program::Send(const sf::String& name, float value)
    {
        if (!myIsLinked)
            return;

        GLint loc = glGetUniformLocation(myProgram, name.ToAnsiString().c_str());
        glUseProgram(myProgram);
        glUniform1f(loc, value);
    }
示例#7
0
文件: Shader.cpp 项目: tsingzhen/sf3d
    void    Program::Send(const sf::String& name, float f1, float f2, float f3, float f4)
    {
        if (!myIsLinked)
            return;

        GLint loc = glGetUniformLocation(myProgram, name.ToAnsiString().c_str());
        glUseProgram(myProgram);

        glUniform4f(loc, f1, f2, f3, f4);
    }
示例#8
0
文件: Shader.cpp 项目: tsingzhen/sf3d
    void    Program::Send(const sf::String& name, const sf::Vector3f& vector)
    {
        if (!myIsLinked)
            return;

        GLint loc = glGetUniformLocation(myProgram, name.ToAnsiString().c_str());
        glUseProgram(myProgram);

        glUniform3f(loc, vector.x, vector.y, vector.z);
    }
示例#9
0
文件: Shader.cpp 项目: tsingzhen/sf3d
    void    Program::Send(const sf::String& name, Texture& texture)
    {
        if (!myIsLinked)
            return;

        GLint loc = glGetUniformLocation(myProgram, name.ToAnsiString().c_str());
        glUseProgram(myProgram);

        myTextures[loc] = &texture;
    }
示例#10
0
	ResourceCache::ResourceCache(sf::String& contentDirectory)
	{
		gLogger.Write("Resource Cache: Created");
		
		ContentDirectory = contentDirectory.ToAnsiString();
		
		gLogger.Write("Resource Cache: Directory: " + ContentDirectory);

		
	}
示例#11
0
文件: Shader.cpp 项目: tsingzhen/sf3d
    void    Program::Send(const sf::String& name, const sf::Color& color)
    {
        if (!myIsLinked)
            return;

        float fcolor[4] = { static_cast<float>(color.r) / 255.f,
                            static_cast<float>(color.g) / 255.f,
                            static_cast<float>(color.b) / 255.f,
                            static_cast<float>(color.a) / 255.f };

        GLint loc = glGetUniformLocation(myProgram, name.ToAnsiString().c_str());
        glUseProgram(myProgram);

        glUniform4fv(loc, 4, fcolor);
    }
示例#12
0
文件: Shader.cpp 项目: tsingzhen/sf3d
    void    Shader::LoadFromFile(const sf::String& filename)
    {
        std::fstream file;
        file.open(filename.ToAnsiString().c_str());
        if (file.fail())
        {
            return;
        }


        std::stringstream bufStr;
        bufStr << file.rdbuf();
        file.close();

        const char* buffer = bufStr.str().c_str();
        glShaderSource(myShader, 1, &buffer, NULL);

        glCompileShader(myShader);
        GLint status, logSize;
        glGetShaderiv(myShader, GL_COMPILE_STATUS, &status);

        if (status != GL_TRUE)
        {
            glGetShaderiv(myShader, GL_INFO_LOG_LENGTH, &logSize);
            char* log = new char[logSize + 1];
            memset(log, 0, logSize + 1);
            glGetShaderInfoLog(myShader, logSize, &logSize, log);

            std::cerr << "Unable to compile ";
            if (myType == VERTEX_SHADER)
                std::cerr << "vertex";
            else
                std::cerr << "fragment";

            std::cerr << " shader. Reason :" << std::endl;
            std::cerr << log << std::endl;
            delete[] log;
            return;
        }
    }
示例#13
0
 void    LogManager::Warning(const sf::String& message)
 {
     myLogFile << "Warning : " << message.ToAnsiString() << std::endl;
 }
示例#14
0
 void    LogManager::Error(const sf::String& message)
 {
     myLogFile << "Error : " << message.ToAnsiString() << std::endl;
 }
示例#15
0
float stringToFloat(const sf::String &pStr)
{
	return atof(pStr.ToAnsiString().c_str());
}