diff --git a/examples/basicGLFWWindow/main.cpp b/examples/basicGLFWWindow/main.cpp index 7f54828..2406bbc 100644 --- a/examples/basicGLFWWindow/main.cpp +++ b/examples/basicGLFWWindow/main.cpp @@ -1,33 +1,55 @@ +// 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); - OatmealUtils::get("window")->info("Initializing GLFW"); + // Initialize the GLFW backend + OatmealUtils::getLogger("window")->info("Initializing GLFW"); glfwInit(); - OatmealUtils::get("window")->info("Setting window hints"); + // 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); - OatmealUtils::get("window")->info("Create window"); + // 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::get("window")->critical("Failed to create window: ({}) {}", code, 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(); } - OatmealUtils::get("window")->info("Cleaning up"); + // Cleanup the window and terminate the glfw backend + OatmealUtils::getLogger("window")->info("Cleaning up"); glfwDestroyWindow(window); glfwTerminate(); diff --git a/examples/createContext/main.cpp b/examples/createContext/main.cpp index bdbfcad..f12f7d8 100644 --- a/examples/createContext/main.cpp +++ b/examples/createContext/main.cpp @@ -1,3 +1,8 @@ +// createContext +// Still in progress, although I'm 95% sure this wont get changed. +// Come back later! +// - Firewire + #include #include #include "GLFW/glfw3.h" @@ -15,7 +20,7 @@ int main() { try { Oatmeal::ctx ctx(window); } catch (const std::exception &e) { - OatmealUtils::get("context")->critical("{}", e.what()); + OatmealUtils::getLogger("context")->critical("{}", e.what()); return EXIT_FAILURE; } @@ -24,7 +29,7 @@ int main() { glfwPollEvents(); } - OatmealUtils::get("window")->info("Cleaning up"); + OatmealUtils::getLogger("window")->info("Cleaning up"); glfwDestroyWindow(window); glfwTerminate(); diff --git a/examples/logging/main.cpp b/examples/logging/main.cpp index b248898..8a6c6e1 100644 --- a/examples/logging/main.cpp +++ b/examples/logging/main.cpp @@ -1,3 +1,9 @@ +// Logging +// This program is just to test out/show any new features I add to the shared/logging.h file. +// It is mostly a wrapper around spdlog, nothing fancy at all. +// The code should be self explanatory enough so I'm not going to bother commenting everything out. +// - Firewire + #include #include "shared/logger.h" @@ -5,13 +11,13 @@ int main() { OatmealUtils::initLogging(); OatmealUtils::createLogger("logger", nullptr); - OatmealUtils::get("logger")->debug("This is a debug message!"); - OatmealUtils::get("logger")->info("This is an info message!"); - OatmealUtils::get("logger")->warn("This is a warning message!"); - OatmealUtils::get("logger")->critical("This is a critical message!"); + OatmealUtils::getLogger("logger")->debug("This is a debug message!"); + OatmealUtils::getLogger("logger")->info("This is an info message!"); + OatmealUtils::getLogger("logger")->warn("This is a warning message!"); + OatmealUtils::getLogger("logger")->critical("This is a critical message!"); uint32_t a = 5; std::string b = "Test string arg!"; - OatmealUtils::get("logger")->info("String arg: {} uint32_t args: {}", b, a); + OatmealUtils::getLogger("logger")->info("String arg: {} uint32_t args: {}", b, a); return 0; } diff --git a/examples/shared/shared/logger.h b/examples/shared/shared/logger.h index ddf5aef..e14c911 100644 --- a/examples/shared/shared/logger.h +++ b/examples/shared/shared/logger.h @@ -49,8 +49,8 @@ namespace OatmealUtils { } inline void createLogger(std::string name, std::string filename) { createLogger(name.c_str(), filename.c_str()); } - inline std::shared_ptr get(const char *name) { return spdlog::get(name); } - inline std::shared_ptr get(std::string name) { return spdlog::get(name); } + inline std::shared_ptr getLogger(const char *name) { return spdlog::get(name); } + inline std::shared_ptr getLogger(std::string name) { return spdlog::get(name); } } // namespace OatmealUtils