// basicGLFWWindow // While I've got a basic initWindow() function in shared/window.h, I mostly just wanted to give an example of how to // create a window with glfw without it. You can always figure out from the window.h file as well, but it is nice and // easy to just look here instead, as you're probably already here anyways. // Oatmeal does ship with GLFW linked as public, so you should be able to just link with it in your CMakeLists.txt file // without having to add it yourself. // - Firewire #include #include #include "GLFW/glfw3.h" #include "shared/logger.h" int main() { // Init and create the logger OatmealUtils::initLogging(); OatmealUtils::createLogger("window", nullptr); // Initialize the GLFW backend OatmealUtils::getLogger("window")->info("Initializing GLFW"); glfwInit(); // GLFW works on hints for configuration. // Since oatmeal is entirely vulkan based and GLFW creates an opengl context by default, we need to tell it not to. // At the time of writing (very very early indev) there is no resizable window support, so thats turned off here as // well. OatmealUtils::getLogger("window")->info("Setting window hints"); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); // Create the window, running a small error check just in case it failed for whatever reason; and if it did, grab // the error from glfw and print it out. OatmealUtils::getLogger("window")->info("Create window"); GLFWwindow *window = glfwCreateWindow(800, 600, "Oatmeal - Basic GLFW window", nullptr, nullptr); if (window == nullptr) { const char *desc; uint32_t code = glfwGetError(&desc); OatmealUtils::getLogger("window")->critical("Failed to create window: ({}) {}", code, desc); exit(EXIT_FAILURE); } // This here is whats known as the main application loop. Everything with graphics/games/whatever runs in a loop, // updating values as needed before it starts over again. The time it takes to run that loop is known at the // frametime, and how many times you can run that loop per second is the FPS (sorta) // Since we are just creating a window and have no way of updating it yet, we can just poll for any events and // continue. while (!glfwWindowShouldClose(window)) { glfwPollEvents(); } // Cleanup the window and terminate the glfw backend OatmealUtils::getLogger("window")->info("Cleaning up"); glfwDestroyWindow(window); glfwTerminate(); return 0; }