本文整理汇总了C++中Compositor::make_context方法的典型用法代码示例。如果您正苦于以下问题:C++ Compositor::make_context方法的具体用法?C++ Compositor::make_context怎么用?C++ Compositor::make_context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compositor
的用法示例。
在下文中一共展示了Compositor::make_context方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Vector
void
TextScroller::draw(Compositor& compositor)
{
auto& context = compositor.make_context();
context.color().draw_filled_rect(Vector(0, 0), Vector(static_cast<float>(context.get_width()), static_cast<float>(context.get_height())),
Color(0.6f, 0.7f, 0.8f, 0.5f), 0);
context.color().draw_surface_part(background, Rectf(0, 0,
static_cast<float>(background->get_width()),
static_cast<float>(background->get_height())),
Rectf(0, 0,
static_cast<float>(context.get_width()),
static_cast<float>(context.get_height())), 0);
float y = static_cast<float>(context.get_height()) - scroll;
for (auto& line : lines) {
if (y + line->get_height() >= 0 && static_cast<float>(context.get_height()) - y >= 0) {
line->draw(context, Rectf(LEFT_BORDER, y, static_cast<float>(context.get_width()) - 2*LEFT_BORDER, y), LAYER_GUI);
}
y += line->get_height();
}
if(y < 0 && !fading ) {
fading = true;
ScreenManager::current()->pop_screen(std::unique_ptr<ScreenFade>(new FadeOut(0.5)));
}
}
示例2: assert
void
ScreenManager::draw(Compositor& compositor)
{
assert(!m_screen_stack.empty());
static Uint32 fps_ticks = SDL_GetTicks();
// draw the actual screen
m_screen_stack.back()->draw(compositor);
// draw effects and hud
auto& context = compositor.make_context(true);
m_menu_manager->draw(context);
if (m_screen_fade)
{
m_screen_fade->draw(context);
}
Console::current()->draw(context);
if (g_config->show_fps)
{
draw_fps(context, m_fps);
}
if (g_config->show_player_pos)
{
draw_player_pos(context);
}
// render everything
compositor.render();
/* Calculate frames per second */
if (g_config->show_fps)
{
static int frame_count = 0;
++frame_count;
if (SDL_GetTicks() - fps_ticks >= 500)
{
m_fps = static_cast<float>(frame_count) / 0.5f;
frame_count = 0;
fps_ticks = SDL_GetTicks();
}
}
}
示例3: Rectf
void
TitleScreen::draw(Compositor& compositor)
{
auto& context = compositor.make_context();
Sector& sector = m_titlesession->get_current_sector();
sector.draw(context);
context.color().draw_surface_scaled(m_frame,
Rectf(0, 0, static_cast<float>(context.get_width()), static_cast<float>(context.get_height())),
LAYER_FOREGROUND1);
context.color().draw_text(Resources::small_font,
m_copyright_text,
Vector(5.0f, static_cast<float>(context.get_height()) - 50.0f),
ALIGN_LEFT, LAYER_FOREGROUND1);
context.color().draw_text(Resources::small_font,
m_videosystem_name,
Vector(static_cast<float>(context.get_width()) - 5.0f,
static_cast<float>(context.get_height()) - 14.0f),
ALIGN_RIGHT, LAYER_FOREGROUND1);
}