Git Product home page Git Product logo

dotnet / silk.net Goto Github PK

View Code? Open in Web Editor NEW
3.7K 68.0 349.0 1.14 GB

The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX bindings library your mother warned you about.

Home Page: https://dotnet.github.io/Silk.NET

License: MIT License

C# 99.76% Batchfile 0.01% Shell 0.01% GLSL 0.01% PowerShell 0.01% C 0.02% C++ 0.01% Makefile 0.01% CMake 0.01% Java 0.06% HLSL 0.01% HTML 0.01% CSS 0.14% JavaScript 0.01% Zig 0.01% WGSL 0.01%
opengl csharp vulkan openal opencl native graphics 3d graphics-library game-development

silk.net's Introduction


NuGet Version Preview Feed CI Build Join our Discord

Silk.NET is your one-stop-shop for high-speed .NET multimedia, graphics, and compute; providing bindings to popular low-level APIs such as OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX.

Use Silk.NET to spruce up applications with cross-platform 3D graphics, audio, compute and haptics!

Silk.NET works on any .NET Standard 2.0 compliant platform, including .NET 6.0, Xamarin, .NET Framework 4.6.1+, and .NET Core 2.0+.


.NET Foundation

Proud to be an official project under the benevolent .NET Foundation umbrella.

Features

Performance

Having poured lots of hours into examining generated C# code and its JIT assembly, you can count on us to deliver blazing fast bindings with negligible overhead induced by Silk.NET!

Up-to-date

With an efficient bindings regeneration mechanism, we are committed to ensuring our bindings reflect the latest specifications with frequent updates generated straight from the upstream sources.

High-level utilities

In addition to providing high-speed, direct, and transparent bindings, we provide high-level utilities and wrappers to maximise productivity in common workloads such as platform-agnostic abstractions around Windowing and Input, bringing your apps to a vast number of platforms without changing a single line!

Good-to-go

Silk.NET caters for anything you could need in swift development of multimedia, graphics, compute applications. Silk.NET is an all-in-one solution, complete with Graphics, Compute, Audio, Input, and Windowing.

The team

We currently have the following maintainers:

In addition, the Silk.NET working group help drive larger user-facing changes providing key consultation from the perspective of dedicated users and professionals.

Building from source

Prerequisites

  • .NET 6 SDK and .NET 7 SDK
  • Android, iOS, and Mac Catalyst workloads (use dotnet workload install android ios maccatalyst to install them)
    • On Linux, ios and maccatalyst should be omitted as they are not available
  • Android SDK versions 31, 33, and 34 with NDK tools installed
    • On Windows, for best results, this should be installed into C:\ProgramData\Android\android-sdk
  • Java JDK 11+
  • Visual Studio 2022 Community version 17.0 or later (optional)

Instructions

  • Clone the repository
    • Note: Avoid performing a recursive clone as the submodules are not necessary for a normal build
  • Run build.sh, build.cmd, build.ps1, or nuke compile
    • On Linux, you may need to pass --msbuild-properties AndroidSdkDirectory=/path/to/android/sdk
  • Use the built assemblies
    • To get .nupkgs that you can use with NuGet instead, use nuke pack

There are more advanced build actions you can do too, such as FullBuild, Pack, FullPack, among others which you can view by doing nuke --plan.

Contributing

Silk.NET uses and encourages Early Pull Requests. Please don't wait until you're done to open a PR!

  1. Fork Silk.NET
  2. Add an empty commit to a new branch to start your work off: git commit --allow-empty -m "start of [thing you're working on]"
  3. Once you've pushed a commit, open a draft pull request. Do this before you actually start working.
  4. Make your commits in small, incremental steps with clear descriptions.
  5. Tag a maintainer when you're done and ask for a review!

The Silk.NET solution is very large. Learn about how you can combat this using our build process in CONTRIBUTING.md.

Funding

Silk.NET requires significant effort to maintain, as such we greatly appreciate any financial support you are able to provide!

This helps ensure Silk.NET's long term viability, and to help support the developers who maintain Silk.NET in their free time. Kai is accepting GitHub Sponsorships.

Further resources

Licensing and governance

Silk.NET is distributed under the very permissive MIT/X11 license and all dependencies are distributed under MIT-compatible licenses.

Silk.NET is a .NET Foundation project, and has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the .NET Foundation Code of Conduct.


JetBrains

Special thanks to JetBrains for supporting us with open-source licenses for their IDEs.

silk.net's People

Contributors

alexrp avatar alexx999 avatar aquagoose avatar beyley avatar dependabot[bot] avatar devvoid avatar dmitrygolubenkov avatar github-actions[bot] avatar hurricankai avatar jsm174 avatar khitiara avatar krmr avatar lumi2021 avatar nathan-alden-sr avatar okaniku avatar otac0n avatar paralaxsd avatar perksey avatar philt avatar pyrdacor avatar rhyswhy avatar roeyskoe avatar silkdotnet avatar thargy avatar theprotonfactor avatar thomasmiz avatar tilkinsc avatar vincenzoml avatar whiteblackgoose avatar zvasya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

silk.net's Issues

actual examples

Silk looks really interesting, but the examples provided (at the tike of my posting) are copied and pasted console.writeLine("hello world") examples. Where might I be able to find actual useful Silk examples?

Thanks

Headless mode

  • [ x] I have definitely checked that there are no proposals for this already in the proposals folder

Summary of feature

It is not a thing that will be used commonly but for some people it will be useful. Creating headless mode could be just use for handling input from controllers. Since Silk.net is very cross platform this could be beneficial.

What headless mean in my point of view. Do not create a window.

Comments

C# 8 Nullable Support

Summary of feature

C# Nullable to be supported / used in the libary. C# 8 is just around the corner and this would improve ease of use with C# 8. Personally I don't feel like this is slowing development of Libs at all.

Comments

Silk.NET's 2020 outlook

Silk.NET's 2020 outlook

Last year in June, I started Silk.NET with some great friends to build a set of fresh bindings to OpenGL (and related libraries) built for modern C#. And in August, we achieved that goal after only 2 months of development. That's crazy! Needless to say, 2019 was a very crazy year for me and Silk.NET but this next year is going to be even crazier!

Upcoming releases

In case you're not following the progress of Silk.NET using our progress tracker, we have 1 more preview (Preview 4) planned with an optional follow-up preview (Preview 5) if any bugs are found before the 1.0 release. The Silk Working Group has finalized the dates for the next releases and they are as follows:

  • 1.0 Preview 4: Friday 28th February
  • 1.0 Preview 5: N.E.T. Friday 24th April (it may release any time before 1.0 if bugs are found)
  • 1.0 Full Release: Friday 12th June
  • 2.0 Preview 1: Q4 2020/Q1 2021

WHAT? Is that a 1.0 release date announcement?!?! I hear you saying. Yes, yes it is. Only 3 days after our 1st birthday will be the 1st full release of Silk.NET, which we're all very excited about. Silk's philosophy from the start has been rapid evolution in an accelerated timeframe, and we will continue on the path we've paved all the way to 2.0.

Silk.NET 2.0

Silk.NET 2.0 is the next big release after 1.0 (shocker, right?) and will include many awesome features, such as expansion beyond Khronos APIs. We still don't know what'll be in this release ourselves, but this will be our first release targeting .NET 5 exclusively. This is so we aren't held back by the limitations of .NET Standard as we have been a couple of times during the development of 1.0. Current plans include bindings to assimp, DirectX, Metal, and I'm sure we'll come up with more stuff to bind to when the time comes ;)

Project Hedra

Project Hedra is the first commercial project that uses Silk.NET and it's truly beautiful. It's an ambitious open-world, low-poly RPG. Choose your class, explore endless procedurally generated worlds, unlock different skills and complete quests. 2020 truly is starting off strong with a January 24th release date, so be sure to check out its website and/or Steam page.

Closing

This past year has been a great year for Silk.NET and Ultz as a whole, and I'm really excited about what happens over the course of this next year and, heck, over the course of this next decade! Thank you all for joining us on the journey from preview to release, and we can't wait to see what happens next for Silk.NET.

Dylan Perks
Chief Executive at Ultz Limited
Maintainer at the Silk Working Group

Vsync broken in GlfwWindow

Summary

Vsync is the wrong way round.

When creating a window and setting vsync to on the framerate is unlimited and setting vsync off limits the framerate to the refresh rate. This is the exact opposite of the desired behaviour.

Comments

Looking at GlfwWindow.cs in ''RaiseRenderFrame" on line 631 to 641 there is the below code:

// Identical to RaiseUpdateFrame.
if (FramesPerSecond > double.Epsilon
     && (VSync == VSyncMode.Off || VSync == VSyncMode.Adaptive && IsRunningSlowly))
{
    var sleepTime = _renderPeriod - _renderStopwatch.Elapsed.TotalSeconds;

    if (sleepTime > 0.0)
    {
        Thread.Sleep((int) (1000 * sleepTime));
    }
}

Reading the above, unless i'm mistaken if vsync is off or adaptive and running slow, we sleep the thread resulting in the framerate being limited whereas if vsync is on we don't sleep therefore the framerate is unlimited.

Surely this logic is backwards?

More examples (compute, 2D charts)

I would like to get to know your library. But I need more examples, much more.

  • hardware accelerated 2D charts (is that possible)
  • what to do to build a fully working 3D control like HelixViewPort3D
  • compute stuff, which algorithms can be accelerated using the GPU
  • what about shader compiler

Preview4 GL.GetApi throws exception

Summary

A call to GL.GetApi throws the following exception:

System.TypeInitializationException
  HResult=0x80131534
  Message = The type initializer for 'Silk.NET.OpenGL.GL' threw an exception.
  Source = Silk.NET.OpenGL
  StackTrace:
   at Silk.NET.OpenGL.GL.GetApi()
   ...
  InnerException:
    KeyNotFoundException: The given key 'Silk.NET.Core.Loader.GLSymbolLoader' was not present in the dictionary.

Steps to reproduce

  • Platform: Desktop, Windows 7
  • Framework Version: .NET Core 3.1
  1. I created a window with GlfwPlatform.Instance.GetView(options) as IWindow.
  2. GL.GetApi is then called in a static ctor of some class. But the call happens only after everything is initialized as the static ctor is invoked when I first try to access the GL context (which worked in preview3).

Comments

The assembly in which is the call to GetApi is a .NET Standard 2.0 DLL and only has Silk.NET.OpenGL as a nuget reference. The main executable is a .NET Core 3.1 EXE which references the mentioned DLL as well as most Silk.NET nuget packages (except for Vulkan). All referenced versions are preview4.

Infinite loop in OpenAL GetStringList

The loop in GetStringList will never break because Marshal.PtrToStringAnsi only returns null when the pointer passed into it is null.

A better alternative might be to check if the string is null or if its length is 0.

PhysicalDeviceMemoryProperties and similar structures should use fixed buffers

The C declaration goes as follows:

typedef struct VkPhysicalDeviceMemoryProperties {
    uint32_t        memoryTypeCount;
    VkMemoryType    memoryTypes[VK_MAX_MEMORY_TYPES];
    uint32_t        memoryHeapCount;
    VkMemoryHeap    memoryHeaps[VK_MAX_MEMORY_HEAPS];
} VkPhysicalDeviceMemoryProperties;

MemoryTypes and MemoryHeaps members should be fixed buffers rather than a collection of fields inside the structure.

Tracking Issue for Silk.NET 1.0

Development

Workflow

  • Development Complete
  • Pre-release
  • AdvancedDLSupport grant obtained
  • Pre-release 2 (bugfix)
  • Add a metapackage containing the core spec of all subsystems.
  • Pre-release 3 with Vulkan support
  • Pre-release 4 with OpenCL support
  • Pre-release 5 (bugfix)
  • 1.0 ๐ŸŽ‰

Miscellaneous Tasks

  • Setup Azure Pipelines
  • Setup a development NuGet feed

Missing/Wrong mapped keys on Xbox 360 Wireless

Summary

I noticed that some keys are not mapped correctly to names.
Button number 11 (counting from zero) is responsible for DPadUp but it s not correct. When i click DPadRight then this button is true.
There is not a a DPadLeft.

Steps to reproduce

  • Platform: Desktop
  • Framework Version: .NET Core 3
  1. First I did this
    I created from my .Net Standard 2.1 Library
  2. Then I did this
    Then I called function responsible for detecting buttons

Comments

There is list of detected buttons
First collumn is index, second current state, last is name of button

0 False A
1 False B
2 False X
3 False Y
4 False LeftBumper
5 False RightBumper
6 False Back
7 False Start
8 False Home
9 False LeftStick
10 False RightStick
11 False DPadUp
12 False DPadRight
13 False DPadDown

Consider using dependency injection in ISilkPlatform

Preamble

ISilkPlatform was created to represent one implementation of Silk.NET's APIs. However, during development, it ended up becoming a windowing platform, rather than a platform for all APIs.

As a result of this, the OpenGL bindings are currently dependent on Silk.NET.Windowing, which means that the user will need to download our windowing APIs even if they've chosen to bypass it (which should be allowed).

Proposal

  • Move ISilkPlatform and Silk (static class) into Silk.NET.Core
  • Remove all module-specific APIs from ISilkPlatform
  • Add methods for dependency injection into ISilkPlatform, such as Use<T>(T instance) and GetInstance<T>()
  • Add an IWindowPlatform interface
  • Make Window (static class) inject the appropriate IWindowPlatform for the current environment

Create property per button and axis

  • I have definitely checked that there are no proposals for this already in the proposals folder

Summary of feature

It would be nice if we can get e.g Gamepads[0].Buttons.A vs Gamepads[0].Buttons[0]
The same for Joystick. Non standard buttons could be available in Buttons.Others[number]

Comments

Use a custom symbol loader

Summary

We need to create a custom symbol loader using ADL so that we're able to load extension functions. To do this, we first need to champion AdvancedDLSupport 4.0.0, and then we need to implement ISymbolLoader using glfwGetProcAddress

Comments

Add any other context about the problem here.

Additional windows do not properly close

Summary

Can not close additional windows created. Messing around with a IMGUI library and was trying to implement something like Viewports from Dear IMGUI where it creates windows on the fly to support dragging around outside of the main window.

If you close the smaller window the IsClosing flag is set to true, but it never actually closes.

Steps to reproduce

  • Platform: Desktop
  • Framework Version: .NET Core 3
  static void Main(string[] args)
        {
            var windowOptions = new WindowOptions();
            windowOptions.Size = new System.Drawing.Size(800, 600);
            windowOptions.Title = "Hello World";

            var mainWindow = Window.Create(windowOptions);
            var windows = new List<IWindow>();
            windows.Add(CreateWindow("test", 200, 200));

            mainWindow.Open();
            while (!mainWindow.IsClosing)
            {
                mainWindow.DoEvents();
                mainWindow.DoUpdate();
                mainWindow.DoRender();

                for (int i = windows.Count - 1; i >= 0; i--)
                {
                    var it = windows[i];
                    if (it.IsClosing)
                    {
                        it.Close();
                        //     windows.RemoveAt(i);
                    }
                    // else
                    {

                        it.DoEvents();
                        it.DoUpdate();
                        it.DoRender();
                    }
                }

                System.Threading.Thread.Sleep(16);
            }

        }

        public static IWindow CreateWindow(string title, int width, int height)
        {
            var windowOptions = new WindowOptions();
            windowOptions.Size = new System.Drawing.Size(200, 200);
            windowOptions.Title = "Hello World";


            var window = Window.Create(windowOptions);
            window.Open();
            return window;
        }

GL.GetShaderInfoLog calls return a string filled with whitespace instead of the expected log.

Summary

GL.*InfoLog calls return a string filled with whitespace instead of the expected log.

Steps to reproduce

  • Platform: Desktop
  • Framework Version: .NET Standard 2.0 / .NET Framework 472
  1. Create a GLSL program with syntax errors
  2. Compile it and retrieve it's compilation log using GetShaderInfoLog
  3. GetShaderInfoLog returns string full of whitespace with no characters.

Comments

It might have to do with how the string is marshalled.

Refactoring of BuildTools/Common/Profile

This will need quite some refactoring to propperly work with C# 8 Nullable, to guarantee non-null values everywhere.
For now (in #40) everything is set to some default value, but this could lead to some unexpected behaviour (for example, if for whatever reason ClassName isn't set, a class with an empty name will be generated, which means invalid generated code.
Low priority, as it works, but when working with this code, consider refactoring it, or at least take care.

Multiple calls to GetInput extension lead to new glfw input contexts

Summary

Multiple calls to the GetInput extension will create a new glfw input context each time. Therefore event registering on other than the first input context will not raise the events.

Steps to reproduce

  • Platform: Any
  • Framework Version: Any
  1. Create one method for initialize keyboard events and one for initialize mouse events.
  2. In each method use GetInput() to retrieve the input context and add event handlers for keyboard events (first method) and mouse events (second method).
  3. Mouse event callbacks are not called as the used input context is not considered by Silk. Only the first one is.

The problem is the method GetInput below. It creates a new instance of the input context instead of reusing the existing one if present.

    public class GlfwInputPlatform : IInputPlatform
    {
        public bool IsApplicable(IWindow window)
        {
            return window is GlfwWindow;
        }

        public IInputContext GetInput(IWindow window)
        {
            // the cast isn't needed, but is used to make sure that what we've got is actually a GlfwWindow
            return new GlfwInputContext((GlfwWindow)window); // <- Problem, should reuse context when called for the second time
        }
    }

Possible solutions

  • Reuse context on second and subsequent calls
  • Documentation that each time it is called a new context is created (in this case rename to CreateInput)
  • Make Silk register each of the created contexts and ensure that all of them are handled

I would prefer first fix.

Obtain a new AdvancedDLSupport license grant

Previously, Ultz had a license grant allowing static linking of ADL (the library we use for native interop) for iOS. This has since been invalidated and needs to be renewed for the rebrand of ElgarTK to Silk.NET.

Details for the licensor

Library: Silk.NET
Licensor: Firwood Software
Licensee: Ultz Limited
Signatory: Jarl Gullberg

Status

  • We're waiting for the licensor (@Nihlus from @firwood-software) to grant a license.
  • We're waiting for the PDF version of the grant to be added to the Silk.NET-Docs repo
  • We're waiting for the plaintext version of the grant to be added to THIRD_PARTIED.md.
  • We're all set for mobile support.

IKeyboard.IsKeyPressed() crashes with GLFW.

Summary

When checking if a key is pressed using IKeyboard.IsKeyPressed(Key); when using GLFW input, there is the potential for certain keys to cause an ArgumentOutOfRangeException if the key is not pressed. If the key is pressed the crash doesn't occur but there's always the potential for some keys to crash if unpressed.

Steps to reproduce

  • Platform: Desktop
  • Framework Version: .NET Core 3
  1. Use the same code as found in the input example with GLFW.
  2. On a KeyDown or KeyUp event, add the code:
private void KeyDown(IKeyboard keyboard, Key key)
{
    // Determine if either the "shift," "control," "alt" or "meta" (Windows) keys are pressed.
    bool shiftDown = keyboard.IsKeyPressed(Key.LShift) || keyboard.IsKeyPressed(Key.RShift);
    bool controlDown = keyboard.IsKeyPressed(Key.LControl) || keyboard.IsKeyPressed(Key.RControl);
    bool altDown = keyboard.IsKeyPressed(Key.LAlt) || keyboard.IsKeyPressed(Key.RAlt);
    bool metaDown = keyboard.IsKeyPressed(Key.WinLeft) || keyboard.IsKeyPressed(Key.WinRight);

    // Print the state of each modifier key to the console.
    Console.WriteLine($"Key={key}, Shift={shiftDown}, Ctrl={controlDown}, Alt={altDown}, Meta={metaDown}");
}
  1. Try pressing any key. You should end up with an ArgumentOutOfRangeException when checking if CTRL is down.
  2. Now try pressing CTRL. You should crash on Alt now.
  3. Try pressing Alt. CTRL will crash.
  4. Meta is inapplicable to Windows since the OS hijacks it and the program never gets that keystroke, so for that you'll need to be on Linux or something, but I imagine if you press CTRL and Alt, Meta will crash.

Comments

I could be wrong but I noticed that Shift is unaffected by this bug. I haven't seen it crash yet. Seems to be only CTRL, Alt and possibly Meta? It might affect other keys as well but I haven't tried them. I should also note that this bug is in Preview 2, I haven't tried on git yet.

At the time of writing there is a working example of this bug in my Peace Engine, start up the test app and start pressing keys. Should crash in the same way described here.

Cursor mode is not fully implemented :/

Summary of feature

Cursor mode enum is there but it is not used yet nor is it changeable.

Comments

Basically I forgot to add this functionality in my previous PR. Shame on me. :( This has still to be implemented. Shouldn't be much of work hopefully.

Add a GetAllVideoModes method to IMonitor to aid video mode selection.

  • I have definitely checked that there are no proposals for this already in the proposals folder

Summary of feature

We should add a GetAllVideoModes method to IMonitor so that users can access all the available video modes as described by GLFW. This will allow for better resolution changing for Silk.NET.

Comments

Requested by Zaphyk, working group member and Project Hedra dev. High priority.

Can't find GLFW3 in preview 4

Summary

Even after updating my project to use Silk.NET version 1.0.0-preview4, when running on a computer that doesn't have glfw3 installed, I get the following:

Unhandled exception. System.NotSupportedException: Couldn't find a suitable windowing platform. You probably forgot to copy a glfw3 library into your bin/Debug or bin/Release folder (this won't be a problem in Preview 4)

Steps to reproduce

  • Platform: Desktop, Windows 10
  • Framework Version: .NET Core 3.1.101
  1. Create a project with the following Program.cs:
namespace HelloWindow
{
    static class Program
    {
        static void Main(string[] args)
        {
            var options = WindowOptions.Default;
            options.Title = "Hello Window!";

            var window = Window.Create(options);

            window.Run();
        }
    }
}
  1. Run the project with either dotnet run -c Release or dotnet run -c Debug.
    • Make sure you don't have a copy of glfw3.dll in your path or Release/Debug directories!

Comments

I'm really enjoying using Silk.NET, thanks for this awesome library ๐Ÿ˜ƒ

AccessViolation when running InputTest example

Summary

An AccessViolationException is thrown when running the examples/InputTest.

Steps to reproduce

  • Platform: Windows 10
  • Framework Version: .NET Core 3
  1. Copied glfw3.dll to examples/InputTest
  2. cd examples/InputTest
  3. Ran dotnet run

Stack trace:

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Generated_Glfw_bc0abf19_8fe1_408c_bda7_1a5a99c6e70e.SetKeyCallback_glfwSetKeyCallback_57_5240c697-dfcf-4267-9baa-39462998f515_wrapped(Silk.NET.GLFW.WindowHandle*, IntPtr)
   at Generated_Glfw_bc0abf19_8fe1_408c_bda7_1a5a99c6e70e.SetKeyCallback(Silk.NET.GLFW.WindowHandle*, KeyCallback)
   at Silk.NET.Input.Desktop.InputHandler.RegisterContext(Silk.NET.Input.Desktop.GlfwInputContext)
   at Silk.NET.Input.Desktop.GlfwInputContext..ctor(Silk.NET.Windowing.Desktop.GlfwWindow)
   at Silk.NET.Input.Desktop.GlfwInputPlatform.GetInput(Silk.NET.Windowing.Common.IWindow)
   at Silk.NET.Input.InputWindowExtensions.GetInput(Silk.NET.Windowing.Common.IWindow)
   at InputTest.Program.Main()

Comments

examples/Triangle worked fine.

Rumble API

Currently, Silk.NET lacks a rumble API. This is because we decided we wanted to make a more extensive API than one function, to allow for unique cases such as Nintendo Switch's HD rumble. In a future preview, we should add a rumble API in.

Mouse movement event in IMouse

  • I have definitely checked that there are no proposals for this already in the proposals folder

Summary of feature

There should be a way to receive an event when the mouse cursor moves and get the position and relative movement of the mouse cursor in the event.

Comments

Guess this was overlooked, I noticed IMouse doesn't have a MouseMove event or anything. Hard to write a UI framework if you can't see where the mouse is :P

Make depth buffer bits configurable

For my current game I need a depth buffer of at least 24 bits and need to enforce this on window creation. At the moment the glfw depth buffer bit hint is not called at all. Please add the depth buffer bit option to WindowOptions and call the associated glfw hint method. The default value may be GLFW_DONT_CARE to keep compatibility.

Mobile support

  • EGL window platform (for Android) - Silk.NET.Windowing.Android
  • EAGL window platform (for Apple) - Silk.NET.Windowing.Apple

Window & View separation

  • I have definitely checked that there are no proposals for this already in the proposals folder

Summary of feature

Currently, our windowing API has a lot of APIs that aren't really applicable on mobile platforms and after trying to write a UWP windowing backend, I figured that this needs a bit of work. I propose that we separate the core APIs that are common among desktop and mobile platforms into their own set of interfaces, prefixed by IView. IWindow will then inherit the IView interfaces so that the APIs aren't duplicated and to maximise ease of cross-platform support.

Also, a GetOrCreateView method will have to be added as mobile window usually only support one view (for UWP this is CoreWindow, for Android this is ANativeWindow, etc etc)

I'll add a proposal shortly detailing this.

Comments

https://discordapp.com/channels/521092042781229087/587346162802229298/658816946703171585
High Priority - Required for an internal project

Add built-in support for click/doubleclick

The input layer only has mouse up and down events. Double clicks are a very common use case. At the moment every Silk user is forced to implement this functionality on its own. A general built-in support is much appreciated.

Adding events for Click and DoubleClick would be nice.

Make switching from fullscreen to window possible

At the moment when switching to fullscreen a GLFW monitor is set. When trying to return to a different window state (Normal, Minimized, Maximized) the monitor is still set and therefore fullscreen mode will remain.

It would be nice to allow switching back from fullscreen to window. I guess it could be done by setting the monitor back to null/0 in the mentioned case.

Consider fixing typo in announcement

Summary

Ourselves was spelt incorrectly in the 2020 announcement.

Steps to reproduce

  • Platform: All
  • Framework Version: Chrome
  1. Opened GitHub
  2. Browsed Issues on Ultz/Silk.NET
  3. Viewed #96
  4. Read "outselves"
  5. Immediately fell out my chair.

Comments

Literally unreadable.

Add/use OnXYZ event methods instead of raising events directly

Summary of feature

Add protected virtual OnXYZ methods for window events. This way users can override those methods in custom derived window classes and control the event emission by call the base.OnXYZ method or not.

The GlfwWindow implementation will basically call the OnXYZ methods instead of invoking the events directly. The default implementations of the OnXYZ methods will just raise the associated event.

Example of implementation

    // part of GlfwWindow.cs
    ...
    var delta = _renderStopwatch.Elapsed.TotalSeconds;
    
    OnRender(delta); // changed from Render?.Invoke(delta);
    
    if (ShouldSwapAutomatically)
    {
        SwapBuffers();
    }
    ...
    
    // somewhere else in GlfwWindow.cs
    protected virtual void OnRender(double delta)
    {
        Render?.Invoke(delta);
    }

Use case

A custom user window may handle the render logic internally (by overriding the OnRender method) but it may want to prevent populating the Render event to the outside or only do so based on some internal conditions.

This is also handy if it should be ensured that the additional logic is executed before the event is consumed by someone else. The developer of the custom window can call base.OnXYZ after his additional code.

    // part of MyCustomWindowClass
    protected override void OnRender(double delta)
    {
        // do some render related stuff that should be done
        // before anyone is notified about the event ...
        base.OnRender(delta); // raise the event through base method
    }

Implementation

I could implement this very quickly with a PR if you want me to.

Tracking issue for Silk.NET 2.0

Development

  • [Complete] DirectX and Windows bindings (!!!!!! MORE !!!!!!) - @Perksey
  • [Complete] Assimp bindings - @Perksey
  • [Complete] Android support - @Perksey
  • [Complete] iOS support (!!!!! NEEDS ROBUSTNESS IMPROVEMENTS ASAP !!!!!) - @Perksey
  • [Complete] SDL support - @Perksey
  • [Complete] Maths library - @HurricanKai
  • [Complete] Bindings generator overhaul - @Perksey
  • [Complete] OpenXR bindings - @Perksey
  • [Complete] Function pointer interop source generator - @HurricanKai
  • [Complete] Overload overhaul (as discussed in 14/08/2020's meeting) - @Perksey

Milestones

  • Preview 1 with Assimp and experimental OpenXR bindings (July 2020)
  • Preview 2 with SDL bindings/windowing support and new interop (Update Friday September August 2020)
  • Preview 3 with mobile windowing support (Early October Early November 2020)
  • Preview 4 with Maths, as well as DirectX bindings (Early December 2020)
  • Preview 5 release candidate (Late December 2020)
  • Full release ๐ŸŽ‰ (New Year's Day 2021)

Dates are a loose estimate and are subject to change.

GlfwProvider makes incorrect assumptions about GLFW main thread, does not work on macOS

Summary

GlfwProvider has its own dispatcher and its own GLFW thread. This seems to be to satisfy the "can only be called on main thread" stuff, but it's missing the definition of "main thread" in GLFW's documentation.

GLFW seems to imply that the main thread HAS to be the thread that called main, or well, Main in the .NET case. Putting all the GLFW calls on another thread via the dispatcher 100% violates this.

The result? Guaranteed crash using it on macOS.

Crash details
~/code/silk.net/examples/BlankWindow master|โœ“
$ dotnet run
Entry thread is 1
2019-09-29 19:05:45.045 BlankWindow[15433:1742318] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1575.12/Foundation/Misc.subproj/NSUndoManager.m:361
2019-09-29 19:05:45.046 BlankWindow[15433:1742318] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff40850e39 __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff6af993c6 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff4086be3e +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00007fff42b28c85 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
	4   Foundation                          0x00007fff42a5bcfa +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 473
	5   AppKit                              0x00007fff3de0b915 -[NSApplication run] + 916
	6   libglfw.3.3.dylib                   0x00000001075ebe85 _glfwPlatformCreateWindow + 85
	7   libglfw.3.3.dylib                   0x00000001075e5895 glfwCreateWindow + 469
	8   ???                                 0x0000000114727d6c 0x0 + 4638014828
	9   ???                                 0x0000000114727c9f 0x0 + 4638014623
	10  ???                                 0x0000000114727430 0x0 + 4638012464
	11  libcoreclr.dylib                    0x0000000104d59c3b CallDescrWorkerInternal + 124
	12  libcoreclr.dylib                    0x0000000104ba52a8 _Z26CallDescrWorkerWithHandlerP13CallDescrDatai + 104
	13  libcoreclr.dylib                    0x0000000104c696df _Z32CallDescrWorkerReflectionWrapperP13CallDescrDataP5Frame + 127
	14  libcoreclr.dylib                    0x0000000104c6a667 _ZN19RuntimeMethodHandle12InvokeMethodEP6ObjectP8PtrArrayP15SignatureNativebb + 3143
	15  ???                                 0x000000011336750a 0x0 + 4617303306
	16  ???                                 0x0000000113206994 0x0 + 4615858580
	17  ???                                 0x000000011471f175 0x0 + 4637978997
	18  ???                                 0x00000001132d5302 0x0 + 4616704770
	19  ???                                 0x00000001132deba1 0x0 + 4616743841
	20  ???                                 0x00000001132d541e 0x0 + 4616705054
	21  libcoreclr.dylib                    0x0000000104d59c3b CallDescrWorkerInternal + 124
	22  libcoreclr.dylib                    0x0000000104ba6029 _ZN18MethodDescCallSite16CallTargetWorkerEPKmPmi + 1657
	23  libcoreclr.dylib                    0x0000000104bba98f _ZN12ThreadNative20KickOffThread_WorkerEPv + 431
	24  libcoreclr.dylib                    0x0000000104b66fa3 _ZL31ManagedThreadBase_DispatchOuterP22ManagedThreadCallState + 323
	25  libcoreclr.dylib                    0x0000000104b67590 _ZN17ManagedThreadBase7KickOffEPFvPvES0_ + 32
	26  libcoreclr.dylib                    0x0000000104bbac2d _ZN12ThreadNative13KickOffThreadEPv + 397
	27  libcoreclr.dylib                    0x00000001049df384 _ZN7CorUnix10CPalThread11ThreadEntryEPv + 436
	28  libsystem_pthread.dylib             0x00007fff6c9522eb _pthread_body + 126
	29  libsystem_pthread.dylib             0x00007fff6c955249 _pthread_start + 66
	30  libsystem_pthread.dylib             0x00007fff6c95140d thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Steps to reproduce

Run BlankWindow on macOS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.