コード例 #1
0
ファイル: main.cpp プロジェクト: GiantMonsterCo/glslViewer
// Rendering Thread
//============================================================================
void onFileChange(){
    std::string type = files[*iHasChanged].type;
    std::string path = files[*iHasChanged].path;

    if ( type == "fragment" ){
        fragSource = "";
        if(loadFromPath(path, &fragSource)){
            shader.detach(GL_FRAGMENT_SHADER | GL_VERTEX_SHADER);
            shader.load(fragSource,vertSource);
        }
    } else if ( type == "vertex" ){
        vertSource = "";
        if(loadFromPath(path, &vertSource)){
            shader.detach(GL_FRAGMENT_SHADER | GL_VERTEX_SHADER);
            shader.load(fragSource,vertSource);
        }
    } else if ( type == "geometry" ){
        // TODO
    } else if ( type == "image" ){
        for (std::map<std::string,Texture*>::iterator it = textures.begin(); it!=textures.end(); ++it) {
            if ( path == it->second->getFilePath() ){
                it->second->load(path);
                break;
            }
        }
    }   
}
コード例 #2
0
void LibLoader::loadDirectory(const std::string &path)
{
	struct dirent *file;
	DIR *rep;

	rep = opendir(path.c_str());
	if (rep)
	{
		while ((file = readdir(rep)))
		{
			std::string filename = file->d_name;
			if (suffixMatch(filename))
			{
				std::string toLoad;
#ifdef __unix
				toLoad = path + "/" + filename;
#elif _WIN32
				toLoad = path + "\\" + filename;
#endif
				loadFromPath(toLoad);
			}
		}
		closedir(rep);
	}
}
コード例 #3
0
ファイル: versions.cpp プロジェクト: MAPJe71/libyuni
	void List::findFromPrefixes(const String::List& prefix)
	{
		if (not prefix.empty())
		{
			const String::List::const_iterator end = prefix.end();
			for (String::List::const_iterator i = prefix.begin(); i != end; ++i)
				loadFromPath(*i);
		}
	}
コード例 #4
0
SplicePicturesImageItem::SplicePicturesImageItem(QJsonObject &json) {
    row = json.take("row").toInt();
    col = json.take("col").toInt();
    path = json.take("path").toString();
    x = json.take("x").toInt();
    y = json.take("y").toInt();
    rotation = Rational(json.take("rotation").toString());
    zoom = Rational(json.take("zoom").toString());
    loadFromPath(path);
}
コード例 #5
0
ファイル: main.cpp プロジェクト: GiantMonsterCo/glslViewer
void setup() {
    glEnable(GL_DEPTH_TEST);
    glFrontFace(GL_CCW);
    
    //  Load Geometry
    //
    if ( iGeom == -1 ){
        vbo = rect(0.0,0.0,1.0,1.0).getVbo();
    } else {
        Mesh model;
        model.load(files[iGeom].path);
        vbo = model.getVbo();
        glm::vec3 toCentroid = getCentroid(model.getVertices());
        // model_matrix = glm::scale(glm::vec3(0.001));
        model_matrix = glm::translate(-toCentroid);
    }

    //  Build shader;
    //
    if ( iFrag != -1 ) {
        fragSource = "";
        if(!loadFromPath(files[iFrag].path, &fragSource)) {
            return;
        }
    } else {
        fragSource = vbo->getVertexLayout()->getDefaultFragShader();
    }

    if ( iVert != -1 ) {
        vertSource = "";
        loadFromPath(files[iVert].path, &vertSource);
    } else {
        vertSource = vbo->getVertexLayout()->getDefaultVertShader();
    }    
    shader.load(fragSource,vertSource);
    
    cam.setViewport(getWindowWidth(),getWindowHeight());
    cam.setPosition(glm::vec3(0.0,0.0,-3.));
}
コード例 #6
0
ファイル: bitmap.cpp プロジェクト: amaula/ode-0.12
void image_build(std::string const &src, std::string const &dst)
{
    ILBitmap *bmp = static_cast<ILBitmap *>(loadFromPath(src));
    std::string out(filenoext(dst) + ".tga");
    std::wstring path;
    path.insert(path.end(), out.begin(), out.end());
    ilBindImage(bmp->img_);
    ilEnable(IL_FILE_OVERWRITE);
    ilSave(IL_TGA, path.c_str());
    int err = ilGetError();
    if (err != IL_NO_ERROR)
    {
        throw std::runtime_error("Error saving file: " + dst);
    }
}
コード例 #7
0
ファイル: versions.cpp プロジェクト: MAPJe71/libyuni
	void List::checkRootFolder(const String& root)
	{
		String yuniMarker;
		yuniMarker << root << SEP << "mark-for-yuni-sources";

		if (IO::File::Exists(yuniMarker))
		{
			if (pOptDebug)
				std::cout << "[yuni-config][debug] found special yuni marker `" << yuniMarker << "`" << std::endl;

			# ifdef YUNI_OS_WINDOWS
			loadFromPath(root + "\\..\\..\\..");
			# else
			loadFromPath(root + "/../../..");
			# endif
			return;
		}

		# ifdef YUNI_OS_MSVC //Visual Studio
		// For dealing with the paths like '{Debug,Release}/yuni-config.exe'
		if (IO::File::Exists(String() << root << "\\..\\mark-for-yuni-sources"))
			loadFromPath(root + "\\..\\..\\..\\..");
		# endif
	}
コード例 #8
0
void WindowPosition::initialise(wxTopLevelWindow* window, 
                                const std::string& windowStateKey,
                                float defaultXFraction, 
                                float defaultYFraction)
{
    // Set up events and such
    connect(window);

    // Load from registry if possible
    if (GlobalRegistry().keyExists(windowStateKey))
    {
        loadFromPath(windowStateKey);
    }
    else
    {
        fitToScreen(defaultXFraction, defaultYFraction);
    }

    applyPosition();
}
コード例 #9
0
    else mainPacsWidget->deleteLater();

    // dynamic data sources (from plugins)

    foreach(QString dataSourceName, medAbstractDataSourceFactory::instance()->dataSourcePlugins())
    {
        qDebug()<< "factory creates dataSource:" << dataSourceName;
        medAbstractDataSource *dataSource = medAbstractDataSourceFactory::instance()->create(dataSourceName, 0);
        d->dataSources.push_back(dataSource);
        connectDataSource(dataSource);
    }

    connect(d->fsSource, SIGNAL(open(QString)),
            this, SLOT(openFromPath(QString)));
    connect(d->fsSource, SIGNAL(load(QString)),
            this, SLOT(loadFromPath(QString)));
    connect(d->dbSource, SIGNAL(open(const medDataIndex&)),
            this, SLOT(openFromIndex(medDataIndex)));
}


void medDataSourceManager::connectDataSource(medAbstractDataSource *dataSource)
{
    connect(dataSource, SIGNAL(exportData(const medDataIndex&)),
            this, SLOT(exportData(const medDataIndex&)));

    connect(dataSource, SIGNAL(dataReceived(medAbstractData*)),
            this, SLOT(importData(medAbstractData*)));

    connect(dataSource, SIGNAL(dataReceivingFailed(QString)),
            this, SLOT(emitDataReceivingFailed(QString)));
コード例 #10
0
SplicePicturesImageItem::SplicePicturesImageItem(int row, int col, QString path)
    : row(row), col(col), x(0), y(0), path(path), rotation(0), zoom(1)
{
    loadFromPath(path);
}
コード例 #11
0
ファイル: versions.cpp プロジェクト: MAPJe71/libyuni
	void List::loadFromPath(const String& folder)
	{
		String path;
		IO::Canonicalize(path, folder);
		if (pOptDebug)
			std::cout << "[yuni-config][debug] :: reading `" << path << "`" << std::endl;

		VersionInfo::Settings info;
		info.mapping = mappingStandard;

		String s;
		s << path << SEP << "yuni.version";
		if (not IO::File::Exists(s))
		{
			s.clear() << path << SEP << "include" << SEP << "yuni" << SEP << "yuni.version";
			if (not IO::File::Exists(s))
			{
				info.mapping = mappingSVNSources;
				s.clear() << path << SEP << "src" << SEP << "yuni" << SEP << "yuni.version";
				if (not IO::File::Exists(s))
                {
					if (pOptDebug)
						std::cout << "[yuni-config][debug] :: " << s << " not found" << std::endl;
					return;
                }
			}
		}

		IO::File::Stream file;
		if (file.open(s))
		{
			String key;
			String value;

			Version version;

			// A buffer. The given capacity will be the maximum length for a single line
			Clob buffer;
			buffer.reserve(8000);
			while (file.readline(buffer))
			{
				buffer.extractKeyValue(key, value);

				if (key.empty() || key == "[")
					continue;
				if (key == "version.hi")
					version.hi = value.to<unsigned int>();
				if (key == "version.lo")
					version.lo = value.to<unsigned int>();
				if (key == "version.rev")
					version.revision = value.to<unsigned int>();
				if (key == "version.target")
					info.compilationMode = value;
				if (key == "modules.available")
					value.split(info.modules, ";\"', \t", false);
				if (key == "support.opengl")
					info.supportOpenGL = value.to<bool>();
				if (key == "support.directx")
					info.supportDirectX = value.to<bool>();
				if (key == "redirect")
					loadFromPath(value);
				if (key == "path.include")
				{
					if (not value.empty())
						info.includePath.push_back(value);
				}
				if (key == "path.lib")
				{
					if (not value.empty())
						info.libPath.push_back(value);
				}
			}

			if (not version.null() and not info.modules.empty())
			{
				info.path = path;
				info.compiler = pCompiler;
				pList[version] = info;

				if (pOptDebug)
				{
					std::cout << "[yuni-config][debug]  - found installation `" << path
						<< "` (" << version << ")" << std::endl;
				}
			}
			else
			{
				std::cerr << "error: " << s << ": invalid file";
				if (version.null())
					std::cerr << " (invalid version)" << std::endl;
				else if (info.modules.empty())
					std::cerr << " (no module)" << std::endl;
			}
		}
	}
コード例 #12
0
ファイル: database.cpp プロジェクト: CyberShadow/verysleepy-1
bool Database::reload(bool collapseOSCalls)
{
    return loadFromPath(profilepath, collapseOSCalls);
}