examples - rework shared into header only

This commit is contained in:
2026-04-12 23:26:50 -04:00
parent c412073c23
commit fd35e93831
5 changed files with 100 additions and 73 deletions

29
examples/shared/window.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef OATMEAL_UTILS_WINDOW
#define OATMEAL_UTILS_WINDOW
#include <cstdint>
#include "GLFW/glfw3.h"
#include "shared/logger.h"
namespace OatmealUtils {
inline GLFWwindow *initWindow(const char *title, uint32_t width, uint32_t height) {
OatmealUtils::initLogging();
OatmealUtils::createLogger("window", nullptr);
OatmealUtils::get("window")->debug("Initializing window backend");
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
OatmealUtils::get("window")->debug("Creating window");
GLFWwindow *window = glfwCreateWindow(width, height, title, nullptr, nullptr);
if (window == nullptr) {
const char *desc;
uint32_t code = glfwGetError(&desc);
OatmealUtils::get("window")->critical("Failed to create window: ({}) {}", code, desc);
exit(EXIT_FAILURE);
}
return window;
}
} // namespace OatmealUtils
#endif // !OATMEAL_UTILS_WINDOW