Java – split screen in libgdx
The question is short and simple How to create split screen effect in libgdx If I create two cameras, it will draw one located somewhere, and then draw the next, overwriting the previous camera Then I want to use multiple screens, but it doesn't seem to work because it only supports resizing rather than repositioning within the window I also use @ R_ 275_ 2419@2DDebugRenderer And shaperer, so it also needs to cut them off under the split screen limit There seems to be no documentation on the libgdx website
Solution
After asking on the #libgdx IRC, he pointed out to me the function GDx gl. glViewport(int x,int y,int width,int height). So you only need a camera Just set the viewport on the left side of the screen, then execute the drawing command, then set the viewport on the right side of the screen and draw again like this:
@Override public void render( float delta ) { /*Wipe Screen to black*/ Gdx.gl.glClearColor( Color.BLACK ); Gdx.gl.glClear( GL10.GL_COLOR_BUFFER_BIT ); /*Left Half*/ Gdx.gl.glViewport( 0,Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight() ); //Set up camera with viewport in mind draw( delta ); /*Right Half*/ Gdx.gl.glViewport( Gdx.graphics.getWidth()/2,Gdx.graphics.getHeight() ); //Set up camera again with other viewport in mind draw( delta ); }
You just need to set up the camera to position and convert to a limited screen as you want, not the whole screen You can also use a second camera