Skip to content

Commit

Permalink
Added exit on key press for persist
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Lascu committed Jun 21, 2017
1 parent 53409eb commit 0181a03
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion get_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ void printProgramError(GLuint program) {
}
}

void persistKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) {
exit(EXIT_SUCCESS);
}

int go(int argc, char* argv[]) {

glfwWindowHint(GLFW_RESIZABLE, 0);
Expand Down Expand Up @@ -290,7 +294,11 @@ int go(int argc, char* argv[]) {
std::cerr << "Error producing PNG file: " << lodepng_error_text(png_error) << std::endl;
return EXIT_FAILURE;
}
if (!persist) {
if (persist) {
printf("Press any key to close the window...\n");
glfwSetKeyCallback(window, persistKeyCallback);
}
else {
return EXIT_SUCCESS;
}
}
Expand Down

0 comments on commit 0181a03

Please sign in to comment.