Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Zig build package and bindings for GLFW

License

NotificationsYou must be signed in to change notification settings

zig-gamedev/zglfw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zig build package and bindings forGLFW 3.4

Getting started

Examplebuild.zig:

pubfnbuild(b:*std.Build)void {constexe=b.addExecutable(.{... });constzglfw=b.dependency("zglfw", .{});exe.root_module.addImport("zglfw",zglfw.module("root"));if (target.result.os.tag!=.emscripten) {exe.linkLibrary(zglfw.artifact("glfw"));    }}

Now in your code you may import and usezglfw:

constglfw=@import("zglfw");pubfnmain()!void {tryglfw.init();deferglfw.terminate();constwindow=tryglfw.createWindow(600,600,"zig-gamedev: minimal_glfw_gl",null);deferglfw.destroyWindow(window);// or, using the equivalent, encapsulated, "objecty" API:constwindow=tryglfw.Window.create(600,600,"zig-gamedev: minimal_glfw_gl",null);deferwindow.destroy();// setup your graphics context herewhile (!window.shouldClose()) {glfw.pollEvents();// render your things herewindow.swapBuffers();    }}

Seezig-gamedev samples for more complete usage examples.

Usage with Vulkan

To match types fromzglfw functions and Vulkan libraryimport_vulkan option may be used. When using this optionvulkan import must be provided to the root module.

Examplebuild.zig withvulkan-zig:

constvulkan_headers=b.dependency("vulkan_headers");constvulkan=b.dependency("vulkan_zig", .{    .registry=vulkan_headers.path("registry/vk.xml"),}).module("vulkan-zig");constzglfw=b.dependency("zglfw", .{ .import_vulkan=true });constzglfw_mod=zglfw.module("root");zglfw_mod.addImport("vulkan",vulkan);constexe=b.addExecutable(.{    .name="vk_setup",    .root_module=b.createModule(.{        .root_source_file=b.path("src/main.zig"),        .target=target,        .optimize=optimize,        .imports= &.{            .{ .name="zglfw", .module=zglfw_mod },            .{ .name="vulkan", .module=vulkan },        },    }),});exe.root_module.linkLibrary(zglfw.artifact("glfw"));

About

Zig build package and bindings for GLFW

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors16


[8]ページ先頭

©2009-2025 Movatter.jp