This commit is contained in:
18
examples/createContext/CMakeLists.txt
Normal file
18
examples/createContext/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(oatmeal)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
add_executable(createContext "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
|
||||
target_include_directories(createContext PRIVATE oatmeal SharedUtils)
|
||||
target_link_libraries(createContext oatmeal SharedUtils)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set_target_properties(createContext PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Debug/")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set_target_properties(createContext PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Release/")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
set_target_properties(createContext PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Relwithdeb/")
|
||||
endif()
|
||||
|
||||
47
examples/createContext/main.cpp
Normal file
47
examples/createContext/main.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "shared/logger.h"
|
||||
|
||||
#include "ctx.h"
|
||||
|
||||
int main() {
|
||||
OatmealUtils::initLogging();
|
||||
OatmealUtils::createLogger("window", nullptr);
|
||||
OatmealUtils::createLogger("context", nullptr);
|
||||
|
||||
OatmealUtils::get("window")->info("Initializing GLFW");
|
||||
glfwInit();
|
||||
|
||||
OatmealUtils::get("window")->info("Setting window hints");
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
|
||||
OatmealUtils::get("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);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
try {
|
||||
Oatmeal::ctx ctx(window);
|
||||
} catch (const std::exception &e) {
|
||||
OatmealUtils::get("context")->critical("{}", e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
OatmealUtils::get("window")->info("Cleaning up");
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -3,8 +3,8 @@ project(oatmeal)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
add_executable(logging "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
|
||||
target_include_directories(logging PRIVATE oatmeal SharedUtils)
|
||||
target_link_libraries(logging oatmeal SharedUtils)
|
||||
target_include_directories(logging PRIVATE SharedUtils)
|
||||
target_link_libraries(logging SharedUtils)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set_target_properties(logging PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/Debug/")
|
||||
|
||||
Reference in New Issue
Block a user