367 lines
22 KiB
Plaintext
367 lines
22 KiB
Plaintext
//-----------------------------------------------------------------------
|
|
// -----------------------------------------------------------------------
|
|
// 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
|
|
|
|
internal static unsafe int glfwInit() => _glfw.glfwInit();
|
|
|
|
internal static unsafe void glfwTerminate() => _glfw.glfwTerminate();
|
|
|
|
internal static unsafe void glfwInitHint(int hint, int value) => _glfw.glfwInitHint(hint, value);
|
|
|
|
internal static unsafe void glfwGetVersion(int* major, int* minor, int* rev) => _glfw.glfwGetVersion(major, minor, rev);
|
|
|
|
internal static unsafe byte* glfwGetVersionString() => _glfw.glfwGetVersionString();
|
|
|
|
internal static unsafe int glfwGetError(byte** description) => _glfw.glfwGetError(description);
|
|
|
|
internal static unsafe delegate*<int, byte*, void> glfwSetErrorCallback(delegate*<int, byte*, void> callback) => _glfw.glfwSetErrorCallback(callback);
|
|
|
|
internal static unsafe IntPtr* glfwGetMonitors(int* count) => _glfw.glfwGetMonitors(count);
|
|
|
|
internal static unsafe IntPtr glfwGetPrimaryMonitor() => _glfw.glfwGetPrimaryMonitor();
|
|
|
|
internal static unsafe void glfwGetMonitorPos(IntPtr monitor, int* xpos, int* ypos) => _glfw.glfwGetMonitorPos(monitor, xpos, ypos);
|
|
|
|
internal static unsafe void glfwGetMonitorWorkarea(
|
|
IntPtr monitor,
|
|
int* xpos,
|
|
int* ypos,
|
|
int* width,
|
|
int* height)
|
|
{
|
|
_glfw.glfwGetMonitorWorkarea(monitor, xpos, ypos, width, height);
|
|
}
|
|
|
|
internal static unsafe void glfwGetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM) => _glfw.glfwGetMonitorPhysicalSize(monitor, widthMM, heightMM);
|
|
|
|
internal static unsafe void glfwGetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale) => _glfw.glfwGetMonitorContentScale(monitor, xscale, yscale);
|
|
|
|
internal static unsafe byte* glfwGetMonitorName(IntPtr monitor) => _glfw.glfwGetMonitorName(monitor);
|
|
|
|
internal static unsafe void glfwSetMonitorUserPointer(IntPtr monitor, void* pointer) => _glfw.glfwSetMonitorUserPointer(monitor, pointer);
|
|
|
|
internal static unsafe void* glfwGetMonitorUserPointer(IntPtr monitor) => _glfw.glfwGetMonitorUserPointer(monitor);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, void> glfwSetMonitorCallback(
|
|
delegate*<glfwWindow*, int, void> callback) => _glfw.glfwSetMonitorCallback(callback);
|
|
|
|
internal static unsafe glfwVideomode* glfwGetVideoModes(IntPtr monitor, int* count) => _glfw.glfwGetVideoModes(monitor, count);
|
|
|
|
internal static unsafe glfwVideomode* glfwGetVideoMode(IntPtr monitor) => _glfw.glfwGetVideoMode(monitor);
|
|
|
|
internal static unsafe void glfwSetGamma(IntPtr monitor, float gamma) => _glfw.glfwSetGamma(monitor, gamma);
|
|
|
|
internal static unsafe glfwGammaramp* glfwGetGammaRamp(IntPtr monitor) => _glfw.glfwGetGammaRamp(monitor);
|
|
|
|
internal static unsafe void glfwSetGammaRamp(IntPtr monitor, glfwGammaramp* ramp) => _glfw.glfwSetGammaRamp(monitor, ramp);
|
|
|
|
internal static unsafe void glfwDefaultWindowHints() => _glfw.glfwDefaultWindowHints();
|
|
|
|
internal static unsafe void glfwWindowHint(int hint, int value) => _glfw.glfwWindowHint(hint, value);
|
|
|
|
internal static unsafe void glfwWindowHintString(int hint, byte* value) => _glfw.glfwWindowHintString(hint, value);
|
|
|
|
internal static unsafe IntPtr glfwCreateWindow(
|
|
int width,
|
|
int height,
|
|
byte[] title,
|
|
IntPtr monitor,
|
|
IntPtr share) => _glfw.glfwCreateWindow(width, height, title, monitor, share);
|
|
|
|
internal static unsafe void glfwDestroyWindow(IntPtr window) => _glfw.glfwDestroyWindow(window);
|
|
|
|
internal static unsafe int glfwWindowShouldClose(IntPtr window) => _glfw.glfwWindowShouldClose(window);
|
|
|
|
internal static unsafe void glfwSetWindowShouldClose(IntPtr window, int value) => _glfw.glfwSetWindowShouldClose(window, value);
|
|
|
|
internal static unsafe void glfwSetWindowTitle(IntPtr window, byte* title) => _glfw.glfwSetWindowTitle(window, title);
|
|
|
|
internal static unsafe void glfwSetWindowIcon(IntPtr window, int count, GLFWimage* images) => _glfw.glfwSetWindowIcon(window, count, images);
|
|
|
|
internal static unsafe void glfwGetWindowPos(IntPtr window, int* xpos, int* ypos) => _glfw.glfwGetWindowPos(window, xpos, ypos);
|
|
|
|
internal static unsafe void glfwSetWindowPos(IntPtr window, int xpos, int ypos) => _glfw.glfwSetWindowPos(window, xpos, ypos);
|
|
|
|
internal static unsafe void glfwGetWindowSize(IntPtr window, int* width, int* height) => _glfw.glfwGetWindowSize(window, width, height);
|
|
|
|
internal static unsafe void glfwSetWindowSizeLimits(
|
|
IntPtr window,
|
|
int minwidth,
|
|
int minheight,
|
|
int maxwidth,
|
|
int maxheight) => _glfw.glfwSetWindowSizeLimits(window, minwidth, minheight, maxwidth, maxheight);
|
|
|
|
internal static unsafe void glfwSetWindowAspectRatio(IntPtr window, int numer, int denom) => _glfw.glfwSetWindowAspectRatio(window, numer, denom);
|
|
|
|
internal static unsafe void glfwSetWindowSize(IntPtr window, int width, int height) => _glfw.glfwSetWindowSize(window, width, height);
|
|
|
|
internal static unsafe void glfwGetFramebufferSize(IntPtr window, int* width, int* height) => _glfw.glfwGetFramebufferSize(window, width, height);
|
|
|
|
internal static unsafe void glfwGetWindowFrameSize(IntPtr window, int* left, int* top, int* right, int* bottom) => _glfw.glfwGetWindowFrameSize(window, left, top, right, bottom);
|
|
|
|
internal static unsafe void glfwGetWindowContentScale(IntPtr window, float* xscale, float* yscale) => _glfw.glfwGetWindowContentScale(window, xscale, yscale);
|
|
|
|
internal static unsafe float glfwGetWindowOpacity(IntPtr window) => _glfw.glfwGetWindowOpacity(window);
|
|
|
|
internal static unsafe void glfwSetWindowOpacity(IntPtr window, float opacity) => _glfw.glfwSetWindowOpacity(window, opacity);
|
|
|
|
internal static unsafe void glfwIconifyWindow(IntPtr window) => _glfw.glfwIconifyWindow(window);
|
|
|
|
internal static unsafe void glfwRestoreWindow(IntPtr window) => _glfw.glfwRestoreWindow(window);
|
|
|
|
internal static unsafe void glfwMaximizeWindow(IntPtr window) => _glfw.glfwMaximizeWindow(window);
|
|
|
|
internal static unsafe void glfwShowWindow(IntPtr window) => _glfw.glfwShowWindow(window);
|
|
|
|
internal static unsafe void glfwHideWindow(IntPtr window) => _glfw.glfwHideWindow(window);
|
|
|
|
internal static unsafe void glfwFocusWindow(IntPtr window) => _glfw.glfwFocusWindow(window);
|
|
|
|
internal static unsafe void glfwRequestWindowAttention(IntPtr window) => _glfw.glfwRequestWindowAttention(window);
|
|
|
|
internal static unsafe IntPtr glfwGetWindowMonitor(IntPtr window) => _glfw.glfwGetWindowMonitor(window);
|
|
|
|
internal static unsafe void glfwSetWindowMonitor(
|
|
IntPtr window,
|
|
IntPtr monitor,
|
|
int xpos,
|
|
int ypos,
|
|
int width,
|
|
int height,
|
|
int refreshRate) => _glfw.glfwSetWindowMonitor(
|
|
window, monitor, xpos, ypos, width, height, refreshRate);
|
|
|
|
internal static unsafe int glfwGetWindowAttrib(IntPtr window, int attrib) => _glfw.glfwGetWindowAttrib(window, attrib);
|
|
|
|
internal static unsafe void glfwSetWindowAttrib(IntPtr window, int attrib, int value) => _glfw.glfwSetWindowAttrib(window, attrib, value);
|
|
|
|
internal static unsafe void glfwSetWindowUserPointer(IntPtr window, void* pointer) => _glfw.glfwSetWindowUserPointer(window, pointer);
|
|
|
|
internal static unsafe void* glfwGetWindowUserPointer(IntPtr window) => _glfw.glfwGetWindowUserPointer(window);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, int, void> glfwSetWindowPosCallback(
|
|
IntPtr window,
|
|
IntPtr callback) => _glfw.glfwSetWindowPosCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, int, void> glfwSetWindowSizeCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, int, void> callback) => _glfw.glfwSetWindowSizeCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, void> glfwSetWindowCloseCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, void> callback) => _glfw.glfwSetWindowCloseCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, void> glfwSetWindowRefreshCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, void> callback) => _glfw.glfwSetWindowRefreshCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, void> glfwSetWindowFocusCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, void> callback) => _glfw.glfwSetWindowFocusCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, void> glfwSetWindowIconifyCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, void> callback) => _glfw.glfwSetWindowIconifyCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, void> glfwSetWindowMaximizeCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, void> callback) => _glfw.glfwSetWindowMaximizeCallback(window, callback);
|
|
|
|
internal static unsafe FrameBufferSizeHandler glfwSetFramebufferSizeCallback(IntPtr window, IntPtr callback) => _glfw.glfwSetFramebufferSizeCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, float, float> glfwSetWindowContentScaleCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, float, float> callback) => _glfw.glfwSetWindowContentScaleCallback(window, callback);
|
|
|
|
internal static unsafe void glfwPollEvents() => _glfw.glfwPollEvents();
|
|
|
|
internal static unsafe void glfwWaitEvents() => _glfw.glfwWaitEvents();
|
|
|
|
internal static unsafe void glfwWaitEventsTimeout(double timeout) => _glfw.glfwWaitEventsTimeout(timeout);
|
|
|
|
internal static unsafe void glfwPostEmptyEvent() => _glfw.glfwPostEmptyEvent();
|
|
|
|
internal static unsafe int glfwGetInputMode(IntPtr window, int mode) => _glfw.glfwGetInputMode(window, mode);
|
|
|
|
internal static unsafe void glfwSetInputMode(IntPtr window, int mode, int value) => _glfw.glfwSetInputMode(window, mode, value);
|
|
|
|
internal static unsafe int glfwRawMouseMotionSupported() => _glfw.glfwRawMouseMotionSupported();
|
|
|
|
internal static unsafe byte* glfwGetKeyName(int key, int scancode) => _glfw.glfwGetKeyName(key, scancode);
|
|
|
|
internal static unsafe int glfwGetKeyScancode(int key) => _glfw.glfwGetKeyScancode(key);
|
|
|
|
internal static unsafe KeyStatus glfwGetKey(IntPtr window, int key) => _glfw.glfwGetKey(window, key);
|
|
|
|
internal static unsafe int glfwGetMouseButton(IntPtr window, int button) => _glfw.glfwGetMouseButton(window, button);
|
|
|
|
internal static unsafe void glfwGetCursorPos(IntPtr window, double* xpos, double* ypos) => _glfw.glfwGetCursorPos(window, xpos, ypos);
|
|
|
|
internal static unsafe void glfwSetCursorPos(IntPtr window, double xpos, double ypos) => _glfw.glfwSetCursorPos(window, xpos, ypos);
|
|
|
|
internal static unsafe GLFWcursor* glfwCreateCursor(GLFWimage* image, int xhot, int yhot) => _glfw.glfwCreateCursor(image, xhot, yhot);
|
|
|
|
internal static unsafe GLFWcursor* glfwCreateStandardCursor(int shape) => _glfw.glfwCreateStandardCursor(shape);
|
|
|
|
internal static unsafe void glfwDestroyCursor(GLFWcursor* cursor) => _glfw.glfwDestroyCursor(cursor);
|
|
|
|
internal static unsafe void glfwSetCursor(IntPtr window, GLFWcursor* cursor) => _glfw.glfwSetCursor(window, cursor);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, int, int, int, void> glfwSetKeyCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, int, int, int, void> callback) => _glfw.glfwSetKeyCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, uint, void> glfwSetCharCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, uint, void> callback) => _glfw.glfwSetCharCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, int, void> glfwSetCharModsCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, int, void> callback) => _glfw.glfwSetCharModsCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, int, int, void> glfwSetMouseButtonCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, int, int, void> callback) => _glfw.glfwSetMouseButtonCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, double, double, void> glfwSetCursorPosCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, double, double, void> callback) => _glfw.glfwSetCursorPosCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, void> glfwSetCursorEnterCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, void> callback) => _glfw.glfwSetCursorEnterCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, double, double, void> glfwSetScrollCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, double, double, void> callback) => _glfw.glfwSetScrollCallback(window, callback);
|
|
|
|
internal static unsafe delegate*<glfwWindow*, int, byte**, void> glfwSetDropCallback(
|
|
IntPtr window,
|
|
delegate*<glfwWindow*, int, byte**, void> callback) => _glfw.glfwSetDropCallback(window, callback);
|
|
|
|
internal static unsafe int glfwJoystickPresent(int jid) => _glfw.glfwJoystickPresent(jid);
|
|
|
|
internal static unsafe float* glfwGetJoystickAxes(int jid, int* count) => _glfw.glfwGetJoystickAxes(jid, count);
|
|
|
|
internal static unsafe byte* glfwGetJoystickButtons(int jid, int* count) => _glfw.glfwGetJoystickButtons(jid, count);
|
|
|
|
internal static unsafe byte* glfwGetJoystickHats(int jid, int* count) => _glfw.glfwGetJoystickHats(jid, count);
|
|
|
|
internal static unsafe byte* glfwGetJoystickName(int jid) => _glfw.glfwGetJoystickName(jid);
|
|
|
|
internal static unsafe byte* glfwGetJoystickGUID(int jid) => _glfw.glfwGetJoystickGUID(jid);
|
|
|
|
internal static unsafe void glfwSetJoystickUserPointer(int jid, void* pointer) => _glfw.glfwSetJoystickUserPointer(jid, pointer);
|
|
|
|
internal static unsafe void* glfwGetJoystickUserPointer(int jid) => _glfw.glfwGetJoystickUserPointer(jid);
|
|
|
|
internal static unsafe int glfwJoystickIsGamepad(int jid) => _glfw.glfwJoystickIsGamepad(jid);
|
|
|
|
internal static unsafe delegate*<int, int, void> glfwSetJoystickCallback(delegate*<int, int, void> callback) => _glfw.glfwSetJoystickCallback(callback);
|
|
|
|
internal static unsafe int glfwUpdateGamepadMappings(byte* str) => _glfw.glfwUpdateGamepadMappings(str);
|
|
|
|
internal static unsafe byte* glfwGetGamepadName(int jid) => _glfw.glfwGetGamepadName(jid);
|
|
|
|
internal static unsafe int glfwGetGamepadState(int jid, GLFWgamepadstate* state) => _glfw.glfwGetGamepadState(jid, state);
|
|
|
|
internal static unsafe void glfwSetClipboardString(IntPtr window, byte* str) => _glfw.glfwSetClipboardString(window, str);
|
|
|
|
internal static unsafe byte* glfwGetClipboardString(IntPtr window) => _glfw.glfwGetClipboardString(window);
|
|
|
|
internal static unsafe double glfwGetTime() => _glfw.glfwGetTime();
|
|
|
|
internal static unsafe void glfwSetTime(double time) => _glfw.glfwSetTime(time);
|
|
|
|
internal static unsafe ulong* glfwGetTimerValue() => _glfw.glfwGetTimerValue();
|
|
|
|
internal static unsafe ulong* glfwGetTimerFrequency() => _glfw.glfwGetTimerFrequency();
|
|
|
|
internal static unsafe void glfwMakeContextCurrent(IntPtr window) => _glfw.glfwMakeContextCurrent(window);
|
|
|
|
internal static unsafe IntPtr glfwGetCurrentContext() => _glfw.glfwGetCurrentContext();
|
|
|
|
internal static unsafe void glfwSwapBuffers(IntPtr window) => _glfw.glfwSwapBuffers(window);
|
|
|
|
internal static unsafe void glfwSwapInterval(int interval) => _glfw.glfwSwapInterval(interval);
|
|
|
|
internal static unsafe int glfwExtensionSupported(byte* extension) => _glfw.glfwExtensionSupported(extension);
|
|
|
|
internal static unsafe IntPtr glfwGetProcAddress(string procname) => _glfw.glfwGetProcAddress(procname);
|
|
|
|
internal static unsafe int glfwVulkanSupported() => _glfw.glfwVulkanSupported();
|
|
|
|
internal static unsafe byte** glfwGetRequiredInstanceExtensions(uint* count) => _glfw.glfwGetRequiredInstanceExtensions(count);
|
|
|
|
/*
|
|
[LibraryImport(NativeLibName, EntryPoint = "glfwGetInstanceProcAddress")] internal static unsafe partial delegate*<void> 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
|
|
}
|
|
}
|