Glfw3.SetKeyCallback (hWin, HandleKeyDelegate);
Glfw3.SetMouseButtonPosCallback (hWin, HandleMouseButtonDelegate);
Glfw3.SetCursorPosCallback (hWin, HandleCursorPosDelegate);
- Glfw3.SetWindowSizeCallback (hWin, HandleWindowSizeDelegate);
Glfw3.SetScrollCallback (hWin, HandleScrollDelegate);
Glfw3.SetCharCallback (hWin, HandleCharDelegate);
protected virtual void onChar (CodePoint cp) { }
#region events delegates
- static void HandleWindowSizeDelegate (IntPtr window, int width, int height) { }
- static void HandleCursorPosDelegate (IntPtr window, double xPosition, double yPosition) {
+
+ static CursorPosDelegate HandleCursorPosDelegate = (window, xPosition, yPosition) => {
windows[window].onMouseMove (xPosition, yPosition);
windows[window].lastMouseX = xPosition;
windows[window].lastMouseY = yPosition;
- }
- static void HandleMouseButtonDelegate (IntPtr window, Glfw.MouseButton button, InputAction action, Modifier mods) {
+ };
+ static MouseButtonDelegate HandleMouseButtonDelegate = (IntPtr window, Glfw.MouseButton button, InputAction action, Modifier mods) => {
if (action == InputAction.Press) {
windows[window].buttons[(int)button] = true;
windows[window].onMouseButtonDown (button);
windows[window].buttons[(int)button] = false;
windows[window].onMouseButtonUp (button);
}
- }
- static void HandleScrollDelegate (IntPtr window, double xOffset, double yOffset) {
+ };
+ static ScrollDelegate HandleScrollDelegate = (IntPtr window, double xOffset, double yOffset) => {
windows[window].onScroll (xOffset, yOffset);
- }
- static void HandleKeyDelegate (IntPtr window, Key key, int scanCode, InputAction action, Modifier modifiers) {
+ };
+ static KeyDelegate HandleKeyDelegate = (IntPtr window, Key key, int scanCode, InputAction action, Modifier modifiers) => {
windows[window].KeyModifiers = modifiers;
if (action == InputAction.Press || action == InputAction.Repeat) {
windows[window].onKeyDown (key, scanCode, modifiers);
} else {
windows[window].onKeyUp (key, scanCode, modifiers);
}
- }
- static void HandleCharDelegate (IntPtr window, CodePoint codepoint) {
+ };
+ static CharDelegate HandleCharDelegate = (IntPtr window, CodePoint codepoint) => {
windows[window].onChar (codepoint);
- }
+ };
#endregion
/// <summary>
return formats;
}
- public VkPresentModeKHR [] GetSurfacePresentModes (VkSurfaceKHR surf)
- {
+ public VkPresentModeKHR[] GetSurfacePresentModes (VkSurfaceKHR surf) {
vkGetPhysicalDeviceSurfacePresentModesKHR (phy, surf, out uint count, IntPtr.Zero);
- VkPresentModeKHR [] modes = new VkPresentModeKHR [count];
-
- vkGetPhysicalDeviceSurfacePresentModesKHR (phy, surf, out count, modes.Pin ());
- modes.Unpin ();
-
- return modes;
+ if (Type.GetType ("Mono.Runtime") == null) {
+ int[] modes = new int[count];//this cause an error on mono
+ vkGetPhysicalDeviceSurfacePresentModesKHR (phy, surf, out count, modes.Pin ());
+ modes.Unpin ();
+ return modes.Cast<VkPresentModeKHR> ().ToArray ();
+ } else {
+ VkPresentModeKHR[] modes = new VkPresentModeKHR[count];//enums not blittable on ms.Net
+ vkGetPhysicalDeviceSurfacePresentModesKHR (phy, surf, out count, modes.Pin ());
+ modes.Unpin ();
+ return modes;
+ }
}
public VkFormatProperties GetFormatProperties (VkFormat format)
{