Allow mfb_open_ex options
This commit is contained in:
parent
5346d16aba
commit
05047c49d8
@ -20,8 +20,18 @@ pub const Window = struct{
|
|||||||
|
|
||||||
pub const State = enum {ok, exit};
|
pub const State = enum {ok, exit};
|
||||||
|
|
||||||
pub fn open(title: [*:0]const u8, width: u32, height: u32) !Window {
|
pub const OpenFlags = packed struct {
|
||||||
const cwin: ?*minifb_c.mfb_window = minifb_c.mfb_open(@as([*c]const u8, title), width, height);
|
resizable: bool = false,
|
||||||
|
fullscreen: bool = false,
|
||||||
|
fullscreenDesktop: bool = false,
|
||||||
|
borderless: bool = false,
|
||||||
|
alwaysOnTop: bool = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn open(title: [*:0]const u8, width: u32, height: u32, flags: OpenFlags) !Window {
|
||||||
|
const intFlags: u32 = @bitCast(u5, flags);
|
||||||
|
const cTitle = @as([*c]const u8, title);
|
||||||
|
const cwin: ?*minifb_c.mfb_window = minifb_c.mfb_open_ex(cTitle, width, height, intFlags);
|
||||||
if (cwin) |value| {
|
if (cwin) |value| {
|
||||||
return Window {.cwin=value};
|
return Window {.cwin=value};
|
||||||
} else {
|
} else {
|
||||||
|
@ -41,6 +41,7 @@ const State = struct {
|
|||||||
|
|
||||||
buf.drawRectangle(.{.x=0,.y=0}, .{.x=Width, .y=Height}, grey(@floatToInt(u8, bgValue)));
|
buf.drawRectangle(.{.x=0,.y=0}, .{.x=Width, .y=Height}, grey(@floatToInt(u8, bgValue)));
|
||||||
buf.drawRectangle(.{.x=Width/3, .y=Height/3}, .{.x=2*Width/3, .y=2*Height/3}, mfb.rgb(255,0,0));
|
buf.drawRectangle(.{.x=Width/3, .y=Height/3}, .{.x=2*Width/3, .y=2*Height/3}, mfb.rgb(255,0,0));
|
||||||
|
buf.drawRectangle(.{.x=0,.y=0}, .{.x=10,.y=10}, mfb.rgb(0,0,255));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -96,8 +97,7 @@ pub fn main() !void {
|
|||||||
var gp_allocator = std.heap.GeneralPurposeAllocator(.{}){};
|
var gp_allocator = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
const alloc = &gp_allocator.allocator;
|
const alloc = &gp_allocator.allocator;
|
||||||
|
|
||||||
std.log.info("All your codebase are belong to us.", .{});
|
var win = mfb.Window.open("Hello minifb-zig", Width, Height, .{.resizable=true}) catch unreachable;
|
||||||
var win = mfb.Window.open("Hello minifb-zig", Width, Height) catch unreachable;
|
|
||||||
mfb.setTargetFPS(7);
|
mfb.setTargetFPS(7);
|
||||||
|
|
||||||
var state = try State.init(3);
|
var state = try State.init(3);
|
||||||
|
Loading…
Reference in New Issue
Block a user