libktx / ktx

Kotlin extensions for the libGDX game framework
https://libktx.github.io/
Creative Commons Zero v1.0 Universal
1.35k stars 71 forks source link

Unable to load assets in HeadlessApplication #441

Closed ronjunevaldoz closed 1 year ago

ronjunevaldoz commented 1 year ago

I'm not sure if loading assets via HeadlessApplication is supported. I tried the below example to load assets via ktx-async and AssetStorage. Assume that this was working in desktop mode.

if(Gdx.files.internal("data/model/test.gltf").exists()) {
   println("exists")
}
// exists
// onCreate
 KtxAsync.launch {
   setLoader(".gltf") { GLTFAssetLoader() }
   load<SceneAsset>("data/model/test.gltf")
}

Encountered error ktx.assets.async.AssetLoadingException: Unable to load asset: data/model/test.gltf

czyzby commented 1 year ago

It's not supported. You'll notice that the whole Graphics class has a mock implementation on the headless platform. If you'd like to load assets with a headless application, try launching the desktop backend without a window.