lower framerate when not focused
This commit is contained in:
@@ -427,6 +427,10 @@ pub const Window = struct {
|
|||||||
pub fn should_close(self: Self) bool {
|
pub fn should_close(self: Self) bool {
|
||||||
return c.glfwWindowShouldClose(self.handle) == c.GLFW_TRUE;
|
return c.glfwWindowShouldClose(self.handle) == c.GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn focused(self: Self) bool {
|
||||||
|
return c.glfwGetWindowAttrib(self.handle, c.GLFW_FOCUSED) == c.GLFW_TRUE;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn wait_events() []const Bus.Event {
|
pub fn wait_events() []const Bus.Event {
|
||||||
|
@@ -89,8 +89,10 @@ pub fn main() !void {
|
|||||||
while (!au.W.should_close()) : (flight_idx = (flight_idx + 1) % flight.len) {
|
while (!au.W.should_close()) : (flight_idx = (flight_idx + 1) % flight.len) {
|
||||||
const frame = flight[flight_idx];
|
const frame = flight[flight_idx];
|
||||||
|
|
||||||
// todo switch mode depending on if window is focused
|
const events = if (au.W.focused())
|
||||||
const events = au.wait_events_timeout(0.10);
|
au.wait_events_timeout(0.1)
|
||||||
|
else
|
||||||
|
au.wait_events_timeout(0.5);
|
||||||
|
|
||||||
for (events) |u| {
|
for (events) |u| {
|
||||||
switch (u) {
|
switch (u) {
|
||||||
|
Reference in New Issue
Block a user