当前位置: 首页>>代码示例>>C++>>正文


C++ fs::IFile类代码示例

本文整理汇总了C++中fs::IFile的典型用法代码示例。如果您正苦于以下问题:C++ IFile类的具体用法?C++ IFile怎么用?C++ IFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loaded

void Model::loaded(FS::IFile& file, bool success, FS::FileSystem& fs)
{
	PROFILE_FUNCTION();
	if (success)
	{
		FileHeader header;
		file.read(&header, sizeof(header));
		if (header.m_magic == FILE_MAGIC &&
			header.m_version <= (uint32_t)FileVersion::LATEST &&
			parseMeshes(file) && parseGeometry(file) && parseBones(file) &&
			parseLODs(file))
		{
			m_size = file.size();
			decrementDepCount();
		}
		else
		{
			g_log_warning.log("renderer") << "Error loading model "
										  << m_path.c_str();
			onFailure();
			return;
		}
	}
	else
	{
		g_log_warning.log("renderer") << "Error loading model "
									  << m_path.c_str();
		onFailure();
	}
}
开发者ID:gamedevforks,项目名称:LumixEngine,代码行数:30,代码来源:model.cpp

示例2:

JsonSerializer::JsonSerializer(FS::IFile& file,
	AccessMode access_mode,
	const Path& path,
	IAllocator& allocator)
	: m_file(file)
	, m_access_mode(access_mode)
	, m_allocator(allocator)
{
	m_is_error = false;
	copyString(m_path, path.c_str());
	m_is_first_in_block = true;
	m_data = nullptr;
	m_is_string_token = false;
	if (m_access_mode == READ)
	{
		m_data_size = (int)file.size();
		if (file.getBuffer() != nullptr)
		{
			m_data = (const char*)file.getBuffer();
			m_own_data = false;
		}
		else
		{
			int size = (int)m_file.size();
			char* data = (char*)m_allocator.allocate(size);
			m_own_data = true;
			file.read(data, m_data_size);
			m_data = data;
		}
		m_token = m_data;
		m_token_size = 0;
		deserializeToken();
	}
}
开发者ID:Ghost-yc,项目名称:LumixEngine,代码行数:34,代码来源:json_serializer.cpp

示例3: loadRaw

bool Texture::loadRaw(FS::IFile& file)
{
	PROFILE_FUNCTION();
	size_t size = file.size();
	m_BPP = 2;
	m_width = (int)sqrt(size / m_BPP);
	m_height = m_width;

	if (m_data_reference)
	{
		m_data.resize(size);
		file.read(&m_data[0], size);
	}

	const uint16_t* src_mem = (const uint16_t*)file.getBuffer();
	const bgfx::Memory* mem = bgfx::alloc(m_width * m_height * sizeof(float));
	float* dst_mem = (float*)mem->data;

	for (int i = 0; i < m_width * m_height; ++i)
	{
		dst_mem[i] = src_mem[i] / 65535.0f;
	}

	m_texture_handle = bgfx::createTexture2D(
		m_width, m_height, 1, bgfx::TextureFormat::R32F, 0, nullptr);
	bgfx::updateTexture2D(
		m_texture_handle,
		0,
		0,
		0,
		m_width,
		m_height,
		mem);
	return bgfx::isValid(m_texture_handle);
}
开发者ID:zhouxh1023,项目名称:LumixEngine,代码行数:35,代码来源:texture.cpp

示例4: save

void Texture::save()
{
	char ext[5];
	ext[0] = 0;
	PathUtils::getExtension(ext, 5, getPath().c_str());
	if (strcmp(ext, "raw") == 0 && m_BPP == 2)
	{
		FS::FileSystem& fs = m_resource_manager.getFileSystem();
		FS::IFile* file = fs.open(fs.getDefaultDevice(),
								  getPath().c_str(),
								  FS::Mode::OPEN_OR_CREATE | FS::Mode::WRITE);

		file->write(&m_data[0], m_data.size() * sizeof(m_data[0]));
		fs.close(*file);
	}
	else if (strcmp(ext, "tga") == 0 && m_BPP == 4)
	{
		saveTGA();
	}
	else
	{
		g_log_error.log("renderer") << "Texture " << getPath()
									<< " can not be saved - unsupported format";
	}
}
开发者ID:zoadianCollection,项目名称:LumixEngine,代码行数:25,代码来源:texture.cpp

示例5: parseVertexDef

bool Model::parseVertexDef(FS::IFile& file, bgfx::VertexDecl* vertex_definition)
{
	vertex_definition->begin();

	uint32 attribute_count;
	file.read(&attribute_count, sizeof(attribute_count));

	for (uint32 i = 0; i < attribute_count; ++i)
	{
		char tmp[50];
		uint32 len;
		file.read(&len, sizeof(len));
		if (len > sizeof(tmp) - 1)
		{
			return false;
		}
		file.read(tmp, len);
		tmp[len] = '\0';

		if (compareString(tmp, "in_position") == 0)
		{
			vertex_definition->add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float);
		}
		else if (compareString(tmp, "in_colors") == 0)
		{
			vertex_definition->add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true, false);
		}
		else if (compareString(tmp, "in_tex_coords") == 0)
		{
			vertex_definition->add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float);
		}
		else if (compareString(tmp, "in_normal") == 0)
		{
			vertex_definition->add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true);
		}
		else if (compareString(tmp, "in_tangents") == 0)
		{
			vertex_definition->add(bgfx::Attrib::Tangent, 4, bgfx::AttribType::Uint8, true, true);
		}
		else if (compareString(tmp, "in_weights") == 0)
		{
			vertex_definition->add(bgfx::Attrib::Weight, 4, bgfx::AttribType::Float);
		}
		else if (compareString(tmp, "in_indices") == 0)
		{
			vertex_definition->add(bgfx::Attrib::Indices, 4, bgfx::AttribType::Int16, false, true);
		}
		else
		{
			ASSERT(false);
			return false;
		}

		uint32 type;
		file.read(&type, sizeof(type));
	}

	vertex_definition->end();
	return true;
}
开发者ID:badkangaroo,项目名称:LumixEngine,代码行数:60,代码来源:model.cpp

示例6: load

bool Shader::load(FS::IFile& file)
{
	lua_State* L = luaL_newstate();
	luaL_openlibs(L);
	registerFunctions(this, &m_combintions, &getRenderer(), L);
	m_render_states = BGFX_STATE_DEPTH_TEST_LEQUAL;

	bool errors = luaL_loadbuffer(L, (const char*)file.getBuffer(), file.size(), "") != LUA_OK;
	errors = errors || lua_pcall(L, 0, 0, 0) != LUA_OK;
	if (errors)
	{
		g_log_error.log("Renderer") << getPath().c_str() << ": " << lua_tostring(L, -1);
		lua_pop(L, 1);
		return false;
	}
	
	if (!generateInstances())
	{
		g_log_error.log("Renderer") << "Could not load instances of shader " << getPath().c_str();
		return false;
	}

	m_size = file.size();
	lua_close(L);
	return true;
}
开发者ID:Fergus1986,项目名称:LumixEngine,代码行数:26,代码来源:shader.cpp

示例7: load

bool LuaScript::load(FS::IFile& file)
{
	m_properties.clear();
	m_source_code.set((const char*)file.getBuffer(), (int)file.size());
	parseProperties();
	m_size = file.size();
	return true;
}
开发者ID:badkangaroo,项目名称:LumixEngine,代码行数:8,代码来源:lua_script_manager.cpp

示例8: loadDDS

bool Texture::loadDDS(FS::IFile& file)
{
	bgfx::TextureInfo info;
	m_texture_handle = bgfx::createTexture(
		bgfx::copy(file.getBuffer(), file.size()), 0, 0, &info);
	m_BPP = -1;
	m_width = info.width;
	m_height = info.height;
	return bgfx::isValid(m_texture_handle);
}
开发者ID:zhouxh1023,项目名称:LumixEngine,代码行数:10,代码来源:texture.cpp

示例9: load

bool Clip::load(FS::IFile& file)
{
	short* output = nullptr;
	auto res = stb_vorbis_decode_memory(
		(unsigned char*)file.getBuffer(), (int)file.size(), &m_channels, &m_sample_rate, &output);
	if (res <= 0) return false;

	m_data.resize(res * m_channels);
	copyMemory(&m_data[0], output, res * m_channels * sizeof(m_data[0]));
	free(output);

	return true;
}
开发者ID:Garfield-Chen,项目名称:LumixEngine,代码行数:13,代码来源:clip_manager.cpp

示例10: parseVertexDeclEx

bool Model::parseVertexDeclEx(FS::IFile& file, bgfx::VertexDecl* vertex_decl)
{
	vertex_decl->begin();

	u32 attribute_count;
	file.read(&attribute_count, sizeof(attribute_count));

	for (u32 i = 0; i < attribute_count; ++i)
	{
		i32 attr;
		file.read(&attr, sizeof(attr));

		if (attr == (i32)Attrs::Position)
		{
			vertex_decl->add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float);
		}
		else if (attr == (i32)Attrs::Color0)
		{
			vertex_decl->add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true, false);
		}
		else if (attr == (i32)Attrs::TexCoord0)
		{
			vertex_decl->add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float);
		}
		else if (attr == (i32)Attrs::Normal)
		{
			vertex_decl->add(bgfx::Attrib::Normal, 4, bgfx::AttribType::Uint8, true, true);
		}
		else if (attr == (i32)Attrs::Tangent)
		{
			vertex_decl->add(bgfx::Attrib::Tangent, 4, bgfx::AttribType::Uint8, true, true);
		}
		else if (attr == (i32)Attrs::Weight)
		{
			vertex_decl->add(bgfx::Attrib::Weight, 4, bgfx::AttribType::Float);
		}
		else if (attr == (i32)Attrs::Indices)
		{
			vertex_decl->add(bgfx::Attrib::Indices, 4, bgfx::AttribType::Int16, false, true);
		}
		else
		{
			ASSERT(false);
			return false;
		}
	}

	vertex_decl->end();
	return true;
}
开发者ID:nem0,项目名称:LumixEngine,代码行数:50,代码来源:model.cpp

示例11: load

bool Texture::load(FS::IFile& file)
{
	PROFILE_FUNCTION();

	const char* path = getPath().c_str();
	size_t len = getPath().length();
	bool loaded = false;
	if (len > 3 && compareString(path + len - 4, ".dds") == 0)
	{
		loaded = loadDDS(file);
	}
	else if (len > 3 && compareString(path + len - 4, ".raw") == 0)
	{
		loaded = loadRaw(file);
	}
	else
	{
		loaded = loadTGA(file);
	}
	if (!loaded)
	{
		g_log_warning.log("Renderer") << "Error loading texture " << path;
		return false;
	}

	m_size = file.size();
	return true;
}
开发者ID:dreamsxin,项目名称:LuxEngine,代码行数:28,代码来源:texture.cpp

示例12: parseLODs

bool Model::parseLODs(FS::IFile& file)
{
	i32 lod_count;
	file.read(&lod_count, sizeof(lod_count));
	if (lod_count <= 0 || lod_count > lengthOf(m_lods))
	{
		return false;
	}
	for (int i = 0; i < lod_count; ++i)
	{
		file.read(&m_lods[i].to_mesh, sizeof(m_lods[i].to_mesh));
		file.read(&m_lods[i].distance, sizeof(m_lods[i].distance));
		m_lods[i].from_mesh = i > 0 ? m_lods[i - 1].to_mesh + 1 : 0;
	}
	return true;
}
开发者ID:nem0,项目名称:LumixEngine,代码行数:16,代码来源:model.cpp

示例13: loaded

void LuaScript::loaded(FS::IFile& file, bool success, FS::FileSystem& fs)
{
	if (success)
	{
		m_source_code.set((const char*)file.getBuffer(), file.size());
		parseProperties();
		m_size = file.size();
		decrementDepCount();
	}
	else
	{
		g_log_error.log("lua_script") << "Could not load script "
									  << m_path.c_str();
		onFailure();
	}
}
开发者ID:gamedevforks,项目名称:LumixEngine,代码行数:16,代码来源:lua_script_manager.cpp

示例14: parseLODs

bool Model::parseLODs(FS::IFile& file)
{
	int32 lod_count;
	file.read(&lod_count, sizeof(lod_count));
	if (lod_count <= 0)
	{
		return false;
	}
	m_lods.resize(lod_count);
	for (int i = 0; i < lod_count; ++i)
	{
		file.read(&m_lods[i].m_to_mesh, sizeof(m_lods[i].m_to_mesh));
		file.read(&m_lods[i].m_distance, sizeof(m_lods[i].m_distance));
		m_lods[i].m_from_mesh = i > 0 ? m_lods[i - 1].m_to_mesh + 1 : 0;
	}
	return true;
}
开发者ID:badkangaroo,项目名称:LumixEngine,代码行数:17,代码来源:model.cpp

示例15: load

bool Model::load(FS::IFile& file)
{
	PROFILE_FUNCTION();
	FileHeader header;
	file.read(&header, sizeof(header));
	if (header.m_magic == FILE_MAGIC 
		&& header.m_version <= (uint32)FileVersion::LATEST 
		&& parseMeshes(file) 
		&& parseGeometry(file) 
		&& parseBones(file) 
		&& parseLODs(file))
	{
		m_size = file.size();
		return true;
	}

	g_log_warning.log("renderer") << "Error loading model " << getPath().c_str();
	return false;
}
开发者ID:badkangaroo,项目名称:LumixEngine,代码行数:19,代码来源:model.cpp


注:本文中的fs::IFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。