IT WORKS!!!

This commit is contained in:
Benjamin Palko 2024-08-07 00:10:57 -04:00
parent e2f3f1b09f
commit 4926cce7f1
6 changed files with 52 additions and 8 deletions

1
.clang-format Normal file
View file

@ -0,0 +1 @@
SortIncludes: "Never"

View file

@ -6,10 +6,14 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(GLFW_BUILD_WAYLAND ON)
project(HelloWorld CXX) project(HelloWorld CXX)
find_package(fmt CONFIG REQUIRED) 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)

View file

@ -1 +1 @@
rm -rf build rm -rf build .cache

View file

@ -1,7 +1,14 @@
{ {
pkgs ? import <nixpkgs> { }, pkgs ? import <nixpkgs> { },
}: }:
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 is usually what you want -- tools you need to run
nativeBuildInputs = with pkgs.buildPackages; [ nativeBuildInputs = with pkgs.buildPackages; [
gnumake gnumake
@ -14,7 +21,7 @@ pkgs.mkShell {
shellHook = '' shellHook = ''
export VCPKG_ROOT="${pkgs.vcpkg.outPath}/share/vcpkg"; export VCPKG_ROOT="${pkgs.vcpkg.outPath}/share/vcpkg";
export CC="${pkgs.clang.outPath}/bin/clang"; # export CC="${pkgs.clang.outPath}/bin/clang";
export CXX="${pkgs.clang.outPath}/bin/clang++"; # export CXX="${pkgs.clang.outPath}/bin/clang++";
''; '';
} }

View file

@ -1,6 +1,38 @@
#include <fmt/core.h> #include <fmt/core.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
int main() { 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; return 0;
} }

View file

@ -1,3 +1,3 @@
{ {
"dependencies": ["fmt"] "dependencies": ["fmt", "glfw3", "glad"]
} }