glfw: update from 3.3.8 to 3.4

This commit is contained in:
Laytan Laats
2024-03-18 22:19:23 +01:00
parent 97be7feb99
commit 65e68f11f8
14 changed files with 124 additions and 64 deletions
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -6,8 +6,8 @@ import "vendor:glfw"
import "core:os"
GLFW_MAJOR :: 3
GLFW_MINOR :: 3
GLFW_PATCH :: 4
GLFW_MINOR :: 4
GLFW_PATCH :: 0
TEST_count := 0
TEST_fail := 0
@@ -46,4 +46,4 @@ main :: proc() {
test_glfw :: proc(t: ^testing.T) {
major, minor, patch := glfw.GetVersion()
expect(t, major == GLFW_MAJOR && minor == GLFW_MINOR, fmt.tprintf("Expected GLFW.GetVersion: %v.%v.%v, got %v.%v.%v instead", GLFW_MAJOR, GLFW_MINOR, GLFW_PATCH, major, minor, patch))
}
}
+22 -7
View File
@@ -21,14 +21,21 @@ when ODIN_OS == .Windows {
"system:shell32.lib",
}
}
} else when ODIN_OS == .Linux {
foreign import glfw "system:glfw"
} else when ODIN_OS == .Darwin {
foreign import glfw {
"../lib/darwin/libglfw3.a",
"system:Cocoa.framework",
"system:IOKit.framework",
"system:OpenGL.framework",
when GLFW_SHARED {
foreign import glfw {
"system:glfw",
"system:Cocoa.framework",
"system:IOKit.framework",
"system:OpenGL.framework",
}
} else {
foreign import glfw {
"../lib/darwin/libglfw3.a",
"system:Cocoa.framework",
"system:IOKit.framework",
"system:OpenGL.framework",
}
}
} else {
foreign import glfw "system:glfw"
@@ -44,6 +51,10 @@ foreign glfw {
InitHint :: proc(hint, value: c.int) ---
InitAllocator :: proc(#by_ptr allocator: Allocator) ---
InitVulkanLoader :: proc(loader: vk.ProcGetInstanceProcAddr) ---
GetVersion :: proc(major, minor, rev: ^c.int) ---
GetError :: proc(description: ^cstring) -> c.int ---
@@ -94,6 +105,7 @@ foreign glfw {
GetKey :: proc(window: WindowHandle, key: c.int) -> c.int ---
GetKeyName :: proc(key, scancode: c.int) -> cstring ---
SetWindowShouldClose :: proc(window: WindowHandle, value: b32) ---
GetWindowTitle :: proc(window: WindowHandle) -> cstring ---
JoystickPresent :: proc(joy: c.int) -> b32 ---
GetJoystickName :: proc(joy: c.int) -> cstring ---
GetKeyScancode :: proc(key: c.int) -> c.int ---
@@ -184,5 +196,8 @@ foreign glfw {
SetJoystickCallback :: proc(cbfun: JoystickProc) -> JoystickProc ---
SetErrorCallback :: proc(cbfun: ErrorProc) -> ErrorProc ---
GetPlatform :: proc() -> c.int ---
PlatformSupported :: proc(platform: c.int) -> b32 ---
}
+11
View File
@@ -30,6 +30,13 @@ GamepadState :: struct {
axes: [6]f32,
}
Allocator :: struct {
allocate: AllocateProc,
reallocate: ReallocateProc,
deallocate: DeallocateProc,
user: rawptr,
}
/*** Procedure type declarations ***/
WindowIconifyProc :: #type proc "c" (window: WindowHandle, iconified: c.int)
WindowRefreshProc :: #type proc "c" (window: WindowHandle)
@@ -53,3 +60,7 @@ CursorEnterProc :: #type proc "c" (window: WindowHandle, entered: c.int)
JoystickProc :: #type proc "c" (joy, event: c.int)
ErrorProc :: #type proc "c" (error: c.int, description: cstring)
AllocateProc :: #type proc "c" (size: c.size_t, user: rawptr) -> rawptr
ReallocateProc :: #type proc "c" (block: rawptr, size: c.size_t, user: rawptr) -> rawptr
DeallocateProc :: #type proc "c" (block: rawptr, user: rawptr)
+71 -26
View File
@@ -6,8 +6,8 @@ GLFW_SHARED :: #config(GLFW_SHARED, false)
/*** Constants ***/
/* Versions */
VERSION_MAJOR :: 3
VERSION_MINOR :: 3
VERSION_REVISION :: 8
VERSION_MINOR :: 4
VERSION_REVISION :: 0
/* Booleans */
TRUE :: true
@@ -251,17 +251,21 @@ GAMEPAD_AXIS_RIGHT_TRIGGER :: 5
GAMEPAD_AXIS_LAST :: GAMEPAD_AXIS_RIGHT_TRIGGER
/* Error constants */
NO_ERROR :: 0x00000000
NOT_INITIALIZED :: 0x00010001
NO_CURRENT_CONTEXT :: 0x00010002
INVALID_ENUM :: 0x00010003
INVALID_VALUE :: 0x00010004
OUT_OF_MEMORY :: 0x00010005
API_UNAVAILABLE :: 0x00010006
VERSION_UNAVAILABLE :: 0x00010007
PLATFORM_ERROR :: 0x00010008
FORMAT_UNAVAILABLE :: 0x00010009
NO_WINDOW_CONTEXT :: 0x0001000A
NO_ERROR :: 0x00000000
NOT_INITIALIZED :: 0x00010001
NO_CURRENT_CONTEXT :: 0x00010002
INVALID_ENUM :: 0x00010003
INVALID_VALUE :: 0x00010004
OUT_OF_MEMORY :: 0x00010005
API_UNAVAILABLE :: 0x00010006
VERSION_UNAVAILABLE :: 0x00010007
PLATFORM_ERROR :: 0x00010008
FORMAT_UNAVAILABLE :: 0x00010009
NO_WINDOW_CONTEXT :: 0x0001000A
CURSOR_UNAVAILABLE :: 0x0001000B
FEATURE_UNAVAILABLE :: 0x0001000C
FEATURE_UNIMPLEMENTED :: 0x0001000D
PLATFORM_UNAVAILABLE :: 0x0001000E
/* Window attributes */
FOCUSED :: 0x00020001
@@ -276,6 +280,9 @@ CENTER_CURSOR :: 0x00020009
TRANSPARENT_FRAMEBUFFER :: 0x0002000A
HOVERED :: 0x0002000B
FOCUS_ON_SHOW :: 0x0002000C
MOUSE_PASSTHROUGH :: 0x0002000D
POSITION_X :: 0x0002000E
POSITION_Y :: 0x0002000F
/* Pixel window attributes */
RED_BITS :: 0x00021001
@@ -302,12 +309,14 @@ CONTEXT_VERSION_MINOR :: 0x00022003
CONTEXT_REVISION :: 0x00022004
CONTEXT_ROBUSTNESS :: 0x00022005
OPENGL_FORWARD_COMPAT :: 0x00022006
OPENGL_DEBUG_CONTEXT :: 0x00022007
CONTEXT_DEBUG :: 0x00022007
OPENGL_DEBUG_CONTEXT :: CONTEXT_DEBUG // Backwards compatibility
OPENGL_PROFILE :: 0x00022008
CONTEXT_RELEASE_BEHAVIOR :: 0x00022009
CONTEXT_NO_ERROR :: 0x0002200A
CONTEXT_CREATION_API :: 0x0002200B
SCALE_TO_MONITOR :: 0x0002200C
SCALE_FRAMEBUFFER :: 0x0002200D
/* Cross platform attributes */
COCOA_RETINA_FRAMEBUFFER :: 0x00023001
@@ -315,6 +324,9 @@ COCOA_FRAME_NAME :: 0x00023002
COCOA_GRAPHICS_SWITCHING :: 0x00023003
X11_CLASS_NAME :: 0x00024001
X11_INSTANCE_NAME :: 0x00024002
WIN32_KEYBOARD_MENU :: 0x00025001
WIN32_SHOWDEFAULT :: 0x00025002
WAYLAND_APP_ID :: 0x00026001
/* APIs */
NO_API :: 0
@@ -341,6 +353,7 @@ LOCK_KEY_MODS :: 0x00033004
CURSOR_NORMAL :: 0x00034001
CURSOR_HIDDEN :: 0x00034002
CURSOR_DISABLED :: 0x00034003
CURSOR_CAPTURED :: 0x00034004
/* Mouse motion */
RAW_MOUSE_MOTION :: 0x00033005
@@ -355,24 +368,56 @@ NATIVE_CONTEXT_API :: 0x00036001
EGL_CONTEXT_API :: 0x00036002
OSMESA_CONTEXT_API :: 0x00036003
ANGLE_PLATFORM_TYPE_NONE :: 0x00037001
ANGLE_PLATFORM_TYPE_OPENGL :: 0x00037002
ANGLE_PLATFORM_TYPE_OPENGLES :: 0x00037003
ANGLE_PLATFORM_TYPE_D3D9 :: 0x00037004
ANGLE_PLATFORM_TYPE_D3D11 :: 0x00037005
ANGLE_PLATFORM_TYPE_VULKAN :: 0x00037007
ANGLE_PLATFORM_TYPE_METAL :: 0x00037008
WAYLAND_PREFER_LIBDECOR :: 0x00038001
WAYLAND_DISABLE_LIBDECOR :: 0x00038002
ANY_POSITION :: 0x80000000
/* Types of cursors */
ARROW_CURSOR :: 0x00036001
IBEAM_CURSOR :: 0x00036002
CROSSHAIR_CURSOR :: 0x00036003
HAND_CURSOR :: 0x00036004
HRESIZE_CURSOR :: 0x00036005
VRESIZE_CURSOR :: 0x00036006
RESIZE_NWSE_CURSOR :: 0x00036007
RESIZE_NESW_CURSOR :: 0x00036008
ARROW_CURSOR :: 0x00036001
IBEAM_CURSOR :: 0x00036002
CROSSHAIR_CURSOR :: 0x00036003
POINTING_HAND_CURSOR :: 0x00036004
RESIZE_EW_CURSOR :: 0x00036005
RESIZE_NS_CURSOR :: 0x00036006
RESIZE_NWSE_CURSOR :: 0x00036007
RESIZE_NESW_CURSOR :: 0x00036008
RESIZE_ALL_CURSOR :: 0x00036009
NOT_ALLOWED_CURSOR :: 0x0003600A
/* Backwards compatibility cursors. */
HRESIZE_CURSOR :: RESIZE_EW_CURSOR
VRESIZE_CURSOR :: RESIZE_NS_CURSOR
HAND_CURSOR :: POINTING_HAND_CURSOR
/* Joystick? */
CONNECTED :: 0x00040001
DISCONNECTED :: 0x00040002
/* macOS specific init hint. */
JOYSTICK_HAT_BUTTONS :: 0x00050001
COCOA_CHDIR_RESOURCES :: 0x00051001
COCOA_MENUBAR :: 0x00051002
JOYSTICK_HAT_BUTTONS :: 0x00050001
ANGLE_PLATFORM_TYPE :: 0x00050002
PLATFORM :: 0x00050003
/* Platform specific init hints. */
COCOA_CHDIR_RESOURCES :: 0x00051001
COCOA_MENUBAR :: 0x00051002
X11_XCB_VULKAN_SURFACE :: 0x00052001
WAYLAND_LIBDECOR :: 0x00053001
ANY_PLATFORM :: 0x00060000
PLATFORM_WIN32 :: 0x00060001
PLATFORM_COCOA :: 0x00060002
PLATFORM_WAYLAND :: 0x00060003
PLATFORM_X11 :: 0x00060004
PLATFORM_NULL :: 0x00060005
/* */
DONT_CARE :: -1
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+3 -11
View File
@@ -4,18 +4,10 @@ package glfw
import NS "vendor:darwin/Foundation"
when GLFW_SHARED {
#panic("Dynamic linking for glfw is not supported for darwin yet")
foreign import glfw {"_"}
} else {
foreign import glfw {
"lib/darwin/libglfw3.a",
}
}
@(default_calling_convention="c", link_prefix="glfw")
foreign glfw {
GetCocoaWindow :: proc(window: WindowHandle) -> ^NS.Window ---
foreign {
GetCocoaWindow :: proc(window: WindowHandle) -> ^NS.Window ---
GetCocoaView :: proc(window: WindowHandle) -> ^NS.View ---
}
// TODO:
+1 -17
View File
@@ -4,24 +4,8 @@ package glfw
import win32 "core:sys/windows"
when GLFW_SHARED {
foreign import glfw {
"lib/glfw3dll.lib",
"system:user32.lib",
"system:gdi32.lib",
"system:shell32.lib",
}
} else {
foreign import glfw {
"lib/glfw3_mt.lib",
"system:user32.lib",
"system:gdi32.lib",
"system:shell32.lib",
}
}
@(default_calling_convention="c", link_prefix="glfw")
foreign glfw {
foreign {
GetWin32Adapter :: proc(monitor: MonitorHandle) -> cstring ---
GetWin32Monitor :: proc(monitor: MonitorHandle) -> cstring ---
GetWin32Window :: proc(window: WindowHandle) -> win32.HWND ---
+6
View File
@@ -11,6 +11,8 @@ GammaRamp :: glfw.GammaRamp
Image :: glfw.Image
GamepadState :: glfw.GamepadState
Allocator :: glfw.Allocator
/*** Procedure type declarations ***/
WindowIconifyProc :: glfw.WindowIconifyProc
WindowRefreshProc :: glfw.WindowRefreshProc
@@ -34,3 +36,7 @@ CursorEnterProc :: glfw.CursorEnterProc
JoystickProc :: glfw.JoystickProc
ErrorProc :: glfw.ErrorProc
AllocateProc :: glfw.AllocateProc
ReallocateProc :: glfw.ReallocateProc
DeallocateProc :: glfw.DeallocateProc
+7
View File
@@ -8,6 +8,10 @@ Terminate :: glfw.Terminate
InitHint :: glfw.InitHint
InitAllocator :: glfw.InitAllocator
InitVulkanLoader :: glfw.InitVulkanLoader
GetVersion :: proc "c" () -> (major, minor, rev: c.int) {
glfw.GetVersion(&major, &minor, &rev)
return
@@ -121,6 +125,7 @@ GetKeyName :: proc "c" (key, scancode: c.int) -> string {
return string(glfw.GetKeyName(key, scancode))
}
SetWindowShouldClose :: glfw.SetWindowShouldClose
GetWindowTitle :: glfw.GetWindowTitle
JoystickPresent :: glfw.JoystickPresent
GetJoystickName :: proc "c" (joy: c.int) -> string {
return string(glfw.GetJoystickName(joy))
@@ -237,6 +242,8 @@ SetJoystickCallback :: glfw.SetJoystickCallback
SetErrorCallback :: glfw.SetErrorCallback
GetPlatform :: glfw.GetPlatform
PlatformSupported :: glfw.PlatformSupported
// Used by vendor:OpenGL
gl_set_proc_address :: proc(p: rawptr, name: cstring) {