Really odd problem… I was using ShapeRenderer for the first time and all was going fine, until I seemed to notice that the rectangle on my menu screen looked odd. So I took a screenshot of it and zoomed in only to find that it was just as I thought: The top-left-most pixel of the rectangle was missing…
Now, I can’t imagine what might be wrong with my code since it seems pretty straightforward:
ShapeRenderer sr = new ShapeRenderer();
sr.begin(ShapeType.Line);
sr.setColor(255/LogapGame.colorConvert,
255/LogapGame.colorConvert,
192/LogapGame.colorConvert,
255/LogapGame.colorConvert);
if(selected == -1){
} else if(selected == 0){
sr.rect(102, 91, 103, 15);
} else if(selected == 1){
} else if(selected == 2){
} else if(selected == 3){
} else if(selected == 4){
}
sr.end();
I even took a look at the rect() code in LibGDX and everything seems to be fine there as well:
/** Draws a rectangle in the x/y plane. The x and y coordinate specify the bottom left corner of the rectangle. The
* {@link ShapeType} passed to begin has to be {@link ShapeType#Filled} or {@link ShapeType#Line}.
* @param x
* @param y
* @param width
* @param height */
public void rect(float x, float y, float width, float height){
if (currType != ShapeType.Filled && currType != ShapeType.Line)
throw new GdxRuntimeException("Must call begin(ShapeType.Filled) or begin(ShapeType.Line)");
checkDirty();
checkFlush(8);
if(currType == ShapeType.Line){
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x, y, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x + width, y, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x + width, y, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x + width, y + height, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x + width, y + height, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x, y + height, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x, y + height, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x, y, 0);
}
else {
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x, y, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x + width, y, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x + width, y + height, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x + width, y + height, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x, y + height, 0);
renderer.color(color.r, color.g, color.b, color.a);
renderer.vertex(x, y, 0);
}
}
So idk… … …help? :-\