//----------------------------------------------------------------------- // ----------------------------------------------------------------------- // file="glfw.cs" // Project: StgSharp // AuthorGroup: Nitload Space // Copyright (c) Nitload Space. All rights reserved. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the “Software”), to deal in the Software without restriction, // including without limitation the rights to use, copy, modify, merge, // publish, distribute, sublicense, and/or sell copies of the Software, // and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // // The above copyright notice and // this permission notice shall be included in all copies // or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED “AS IS”, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using StgSharp.Graphics; using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; namespace StgSharp.Internal { internal unsafe partial class InternalIO { private static GLFWFunction _glfw; [LibraryImport(NativeLibName, EntryPoint = "load_glfw_functions")] internal static unsafe partial void glfwLoadLibrary(GLFWFunction* context); internal static unsafe void LoadGlfw() { _glfw = new GLFWFunction(); fixed (GLFWFunction* func = &_glfw) { } } #region api call [LibraryImport(NativeLibName, EntryPoint = "glfwInit")] internal static unsafe partial int glfwInit(); [LibraryImport(NativeLibName, EntryPoint = "glfwTerminate")] internal static unsafe partial void glfwTerminate(); [LibraryImport(NativeLibName, EntryPoint = "glfwInitHint")] internal static unsafe partial void glfwInitHint(int hint, int value); [LibraryImport(NativeLibName, EntryPoint = "glfwGetVersion")] internal static unsafe partial void glfwGetVersion(int* major, int* minor, int* rev); [LibraryImport(NativeLibName, EntryPoint = "glfwGetVersionString")] internal static unsafe partial byte* glfwGetVersionString(); [LibraryImport(NativeLibName, EntryPoint = "glfwGetError")] internal static unsafe partial int glfwGetError(byte** description); [LibraryImport(NativeLibName, EntryPoint = "glfwSetErrorCallback")] internal static unsafe partial delegate* glfwSetErrorCallback( delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwGetMonitors")] internal static unsafe partial IntPtr* glfwGetMonitors(int* count); [LibraryImport(NativeLibName, EntryPoint = "glfwGetPrimaryMonitor")] internal static unsafe partial IntPtr glfwGetPrimaryMonitor(); [LibraryImport(NativeLibName, EntryPoint = "glfwGetMonitorPos")] internal static unsafe partial void glfwGetMonitorPos(IntPtr monitor, int* xpos, int* ypos); [LibraryImport(NativeLibName, EntryPoint = "glfwGetMonitorWorkarea")] internal static unsafe partial void glfwGetMonitorWorkarea( IntPtr monitor, int* xpos, int* ypos, int* width, int* height); [LibraryImport(NativeLibName, EntryPoint = "glfwGetMonitorPhysicalSize")] internal static unsafe partial void glfwGetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM); [LibraryImport(NativeLibName, EntryPoint = "glfwGetMonitorContentScale")] internal static unsafe partial void glfwGetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale); [LibraryImport(NativeLibName, EntryPoint = "glfwGetMonitorName")] internal static unsafe partial byte* glfwGetMonitorName(IntPtr monitor); [LibraryImport(NativeLibName, EntryPoint = "glfwSetMonitorUserPointer")] internal static unsafe partial void glfwSetMonitorUserPointer(IntPtr monitor, void* pointer); [LibraryImport(NativeLibName, EntryPoint = "glfwGetMonitorUserPointer")] internal static unsafe partial void* glfwGetMonitorUserPointer(IntPtr monitor); [LibraryImport(NativeLibName, EntryPoint = "glfwSetMonitorCallback")] internal static unsafe partial delegate* glfwSetMonitorCallback( delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwGetVideoModes")] internal static unsafe partial glfwVideomode* glfwGetVideoModes(IntPtr monitor, int* count); [LibraryImport(NativeLibName, EntryPoint = "glfwGetVideoMode")] internal static unsafe partial glfwVideomode* glfwGetVideoMode(IntPtr monitor); [LibraryImport(NativeLibName, EntryPoint = "glfwSetGamma")] internal static unsafe partial void glfwSetGamma(IntPtr monitor, float gamma); [LibraryImport(NativeLibName, EntryPoint = "glfwGetGammaRamp")] internal static unsafe partial glfwGammaramp* glfwGetGammaRamp(IntPtr monitor); [LibraryImport(NativeLibName, EntryPoint = "glfwSetGammaRamp")] internal static unsafe partial void glfwSetGammaRamp(IntPtr monitor, glfwGammaramp* ramp); [LibraryImport(NativeLibName, EntryPoint = "glfwDefaultWindowHints")] internal static unsafe partial void glfwDefaultWindowHints(); [LibraryImport(NativeLibName, EntryPoint = "glfwWindowHint")] internal static unsafe partial void glfwWindowHint(int hint, int value); [LibraryImport(NativeLibName, EntryPoint = "glfwWindowHintString")] internal static unsafe partial void glfwWindowHintString(int hint, byte* value); [LibraryImport(NativeLibName, EntryPoint = "glfwCreateWindow")] internal static unsafe partial IntPtr glfwCreateWindow( int width, int height, byte[] title, IntPtr monitor, IntPtr share); [LibraryImport(NativeLibName, EntryPoint = "glfwDestroyWindow")] internal static unsafe partial void glfwDestroyWindow(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwWindowShouldClose")] internal static unsafe partial int glfwWindowShouldClose(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowShouldClose")] internal static unsafe partial void glfwSetWindowShouldClose(IntPtr window, int value); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowTitle")] internal static unsafe partial void glfwSetWindowTitle(IntPtr window, byte* title); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowIcon")] internal static unsafe partial void glfwSetWindowIcon(IntPtr window, int count, GLFWimage* images); [LibraryImport(NativeLibName, EntryPoint = "glfwGetWindowPos")] internal static unsafe partial void glfwGetWindowPos(IntPtr window, int* xpos, int* ypos); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowPos")] internal static unsafe partial void glfwSetWindowPos(IntPtr window, int xpos, int ypos); [LibraryImport(NativeLibName, EntryPoint = "glfwGetWindowSize")] internal static unsafe partial void glfwGetWindowSize(IntPtr window, int* width, int* height); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowSizeLimits")] internal static unsafe partial void glfwSetWindowSizeLimits( IntPtr window, int minwidth, int minheight, int maxwidth, int maxheight); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowAspectRatio")] internal static unsafe partial void glfwSetWindowAspectRatio(IntPtr window, int numer, int denom); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowSize")] internal static unsafe partial void glfwSetWindowSize(IntPtr window, int width, int height); [LibraryImport(NativeLibName, EntryPoint = "glfwGetFramebufferSize")] internal static unsafe partial void glfwGetFramebufferSize(IntPtr window, int* width, int* height); [LibraryImport(NativeLibName, EntryPoint = "glfwGetWindowFrameSize")] internal static unsafe partial void glfwGetWindowFrameSize( IntPtr window, int* left, int* top, int* right, int* bottom); [LibraryImport(NativeLibName, EntryPoint = "glfwGetWindowContentScale")] internal static unsafe partial void glfwGetWindowContentScale(IntPtr window, float* xscale, float* yscale); [LibraryImport(NativeLibName, EntryPoint = "glfwGetWindowOpacity")] internal static unsafe partial float glfwGetWindowOpacity(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowOpacity")] internal static unsafe partial void glfwSetWindowOpacity(IntPtr window, float opacity); [LibraryImport(NativeLibName, EntryPoint = "glfwIconifyWindow")] internal static unsafe partial void glfwIconifyWindow(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwRestoreWindow")] internal static unsafe partial void glfwRestoreWindow(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwMaximizeWindow")] internal static unsafe partial void glfwMaximizeWindow(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwShowWindow")] internal static unsafe partial void glfwShowWindow(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwHideWindow")] internal static unsafe partial void glfwHideWindow(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwFocusWindow")] internal static unsafe partial void glfwFocusWindow(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwRequestWindowAttention")] internal static unsafe partial void glfwRequestWindowAttention(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwGetWindowMonitor")] internal static unsafe partial IntPtr glfwGetWindowMonitor(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowMonitor")] internal static unsafe partial void glfwSetWindowMonitor( IntPtr window, IntPtr monitor, int xpos, int ypos, int width, int height, int refreshRate); [LibraryImport(NativeLibName, EntryPoint = "glfwGetWindowAttrib")] internal static unsafe partial int glfwGetWindowAttrib(IntPtr window, int attrib); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowAttrib")] internal static unsafe partial void glfwSetWindowAttrib(IntPtr window, int attrib, int value); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowUserPointer")] internal static unsafe partial void glfwSetWindowUserPointer(IntPtr window, void* pointer); [LibraryImport(NativeLibName, EntryPoint = "glfwGetWindowUserPointer")] internal static unsafe partial void* glfwGetWindowUserPointer(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowPosCallback")] internal static unsafe partial delegate* glfwSetWindowPosCallback( IntPtr window, IntPtr callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowSizeCallback")] internal static unsafe partial delegate* glfwSetWindowSizeCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowCloseCallback")] internal static unsafe partial delegate* glfwSetWindowCloseCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowRefreshCallback")] internal static unsafe partial delegate* glfwSetWindowRefreshCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowFocusCallback")] internal static unsafe partial delegate* glfwSetWindowFocusCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowIconifyCallback")] internal static unsafe partial delegate* glfwSetWindowIconifyCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowMaximizeCallback")] internal static unsafe partial delegate* glfwSetWindowMaximizeCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetFramebufferSizeCallback")] internal static unsafe partial FrameBufferSizeHandler glfwSetFramebufferSizeCallback( IntPtr window, IntPtr callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetWindowContentScaleCallback")] internal static unsafe partial delegate* glfwSetWindowContentScaleCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwPollEvents")] internal static unsafe partial void glfwPollEvents(); [LibraryImport(NativeLibName, EntryPoint = "glfwWaitEvents")] internal static unsafe partial void glfwWaitEvents(); [LibraryImport(NativeLibName, EntryPoint = "glfwWaitEventsTimeout")] internal static unsafe partial void glfwWaitEventsTimeout(double timeout); [LibraryImport(NativeLibName, EntryPoint = "glfwPostEmptyEvent")] internal static unsafe partial void glfwPostEmptyEvent(); [LibraryImport(NativeLibName, EntryPoint = "glfwGetInputMode")] internal static unsafe partial int glfwGetInputMode(IntPtr window, int mode); [LibraryImport(NativeLibName, EntryPoint = "glfwSetInputMode")] internal static unsafe partial void glfwSetInputMode(IntPtr window, int mode, int value); [LibraryImport(NativeLibName, EntryPoint = "glfwRawMouseMotionSupported")] internal static unsafe partial int glfwRawMouseMotionSupported(); [LibraryImport(NativeLibName, EntryPoint = "glfwGetKeyName")] internal static unsafe partial byte* glfwGetKeyName(int key, int scancode); [LibraryImport(NativeLibName, EntryPoint = "glfwGetKeyScancode")] internal static unsafe partial int glfwGetKeyScancode(int key); [LibraryImport(NativeLibName, EntryPoint = "glfwGetKey")] internal static unsafe partial KeyStatus glfwGetKey(IntPtr window, int key); [LibraryImport(NativeLibName, EntryPoint = "glfwGetMouseButton")] internal static unsafe partial int glfwGetMouseButton(IntPtr window, int button); [LibraryImport(NativeLibName, EntryPoint = "glfwGetCursorPos")] internal static unsafe partial void glfwGetCursorPos(IntPtr window, double* xpos, double* ypos); [LibraryImport(NativeLibName, EntryPoint = "glfwSetCursorPos")] internal static unsafe partial void glfwSetCursorPos(IntPtr window, double xpos, double ypos); [LibraryImport(NativeLibName, EntryPoint = "glfwCreateCursor")] internal static unsafe partial GLFWcursor* glfwCreateCursor(GLFWimage* image, int xhot, int yhot); [LibraryImport(NativeLibName, EntryPoint = "glfwCreateStandardCursor")] internal static unsafe partial GLFWcursor* glfwCreateStandardCursor(int shape); [LibraryImport(NativeLibName, EntryPoint = "glfwDestroyCursor")] internal static unsafe partial void glfwDestroyCursor(GLFWcursor* cursor); [LibraryImport(NativeLibName, EntryPoint = "glfwSetCursor")] internal static unsafe partial void glfwSetCursor(IntPtr window, GLFWcursor* cursor); [LibraryImport(NativeLibName, EntryPoint = "glfwSetKeyCallback")] internal static unsafe partial delegate* glfwSetKeyCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetCharCallback")] internal static unsafe partial delegate* glfwSetCharCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetCharModsCallback")] internal static unsafe partial delegate* glfwSetCharModsCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetMouseButtonCallback")] internal static unsafe partial delegate* glfwSetMouseButtonCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetCursorPosCallback")] internal static unsafe partial delegate* glfwSetCursorPosCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetCursorEnterCallback")] internal static unsafe partial delegate* glfwSetCursorEnterCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetScrollCallback")] internal static unsafe partial delegate* glfwSetScrollCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwSetDropCallback")] internal static unsafe partial delegate* glfwSetDropCallback( IntPtr window, delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwJoystickPresent")] internal static unsafe partial int glfwJoystickPresent(int jid); [LibraryImport(NativeLibName, EntryPoint = "glfwGetJoystickAxes")] internal static unsafe partial float* glfwGetJoystickAxes(int jid, int* count); [LibraryImport(NativeLibName, EntryPoint = "glfwGetJoystickButtons")] internal static unsafe partial byte* glfwGetJoystickButtons(int jid, int* count); [LibraryImport(NativeLibName, EntryPoint = "glfwGetJoystickHats")] internal static unsafe partial byte* glfwGetJoystickHats(int jid, int* count); [LibraryImport(NativeLibName, EntryPoint = "glfwGetJoystickName")] internal static unsafe partial byte* glfwGetJoystickName(int jid); [LibraryImport(NativeLibName, EntryPoint = "glfwGetJoystickGUID")] internal static unsafe partial byte* glfwGetJoystickGUID(int jid); [LibraryImport(NativeLibName, EntryPoint = "glfwSetJoystickUserPointer")] internal static unsafe partial void glfwSetJoystickUserPointer(int jid, void* pointer); [LibraryImport(NativeLibName, EntryPoint = "glfwGetJoystickUserPointer")] internal static unsafe partial void* glfwGetJoystickUserPointer(int jid); [LibraryImport(NativeLibName, EntryPoint = "glfwJoystickIsGamepad")] internal static unsafe partial int glfwJoystickIsGamepad(int jid); [LibraryImport(NativeLibName, EntryPoint = "glfwSetJoystickCallback")] internal static unsafe partial delegate* glfwSetJoystickCallback(delegate* callback); [LibraryImport(NativeLibName, EntryPoint = "glfwUpdateGamepadMappings")] internal static unsafe partial int glfwUpdateGamepadMappings(byte* str); [LibraryImport(NativeLibName, EntryPoint = "glfwGetGamepadName")] internal static unsafe partial byte* glfwGetGamepadName(int jid); [LibraryImport(NativeLibName, EntryPoint = "glfwGetGamepadState")] internal static unsafe partial int glfwGetGamepadState(int jid, GLFWgamepadstate* state); [LibraryImport(NativeLibName, EntryPoint = "glfwSetClipboardString")] internal static unsafe partial void glfwSetClipboardString(IntPtr window, byte* str); [LibraryImport(NativeLibName, EntryPoint = "glfwGetClipboardString")] internal static unsafe partial byte* glfwGetClipboardString(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwGetTime")] internal static unsafe partial double glfwGetTime(); [LibraryImport(NativeLibName, EntryPoint = "glfwSetTime")] internal static unsafe partial void glfwSetTime(double time); [LibraryImport(NativeLibName, EntryPoint = "glfwGetTimerValue")] internal static unsafe partial ulong* glfwGetTimerValue(); [LibraryImport(NativeLibName, EntryPoint = "glfwGetTimerFrequency")] internal static unsafe partial ulong* glfwGetTimerFrequency(); [LibraryImport(NativeLibName, EntryPoint = "glfwMakeContextCurrent")] internal static unsafe partial void glfwMakeContextCurrent(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwGetCurrentContext")] internal static unsafe partial IntPtr glfwGetCurrentContext(); [LibraryImport(NativeLibName, EntryPoint = "glfwSwapBuffers")] internal static unsafe partial void glfwSwapBuffers(IntPtr window); [LibraryImport(NativeLibName, EntryPoint = "glfwSwapInterval")] internal static unsafe partial void glfwSwapInterval(int interval); [LibraryImport(NativeLibName, EntryPoint = "glfwExtensionSupported")] internal static unsafe partial int glfwExtensionSupported(byte* extension); [LibraryImport(NativeLibName, EntryPoint = "glfwGetProcAddress", StringMarshalling = StringMarshalling.Utf8)] internal static unsafe partial IntPtr glfwGetProcAddress(string procname); [LibraryImport(NativeLibName, EntryPoint = "glfwVulkanSupported")] internal static unsafe partial int glfwVulkanSupported(); [LibraryImport(NativeLibName, EntryPoint = "glfwGetRequiredInstanceExtensions")] internal static unsafe partial byte** glfwGetRequiredInstanceExtensions(uint* count); /* [LibraryImport(NativeLibName, EntryPoint = "glfwGetInstanceProcAddress")] internal static unsafe partial delegate* glfwGetInstanceProcAddress( VkInstance instance, byte* procname); [LibraryImport(NativeLibName, EntryPoint = "glfwGetPhysicalDevicePresentationSupport")] internal static unsafe partial int glfwGetPhysicalDevicePresentationSupport( VkInstance instance, VkPhysicalDevice device, uint* queuefamily); [LibraryImport(NativeLibName, EntryPoint = "glfwCreateWindowSurface")] internal static unsafe partial VkResult glfwCreateWindowSurface( VkInstance instance, glfwWindow* window, VkAllocationCallbacks* _allocator, VkSurfaceKHR* surface); /**/ #endregion api call } }