try {
        URL url = new URL(this.url);
        InputStream in = new BufferedInputStream(url.openStream());
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] buf = new byte[1024];
        int n = 0;
        while (-1 != (n = in.read(buf))) {
            out.write(buf, 0, n);
        }
        out.close();
        in.close();
        byte[] response = out.toByteArray();
        Pixmap pixmap = new Pixmap(response, 0, response.length);
        texture = new Texture(pixmap); // <- here Im getting an exception
    } catch (Exception e) {
        // cause=NullPointerException
        // pixmap was initialized successfully
    }


所有代码都在线程中工作。
代码在UI线程中效果很好。

有任何想法吗?

最佳答案

我认为您不能在与opengl上下文创建线程不同的线程中使用opengl。

http://code.google.com/p/libgdx/wiki/ApplicationThreading

10-07 19:40
查看更多