wip: receive key input
This commit is contained in:
parent
441a0748d1
commit
0b4e84323c
21
src/main.cpp
21
src/main.cpp
|
@ -38,6 +38,7 @@
|
|||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <astro/stateVectorIndices.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#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<float> 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();
|
||||
|
|
Loading…
Reference in New Issue