diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..d602280 --- /dev/null +++ b/.clang-format @@ -0,0 +1 @@ +SortIncludes: "Never" diff --git a/CMakeLists.txt b/CMakeLists.txt index 20887c2..ddef2e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,10 +6,14 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") +set(GLFW_BUILD_WAYLAND ON) + project(HelloWorld CXX) find_package(fmt CONFIG REQUIRED) +find_package(glfw3 CONFIG REQUIRED) +find_package(glad CONFIG REQUIRED) -add_executable(HelloWorld src/main.cpp) +add_executable(main src/main.cpp) -target_link_libraries(HelloWorld PRIVATE fmt::fmt) +target_link_libraries(main PRIVATE fmt::fmt glfw glad::glad) diff --git a/clean.sh b/clean.sh index 1582321..b3db122 100755 --- a/clean.sh +++ b/clean.sh @@ -1 +1 @@ -rm -rf build +rm -rf build .cache diff --git a/shell.nix b/shell.nix index 828a228..bb570b0 100644 --- a/shell.nix +++ b/shell.nix @@ -1,7 +1,14 @@ { pkgs ? import { }, }: -pkgs.mkShell { +pkgs.llvmPackages.stdenv.mkDerivation { + + name = "Development"; + buildInputs = with pkgs.buildPackages; [ + glfw-wayland + libglvnd + libglvnd.dev + ]; # nativeBuildInputs is usually what you want -- tools you need to run nativeBuildInputs = with pkgs.buildPackages; [ gnumake @@ -14,7 +21,7 @@ pkgs.mkShell { shellHook = '' export VCPKG_ROOT="${pkgs.vcpkg.outPath}/share/vcpkg"; - export CC="${pkgs.clang.outPath}/bin/clang"; - export CXX="${pkgs.clang.outPath}/bin/clang++"; + # export CC="${pkgs.clang.outPath}/bin/clang"; + # export CXX="${pkgs.clang.outPath}/bin/clang++"; ''; } diff --git a/src/main.cpp b/src/main.cpp index 6c64ddf..0f7e61b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,38 @@ #include +#include +#include int main() { - fmt::print("Hello world!\n"); + + if (!glfwInit()) { + const char *description; + int code = glfwGetError(&description); + fmt::print("GLFW failed to init! {}", code); + return -1; + } + GLFWwindow *window = + glfwCreateWindow(640, 480, "HELLO WORLD!", glfwGetPrimaryMonitor(), NULL); + + if (!window) { + glfwTerminate(); + fmt::print("Window or OpenGL context creation failed"); + return -1; + } + + glfwMakeContextCurrent(window); + + /* Loop until the user closes the window */ + while (!glfwWindowShouldClose(window)) { + /* Render here */ + + /* Swap front and back buffers */ + glfwSwapBuffers(window); + + /* Poll for and process events */ + glfwPollEvents(); + } + + glfwTerminate(); + return 0; } diff --git a/vcpkg.json b/vcpkg.json index 80e6b42..188685d 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,3 +1,3 @@ { - "dependencies": ["fmt"] + "dependencies": ["fmt", "glfw3", "glad"] }