-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
Requirements for fully custom Game runtime management #2404
base: master
Are you sure you want to change the base?
Conversation
I think the internal windowing and some of the internal game logic needs to be refactored, this PR might introduce API that would become deprecated once this is on the way. But, at the same time, refactoring those areas properly might also require deprecating large swathes of the current public api as well, so not 100% set on that one, I'll let someone else chime in on this. |
Maybe when I have more time I can take the time to create a mind map of all of the connections to and from the Windowing API. I know last time I dealt with this was due to the Window Exiting bug and it was a pain to walk through all of the seemingly random calls. |
We need samples that showcase the use of those APIs before merging this PR. Otherwise it's hard to know what justify making one API visible and not one another. It could also be that more refactoring becomes required as to hide some implementation details that shouldn't be public because we can't guarantee stability between versions. |
But that's the hard part lol! In all seriousness, I can finally take a proper look at this with my main PC. What I can do is create a project template recreating what was done for the SDL implementation but as an external Stride project to start. |
OK, I have recreated a POC for the SDL example in a separate project and the good news is it works fine. I did miss one more area with the I added a simple case for Custom where it would just return null and added the Source manually in a custom protected override void Initialize()
{
base.Initialize();
var sdlContext = (GameContextSDL)Context;
Input.Sources.Add(new InputSourceSDL(sdlContext.Control));
} Also due to how GameContext and Window are tied together, I had to do something a bit funky but functional in the constructor: public GameWindowSDL(string title, int width = 800, int height = 600)
{
window = new(title);
GameContext = new GameContextSDL(window);
// Setup the initial size of the window
if (width == 0)
{
width = window.ClientSize.Width;
}
if (height == 0)
{
height = window.ClientSize.Height;
}
windowHandle = new WindowHandle(AppContextType.Desktop, window, window.Handle);
window.ClientSize = new Size2(width, height);
window.MouseEnterActions += WindowOnMouseEnterActions;
window.MouseLeaveActions += WindowOnMouseLeaveActions;
var gameForm = window as GameFormSDL;
if (gameForm != null)
{
//gameForm.AppActivated += OnActivated;
//gameForm.AppDeactivated += OnDeactivated;
gameForm.UserResized += OnClientSizeChanged;
gameForm.CloseActions += GameForm_CloseActions;
gameForm.FullscreenToggle += OnFullscreenToggle;
}
else
{
window.ResizeEndActions += WindowOnResizeEndActions;
}
} I will publish the project in a public github repo in a bit for anyone to take a look at. and if all looks good I will look into adding it as a project template like the FPS example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - looking over the POC, I don't see any use for TickLock
or ImageSerializer
, why are those made public ?
I was hoping to create a secondary demo for that. The The second demo goal is to have a fully custom I may want this PR to be draft for now, I had some time when I originally started this PR but I am starting to get a bit swamped with work. If my time frees up this weekend I will get back on it in a couple of days. |
Just finished up some more work on this. I decided to try and go for the big fish with creating an Avalonia control that can render Stride in this branch of my external repo https://github.com/Doprez/custom-stride-window-poc/tree/avalonia-custom-platform Avalonia controlThis gives an example of the Stride systems below:
Whats missing:
Whats broken???: At this point I am well beyond my comfort zone of knowledge so this will definitely be the longest part for me to research and look into. If anyone is willing to take a look maybe it can go a bit faster with some better knowledge but I will still be looking into it as I find time of course. API improvement findings and thoughtsThis also gave me a lot of knowledge on some of the systems in place that definitely need to be cleaned up.
public GameWindowAvalonia(Control control)
{
GameContext = new GameContextAvalonia(control);
Initialize(GameContext);
}
|
Probably the last thing Ill get done at least for this weekend but a few updates in case I forget. API improvementsI cleaned up the creation of gameWindow = new GameWindowAvalonia(this);
gamePlatform = new GamePlatformAvalonia(); // now you can make the game platform before the game is set up.
game = new AvaloniaGame(gamePlatform);
game.Run(gameWindow.GameContext); Previously this was impossible since one could not exist without the other. Remaining known issuesSwapchain issueI resolved the problem with the creation of the New serializer issueI stumbled onto another problem that I haven't been able to find out what I did. I somehow broke the
The good news is, I did not break everything, only the Avalonia project is broken so I am assuming the issue lies within the custom |
Ok, I lied... The fact that this wasn't working drove me nuts so I did a bit more testing and now it actually renders in Avalonia! Serialization issueTurns out the issue with this is that the GameBase class can not be outside of where the Assets folder is in the csproj. I am guessing the reason for this is how the Asset DB is created? this is the class that fails and is in the separate Avalonia dedicated project. I copied the exact same code in the new class GameCopyTest. I dont think anything I would have done would have broken this so it might be out of scope for this but I may want to fix it anyway since it messes with what I need to do for input handling. RenderingTurns out the problem with rendering was that the backbuffer image was being covered by the Avalonia The good news is that means that controls should be able to be rendered on top of the scene. Im saying this without testing as Im just happy that anything I have done works lol. I also need to do a better job of handling events between Stride and Avalonia.
Next stepsInputThis will be the next big change. As I said before the content manager gets in the way, but otherwise this should be as simple as registering Stride events to the ones that exist in Avalonias Avalonia improvementsfor testing I went with the easy approach of just adding the logic directly to the window. This is perfectly fine unless the user wants to create a dockable control like Kryptos-FR will likely need once the gamestudio rewrite is stable. For this I will likely not need to change too much to make it work with a control. I will just need to tie resizing events to the control position and bounds as well as create Input events that are tied to the control again for positioning and bounds logic. |
@tebjan would you be able to take a look at what I have done here? I am pinging you as you mentioned something in another post about using a handle from Angle so Im wondering if what I have done here so far is valid in terms of maintainability or long term use. Link reference in case you dont have it: Also the link to my test project: |
That's a very interesting situation - the error you got says that the serialization system cannot find a registered serializer for EntityComponent class. I would imagine this were to happen if you haven't loaded the Stride.Engine assembly into memory yet before trying to perform the deserialization. But that shouldn't be the case since your class has fields of types from that assembly. Which means there's some other source of confusion. I would suggest to do a clean rebuild (removing the compiled assets, the obj folders in all projects) in case it's caused by some change in dependencies while a cached asset compiled with previous dependency version remained. |
So I just tried now with a clean and removed all of the folders manually for bin and obj. Its the same problem though. As soon as the It might be important to note that it seems like it doesn't fail when loading the GameSettings serializer? I was stepping through and I noticed that it loads the GameSettings first and then fails after with the Scene serializer. |
funny enough, when I inherit the Game class from the main project and add some logic to it in the Avalonia project it works fine... |
I took some time to get most of the inputs working between Avalonia and Stride. Its mostly working but its important to keep note of some limitations:
|
Access changes and questionsFullscreenI did some small cleanups in this PR, To set true fullscreen there are currently 3 ways of updating it from the user.
I have added one new method for setting windowed borderless fullscreen called I think I am happy enough with this but some extra opinions would be nice. The only reason Set sizeThere are currently 3 ways of setting the screen/window size.
Extra thingsIm going to ignore gamepad support for this Avalonia POC only because it would just be a copy paste of the SDL input but without the window. I'm also going to ignore touch for the same reason. It fully depends on knowledge of the UI framework someone is using so the SDL example should be enough for people to work off of from Strides POV. I got the mouse input lock working but it seems to have bad stutter so if someone has a better way of what I'm doing I would love to hear it. https://github.com/Doprez/custom-stride-window-poc/tree/avalonia-custom-platform/MyGame3/MouseHelpers |
This is going to sit as draft while we look into the new Silk.NET.Windowing 3.0 proposal as a replacement. If anyone waiting on this has any concerns, questions or ideas please feel free to add your comments to the discussion about this #2524 |
PR Details
The amount of internal features for Stride makes it very difficult and cumbersome to make any custom root/base features for the engine. This PR opens up a lot of those features to be accessible to any dev just referencing the released Nugets.
Now devs should be able to:
I need to look into it more but with the changes here to the(Nope, need to look into changing the currentGameBase
, can we use this for separating game and window logic?Gamesystems
due to rendering requirements currently built into the main loop. out of scope for now, at least for this PR.)Related Issue
#870
#1315 (Takes the initial work done by @TheKeyblader and adds a few more)
#1474
#1629
Types of changes
Checklist