Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GLFW/glfw3.h>
- #include <stdlib.h>
- #include <stdio.h>
- static void keyCallback(GLFWwindow* win, int key, int scancode, int action, int mode) {
- switch(action) {
- case GLFW_RELEASE:
- printf("Released %c\n", key);
- break;
- case GLFW_PRESS:
- printf("Press %c\n", key);
- break;
- case GLFW_REPEAT:
- printf("Repeat %c\n", key);
- break;
- default:
- exit(0);
- }
- if(key == GLFW_KEY_Q && action == GLFW_PRESS)
- glfwSetWindowShouldClose(win, GL_TRUE);
- }
- int main() {
- GLFWwindow* win;
- if(!glfwInit())
- return -1;
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- glfwWindowHint(GLFW_RESIZABLE, false);
- win = glfwCreateWindow(640, 480, "Bug", nullptr, nullptr);
- if(!win) {
- glfwTerminate();
- return -1;
- }
- glfwMakeContextCurrent(win);
- glfwSetKeyCallback(win, keyCallback);
- /*
- * if console is under GLFW window
- int xposWindow, yposWindow;
- glfwGetWindowPos(win, &xposWindow, &yposWindow);
- glfwSetWindowPos(win, xposWindow + 0, yposWindow);
- */
- while(!glfwWindowShouldClose(win)) {
- glClear(GL_COLOR_BUFFER_BIT);
- glClearColor(0.25f, 0.1f, 0.0f, 0.0f);
- glfwSwapBuffers(win);
- glfwPollEvents();
- }
- glfwTerminate();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement