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

feat: Enable to build SkyBoxAsset using OpenGL #2504

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

Jklawreszuk
Copy link
Collaborator

PR Details

This PR implements / fixes compiling Skybox Asset for OpenGL. I also made few related refactoring changes

Example of a game using Skybox : FirstPersonShooter
Screenshot from 2024-10-25 18-16-23

Related Issue

#2496

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@Jklawreszuk Jklawreszuk changed the title fix: Enable to build SkyBoxAsset using OpenGL feat: Enable to build SkyBoxAsset using OpenGL Oct 25, 2024
Copy link
Collaborator

@Eideren Eideren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

@@ -658,23 +658,23 @@ protected unsafe void InitializePlatformDevice(GraphicsProfile[] graphicsProfile
#endif

#if STRIDE_UI_SDL
gameWindow = (Stride.Graphics.SDL.Window)windowHandle.NativeWindow;
gameWindow = windowHandle?.NativeWindow as SDL.Window ?? new SDL.Window("");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this new window for ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dump window is created to initialize the SDLContext which is then used for the OpenGL api as a context (see 699 line).
The author assumed when casting that the windowhandle object was not null but it wasn't, so I handled it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For opengl on windows this would load in sdl when using a winforms window then ?

Also, shouldn't it be initialized/set in a more appropriate spot then ? I.E.: ensure window is init first and has a native window handle, then this scope is called and retrieves the window without creating one ?

Copy link
Collaborator Author

@Jklawreszuk Jklawreszuk Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it comes to Windows, from what I've noticed, Stride Asset Compiler (always) uses DirectX on Windows to compile assets and I haven't changed that. My change only applies to Linux (or MacOs if someone has decided to support it). So short answer is no

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the second question, this window object is used before the game starts so it will always be null. Also, I am not sure it even creates "real" window because Silk has command for this : SDL.CreateWindow()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently no one predicted it would be possible to run on Linux in the future 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyways, If you have any suggestions feel free to give any ideas

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the OGL stuff requires a window when the D3d one doesn't, but that's best left to a proper refactor I guess.
Can you split the ternary into a specific line with a comment mentioning that this is a workaround specifically for the asset compiler ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Eideren Sure, Done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong, but I think OpenGL has always needed a window to establish its context (the surface where to draw). Direct3D also needed it up until D3D9, but if I remember it correctly, it was D3D10 or 11 that started to allow setting up a swapchain without an associated HWND.
As Xenko supported both D3D9 and OpenGL, that may be the reason for requiring a window. Now that D3D9 is deprecated and D3D11 no longer needs it, only OpenGL is left with that requirement (as Vulkan can also render without a window).

@Eideren Eideren merged commit c7614ee into stride3d:master Oct 27, 2024
7 checks passed
@Eideren
Copy link
Collaborator

Eideren commented Oct 27, 2024

Thanks !

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

Successfully merging this pull request may close these issues.

3 participants