Open Kermalis opened 3 years ago
I ran into this issue too as I was trying to port the library and samples to .net 6. I got the "WinForms Sample/DuckySample" to load by modifying the ObjFileFormat to include a property to provide the GlContext, assigning it when creating the ObjFileFormat, and calling scene.CreateInContext(..) before loading the format.
I don't think it was just you. This seems a pretty clear bug, possibly a design issue by the mandate that the GL context be initialized before being able to utilize the load model data (which was more what I was looking for - something that could parse and open Wavefront OBJ files, rather than a full OpenGL engine.)
This got me as well, spent quite a few minutes investigating file paths, formats and whatnot, and finally found the faulty place: https://github.com/dwmkerr/sharpgl/blob/9a18e2624f488635ee87d4ee5a75aa2e6df09cdd/source/SharpGL/Core/SharpGL.Serialization/Wavefront/ObjFileFormat.cs#L254
Fortunately, it was pretty easy to create a custom ObjFileFormat with context.
I'm trying to follow your samples but it seems basic functionality is not working.
When you do either
SerializationEngine.Instance.LoadScene(path)
ornew ObjFileFormat().LoadData(path)
, there's a crash. This is becauseLoadData()
makes a brand new Scene with no gl context, meaning the Scene's gl context is null. Then when loading textures, it crashes because it callsTexture.Create()
with a null gl context.Am I missing something? I feel like everyone in the planet would be making this issue if it was actually broken. There's no way for me to pass in a gl context. Also, I can't downgrade to 2.4.4 (before this crash would've existed) because your Serialization nuget package does not go before 3.1.0