Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading .obj files with textures does not work? #200

Open
Kermalis opened this issue Jul 11, 2021 · 2 comments
Open

Loading .obj files with textures does not work? #200

Kermalis opened this issue Jul 11, 2021 · 2 comments

Comments

@Kermalis
Copy link

I'm trying to follow your samples but it seems basic functionality is not working.

When you do either SerializationEngine.Instance.LoadScene(path) or new ObjFileFormat().LoadData(path), there's a crash. This is because LoadData() 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 calls Texture.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

@trenttobler
Copy link

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.)

@progmars
Copy link

This got me as well, spent quite a few minutes investigating file paths, formats and whatnot, and finally found the faulty place:

theTexture.Create(scene.CurrentOpenGLContext, textureFile);

Fortunately, it was pretty easy to create a custom ObjFileFormat with context.

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

No branches or pull requests

3 participants