Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7716405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:37:45+00:00 2026-06-01T02:37:45+00:00

I was wondering if there was a way to make Android games in libgdx

  • 0

I was wondering if there was a way to make Android games in libgdx so they all share the same resolution of 480×800. Using Gdx.graphics.setDisplayMode(480, 800, true) doesn’t seem to change anything. Creating an OrthographicCamera of 480 by 800 makes it so the game is 480 by 800, but doesn’t zoom into fullscreen and take up the entire screen like I expected it would. When I tested it out on my phone, the phone just used blank space to fill up the rest of the screen while the game in 480×800 resolution. Here is the code that I’m using.

public class GameScreen implements Screen {

private Game game;
private OrthographicCamera guiCam;
private SpriteBatch batch;
private Texture texture;
private Rectangle glViewport;

public GameScreen (Game game)
{
        this.game = game;
        guiCam = new OrthographicCamera(GAME_WIDTH, GAME_HEIGHT);
        guiCam.position.set(GAME_WIDTH / 2, GAME_HEIGHT / 2, 0);
        batch = new SpriteBatch();
        texture = new Texture(Gdx.files.internal("data/c2.png"));
        glViewport = new Rectangle(0, 0, GAME_WIDTH, GAME_HEIGHT);
}

@Override
public void render(float delta) {
    if (Gdx.input.justTouched()) {
          texture = new Texture(Gdx.files.internal("data/c1.png"));
    }
    GL10 gl = Gdx.graphics.getGL10();
    gl.glClearColor(1, 0, 0, 1);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    gl.glViewport((int) glViewport.x, (int) glViewport.y,
            (int) glViewport.width, (int) glViewport.height);

    guiCam.update();
    guiCam.apply(gl);
    batch.setProjectionMatrix(guiCam.combined);
    batch.begin();
    batch.draw(texture, 0, 0, 0, 0, 142, 192);
    batch.end();
}

private static final int GAME_WIDTH = 480;
private static final int GAME_HEIGHT = 800;
}

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:37:46+00:00Added an answer on June 1, 2026 at 2:37 am

    You’ve set your glViewport to 480×800, that means you’re asking the phone hardware for a 480×800 window to draw on. Because most (all?) phone hardware doesn’t do screen scaling (like your desktop monitor does), they just give you a 480×800 area on the screen.

    You need to get OpenGL to “zoom” your screen, and you do that by setting the glViewport() to the physical resolution of your device (modulo aspect ratio caveats!). You should leave the camera at the ‘virtual’ resolution you prefer (so 480×800 in this case). Now OpenGL will scale all your primitives up to the screen’s resolution.

    As a quick test, try this:

    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    

    The next problem is that if the hardware aspect ratio doesn’t match your ‘virtual’ aspect ratio. In that case you need to decide between stretching, leaving black bars on one side, or changing your virtual aspect ratio. See this blog post for more details on the camera/viewport setup, and some solutions to the aspect ratio issue: http://blog.acamara.es/2012/02/05/keep-screen-aspect-ratio-with-different-resolutions-using-libgdx/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

was wondering if there is a way to make superfish using jquery ui theme
I was wondering whether there is a way to make html5 code visible in
I am wondering if there is a way to make ASP.NET controls play nicely
I am wondering if there is some way to make an box have the
I was wondering, is there a way to make a kind of one to
I was wondering if there is way to open another page using a Modal
I was wondering if there was any way to make tables in html to
I was wondering if there is any way to make a copy of an
I am wondering if there is some way to make an iPhone application where
I was wondering if there was a way to make OpenGL ES render a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.