在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:zenith391/didot开源软件地址:https://github.com/zenith391/didot开源编程语言:Zig 99.5%开源软件介绍:DidotA Zig 3D game engine. IntroductionDidot is a multi-threaded 3D game engine programmed in Zig and aimed at high-level constructs: you manipulate game objects and meshes instead of OpenGL calls and batches. It improves developers life by splitting the engine into multiple modules in order to have easier porting to other platforms. For example, you can change the windowing module from InstallationPrerequisites:
You only need to launch your terminal and execute those commands in an empty directory: git clone https://github.com/zenith391/didot
zig init-exe And then, change the resulting const didot = @import("didot/build.zig");
const Builder = @import("std").build.Builder;
pub fn build(b: *Builder) void {
// ...
exe.setBuildMode(mode);
try didot.addEngineToExe(exe, .{
.prefix = "didot/"
});
exe.install();
// ...
} Using DidotShowing a cube: const std = @import("std");
const zlm = @import("zlm");
usingnamespace @import("didot-graphics");
usingnamespace @import("didot-objects");
usingnamespace @import("didot-app");
const Vec3 = zlm.Vec3;
const Allocator = std.mem.Allocator;
fn init(allocator: *Allocator, app: *Application) !void {
var shader = try ShaderProgram.create(@embedFile("vert.glsl"), @embedFile("frag.glsl"));
var camera = try GameObject.createObject(allocator, null);
camera.getComponent(Transform).?.* = .{
.position = Vec3.new(1.5, 1.5, -0.5),
.rotation = Vec3.new(-120.0, -15.0, 0).toRadians()
};
try camera.addComponent(Camera { .shader = shader });
try app.scene.add(camera);
var cube = try GameObject.createObject(allocator, "Mesh/Cube");
cube.getComponent(Transform).?.position = Vec3.new(-1.2, 0.75, -3);
try app.scene.add(cube);
}
pub fn main() !void {
var gp = std.heap.GeneralPurposeAllocator(.{}) {};
const allocator = &gp.allocator;
var scene = try Scene.create(allocator, null);
comptime var systems = Systems {};
var app = Application(systems) {
.title = "Test Cube",
.initFn = init
};
try app.run(allocator, scene);
} And to make that into a textured cube, only a few lines are necessary: try scene.assetManager.put("Texture/Grass", try TextureAsset.init2D(allocator, "assets/textures/grass.png", "png"));
var material = Material { .texturePath = "Texture/Grass" };
cube.material = material; First line loads You can also look at the example to see how to make camera movement or load models from OBJ files or even load scenes from JSON files. Systems (currently): fn exampleSystem(query: Query(.{*Transform})) !void {
var iterator = query.iterator();
while (iterator.next()) |o| {
std.log.info("Someone's at position {} !", .{o.transform.position});
}
}
pub fn main() !void {
// ...
comptime var systems = Systems {};
systems.addSystem(exampleSystem);
var app = Application(systems) {
.title = "Test Cube",
.initFn = init
};
try app.run(allocator, scene);
} Features
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论