IT WORKS!!!
This commit is contained in:
parent
e2f3f1b09f
commit
4926cce7f1
6 changed files with 52 additions and 8 deletions
1
.clang-format
Normal file
1
.clang-format
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
SortIncludes: "Never"
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
2
clean.sh
2
clean.sh
|
|
@ -1 +1 @@
|
||||||
rm -rf build
|
rm -rf build .cache
|
||||||
|
|
|
||||||
13
shell.nix
13
shell.nix
|
|
@ -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++";
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
34
src/main.cpp
34
src/main.cpp
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"dependencies": ["fmt"]
|
"dependencies": ["fmt", "glfw3", "glad"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue