本文整理汇总了C++中AssetManager::get_texture方法的典型用法代码示例。如果您正苦于以下问题:C++ AssetManager::get_texture方法的具体用法?C++ AssetManager::get_texture怎么用?C++ AssetManager::get_texture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetManager
的用法示例。
在下文中一共展示了AssetManager::get_texture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Terrain::Terrain(AssetManager &assetmanager,
const std::vector<gamedata::terrain_type> &terrain_meta,
const std::vector<gamedata::blending_mode> &blending_meta,
bool is_infinite)
:
infinite{is_infinite} {
// TODO:
//this->limit_positive =
//this->limit_negative =
// maps chunk position to chunks
this->chunks = std::unordered_map<coord::chunk, TerrainChunk *, coord_chunk_hash>{};
// activate blending
this->blending_enabled = true;
this->terrain_id_count = terrain_meta.size();
this->blendmode_count = blending_meta.size();
this->textures = new Texture*[this->terrain_id_count];
this->blending_masks = new Texture*[this->blendmode_count];
this->terrain_id_priority_map = new int[this->terrain_id_count];
this->terrain_id_blendmode_map = new int[this->terrain_id_count];
this->influences_buf = new struct influence[this->terrain_id_count];
log::dbg("terrain prefs: %lu tiletypes, %lu blendmodes", this->terrain_id_count, this->blendmode_count);
// create tile textures (snow, ice, grass, whatever)
for (size_t i = 0; i < this->terrain_id_count; i++) {
auto line = &terrain_meta[i];
terrain_t terrain_id = line->terrain_id;
this->validate_terrain(terrain_id);
// TODO: terrain double-define check?
this->terrain_id_priority_map[terrain_id] = line->blend_priority;
this->terrain_id_blendmode_map[terrain_id] = line->blend_mode;
// TODO: remove hardcoding and rely on nyan data
char *terraintex_filename = util::format("converted/Data/terrain.drs/%d.slp.png", line->slp_id);
std::string terraintex_filename_str{terraintex_filename};
delete[] terraintex_filename;
auto new_texture = assetmanager.get_texture(terraintex_filename_str);
this->textures[terrain_id] = new_texture;
}
// create blending masks (see doc/media/blendomatic)
for (size_t i = 0; i < this->blendmode_count; i++) {
auto line = &blending_meta[i];
char *mask_filename = util::format("converted/blendomatic.dat/mode%02d.png", line->blend_mode);
std::string mask_filename_str{mask_filename};
delete[] mask_filename;
this->blending_masks[i] = assetmanager.get_texture(mask_filename_str);
}
}
示例2: load_terrain
void GameSpec::load_terrain(AssetManager &am) {
// Terrain data files
util::Dir *data_dir = am.get_data_dir();
util::Dir asset_dir = data_dir->append("converted");
std::vector<gamedata::string_resource> string_resources;
util::read_csv_file(asset_dir.join("string_resources.docx"), string_resources);
std::vector<gamedata::terrain_type> terrain_meta;
util::read_csv_file(asset_dir.join("gamedata/gamedata-empiresdat/0000-terrains.docx"), terrain_meta);
std::vector<gamedata::blending_mode> blending_meta;
util::read_csv_file(asset_dir.join("blending_modes.docx"), blending_meta);
// remove any disabled textures
terrain_meta.erase(
std::remove_if(terrain_meta.begin(), terrain_meta.end(),
[](const gamedata::terrain_type &t) { return !t.enabled; }),
terrain_meta.end());
// result attributes
terrain_data.terrain_id_count = terrain_meta.size();
terrain_data.blendmode_count = blending_meta.size();
terrain_data.textures.reserve(terrain_data.terrain_id_count);
terrain_data.blending_masks.reserve(terrain_data.blendmode_count);
terrain_data.terrain_id_priority_map = std::make_unique<int[]>(terrain_data.terrain_id_count);
terrain_data.terrain_id_blendmode_map = std::make_unique<int[]>(terrain_data.terrain_id_count);
terrain_data.influences_buf = std::make_unique<struct influence[]>(terrain_data.terrain_id_count);
log::log(MSG(dbg) << "Terrain prefs: " <<
"tiletypes=" << terrain_data.terrain_id_count << ", "
"blendmodes=" << terrain_data.blendmode_count);
// create tile textures (snow, ice, grass, whatever)
for (size_t i = 0; i < terrain_data.terrain_id_count; i++) {
auto line = &terrain_meta[i];
terrain_t terrain_id = i;
// TODO: validate terrain_id < terrain_id_count
// TODO: terrain double-define check?
terrain_data.terrain_id_priority_map[terrain_id] = line->blend_priority;
terrain_data.terrain_id_blendmode_map[terrain_id] = line->blend_mode;
// TODO: remove hardcoding and rely on nyan data
auto terraintex_filename = util::sformat("%s/%d.slp.png", this->terrain_path.c_str(), line->slp_id);
auto new_texture = am.get_texture(terraintex_filename);
terrain_data.textures[terrain_id] = new_texture;
}
// create blending masks (see doc/media/blendomatic)
for (size_t i = 0; i < terrain_data.blendmode_count; i++) {
auto line = &blending_meta[i];
std::string mask_filename = util::sformat("%s/mode%02d.png", this->blend_path.c_str(), line->blend_mode);
terrain_data.blending_masks[i] = am.get_texture(mask_filename);
}
}