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

Loading…
Cancel
Save