clt84

spine_libgdx version: 3.8.55
libgdx version: 1.9.10

I have a spine box embedded in a fragment via AndroidFragmentApplication(https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidFragmentApplication.java)

When I load in the Spine atlas, json, and packed textures files into the Android application assets and access them via Gdx.files.internal(xyz), the character loads fine. However, I need to be able to download these files to the Android filesystem and access them with Gdx.files.local(xyz) instead -- when I do this, the atlas and skeleton appear to load correctly, but none of the textures are rendered (see attached screenshot).

I've double and triple checked that the .png texture files are downloaded correctly, in the same directory as the atlas and json files, and the paths in the atlas data are pointing to the correct paths where these textures are saved.

Any suggestions on what might be going wrong or how to go about debugging?

Thanks!


for reference, my spine-specific code is very simple:

public final class MyAdapter extends ApplicationAdapter {
private OrthographicCamera camera;
private PolygonSpriteBatch batch;
private SkeletonRenderer renderer;

private SpineFiles spineFiles;
private TextureAtlas atlas;
private Skeleton skeleton;
private AnimationState animationState;

@Override
public void create() {
camera = new OrthographicCamera();
batch = new PolygonSpriteBatch();
renderer = new SkeletonRenderer();
renderer.setPremultipliedAlpha(true);
created = true;
loadSpineFiles();
}

@Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (skeleton != null) {
animationState.update(Gdx.graphics.getDeltaTime()); // Update the animation time.
animationState.apply(skeleton);
skeleton.updateWorldTransform();

camera.update();
batch.getProjectionMatrix().set(camera.combined);

batch.begin();
renderer.draw(batch, skeleton); // Draw the skeleton images.
batch.end();
}
}

@Override
public void dispose() {
batch.dispose();
created = false;
if (atlas != null) {
atlas.dispose();
}
}

private void loadSpineFiles() {
atlas = new TextureAtlas(Gdx.files.local(spineFiles.atlasFile()));
SkeletonJson json = new SkeletonJson(atlas);
SkeletonData skeletonData = json.readSkeletonData(Gdx.files.local(spineFiles.jsonFile()));

AnimationStateData stateData = new AnimationStateData(skeletonData);
animationState = new AnimationState(stateData);
animationState.setTimeScale(1);

skeleton = new Skeleton(skeletonData);
}

---

Should also note that from what I can tell, libgdx is able to open the image files and load them correctly, but for some reason they're the texture regions are still being rendered as black boxes.

---

I've fixed the issue; for anyone else who has this problem, make sure you aren't trying to load textures on a background thread. Textures need to be loaded on the GL thread, via Gdx.app.postRunnable or similar.
Bạn không được cấp phép để xem tập tin đính kèm trong bài viết này.
clt84
  • Bài viết: 2

Mario

Hah, glad you figured it out! OpenGL and threading is a massive pain. libGDX's AssetManager can be used to make sure assets are loaded in the background, but uploaded to the GPU on the main thread.
Hình đại diện của thành viên
Mario

Mario
  • Bài viết: 2356


Quay về Runtimes