Skip to content

Commit

Permalink
Merge pull request #1685 from NogginBops/pal2-work
Browse files Browse the repository at this point in the history
[PAL2] PAL2 native platform work
  • Loading branch information
NogginBops committed Mar 7, 2024
2 parents f938176 + ad7b11c commit e92d5d7
Show file tree
Hide file tree
Showing 142 changed files with 13,606 additions and 1,763 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
*.ogg binary
*.zip binary
*.pdf binary

*.ttf binary
26 changes: 26 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,32 @@

**Note**: The generated functions currently do not have xml documentation attached to them, this will be available in the final release.

## 4.8.2

* FIX: Fixed issue where setting `NativeWindow.WindowState = WindowState.Normal` while fullscreen would not exit fullscreen. (@Th3Dilli)

* API: Added `NativeWindow.FramebufferSize`, `NativeWindow.OnFramebufferResize`, and `NativeWindow.FramebufferResize` to be able to properly get the framebuffer size of the window (useful on macos where framebuffer size is not equal to client size). (@NogginBops)

* API: Added `GameWindowSettings.Win32SuspendTimerOnDrag` propery that allows the internal timer to be suspended while the window is moved or resized. Without this dragging the window will cause an abnormally large time delta since the last frame. (@MV10)

* API: Made `NativeWindowSettings.Size` obsolete in favour of `NativeWindowSettings.ClientSize` (`NativeWindowSettings.Size` has always set the client size of the window, this namechange just makes this clear). (@MV10)

* API: Added ability to override OpenAL and OpenCL native library search path by setting `OpenALLibraryNameContainer.OverridePath` or `OpenCLLibraryNameContainer.OverridePath`. (@NogginBops)

* API: Added `NativeWindowSettings.AutoIconify` and `NativeWindow.AutoIconify` property to control if the window gets minimized if it loses focus while fullscreen. (@MV10)

* API: Added missing enums to `GetPName`. (@BoyBaykiller)

* FIX: Fixed an issue where creating a `NativeWindow` on wayland would freeze in the constructor. (@Th3Dilli)

* BREAKING: Re-implemented `Box2/3.Inflate` to work like `System.Drawing.Rectangle.Inflate`. The old behaviour can be found using `Box2/3.Extend`, as the previous obsoletion message stated. (@MV10, @NogginBops)

* Add example of how to implement `IBindingsContext` in the documentation comments on `IBindingsContext`. (@utkumaden)

* Internal changes to make the build system simpler and easier to modify. (@NogginBops)

* Internal changes from `Math` to `MathF` where appropriate. (@MV10)

## 4.8.1

* API: Added `NativeWindow.HasTransparentFramebuffer` to be able to check if a transparent framebuffer was created successfully. (@NogginBops)
Expand Down
2 changes: 1 addition & 1 deletion build/build.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<!-- so we must later copy the nuget.exe out from this package into our own. -->
<!-- This was not needed when we ran our build using an .fsx file using paket to download dependencies as -->
<!-- paket downloaded these dependencies into a project local folder. -->
<PackageReference Include="NuGet.CommandLine" Version="6.7.0" GeneratePathProperty="true">
<PackageReference Include="NuGet.CommandLine" Version="6.9.1" GeneratePathProperty="true">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 4 additions & 4 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ STRATEGY: MIN
RESTRICTION: || (== netcoreapp3.1) (== netstandard2.0) (== netstandard2.1)
NUGET
remote: https://api.nuget.org/v3/index.json
FsCheck (2.16.5)
FsCheck (2.16.6)
FSharp.Core (>= 4.2.3)
FsCheck.Xunit (2.16.5)
FsCheck (2.16.5)
FsCheck.Xunit (2.16.6)
FsCheck (2.16.6)
xunit.extensibility.execution (>= 2.2 < 3.0)
FSharp.Core (4.2.3)
System.Collections (>= 4.0.11)
Expand Down Expand Up @@ -567,7 +567,7 @@ NUGET
System.Xml.ReaderWriter (>= 4.3)
xunit.abstractions (2.0.1)
NETStandard.Library (>= 1.6)
xunit.assert (2.4.2)
xunit.assert (2.6)
NETStandard.Library (>= 1.6.1)
xunit.extensibility.core (2.2)
NETStandard.Library (>= 1.6)
Expand Down
12 changes: 11 additions & 1 deletion src/OpenAL/OpenTK.Audio.OpenAL/OpenALLibraryNameContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ namespace OpenTK.Audio.OpenAL
/// </summary>
public class OpenALLibraryNameContainer
{
/// <summary>
/// Overrides any platform detection logic and directly searches for the OpenAL library using the provided path.
/// If this is <c>null</c> then no override will happen.
/// </summary>
public static string OverridePath { get; set; } = null;

/// <summary>
/// Gets the library name to use on Windows.
/// </summary>
Expand Down Expand Up @@ -48,7 +54,11 @@ public class OpenALLibraryNameContainer
/// <returns>Library name.</returns>
public string GetLibraryName()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
if (OverridePath != null)
{
return OverridePath;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Android;
}
Expand Down
11 changes: 9 additions & 2 deletions src/OpenTK.Compute/OpenCL/OpenCLLibraryNameContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ namespace OpenTK.Compute.OpenCL
public class OpenCLLibraryNameContainer
{
/// <summary>
/// Gets the library name to use on Linux.
/// Overrides any platform detection logic and directly searches for the OpenCL library using the provided path.
/// If this is <c>null</c> then no override will happen.
/// </summary>
public static string OverridePath { get; set; } = null;

public string Linux => "libOpenCL.so.1";

/// <summary>
Expand All @@ -36,7 +39,11 @@ public class OpenCLLibraryNameContainer
/// <returns>Library name.</returns>
public string GetLibraryName()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
if (OverridePath != null)
{
return OverridePath;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ANDROID")))
{
return Android;
}
Expand Down
38 changes: 38 additions & 0 deletions src/OpenTK.Core/Context/IBindingsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@ namespace OpenTK
/// <summary>
/// Provides methods for querying available functions in a bindings context.
/// </summary>
/// <remarks>
/// If you wish to use OpenTK OpenGL bindings in a custom environment see
/// the example for a tutorial on its usage.
/// </remarks>
/// <example>
/// In order to use this interface, you need to figure out how to load OpenGL
/// function pointers in your custom environment. For example, if you are
/// providing a custom window using SDL, you would use the C function
/// <c>SDL_GL_GetProcAddress</c> to implement this interface.
///
/// <code>
/// using System;
/// using System.Runtime.InteropServices;
/// using OpenTK;
/// using OpenTK.Graphics.OpenGL4;
///
/// public class MySDLBindingsContext : IBindingsContext
/// {
/// public IntPtr GetProcAddress(string procName)
/// {
/// [DllImport("SDL2")]
/// extern static IntPtr SDL_GL_GetProcAddress([MarshalAs(UnmanagedType.LPStr)] string procName);
///
/// return SDL_GL_GetProcAddress(procName);
/// }
/// }
///
/// /// ...
///
/// // In order to load the bindings, call the following function with this
/// // new class you implemented.
/// GL.LoadBindings(new MySDLBindingsContext());
/// </code>
///
/// Do note that every OpenTK.Graphics.XXX namespace has its own pointer table.
/// If you have mixed and matched the namespaces used in your project, you might
/// run into exceptions telling you that the bindings are not loaded.
/// </example>
public interface IBindingsContext
{
/// <summary>
Expand Down
72 changes: 68 additions & 4 deletions src/OpenTK.Core/Platform/ComponentSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ public class ComponentSet : IClipboardComponent,
private IShellComponent? _shellComponent;
private IJoystickComponent? _joystickComponent;

public IWindowComponent Window => _windowComponent;

public ISurfaceComponent Surface => _surfaceComponent;

public IOpenGLComponent OpenGL => _openGLComponent;

public IDisplayComponent Display => _displayComponent;

public IShellComponent Shell => _shellComponent;

public IMouseComponent Mouse => _mouseComponent;

public IKeyboardComponent Keyboard => _keyboardComponent;

public ICursorComponent Cursor => _cursorComponent;

public IIconComponent Icon => _iconComponent;

public IClipboardComponent Clipboard => _clipboardComponent;

public IJoystickComponent Joystick => _joystickComponent;

/// <summary>
/// Indicated whether the component set has been initialized.
/// </summary>
Expand Down Expand Up @@ -402,6 +424,18 @@ void IWindowComponent.SetSize(WindowHandle handle, int width, int height)
_windowComponent!.SetSize(handle, width, height);
}

/// <inheritdoc/>
void IWindowComponent.GetBounds(WindowHandle handle, out int x, out int y, out int width, out int height)
{
_windowComponent!.GetBounds(handle, out x, out y, out width, out height);
}

/// <inheritdoc/>
void IWindowComponent.SetBounds(WindowHandle handle, int x, int y, int width, int height)
{
_windowComponent!.SetBounds(handle, x, y, width, height);
}

/// <inheritdoc/>
void IWindowComponent.GetClientPosition(WindowHandle handle, out int x, out int y)
{
Expand All @@ -426,6 +460,18 @@ void IWindowComponent.SetClientSize(WindowHandle handle, int width, int height)
_windowComponent!.SetClientSize(handle, width, height);
}

/// <inheritdoc/>
void IWindowComponent.GetClientBounds(WindowHandle handle, out int x, out int y, out int width, out int height)
{
_windowComponent!.GetClientBounds(handle, out x, out y, out width, out height);
}

/// <inheritdoc/>
void IWindowComponent.SetClientBounds(WindowHandle handle, int x, int y, int width, int height)
{
_windowComponent!.SetClientBounds(handle, x, y, width, height);
}

/// <inheritdoc/>
void IWindowComponent.GetMaxClientSize(WindowHandle handle, out int? width, out int? height)
{
Expand Down Expand Up @@ -469,19 +515,19 @@ void IWindowComponent.SetMode(WindowHandle handle, WindowMode mode)
}

/// <inheritdoc/>
public void SetFullscreenDisplay(WindowHandle window, DisplayHandle? display)
void IWindowComponent.SetFullscreenDisplay(WindowHandle window, DisplayHandle? display)
{
_windowComponent!.SetFullscreenDisplay(window, display);
}

/// <inheritdoc/>
public void SetFullscreenDisplay(WindowHandle window, DisplayHandle display, VideoMode videoMode)
void IWindowComponent.SetFullscreenDisplay(WindowHandle window, DisplayHandle display, VideoMode videoMode)
{
_windowComponent!.SetFullscreenDisplay(window, display, videoMode);
}

/// <inheritdoc/>
public bool GetFullscreenDisplay(WindowHandle window, [NotNullWhen(true)] out DisplayHandle? display)
bool IWindowComponent.GetFullscreenDisplay(WindowHandle window, [NotNullWhen(true)] out DisplayHandle? display)
{
return _windowComponent!.GetFullscreenDisplay(window, out display);
}
Expand Down Expand Up @@ -511,7 +557,7 @@ bool IWindowComponent.IsAlwaysOnTop(WindowHandle handle)
}

/// <inheritdoc/>
public void SetHitTestCallback(WindowHandle handle, HitTest? test)
void IWindowComponent.SetHitTestCallback(WindowHandle handle, HitTest? test)
{
_windowComponent!.SetHitTestCallback(handle, test);
}
Expand Down Expand Up @@ -678,6 +724,12 @@ void IMouseComponent.SetPosition(int x, int y)
_mouseComponent!.SetPosition(x, y);
}

/// <inheritdoc/>
void IMouseComponent.GetMouseState(out MouseState state)
{
_mouseComponent!.GetMouseState(out state);
}

/// <inheritdoc/>
DisplayHandle IDisplayComponent.Open(int index)
{
Expand Down Expand Up @@ -780,6 +832,18 @@ Key IKeyboardComponent.GetKeyFromScancode(Scancode scancode)
return _keyboardComponent!.GetKeyFromScancode(scancode);
}

/// <inheritdoc/>
void IKeyboardComponent.GetKeyboardState(bool[] keyboardState)
{
_keyboardComponent!.GetKeyboardState(keyboardState);
}

/// <inheritdoc/>
KeyModifier IKeyboardComponent.GetKeyboardModifiers()
{
return _keyboardComponent!.GetKeyboardModifiers();
}

/// <inheritdoc/>
void IKeyboardComponent.BeginIme(WindowHandle window)
{
Expand Down
6 changes: 4 additions & 2 deletions src/OpenTK.Core/Platform/Enums/Key.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,23 @@ public enum Key
/// </summary>
RightControl,
/// <summary>
/// The left alt key.
/// The left alt key (left Option on mac).
/// </summary>
LeftAlt,
/// <summary>
/// The right alt (alt-gr) key.
/// The right alt (alt-gr) key (right Option on mac).
/// </summary>
RightAlt,
/// <summary>
/// The left "OS" key.
/// On windows this is the left windows key.
/// On macOS this is the left Command key.
/// </summary>
LeftGUI,
/// <summary>
/// The right "OS" key.
/// On windows this is the right windows key.
/// On macOS this is the right Command key.
/// </summary>
RightGUI,

Expand Down
Loading

0 comments on commit e92d5d7

Please sign in to comment.