moved rendering to a system.
To ensure that the rendering system is being run in the main thread, I added the concept of "Sync systems", so that when a system group is created it's possible to specify whether it's possible to run it on a separate thread or not.
This commit is contained in:
parent
fd7973173f
commit
16a2a40418
9 changed files with 85 additions and 64 deletions
|
|
@ -1,6 +1,8 @@
|
|||
const std = @import("std");
|
||||
const ecs = @import("ecs");
|
||||
const math = @import("../math.zig");
|
||||
const sideros = @import("sideros");
|
||||
const math = sideros.math;
|
||||
|
||||
const Camera = @This();
|
||||
const UP = @Vector(3, f32){ 0.0, 1.0, 0.0 };
|
||||
|
||||
|
|
@ -19,15 +21,15 @@ front: @Vector(3, f32),
|
|||
up: @Vector(3, f32),
|
||||
speed: f32 = 2.5,
|
||||
|
||||
fn getProjection(width: usize, height: usize) math.Matrix {
|
||||
pub fn getProjection(width: usize, height: usize) math.Matrix {
|
||||
return math.Matrix.perspective(math.rad(45.0), (@as(f32, @floatFromInt(width)) / @as(f32, @floatFromInt(height))), 0.1, 10.0);
|
||||
}
|
||||
|
||||
fn getView(self: Camera) math.Matrix {
|
||||
pub fn getView(self: Camera) math.Matrix {
|
||||
math.lookAt(self.position, self.position + self.front, self.up);
|
||||
}
|
||||
|
||||
fn moveCamera(pool: *ecs.Pool) void {
|
||||
pub fn moveCamera(pool: *ecs.Pool) void {
|
||||
const input = pool.resources.input;
|
||||
const camera = pool.resources.camera;
|
||||
if (input.isKeyDown(.w)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue