Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

How to split a screen in half using LibGDX without scaling?

$
0
0

I am currently working on a racing game with libGDX and I need to split the screen in half for a two-players mode. (Player 1 in first half and Player 2 in second half).

I already have Camera1 that will follow Player 1′s car, and Camera2 that will follow Player 2′s car.

Basically, I want the first half to show Player 1′s car and the second half to show Player 2′s car.

I have been searching for a while online for a way to split screens with LibGDX and found how to split the screen in two with this code:

/*Left Half*/
Gdx.gl.glViewport( 0,0,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight() );

/*Right Half*/
Gdx.gl.glViewport(Gdx.graphics.getWidth()/2,0,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight() );

However, it squeezes the screen into the right half, which is not what I want.

Is there a way to split the screen without squeezing it?


Viewing all articles
Browse latest Browse all 434

Trending Articles