Skip to content

Commit

Permalink
Implemented missing native functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ForeverZer0 committed Jun 6, 2019
1 parent 55740af commit 288600c
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 32 deletions.
18 changes: 0 additions & 18 deletions GLFW.NET/Enums/MesaPixelFormat.cs

This file was deleted.

3 changes: 3 additions & 0 deletions GLFW.NET/Exception.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace GLFW
{
/// <summary>
/// Base exception class for GLFW related errors.
/// </summary>
public class Exception : System.Exception
{
#region Methods
Expand Down
88 changes: 74 additions & 14 deletions GLFW.NET/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,39 @@ public static class Native
#region External

/// <summary>
/// Retrieves a pointer to the Wayland display.
/// <para>The pointer is to a native <c>wl_display</c> struct defined in wayland-client.c.</para>
/// Returns the CGDirectDisplayID of the specified monitor.
/// </summary>
/// <param name="monitor">The monitor to query.</param>
/// <returns>The CGDirectDisplayID of the specified monitor, or <see cref="IntPtr.Zero" /> if an error occurred.</returns>
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetCocoaMonitor", CallingConvention = CallingConvention.Cdecl)]
public static extern uint GetCocoaMonitor(Monitor monitor);

/// <summary>
/// Retrieves a pointer to the X11 display.
/// <para>The pointer is to a native <c>Display</c> struct defined by X11..</para>
/// </summary>
/// <returns>A pointer to the X11 display struct.</returns>
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetX11Display", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetX11Display();

/// <summary>
/// Retrieves a pointer to the Wayland display.
/// <para>The pointer is to a native <c>wl_display</c> struct defined in wayland-client.c.</para>
/// </summary>
/// <returns>A pointer to the Wayland display struct.</returns>
/// <seealso href="https://github.com/msteinert/wayland/blob/master/src/wayland-client.c"/>
/// <seealso href="https://github.com/msteinert/wayland/blob/master/src/wayland-client.c" />
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetWaylandDisplay", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetWaylandDisplay();

/// <summary>
/// Retrieves a pointer to the Wayland output monitor.
/// <para>The pointer is to a native <c>wl_output</c> struct defined in wayland-client.c.</para>
/// Retrieves a pointer to the Wayland output monitor.
/// <para>The pointer is to a native <c>wl_output</c> struct defined in wayland-client.c.</para>
/// </summary>
/// <returns>A pointer to the Wayland output struct.</returns>
/// <seealso href="https://github.com/msteinert/wayland/blob/master/src/wayland-client.c"/>
/// <seealso href="https://github.com/msteinert/wayland/blob/master/src/wayland-client.c" />
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetWaylandMonitor", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetWaylandMonitor(Monitor monitor);

/// <summary>
/// Returns the pointer to the Wayland window for the specified window.
/// </summary>
Expand All @@ -61,6 +77,22 @@ public static class Native
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetX11Window", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetX11Window(Window window);

/// <summary>
/// Returns the RROutput of the specified monitor.
/// </summary>
/// <param name="monitor">The monitor to query.</param>
/// <returns>The RROutput of the specified monitor, or <see cref="IntPtr.Zero" /> if an error occurred.</returns>
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetX11Monitor", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetX11Monitor(Monitor monitor);

/// <summary>
/// Returns the RRCrtc of the specified monitor.
/// </summary>
/// <param name="monitor">The monitor to query.</param>
/// <returns>The RRCrtc of the specified monitor, or <see cref="IntPtr.Zero" /> if an error occurred.</returns>
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetX11Adapter", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetX11Adapter(Monitor monitor);

/// <summary>
/// Returns the pointer to the Cocoa window for the specified window.
/// </summary>
Expand Down Expand Up @@ -133,28 +165,56 @@ public static class Native
public static extern IntPtr GetWin32Window(Window window);

/// <summary>
/// Returns the contents of the selection as a string.
/// Returns the contents of the selection as a string.
/// </summary>
/// <returns>The selected string, or <c>null</c> if error occurs or no string is selected.</returns>
[CanBeNull]
public static string GetX11SelectionString()
{
var ptr = GetX11SelectionStringInternal();
return ptr == IntPtr.Zero ? null : Util.PtrToStringUTF8(ptr);
var ptr = GetX11SelectionStringInternal();
return ptr == IntPtr.Zero ? null : Util.PtrToStringUTF8(ptr);
}

/// <summary>
/// Sets the clipboard string of an X11 window.
/// Sets the clipboard string of an X11 window.
/// </summary>
/// <param name="str">The string to set.</param>
public static void SetX11SelectionString([NotNull] string str)
{
SetX11SelectionString(Encoding.UTF8.GetBytes(str));
SetX11SelectionString(Encoding.UTF8.GetBytes(str));
}

/// <summary>
/// Retrieves the color buffer associated with the specified window.
/// </summary>
/// <param name="window">The window whose color buffer to retrieve.</param>
/// <param name="width">The width of the color buffer.</param>
/// <param name="height">The height of the color buffer.</param>
/// <param name="format">The pixel format of the color buffer.</param>
/// <param name="buffer">A pointer to the first element in the buffer.</param>
/// <returns><c>true</c> if operation was successful, otherwise <c>false</c>.</returns>
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetOSMesaColorBuffer", CallingConvention = CallingConvention.Cdecl)]
public static extern bool
GetOSMesaColorBuffer(Window window, out int width, out int height, out int format, out IntPtr buffer);

/// <summary>
/// Retrieves the depth buffer associated with the specified window.
/// </summary>
/// <param name="window">The window whose depth buffer to retrieve.</param>
/// <param name="width">The width of the depth buffer.</param>
/// <param name="height">The height of the depth buffer.</param>
/// <param name="bytesPerValue">The number of bytes per element in the buffer.</param>
/// <param name="buffer">A pointer to the first element in the buffer.</param>
/// <returns><c>true</c> if operation was successful, otherwise <c>false</c>.</returns>
[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetOSMesaDepthBuffer", CallingConvention = CallingConvention.Cdecl)]
public static extern bool
GetOSMesaDepthBuffer(Window window, out int width, out int height, out int bytesPerValue,
out IntPtr buffer);


[DllImport(Glfw.LIBRARY, EntryPoint = "glfwSetX11SelectionString", CallingConvention = CallingConvention.Cdecl)]
private static extern void SetX11SelectionString([NotNull] byte[] str);

[DllImport(Glfw.LIBRARY, EntryPoint = "glfwGetX11SelectionString", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr GetX11SelectionStringInternal();

Expand Down

0 comments on commit 288600c

Please sign in to comment.