UltravioletFramework / ultraviolet

The Ultraviolet Framework is a .NET game development framework written in C#.
https://github.com/UltravioletFramework/ultraviolet/wiki
MIT License
541 stars 46 forks source link

Getting a window native pointer #122

Closed Ikeiwa closed 4 years ago

Ikeiwa commented 4 years ago

Hi, I'm working on a project that require advanced window feature and I wondered if there was currently a way to get the native pointer of a window to apply special window styles (this and this), and also set the clearing color to transparent, right now if I try to set it to transparent I just get a black background. I'm trying to make a transparent, on top and clic-through window.

tlgkccampbell commented 4 years ago

Probably the easiest way is to start Ultraviolet headless (configuration.Headless = true) so that it doesn't create a primary window. You can then create the window yourself using the Win32 API and add it to the Ultraviolet context with uv.GetPlatform().Windows.CreateFromNativePointer(). You can make this your application's primary window with uv.GetPlatform().Windows.DesignatePrimary().

Unfortunately, I'm not familiar with the steps that would be necessary to make the window transparent.

Ikeiwa commented 4 years ago

I manage to create a native window and use CreateFromNativePointer but when I try to use DesignatePrimary I get an error :

System.ArgumentNullException: 'Value cannot be null.
Parameter name: settings'
tlgkccampbell commented 4 years ago

Can you post a complete stack trace?

Ikeiwa commented 4 years ago
Exception thrown: 'System.ArgumentNullException' in Ultraviolet.Core.dll
   at Ultraviolet.Core.Contract.Require[T](T argument, String message)
   at Ultraviolet.UltravioletApplicationWindowSettings.Save(UltravioletApplicationWindowSettings settings)
   at Ultraviolet.UltravioletApplicationSettings.Save(String path, UltravioletApplicationSettings settings)
   at Ultraviolet.UltravioletApplication.SaveSettings()
   at Ultraviolet.UltravioletApplication.uv_PrimaryWindowChanging(IUltravioletWindow window)
   at Ultraviolet.SDL2.Platform.SDL2UltravioletWindowInfo.OnPrimaryWindowChanging()
   at Ultraviolet.SDL2.Platform.SDL2UltravioletWindowInfo.DesignatePrimary(IUltravioletWindow window)
   at DesktopMascot.Game.OnLoadingContent() in F:\VisualProjects\DesktopMascot\Game.cs:line 48
tlgkccampbell commented 4 years ago

This bug should be fixed in the newest version of Ultraviolet, which I've just pushed to NuGet.