diff --git a/src/main.cpp b/src/main.cpp index ef99cec..2da5b2f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "gfx.hpp" #include "icosphere.hpp" @@ -45,6 +46,14 @@ #include "orbiter.hpp" #include "widget.hpp" +void keyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) +{ + if (key == GLFW_KEY_C && action == GLFW_PRESS) + { + std::cout << "lol!" << std::endl; + } +} + int main() { GLFWwindow* window = nullptr; @@ -54,9 +63,9 @@ int main() GLuint litProgram = compileShaderProgram("./frag_lit.glsl"); GLuint unlitProgram = compileShaderProgram("./frag_unlit.glsl"); + // set up scene Icosphere planet(0.2, 3, litProgram); - std::vector keplerianElements(6); keplerianElements[astro::semiMajorAxisIndex] = .75; keplerianElements[astro::eccentricityIndex] = .5; @@ -68,9 +77,18 @@ int main() Icosphere orbiterSphere(0.07, 2, litProgram); Orbiter orbiter(orbiterSphere, orbit, unlitProgram); + // register input + // TODO: init objects with a reference to the window so that they can register + // their own key inputs + glfwSetKeyCallback(window, keyCallback); + // Main loop while (!glfwWindowShouldClose(window)) { + // TODO: receive input from GLFW + glfwPollEvents(); + + // rendering glClearColor(0.2, 0.3, 0.3, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -79,7 +97,6 @@ int main() orbiter.render(time); glfwSwapBuffers(window); - glfwPollEvents(); } glfwTerminate();