Browse Source

main.cpp: wire up inotify

master
gradient 8 years ago
parent
commit
97a1df16c8
1 changed files with 12 additions and 2 deletions
  1. +12
    -2
      src/main.cpp

+ 12
- 2
src/main.cpp View File

@ -9,6 +9,7 @@
#include "gui.h"
#include "state.h"
#include "notify.h"
#define CLEAR_COLOR 0.0, 0.0, 0.0, 1.0
@ -61,12 +62,14 @@ int main(int argc, char* argv[]) {
// demo state
auto config = Config::from_file("../config.toml");
auto state = DemoState(std::make_shared<Config>(config));
auto inotify = NotifyService();
// set up a GUI state
auto gui = Gui(&state);
if (argc == 2) {
auto proj = Project::fromFile(std::string(argv[1]));
inotify.watch(*proj);
state.current_project = std::move(proj);
}
@ -94,11 +97,12 @@ int main(int argc, char* argv[]) {
glBindVertexArray(0);
double t, t_prev, dt;
unsigned long frame_n = 0;
glfwSetTime(0); t_prev = glfwGetTime();
while(!glfwWindowShouldClose(window) && state.running) {
t = glfwGetTime();
dt = t - t_prev; t_prev = t;
glfwPollEvents();
ImGui_ImplGlfwGL3_NewFrame();
@ -135,8 +139,14 @@ int main(int argc, char* argv[]) {
glfwSwapBuffers(window);
if ((frame_n % 10) == 0) {
inotify._poll();
}
std::cout << std::flush;
std::cerr << std::flush;
frame_n++;
}
ImGui_ImplGlfwGL3_Shutdown();
@ -144,4 +154,4 @@ int main(int argc, char* argv[]) {
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
}

Loading…
Cancel
Save