Created
November 24, 2022 07:40
-
-
Save Beyley/ff40ea7c245e4ff1541cce660802ef56 to your computer and use it in GitHub Desktop.
glfw focus test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <GLFW/glfw3.h> | |
#include <stdio.h> | |
void error_callback(int error, const char* description) | |
{ | |
fprintf(stderr, "Error: %s\n", description); | |
} | |
void function_name(GLFWwindow* window, int focused) { | |
printf("Focus event %d\n", focused); | |
} | |
int main() { | |
glfwInit(); | |
glfwSetErrorCallback(error_callback); | |
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); | |
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); | |
if (!window) | |
{ | |
printf("Creation of window failed!\n"); | |
return 0; | |
} | |
glfwSetWindowFocusCallback(window, function_name); | |
while (!glfwWindowShouldClose(window)) { | |
glfwPollEvents(); | |
} | |
glfwDestroyWindow(window); | |
glfwTerminate(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment