FitViewport gutter scrambled on MacOS

Anything libgdx related goes here!

FitViewport gutter scrambled on MacOS

Postby Landei » Fri Aug 23, 2019 7:55 am

Hi,

I tried my game on MacOS (10.11.6), and after a resize the gutter of FitViewport contains funny artefacts: Image

On resize I do just the usual

Code: Select all
   
override fun resize(width: Int, height: Int) {
        viewport.update(width, height)
}


Is there a way to clean the gutter after a resize? Or should this be considered a bug?
Landei
 
Posts: 12
Joined: Tue May 08, 2018 5:05 pm

Re: FitViewport gutter scrambled on MacOS

Postby shatterblast » Thu Aug 29, 2019 3:41 pm

I think there may be a thing with FitViewport on Apple stuff, but I am not sure. It may have to do with Apple's older version of OpenGL. You might consider preventing resize with your game or perhaps even a different Viewport type if you really need.
shatterblast
 
Posts: 414
Joined: Sun Jul 06, 2014 1:14 pm

Re: FitViewport gutter scrambled on MacOS

Postby evilentity » Thu Aug 29, 2019 6:20 pm

Try clearing the screen with proper viewport then applying fit
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4854
Joined: Wed Aug 24, 2011 11:37 am

Re: FitViewport gutter scrambled on MacOS

Postby Landei » Mon Sep 02, 2019 6:25 pm

Thanks @evilentity, using a second viewport works.

In case someone else runs into it, here are my modifications (Kotlin, sorry)
Code: Select all
private val gutterViewport = StretchViewport(Main.worldWidth, Main.worldHeight, camera)
val viewport = FitViewport(Main.worldWidth, Main.worldHeight, camera)
...
override fun resize(width: Int, height: Int) {
        gutterViewport.update(width, height) //<-- keep it updated as well
        viewport.update(width, height)
}
...
override fun render(delta: Float) {
        gutterViewport.apply()
        //draw what you need for cleanup, e.g. a black rectangle
        viewport.apply()
        //normal stuff here
}


Kinda hacky, but I'm glad it works.
Landei
 
Posts: 12
Joined: Tue May 08, 2018 5:05 pm


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 1 guest