本文整理汇总了C++中MapInfo::construct_frame方法的典型用法代码示例。如果您正苦于以下问题:C++ MapInfo::construct_frame方法的具体用法?C++ MapInfo::construct_frame怎么用?C++ MapInfo::construct_frame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapInfo
的用法示例。
在下文中一共展示了MapInfo::construct_frame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
bool MapScreen::render(Renderer&, double elapsed)
{
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
const glm::vec3 top_cam(mapinfo.pos.x, mapinfo.pos.y + OFFSET_Y, -OFFSET_Z);
const glm::vec3 bot_cam(mapinfo.pos.x, mapinfo.pos.y, 0.0);
/// map image ///
if (mapinfo.tex == nullptr)
{
// we cant do calculations without the base image
return true;
}
auto& shd = shaders[Shaders::MAP];
shd.bind();
// create mvp matrix
mapinfo.matmvp = glm::lookAt(
top_cam, bot_cam, glm::vec3(0, -1, 0));
mapinfo.matmvp = mapinfo.projection * mapinfo.matmvp;
shd.sendMatrix("matmvp", mapinfo.matmvp);
shd.sendFloat("alpha", 1.0f);
mapinfo.mapvao.bind();
// render map texture
mapinfo.tex->bind(0);
mapinfo.mapvao.renderIndexed(GL_TRIANGLES);
// render map mask layer
if (mapinfo.mask.enabled)
{
glEnable(GL_BLEND);
mapinfo.mask.tex->bind(0);
mapinfo.mapvao.renderIndexed(GL_TRIANGLES);
glDisable(GL_BLEND);
}
/// map clouds & shadows ///
for (size_t i = 0; i < mapinfo.border.size(); i++)
{
auto& layer = mapinfo.border.at(i);
const float floatx = 0.005 * sin(6.28 * sin(i + elapsed * 0.25));
const float floaty = 0.05 * sin(6.28 * sin(i + elapsed * 0.5));
layer.matmvp = glm::lookAt(
top_cam + glm::vec3(0, floatx, floaty),
bot_cam + glm::vec3(0, floatx, 0), glm::vec3(0, -1, 0));
layer.matmvp = mapinfo.projection * layer.matmvp;
}
glEnable(GL_BLEND);
shd.sendFloat("alpha", 0.7f);
for (auto& layer : mapinfo.border) {
if (layer.shadow != nullptr)
{
shd.sendMatrix("matmvp", layer.matmvp);
layer.shadow->bind(0);
mapinfo.mapvao.renderIndexed(GL_TRIANGLES);
}
}
glDisable(GL_BLEND);
shd.sendFloat("alpha", 1.0f);
for (auto& layer : mapinfo.border) {
if (layer.cloud != nullptr)
{
shd.sendMatrix("matmvp", layer.matmvp);
layer.cloud->bind(0);
mapinfo.mapvao.renderIndexed(GL_TRIANGLES);
}
}
/// map icons ///
const bool do_map_icons = uint64_t(elapsed * 2.0f) & 1;
if (do_map_icons)
{
Shader& shdSprite = shaders[Shaders::OBJECTS];
shdSprite.bind();
shdSprite.sendMatrix("matmvp", mapinfo.matmvp);
auto& spritegen = mapinfo.spritegen;
spritegen.clear();
// player head
const auto ptloc = mapinfo.generate_player_coords();
const auto frame = mapinfo.construct_frame(mapinfo.sprite_player, ptloc, 8);
spritegen.generate(frame);
// JSON-defined icons & script
for (const auto& icon : mapinfo.icons)
{
const auto frame =
mapinfo.construct_frame(icon.sprite, mapinfo.transform(icon.pos), 8);
spritegen.generate(frame);
}
spritegen.sort();
spritegen.index();
// render lowest to high
spritegen.render(Z_LOWEST, Z_HIGH);
}
//.........这里部分代码省略.........