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

Add WinUI 3 SwapChainPanel support #4191

Merged
merged 5 commits into from
Oct 11, 2023
Merged

Conversation

DDRBoxman
Copy link
Contributor

@DDRBoxman DDRBoxman commented Oct 1, 2023

Checklist

  • Run cargo clippy.
  • Run cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections

Closes #4187

Description

Currently WinUI3 requires using a SwapChainPanel to render into a widget with directx.

This allows passing down a SwapChainPanel reference and then sets the swap chain on the panel.

Testing

Called from a C# Win UI App and rendered the triangle from the tutorial to the swap chain

Screenshot 2023-10-08 201300

@cwfitzgerald
Copy link
Member

Code generally looks fine, there's a bit of architectural stuff I want to deal with after this lands, but lets land first.

@DDRBoxman
Copy link
Contributor Author

DDRBoxman commented Oct 9, 2023

Sample code for how to get the correct pointer to send to native code in c#

IntPtr objectAddress = Marshal.GetComInterfaceForObject(swapChainPanel1, typeof(ISwapChainPanelNative));
CsBindgen.NativeMethods.send_swap_chain_panel((void*)objectAddress);

@DDRBoxman DDRBoxman marked this pull request as ready for review October 9, 2023 01:21
@DDRBoxman DDRBoxman requested a review from a team as a code owner October 9, 2023 01:21
@DDRBoxman DDRBoxman changed the title Add SwapChainPanel support Add WinUI 3 SwapChainPanel support Oct 9, 2023
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Lets do it!

@cwfitzgerald cwfitzgerald merged commit 0f7b530 into gfx-rs:trunk Oct 11, 2023
23 checks passed
@DDRBoxman
Copy link
Contributor Author

🎊

@Codentale
Copy link

Hi @DDRBoxman, nice work!
btw do you mind to share the C# sample project?
thanks.

Called from a C# Win UI App and rendered the triangle from the tutorial to the swap chain

Screenshot 2023-10-08 201300

@DDRBoxman
Copy link
Contributor Author

@Codentale take a look here

https://github.com/DDRBoxman/Cappy3ds/tree/main/win

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

Successfully merging this pull request may close these issues.

Support SwapChainPanel on Windows
3 participants