glfw: build fixes
This commit is contained in:
@@ -3,16 +3,10 @@ const std = @import("std");
|
|||||||
const CFLAGS: []const []const u8 = &.{
|
const CFLAGS: []const []const u8 = &.{
|
||||||
"-std=c99",
|
"-std=c99",
|
||||||
"-Wall",
|
"-Wall",
|
||||||
"-Wextra",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
const target = b.standardTargetOptions(.{
|
const target = b.standardTargetOptions(.{});
|
||||||
.whitelist = &.{
|
|
||||||
std.Target.Query.parse(.{ .arch_os_abi = "x86_64-windows" }) catch unreachable,
|
|
||||||
std.Target.Query.parse(.{ .arch_os_abi = "x86_64-linux" }) catch unreachable,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const vm_dep = b.dependency("vecmath", .{ .target = target });
|
const vm_dep = b.dependency("vecmath", .{ .target = target });
|
||||||
@@ -66,6 +60,8 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
switch (target.result.os.tag) {
|
switch (target.result.os.tag) {
|
||||||
.windows => {
|
.windows => {
|
||||||
|
mod.addCMacro("UNICODE", "");
|
||||||
|
mod.addCMacro("_UNICODE", "");
|
||||||
mod.addCMacro("_GLFW_WIN32", "");
|
mod.addCMacro("_GLFW_WIN32", "");
|
||||||
mod.addCSourceFiles(.{
|
mod.addCSourceFiles(.{
|
||||||
.files = &.{
|
.files = &.{
|
||||||
@@ -82,6 +78,7 @@ pub fn build(b: *std.Build) void {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
.linux => {
|
.linux => {
|
||||||
|
mod.addCMacro("_DEFAULT_SOURCE", "");
|
||||||
mod.addCMacro("_GLFW_X11", "");
|
mod.addCMacro("_GLFW_X11", "");
|
||||||
mod.addCMacro("_GLFW_WAYLAND", "");
|
mod.addCMacro("_GLFW_WAYLAND", "");
|
||||||
mod.addCSourceFiles(.{
|
mod.addCSourceFiles(.{
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ pub const Key = enum(c_int) {
|
|||||||
BACKSLASH = 92,
|
BACKSLASH = 92,
|
||||||
RIGHT_BRACKET = 93,
|
RIGHT_BRACKET = 93,
|
||||||
GRAVE_ACCENT = 96,
|
GRAVE_ACCENT = 96,
|
||||||
WORLD_1 = 61,
|
WORLD_1 = 161,
|
||||||
WORLD_2 = 62,
|
WORLD_2 = 162,
|
||||||
|
|
||||||
// Function keys
|
// Function keys
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ pub const Modifiers = packed struct(c_int) {
|
|||||||
super: bool = false,
|
super: bool = false,
|
||||||
caps_lock: bool = false,
|
caps_lock: bool = false,
|
||||||
num_lock: bool = false,
|
num_lock: bool = false,
|
||||||
_pad6: u28 = 0,
|
_pad6: u26 = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const MouseButton = enum(c_int) {
|
pub const MouseButton = enum(c_int) {
|
||||||
@@ -597,6 +597,10 @@ pub const Monitor = opaque {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub const Window = opaque {
|
pub const Window = opaque {
|
||||||
|
pub inline fn destroy(self: *Window) void {
|
||||||
|
import.glfwDestroyWindow(self);
|
||||||
|
}
|
||||||
|
|
||||||
pub inline fn shouldClose(self: *Window) bool {
|
pub inline fn shouldClose(self: *Window) bool {
|
||||||
return import.glfwWindowShouldClose(self).toBool();
|
return import.glfwWindowShouldClose(self).toBool();
|
||||||
}
|
}
|
||||||
@@ -1026,7 +1030,7 @@ pub const ErrorWithDescription = struct {
|
|||||||
description: ?[*:0]const u8,
|
description: ?[*:0]const u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn getError() ErrorCode {
|
pub inline fn getError() ErrorWithDescription {
|
||||||
var ret: ErrorWithDescription = undefined;
|
var ret: ErrorWithDescription = undefined;
|
||||||
ret.error_code = import.glfwGetError(&ret.description);
|
ret.error_code = import.glfwGetError(&ret.description);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1073,8 +1077,8 @@ pub inline fn windowHintString(hint: WindowHint, value: [*:0]const u8) void {
|
|||||||
import.glfwWindowHintString(hint, value);
|
import.glfwWindowHintString(hint, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn createWindow(width: c_int, height: c_int, title: [*:0]const u8, monitor: ?*Monitor, share: ?*Window) ?*Window {
|
pub inline fn createWindow(size: vm.Vector2Int, title: [*:0]const u8, monitor: ?*Monitor, share: ?*Window) ?*Window {
|
||||||
return import.glfwCreateWindow(width, height, title, monitor, share);
|
return import.glfwCreateWindow(size.x, size.y, title, monitor, share);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn pollEvents() void {
|
pub inline fn pollEvents() void {
|
||||||
@@ -1094,7 +1098,7 @@ pub inline fn postEmptyEvent() void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn rawMouseMotionSupported() bool {
|
pub inline fn rawMouseMotionSupported() bool {
|
||||||
import.glfwRawMouseMotionSupported().toBool();
|
return import.glfwRawMouseMotionSupported().toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getKeyName(key: Key, scancode: c_int) ?[*:0]const u8 {
|
pub inline fn getKeyName(key: Key, scancode: c_int) ?[*:0]const u8 {
|
||||||
@@ -1165,7 +1169,7 @@ pub inline fn vulkanSupported() bool {
|
|||||||
return import.glfwVulkanSupported().toBool();
|
return import.glfwVulkanSupported().toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn getRequiredInstanceExtensions() ?[*][*:0]const u8 {
|
pub inline fn getRequiredInstanceExtensions() ?[][*:0]const u8 {
|
||||||
var count: u32 = undefined;
|
var count: u32 = undefined;
|
||||||
if (import.glfwGetRequiredInstanceExtensions(&count)) |ptr| {
|
if (import.glfwGetRequiredInstanceExtensions(&count)) |ptr| {
|
||||||
return ptr[0..count];
|
return ptr[0..count];
|
||||||
@@ -1187,7 +1191,7 @@ pub const CreateWindowSurfaceResult = struct {
|
|||||||
surface: vk.SurfaceKHR,
|
surface: vk.SurfaceKHR,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub inline fn createWindowSurface(instance: vk.Instance, window: *Window, allocator: ?*const vk.AllocationCallbacks) vk.Result {
|
pub inline fn createWindowSurface(instance: vk.Instance, window: *Window, allocator: ?*const vk.AllocationCallbacks) CreateWindowSurfaceResult {
|
||||||
var ret: CreateWindowSurfaceResult = undefined;
|
var ret: CreateWindowSurfaceResult = undefined;
|
||||||
ret.result = import.glfwCreateWindowSurface(instance, window, allocator, &ret.surface);
|
ret.result = import.glfwCreateWindowSurface(instance, window, allocator, &ret.surface);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user