Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

kgl-stb: cstb.stbi_load and STBImage.load both crash on Windows 10 #24

Open
nlbuescher opened this issue May 20, 2020 · 3 comments
Open

Comments

@nlbuescher
Copy link
Collaborator

Error code -1073741819. Googling this suggests a file system error, but I have no idea. Trying any of the suggested fixes yields no results.

I've copied the entire stb_image.h into a cinterop def with the following headings, and it works fine, but using kgl-stb makes it crash:

excludedFunctions = stbi__err
compilerOpts = -DSTB_IMAGE_IMPLEMENTATION
@Dominaezzz
Copy link
Owner

At first glance, it looks like a static linking issue. Will have to setup some unit tests to investigate.

This flag -DSTB_IMAGE_IMPLEMENTATION is a very tempting solution but my issue with it, is that it leaks the internals of stb_image to the kotlin cinterop. Maybe it's not a big deal since it's abstracted away by kgl, what do you think?

@nlbuescher
Copy link
Collaborator Author

The error occurs at runtime, if that helps.

Currently I only use the cinterop functions because there's still no reasonable way to get a ByteArray from a kotlin native function. You always have to work with IoBuffers, or Memory objects, or some other format that at its core is just a ByteArray, which usually requires figuring out how to create the structure (which has been a nightmare in my experience because of lacking documentation), and then figuring out how to get the Bytes you need out so you can work with them.

There's still no stdlib IO that allows you to read bytes from a file into a ByteArray, and I'm annoyed about it ☹️

With regard to the STB_IMAGE_IMPLEMENTATION define, kgl-stb already does this, but in a more roundabout way with a cpp file. The definitions are still accessible in the cstb package, and the define is not a solution to whatever problem I'm having with Windows 10

@Dominaezzz
Copy link
Owner

This should simplify things. JetBrains/kotlin-native#3971

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants