Add ESC key callback for closing
This commit is contained in:
parent
dce2418762
commit
065c89e902
8
main.cpp
8
main.cpp
@ -32,6 +32,12 @@ private:
|
|||||||
float gravityAmount;
|
float gravityAmount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
|
||||||
|
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
World *world = World::createWorld();
|
World *world = World::createWorld();
|
||||||
world->registerSystem(new GravitySystem(-9.8f));
|
world->registerSystem(new GravitySystem(-9.8f));
|
||||||
@ -61,6 +67,8 @@ int main() {
|
|||||||
/* Make the window's context current */
|
/* Make the window's context current */
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
/* Loop until the user closes the window */
|
/* Loop until the user closes the window */
|
||||||
while (!glfwWindowShouldClose(window)) {
|
while (!glfwWindowShouldClose(window)) {
|
||||||
/* Render here */
|
/* Render here */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user