Ejemplo n.º 1
0
    virtual void doDraw(mono::IRenderer& renderer) const
    {
        if(!m_painting)
            return;

        constexpr mono::Color::RGBA color(0.0f, 1.0f, 0.5f, 1.0f);
        renderer.DrawPoints(m_points, color, 2.0f);
    }
Ejemplo n.º 2
0
void Bullet::Draw(mono::IRenderer& renderer) const
{
    renderer.DrawSprite(*m_sprite);
}
Ejemplo n.º 3
0
void Morpher::Draw(mono::IRenderer& renderer) const
{
    constexpr mono::Color::RGBA color(0, 1, 1);
    renderer.DrawShape(m_shape1, m_shape2, m_morphGrade, color);
    renderer.DrawText(FontId::LARGE, "Here", math::zeroVec, true, color);
}
Ejemplo n.º 4
0
 virtual void Draw(mono::IRenderer& renderer) const
 {
     renderer.DrawSprite(*m_sprite);
 }
Ejemplo n.º 5
0
void Shuttle::Draw(mono::IRenderer& renderer) const
{
    renderer.DrawSprite(*m_sprite);
}
Ejemplo n.º 6
0
void ImGuiRenderer::doDraw(mono::IRenderer& renderer) const
{
    ImGui::GetIO().DisplaySize = ImVec2(m_windowSize.x, m_windowSize.y);
    
    const math::Matrix& projection = math::Ortho(0.0f, m_windowSize.x, m_windowSize.y, 0.0f, -10.0f, 10.0f);
    constexpr math::Matrix model_view;

    renderer.UseShader(m_shader.get());
    m_shader->LoadProjectionMatrix(projection);
    m_shader->LoadModelViewMatrix(model_view);

    glEnable(GL_SCISSOR_TEST);

    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
    glEnableVertexAttribArray(2);

    const ImDrawData* draw_data = ImGui::GetDrawData();

    for (int n = 0; n < draw_data->CmdListsCount; n++)
    {
        const ImDrawList* cmd_list = draw_data->CmdLists[n];
        const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
        const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();

        const void* vertices = (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos));
        const void* coords = (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv));
        const void* colors = (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col));

        glVertexAttribPointer(m_shader->PositionAttribute(), 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), vertices);
        glVertexAttribPointer(m_shader->TextureAttribute(), 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), coords);
        glVertexAttribPointer(m_shader->ColorAttribute(), 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), colors);

        for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
        {
            const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
            if (pcmd->UserCallback)
            {
                pcmd->UserCallback(cmd_list, pcmd);
            }
            else
            {
                const void* id = pcmd->TextureId;
                const auto it = m_textures.find((unsigned int)(intptr_t)id);
                if(it != m_textures.end())
                    renderer.UseTexture(it->second);
                else
                    renderer.ClearTexture();

                glScissor((int)pcmd->ClipRect.x,
                          (int)(m_windowSize.y - pcmd->ClipRect.w),
                          (int)(pcmd->ClipRect.z - pcmd->ClipRect.x),
                          (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
                
                constexpr GLenum data_type = sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
                glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, data_type, idx_buffer);
            }
            
            idx_buffer += pcmd->ElemCount;
        }
    }

    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glDisableVertexAttribArray(2);

    glDisable(GL_SCISSOR_TEST);
}
Ejemplo n.º 7
0
void InvaderEntity::Draw(mono::IRenderer& renderer) const
{
    renderer.DrawSprite(*mSprite);
}