Merge pull request #3294 from laytan/update-glfw-from-3.3.8-to-3.4

glfw: update from 3.3.8 to 3.4
This commit is contained in:
gingerBill
2024-03-21 15:43:25 +00:00
committed by GitHub
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" import "core:os"
GLFW_MAJOR :: 3 GLFW_MAJOR :: 3
GLFW_MINOR :: 3 GLFW_MINOR :: 4
GLFW_PATCH :: 4 GLFW_PATCH :: 0
TEST_count := 0 TEST_count := 0
TEST_fail := 0 TEST_fail := 0
@@ -46,4 +46,4 @@ main :: proc() {
test_glfw :: proc(t: ^testing.T) { test_glfw :: proc(t: ^testing.T) {
major, minor, patch := glfw.GetVersion() 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)) 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", "system:shell32.lib",
} }
} }
} else when ODIN_OS == .Linux {
foreign import glfw "system:glfw"
} else when ODIN_OS == .Darwin { } else when ODIN_OS == .Darwin {
foreign import glfw { when GLFW_SHARED {
"../lib/darwin/libglfw3.a", foreign import glfw {
"system:Cocoa.framework", "system:glfw",
"system:IOKit.framework", "system:Cocoa.framework",
"system:OpenGL.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 { } else {
foreign import glfw "system:glfw" foreign import glfw "system:glfw"
@@ -44,6 +51,10 @@ foreign glfw {
InitHint :: proc(hint, value: c.int) --- InitHint :: proc(hint, value: c.int) ---
InitAllocator :: proc(#by_ptr allocator: Allocator) ---
InitVulkanLoader :: proc(loader: vk.ProcGetInstanceProcAddr) ---
GetVersion :: proc(major, minor, rev: ^c.int) --- GetVersion :: proc(major, minor, rev: ^c.int) ---
GetError :: proc(description: ^cstring) -> c.int --- GetError :: proc(description: ^cstring) -> c.int ---
@@ -94,6 +105,7 @@ foreign glfw {
GetKey :: proc(window: WindowHandle, key: c.int) -> c.int --- GetKey :: proc(window: WindowHandle, key: c.int) -> c.int ---
GetKeyName :: proc(key, scancode: c.int) -> cstring --- GetKeyName :: proc(key, scancode: c.int) -> cstring ---
SetWindowShouldClose :: proc(window: WindowHandle, value: b32) --- SetWindowShouldClose :: proc(window: WindowHandle, value: b32) ---
GetWindowTitle :: proc(window: WindowHandle) -> cstring ---
JoystickPresent :: proc(joy: c.int) -> b32 --- JoystickPresent :: proc(joy: c.int) -> b32 ---
GetJoystickName :: proc(joy: c.int) -> cstring --- GetJoystickName :: proc(joy: c.int) -> cstring ---
GetKeyScancode :: proc(key: c.int) -> c.int --- GetKeyScancode :: proc(key: c.int) -> c.int ---
@@ -184,5 +196,8 @@ foreign glfw {
SetJoystickCallback :: proc(cbfun: JoystickProc) -> JoystickProc --- SetJoystickCallback :: proc(cbfun: JoystickProc) -> JoystickProc ---
SetErrorCallback :: proc(cbfun: ErrorProc) -> ErrorProc --- 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, axes: [6]f32,
} }
Allocator :: struct {
allocate: AllocateProc,
reallocate: ReallocateProc,
deallocate: DeallocateProc,
user: rawptr,
}
/*** Procedure type declarations ***/ /*** Procedure type declarations ***/
WindowIconifyProc :: #type proc "c" (window: WindowHandle, iconified: c.int) WindowIconifyProc :: #type proc "c" (window: WindowHandle, iconified: c.int)
WindowRefreshProc :: #type proc "c" (window: WindowHandle) 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) JoystickProc :: #type proc "c" (joy, event: c.int)
ErrorProc :: #type proc "c" (error: c.int, description: cstring) 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 ***/ /*** Constants ***/
/* Versions */ /* Versions */
VERSION_MAJOR :: 3 VERSION_MAJOR :: 3
VERSION_MINOR :: 3 VERSION_MINOR :: 4
VERSION_REVISION :: 8 VERSION_REVISION :: 0
/* Booleans */ /* Booleans */
TRUE :: true TRUE :: true
@@ -251,17 +251,21 @@ GAMEPAD_AXIS_RIGHT_TRIGGER :: 5
GAMEPAD_AXIS_LAST :: GAMEPAD_AXIS_RIGHT_TRIGGER GAMEPAD_AXIS_LAST :: GAMEPAD_AXIS_RIGHT_TRIGGER
/* Error constants */ /* Error constants */
NO_ERROR :: 0x00000000 NO_ERROR :: 0x00000000
NOT_INITIALIZED :: 0x00010001 NOT_INITIALIZED :: 0x00010001
NO_CURRENT_CONTEXT :: 0x00010002 NO_CURRENT_CONTEXT :: 0x00010002
INVALID_ENUM :: 0x00010003 INVALID_ENUM :: 0x00010003
INVALID_VALUE :: 0x00010004 INVALID_VALUE :: 0x00010004
OUT_OF_MEMORY :: 0x00010005 OUT_OF_MEMORY :: 0x00010005
API_UNAVAILABLE :: 0x00010006 API_UNAVAILABLE :: 0x00010006
VERSION_UNAVAILABLE :: 0x00010007 VERSION_UNAVAILABLE :: 0x00010007
PLATFORM_ERROR :: 0x00010008 PLATFORM_ERROR :: 0x00010008
FORMAT_UNAVAILABLE :: 0x00010009 FORMAT_UNAVAILABLE :: 0x00010009
NO_WINDOW_CONTEXT :: 0x0001000A NO_WINDOW_CONTEXT :: 0x0001000A
CURSOR_UNAVAILABLE :: 0x0001000B
FEATURE_UNAVAILABLE :: 0x0001000C
FEATURE_UNIMPLEMENTED :: 0x0001000D
PLATFORM_UNAVAILABLE :: 0x0001000E
/* Window attributes */ /* Window attributes */
FOCUSED :: 0x00020001 FOCUSED :: 0x00020001
@@ -276,6 +280,9 @@ CENTER_CURSOR :: 0x00020009
TRANSPARENT_FRAMEBUFFER :: 0x0002000A TRANSPARENT_FRAMEBUFFER :: 0x0002000A
HOVERED :: 0x0002000B HOVERED :: 0x0002000B
FOCUS_ON_SHOW :: 0x0002000C FOCUS_ON_SHOW :: 0x0002000C
MOUSE_PASSTHROUGH :: 0x0002000D
POSITION_X :: 0x0002000E
POSITION_Y :: 0x0002000F
/* Pixel window attributes */ /* Pixel window attributes */
RED_BITS :: 0x00021001 RED_BITS :: 0x00021001
@@ -302,12 +309,14 @@ CONTEXT_VERSION_MINOR :: 0x00022003
CONTEXT_REVISION :: 0x00022004 CONTEXT_REVISION :: 0x00022004
CONTEXT_ROBUSTNESS :: 0x00022005 CONTEXT_ROBUSTNESS :: 0x00022005
OPENGL_FORWARD_COMPAT :: 0x00022006 OPENGL_FORWARD_COMPAT :: 0x00022006
OPENGL_DEBUG_CONTEXT :: 0x00022007 CONTEXT_DEBUG :: 0x00022007
OPENGL_DEBUG_CONTEXT :: CONTEXT_DEBUG // Backwards compatibility
OPENGL_PROFILE :: 0x00022008 OPENGL_PROFILE :: 0x00022008
CONTEXT_RELEASE_BEHAVIOR :: 0x00022009 CONTEXT_RELEASE_BEHAVIOR :: 0x00022009
CONTEXT_NO_ERROR :: 0x0002200A CONTEXT_NO_ERROR :: 0x0002200A
CONTEXT_CREATION_API :: 0x0002200B CONTEXT_CREATION_API :: 0x0002200B
SCALE_TO_MONITOR :: 0x0002200C SCALE_TO_MONITOR :: 0x0002200C
SCALE_FRAMEBUFFER :: 0x0002200D
/* Cross platform attributes */ /* Cross platform attributes */
COCOA_RETINA_FRAMEBUFFER :: 0x00023001 COCOA_RETINA_FRAMEBUFFER :: 0x00023001
@@ -315,6 +324,9 @@ COCOA_FRAME_NAME :: 0x00023002
COCOA_GRAPHICS_SWITCHING :: 0x00023003 COCOA_GRAPHICS_SWITCHING :: 0x00023003
X11_CLASS_NAME :: 0x00024001 X11_CLASS_NAME :: 0x00024001
X11_INSTANCE_NAME :: 0x00024002 X11_INSTANCE_NAME :: 0x00024002
WIN32_KEYBOARD_MENU :: 0x00025001
WIN32_SHOWDEFAULT :: 0x00025002
WAYLAND_APP_ID :: 0x00026001
/* APIs */ /* APIs */
NO_API :: 0 NO_API :: 0
@@ -341,6 +353,7 @@ LOCK_KEY_MODS :: 0x00033004
CURSOR_NORMAL :: 0x00034001 CURSOR_NORMAL :: 0x00034001
CURSOR_HIDDEN :: 0x00034002 CURSOR_HIDDEN :: 0x00034002
CURSOR_DISABLED :: 0x00034003 CURSOR_DISABLED :: 0x00034003
CURSOR_CAPTURED :: 0x00034004
/* Mouse motion */ /* Mouse motion */
RAW_MOUSE_MOTION :: 0x00033005 RAW_MOUSE_MOTION :: 0x00033005
@@ -355,24 +368,56 @@ NATIVE_CONTEXT_API :: 0x00036001
EGL_CONTEXT_API :: 0x00036002 EGL_CONTEXT_API :: 0x00036002
OSMESA_CONTEXT_API :: 0x00036003 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 */ /* Types of cursors */
ARROW_CURSOR :: 0x00036001 ARROW_CURSOR :: 0x00036001
IBEAM_CURSOR :: 0x00036002 IBEAM_CURSOR :: 0x00036002
CROSSHAIR_CURSOR :: 0x00036003 CROSSHAIR_CURSOR :: 0x00036003
HAND_CURSOR :: 0x00036004 POINTING_HAND_CURSOR :: 0x00036004
HRESIZE_CURSOR :: 0x00036005 RESIZE_EW_CURSOR :: 0x00036005
VRESIZE_CURSOR :: 0x00036006 RESIZE_NS_CURSOR :: 0x00036006
RESIZE_NWSE_CURSOR :: 0x00036007 RESIZE_NWSE_CURSOR :: 0x00036007
RESIZE_NESW_CURSOR :: 0x00036008 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? */ /* Joystick? */
CONNECTED :: 0x00040001 CONNECTED :: 0x00040001
DISCONNECTED :: 0x00040002 DISCONNECTED :: 0x00040002
/* macOS specific init hint. */ JOYSTICK_HAT_BUTTONS :: 0x00050001
JOYSTICK_HAT_BUTTONS :: 0x00050001 ANGLE_PLATFORM_TYPE :: 0x00050002
COCOA_CHDIR_RESOURCES :: 0x00051001 PLATFORM :: 0x00050003
COCOA_MENUBAR :: 0x00051002
/* 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 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" 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") @(default_calling_convention="c", link_prefix="glfw")
foreign glfw { foreign {
GetCocoaWindow :: proc(window: WindowHandle) -> ^NS.Window --- GetCocoaWindow :: proc(window: WindowHandle) -> ^NS.Window ---
GetCocoaView :: proc(window: WindowHandle) -> ^NS.View ---
} }
// TODO: // TODO:
+1 -17
View File
@@ -4,24 +4,8 @@ package glfw
import win32 "core:sys/windows" 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") @(default_calling_convention="c", link_prefix="glfw")
foreign glfw { foreign {
GetWin32Adapter :: proc(monitor: MonitorHandle) -> cstring --- GetWin32Adapter :: proc(monitor: MonitorHandle) -> cstring ---
GetWin32Monitor :: proc(monitor: MonitorHandle) -> cstring --- GetWin32Monitor :: proc(monitor: MonitorHandle) -> cstring ---
GetWin32Window :: proc(window: WindowHandle) -> win32.HWND --- GetWin32Window :: proc(window: WindowHandle) -> win32.HWND ---
+6
View File
@@ -11,6 +11,8 @@ GammaRamp :: glfw.GammaRamp
Image :: glfw.Image Image :: glfw.Image
GamepadState :: glfw.GamepadState GamepadState :: glfw.GamepadState
Allocator :: glfw.Allocator
/*** Procedure type declarations ***/ /*** Procedure type declarations ***/
WindowIconifyProc :: glfw.WindowIconifyProc WindowIconifyProc :: glfw.WindowIconifyProc
WindowRefreshProc :: glfw.WindowRefreshProc WindowRefreshProc :: glfw.WindowRefreshProc
@@ -34,3 +36,7 @@ CursorEnterProc :: glfw.CursorEnterProc
JoystickProc :: glfw.JoystickProc JoystickProc :: glfw.JoystickProc
ErrorProc :: glfw.ErrorProc 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 InitHint :: glfw.InitHint
InitAllocator :: glfw.InitAllocator
InitVulkanLoader :: glfw.InitVulkanLoader
GetVersion :: proc "c" () -> (major, minor, rev: c.int) { GetVersion :: proc "c" () -> (major, minor, rev: c.int) {
glfw.GetVersion(&major, &minor, &rev) glfw.GetVersion(&major, &minor, &rev)
return return
@@ -121,6 +125,7 @@ GetKeyName :: proc "c" (key, scancode: c.int) -> string {
return string(glfw.GetKeyName(key, scancode)) return string(glfw.GetKeyName(key, scancode))
} }
SetWindowShouldClose :: glfw.SetWindowShouldClose SetWindowShouldClose :: glfw.SetWindowShouldClose
GetWindowTitle :: glfw.GetWindowTitle
JoystickPresent :: glfw.JoystickPresent JoystickPresent :: glfw.JoystickPresent
GetJoystickName :: proc "c" (joy: c.int) -> string { GetJoystickName :: proc "c" (joy: c.int) -> string {
return string(glfw.GetJoystickName(joy)) return string(glfw.GetJoystickName(joy))
@@ -237,6 +242,8 @@ SetJoystickCallback :: glfw.SetJoystickCallback
SetErrorCallback :: glfw.SetErrorCallback SetErrorCallback :: glfw.SetErrorCallback
GetPlatform :: glfw.GetPlatform
PlatformSupported :: glfw.PlatformSupported
// Used by vendor:OpenGL // Used by vendor:OpenGL
gl_set_proc_address :: proc(p: rawptr, name: cstring) { gl_set_proc_address :: proc(p: rawptr, name: cstring) {