Exemplo n.º 1
0
void VideoEngine::DrawGrid(float x, float y, float x_step, float y_step, const Color &c)
{
    PushState();

    Move(0, 0);

    float x_max = _current_context.coordinate_system.GetRight();
    float y_max = _current_context.coordinate_system.GetBottom();

    std::vector<GLfloat> vertices;
    int32 num_vertices = 0;
    for(; x <= x_max; x += x_step) {
        vertices.push_back(x);
        vertices.push_back(_current_context.coordinate_system.GetBottom());
        vertices.push_back(x);
        vertices.push_back(_current_context.coordinate_system.GetTop());
        num_vertices += 2;
    }
    for(; y < y_max; y += y_step) {
        vertices.push_back(_current_context.coordinate_system.GetLeft());
        vertices.push_back(y);
        vertices.push_back(_current_context.coordinate_system.GetRight());
        vertices.push_back(y);
        num_vertices += 2;
    }
    glColor4fv(&c[0]);
    DisableTexture2D();
    EnableVertexArray();
    glVertexPointer(2, GL_FLOAT, 0, &(vertices[0]));
    glDrawArrays(GL_LINES, 0, num_vertices);

    PopState();
}
Exemplo n.º 2
0
void VideoEngine::DrawLine(float x1, float y1, float x2, float y2, float width, const Color& color)
{
    GLfloat vert_coords[] = {
        x1, y1,
        x2, y2
    };
    EnableBlending();
    DisableTexture2D();
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal blending
    glPushAttrib(GL_LINE_WIDTH);

    glLineWidth(width);
    EnableVertexArray();
    DisableColorArray();
    DisableTextureCoordArray();
    glColor4fv((GLfloat *)color.GetColors());
    glVertexPointer(2, GL_FLOAT, 0, vert_coords);
    glDrawArrays(GL_LINES, 0, 2);

    glPopAttrib(); // GL_LINE_WIDTH
}