(LibGDX)创建FrameBuffers时Android应用程序崩溃

时间:2018-10-11 04:47:34

标签: java android opengl-es libgdx opengl-es-2.0

我从Google Play商店收到了一份关于我使用LibGDX创建的Android应用的崩溃报告。

Huawei MediaPad T3 7 (hwbg2), Android 6.0

java.lang.IllegalStateException:
  at com.badlogic.gdx.graphics.glutils.GLFrameBuffer.build (GLFrameBuffer.java:233)
  at com.badlogic.gdx.graphics.glutils.GLFrameBuffer.<init> (GLFrameBuffer.java:87)
  at com.badlogic.gdx.graphics.glutils.FrameBuffer.<init> (FrameBuffer.java:51)
  at com.badlogic.gdx.graphics.glutils.GLFrameBuffer$FrameBufferBuilder.build (GLFrameBuffer.java:474)
  at com.badlogic.gdx.graphics.glutils.FrameBuffer.createFrameBuffer (FrameBuffer.java:72)
  at com.badlogic.gdx.graphics.glutils.FrameBuffer.createFrameBuffer (FrameBuffer.java:56)
  at MY_PACKAGE.editor.Backup.<init> (Backup.java:21)
  at MY_PACKAGE.editor.EditingImage.<init> (EditingImage.java:277)
  at MY_PACKAGE.screens.EditingScreen.<init> (EditingScreen.java:227)
  at MY_PACKAGE.screens.Screens.<init> (Screens.java:42)
  at MY_PACKAGE.MAIN_CLASS$2.run (MAIN_CLASS.java:121)
  at MY_PACKAGE.screens.SplashScreen.render (SplashScreen.java:93)
  at com.badlogic.gdx.Game.render (Game.java:46)
  at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame (AndroidGraphics.java:495)
  at android.opengl.GLSurfaceView$GLThread.guardedRun (GLSurfaceView.java:1599)
  at android.opengl.GLSurfaceView$GLThread.run (GLSurfaceView.java:1295)

GLFrameBuffer.java中的代码:233

if (result == GL20.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)
            throw new IllegalStateException("frame buffer couldn't be constructed: incomplete attachment");

EditingImage.java如下

class EditingImage{

    public static final int pixmapWidth = 1024;

    public EditingImage{
        frameBuffer = FrameBuffer.createFrameBuffer(Pixmap.Format.RGB888,pixmapWidth,pixmapWidth,false);

        ....

        for (int i = 0; i < 50; i++){
          final Backup backup = new Backup(pixmapWidth);
          availableBackups.add(backup);
        }
    }
}

Backup.java如下

Backup(int width){
    frameBuffer = FrameBuffer.createFrameBuffer(Pixmap.Format.RGB888, width, width, false);
    ....
}

在创建FrameBuffer时(在我不知道有多少循环之后),该应用程序已在Backup.java中崩溃。

如您所见,在EditingImage中创建的FrameBuffer尚未崩溃,并且在实例化Backup对象之前已执行。

它在我的手机(华为Y6II)上正常工作。在某些三星手机中也进行了测试。

请帮助!

1 个答案:

答案 0 :(得分:0)

1年11个月后,我发现了问题。

根据文档:

https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/FrameBuffer.html

对于在构造函数中作为参数传递的格式,它应该是RGB565或RGBA4444或RGB5_A1

format-颜色缓冲区的格式;根据OpenGL ES 2.0规范,只有RGB565,RGBA4444和RGB5_A1是可彩色渲染的

我使用的是RGB888