LibGDX FrameBuffer iOS incorrect offset

I had a problem with FrameBuffer on iOS although the same code worked fine on Android.

The problem is that when I draw a group without using FBO, everything is displayed correctly, but if I draw in FBO and then on the screen, I have problems with positioning the group.

I have a regular mask shader and I used FrameBuffer for this:

    fboGroup!!.begin()
    ScreenUtils.clear(Color.CLEAR, true)
    batch.begin()
    batch.projectionMatrix = camera.combined

    batch.setBlendFunction(GL20.GL_ONE_MINUS_DST_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
    super.draw(batch, parentAlpha)

    batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
    batch.color = Color.WHITE

    batch.projectionMatrix = stage.camera.combined

    batch.end()
    fboGroup!!.end(screenXInPixels, screenYInPixels, screenWidthInPixels, screenHeightInPixels)

Upvotes: 0

Views: 10

Answers (1)

The problem was:

fboGroup!!.end(screenXInPixels, screenYInPixels, screenWidthInPixels, screenHeightInPixels)

Decision:

fboGroup!!.end()

or

stage.viewport.apply()

or

class IOSLauncher : IOSApplication.Delegate() {

override fun createApplication(): IOSApplication {
    return IOSApplication(GdxGame(this), IOSApplicationConfiguration().apply {
        // Configure your application here.
        useAccelerometer = false
        useCompass       = false
        hdpiMode         = HdpiMode.Pixels
    })
}

hdpiMode = HdpiMode.Pixels

PS. Vel_daN: Love what You DO 💚.

Upvotes: 0

Related Questions