I am making a game in LibGDX. I'm using the orthographic camera class to scale the image and it works great. My only issue is with the black border. Since opengl draws the image at 0,0 which is the bottom left corner, the black border when the screen is scaled improperly is either on the top or the right. Ex:
Border on right:
Border on top:
What I want to do is make them like this:
Border used to be on right, now it's on right and left, perfectly symmetrical:
Same for this one. It used to just be on top but now it's evenly on top and bottom:
Anyone know how to do this? I think it would look muuuch nicer and more professional. Thanks in advance.
EDIT: This is what I tried so far:
Here is what I did so far:
double ratio = 1280 / 720;
double newRatio = width / height;
System.out.println("" + newRatio + " " + ratio);
System.out.println("" + width + " " + height);
if(newRatio < ratio){
System.out.println("herro");
double x = width / ratio;
double dif = height - x;
cam.setPosition(0f, (float)(dif / 2));
}