Implemented setResizeCallback and setViewport
This commit is contained in:
13
src/main.zig
13
src/main.zig
@ -106,6 +106,18 @@ fn handleActive(win: mfb.Window(State), isActive: bool) callconv(.C) void {
|
||||
}
|
||||
}
|
||||
|
||||
fn handleResize(win: mfb.Window(State), width: i32, height: i32) callconv(.C) void {
|
||||
const did_set = win.setViewport(
|
||||
@intCast(u32, width) / 4,
|
||||
@intCast(u32, height) / 4,
|
||||
@intCast(u32, width) / 2,
|
||||
@intCast(u32, height) / 2,
|
||||
);
|
||||
if (!did_set) {
|
||||
std.log.warn("did not set viewport!", .{});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
var gp_allocator = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
const alloc = gp_allocator.allocator();
|
||||
@ -118,6 +130,7 @@ pub fn main() !void {
|
||||
win.setUserData(&state);
|
||||
|
||||
win.setActiveCallback(handleActive);
|
||||
win.setResizeCallback(handleResize);
|
||||
|
||||
var buf = try Buffer.init(alloc, Width, Height);
|
||||
defer buf.deinit();
|
||||
|
Reference in New Issue
Block a user