ProwlEngine / Prowl

An Open Source C# 3D Game Engine under MIT license, inspired by Unity and featuring a complete editor and built on Silk.NET
MIT License
328 stars 27 forks source link

Embedding the Engine in an AvaloniaUI App #105

Open JaggerJo opened 5 months ago

JaggerJo commented 5 months ago

First, super cool project. I've been following the progress over the years!

I'm currently working on an Avalonia Application running on embedded linux hardware using DRM. I now have a use case where 3D graphics would be interesting (but not strictly required) for a visualisation. It's quite simple to obtain a OpenGL context in Avalonia and draw stuff with Silk.NET. (Example Project). Doing it in "raw" OpenGL is not an option for me. That would be far outside of my comfort zone..

I've noticed that Prowl uses Silk.NET internally. So .. would it be feasible to get the engine running in Avalonia?

michaelsakharov commented 5 months ago

I don't know much about Avalonia so I'm not too sure. It should be possible but it might be a bit of work since I think Dear ImGUI Stands in your way in regards to getting the editor working.

You could probably take the Runtime and turn it into a graphics library independent of the editor fairly easily, (That's something I plan to eventually do) That doesn't come with UI, and would be reasonably easy to get working in Avalonia I think. Your biggest hurdle for that is asset management, You would need to move the asset importers from the editor to the runtime and import them straight to their assets in memory, ditching all the fancy assets to serialized Asset stuff. That should be the only thing "In your way" other then that it's just a matter of replacing the windowing with Avalonia stuff.

JaggerJo commented 5 months ago

Thanks for the quick answer!

Yeah the idea would be to take the Runtime and use it as a high level 3D engine. Basically a replacement for the Helix Toolkit which sadly relies on DirectX / WPF and can't be ported easily.

I've looked at the "Standalone" project. Would that be the best starting point? How would you go about doing that?

michaelsakharov commented 5 months ago

Standalone is a good starting point, that has a StandaloneAssetProvider or a IAssetProvider. You would need to rewrite that to load assets from raw formats (Or your own compiled format) since theres no editor to compile them.

Scenes might be a hurdle, would need some way to load them from assets, maybe json?

But yeah i'd start with getting the runtime to work alongside standalone first. Then look into avalonia.

Keeping prowl stupid simple specifically for cases like this is a big goal for me. Ideally, prowl can be converted and molded for everyone's use cases with little in the way. So if you run into any major issues let me know, ill try to resolve them.

JaggerJo commented 5 months ago

Just starting the Editor Project got me in a weird situation. I can't click / input anything. Is this a known issue on macOS + Apple Silicon?

Screenshot 2024-03-10 at 11 24 03

btw. I thought I knew this project and have seen it years ago, but I realised that was https://github.com/veldrid/veldrid - but you use the same scene in the screenshots so that was what caused the confusion :)

michaelsakharov commented 5 months ago

Just starting the Editor Project got me in a weird situation. I can't click / input anything. Is this a known issue on macOS + Apple Silicon?

Screenshot 2024-03-10 at 11 24 03

btw. I thought I knew this project and have seen it years ago, but I realised that was https://github.com/veldrid/veldrid - but you use the same scene in the screenshots so that was what caused the confusion :)

Unfortunately, Mac OS is a bit broken at the moment, it's being worked on here and there though I don't have a Mac myself so hard to test it. Theres two main issues that i know of at the moment which are: The rendering colors are weirdly off (everything is green) and the input is broken. We also don't know yet if the scene rendering works or not yet.

All good haha, I thought that was a bit weird the project is not even 1 year old yet.