Skip to content

Instantly share code, notes, and snippets.

@Beyley
Created November 24, 2022 07:40
Show Gist options
  • Save Beyley/ff40ea7c245e4ff1541cce660802ef56 to your computer and use it in GitHub Desktop.
Save Beyley/ff40ea7c245e4ff1541cce660802ef56 to your computer and use it in GitHub Desktop.
glfw focus test
#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