Esempio n. 1
0
CL_ShaderObject CL_ShaderObject::load(CL_GraphicContext &gc, const CL_StringRef &resource_id, CL_ResourceManager *resources)
{
	CL_Resource resource = resources->get_resource(resource_id);
	CL_String filename = resource.get_element().get_attribute("file");
	CL_String type = resource.get_element().get_tag_name();
	
	CL_ShaderType shader_type;
	if (type == "fragment-shader")
		shader_type = cl_shadertype_fragment;
	else if (type == "vertex-shader")
		shader_type = cl_shadertype_vertex;
	else
		throw CL_Exception("CL_ShaderObject: Unknown shader type: " + type);

	CL_VirtualDirectory directory = resources->get_directory(resource);

	CL_IODevice file = directory.open_file(filename, CL_File::open_existing, CL_File::access_read, CL_File::share_read);
	int size = file.get_size();
	CL_String8 source(size, 0);
	file.read(&source[0], size);

	CL_ShaderObject shader_object(gc, shader_type, CL_StringHelp::local8_to_text(source));

	if (resource.get_element().get_attribute("compile", "true") == "true")
		if(!shader_object.compile())
			throw CL_Exception(cl_format("Unable to compiler shader program %1: %2", resource_id, shader_object.get_info_log()));

	return shader_object;
}
void CL_ResourceManager::load(const CL_String &fullname, CL_VirtualDirectory directory)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_virtual);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_virtual);
	CL_VirtualDirectory dir = directory.open_directory(path);
	load(dir.open_file(filename, CL_File::open_existing, CL_File::access_read, CL_File::share_read), dir);
}
Esempio n. 3
0
void CL_PNGProvider::save(
	CL_PixelBuffer buffer,
	const CL_String &filename,
	CL_VirtualDirectory &directory)
{
	CL_IODevice file = directory.open_file(filename, CL_File::create_always);
	save(buffer, file);
}
CL_SoundProvider_Wave::CL_SoundProvider_Wave(
	const CL_String &fullname, bool stream)
: impl(new CL_SoundProvider_Wave_Impl)
{
	CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file);
	CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file);
	CL_VirtualFileSystem vfs(path);
	CL_VirtualDirectory dir = vfs.get_root_directory();
	CL_IODevice input = dir.open_file(filename, CL_File::open_existing, CL_File::access_read, CL_File::share_all);
	impl->load(input);
}
void CL_CollisionOutline::save(const CL_StringRef &filename, CL_VirtualDirectory &directory) const
{
	CL_IODevice file = directory.open_file(filename, CL_File::create_always);
	impl->save(file);
}
void CL_ResourceManager::save(const CL_String &filename, CL_VirtualDirectory directory)
{
	save(directory.open_file(filename, CL_File::create_always, CL_File::access_read|CL_File::access_write, CL_File::share_read));
}