1

When I use this code.

private void drawSelected() {
    int width_border = 5; // border on left and right
    int height_border = 5; // border on top and bottom

    for (Entity e : selected) {
        glPushMatrix();
        glPushAttrib(GL_CURRENT_BIT);
        glColor3f(1.0f, 1.0f, 1.0f);
        glTranslatef(e.getX()+cameraX, e.getY()+cameraY, 0);

        glBegin(GL_LINE_LOOP);
        {
            float x1 = -width_border + 1;
            float y1 = -height_border;
            float x2 = e.getSprite().getWidth() + width_border;
            float y2 = e.getSprite().getHeight() + height_border-1;
            glVertex2f(x1, y1);
            glVertex2f(x1, y2);
            glVertex2f(x2, y2);
            glVertex2f(x2, y1);
        }

        glEnd();
        glPopMatrix();
        glPopAttrib();

    }
}

I get this a box drawn like this.

https://i.stack.imgur.com/s0DJS.jpg

This is openGL, where 0,0 is the top left corner of the map.

I don't know why this code is leaving out the bottom left corner of the box. Is there anything I can change to make it so it doesn't leave out that corner?

jozxyqk
  • 16,424
  • 12
  • 91
  • 180
Alex
  • 23
  • 3
  • Quite similar to this question: http://stackoverflow.com/questions/10320332/how-to-render-perfect-wireframed-rectangle-in-2d-mode-with-opengl – jozxyqk Nov 25 '14 at 02:21

0 Answers0