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


C++ CL_GraphicContext::push_translate方法代码示例

本文整理汇总了C++中CL_GraphicContext::push_translate方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_GraphicContext::push_translate方法的具体用法?C++ CL_GraphicContext::push_translate怎么用?C++ CL_GraphicContext::push_translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CL_GraphicContext的用法示例。


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

示例1: render

void CL_GUIComponent::render(CL_GraphicContext &gc, const CL_Rect &clip_rect, bool include_children)
{
    if (!impl->visible)
        return;

    if (!impl->css_layout.is_null())
    {
        impl->css_layout.layout(gc, get_size());
        impl->css_layout.render(gc, this);
    }

    if (impl->func_render.is_null() == false)
    {
        impl->func_render.invoke(gc, clip_rect);
    }
    else
    {
        CL_GUIThemePart part(this);
        CL_Rect geometry = get_size();
        part.render_box(gc, CL_RectPS(0, 0, geometry.get_width(), geometry.get_height()), clip_rect);
    }

    if (include_children)
    {
        if (impl->clip_children)
        {
            push_cliprect(gc, impl->clip_children_rect);
        }

        CL_GUIComponent *cur = impl->first_child;
        while (cur)
        {
            CL_Rect cur_geometry = cur->get_geometry();

            CL_Rect update_rect = component_to_window_coords(clip_rect);
            update_rect.overlap(component_to_window_coords(cur_geometry));
            if (update_rect.get_width() > 0 && update_rect.get_height() > 0)
            {
                CL_Rect child_dirty_rect = cur->window_to_component_coords(update_rect);

                gc.push_translate((float)cur_geometry.left, (float)cur_geometry.top);
                cur->render(gc, child_dirty_rect, true);
                gc.pop_modelview();
            }
            cur = cur->impl->next_sibling;
        }

        if (impl->clip_children)
        {
            pop_cliprect(gc);
        }
    }
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:53,代码来源:gui_component.cpp

示例2: draw

void Sandpit::draw(CL_GraphicContext &p_gc)
{
    assert(m_built);

    if (m_texture.is_null()) {
        // create texture
        m_texture = CL_SharedPtr<CL_Texture>(
                new CL_Texture(
                        p_gc,
                        m_pixelData->get_width(), m_pixelData->get_height()
                )
        );

        m_texture->set_image(*m_pixelData);
    }

    p_gc.set_texture(0, *m_texture);

    CL_Rectf drawRect(0, 0, m_pixelData->get_width(), m_pixelData->get_height());

    p_gc.push_translate(m_position.x, m_position.y);
    CL_Draw::texture(p_gc, drawRect, CL_Colorf::white);
    p_gc.pop_modelview();
}
开发者ID:genail,项目名称:gear,代码行数:24,代码来源:Sandpit.cpp

示例3: draw

bool TextShooter::draw(CL_GraphicContext &gc, unsigned int current_time)
{
    int time_delta = current_time - start_time;
    if (time_delta < 0)	// Not on screen
        return true;

    if (time_delta >= duration)	// Reached destination
        return false;

    CL_Vec3f current_position;

    // Get position
    current_position.x = start_position.x + (((end_position.x - start_position.x) * time_delta) / duration);
    current_position.y = start_position.y + (((end_position.y - start_position.y) * time_delta) / duration);
    current_position.z = start_position.z + (((end_position.z - start_position.z) * time_delta) / duration);

    // Get fade towards end
    float font_alpha = (float) (duration  - time_delta);
    font_alpha /= end_fade_time;
    if (font_alpha > 1.0f) font_alpha = 1.0f;

    // Get initial white colour setting
    float font_white = (float) time_delta;
    font_white /= initial_white_time;
    if (font_white > 1.0f) font_white = 1.0f;
    font_white = 1.0f - font_white;

    // Calculate color
    CL_Colorf font_color;
    if (use_red_component)
    {
        font_color.r = 1.0f;
    }
    else
    {
        font_color.r = font_white;
    }

    if (use_green_component)
    {
        font_color.g = 1.0f;
    }
    else
    {
        font_color.g = font_white;
    }

    if (use_blue_component)
    {
        font_color.b = 1.0f;
    }
    else
    {
        font_color.b = font_white;
    }

    font_color.a = font_alpha;

    // Draw the text
    gc.push_translate(current_position.x, current_position.y, current_position.z);
    gc.push_scale( 2.0f / gc.get_width(), -2.0f / gc.get_height());

    CL_Size text_size = vector_font.get_text_size(gc, text);

    vector_font.draw_text(gc, -text_size.width/2, text_size.height/4, text, font_color);
    gc.pop_modelview();
    gc.pop_modelview();

    return true;
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:70,代码来源:text_shooter.cpp


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