From b47c5e27d89f0f4c7c67d9738d654e3fa32b9bad Mon Sep 17 00:00:00 2001 From: Patrick Schwarzer Date: Sun, 1 Feb 2026 22:07:13 +0100 Subject: [PATCH] Fixed linux compat --- .gitignore | 3 +- .idea/encodings.xml | 7 ++++ CMakeLists.txt | 58 ++++++++++++++++++------------- assets/shaders/basicFragment.frag | 2 +- assets/shaders/basicVertex.vert | 2 +- {Engine => engine}/mesh.h | 0 {Engine => engine}/shader.h | 8 ++--- {Engine => engine}/texture.h | 0 main.cpp | 1 + 9 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 .idea/encodings.xml rename {Engine => engine}/mesh.h (100%) rename {Engine => engine}/shader.h (99%) rename {Engine => engine}/texture.h (100%) diff --git a/.gitignore b/.gitignore index 314b094..30d9503 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -cmake-build-debug/ \ No newline at end of file +cmake-build-debug/ +build \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..af7b022 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b37d98..7e09a0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,43 +1,51 @@ -cmake_minimum_required(VERSION 4.1) -project(Engine2026) +cmake_minimum_required(VERSION 3.15) +project(Engine2026 LANGUAGES CXX C) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) -include_directories(/ - vendor) +find_package(OpenGL REQUIRED) +find_package(glfw3 3.3 QUIET) -add_executable(Engine2026 main.cpp +if(NOT glfw3_FOUND) + message(STATUS "glfw3 not found via find_package") + if(WIN32) + set(GLFW_LIB "${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw/libglfw3.a") + else() + message(FATAL_ERROR "GLFW not found") + endif() +endif() + +add_executable(Engine2026 + main.cpp engine/shader.h engine/texture.h engine/mesh.h - vendor/glad/glad.c ) target_include_directories(Engine2026 PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/vendor") - -target_link_libraries(Engine2026 PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw/libglfw3.a" # Static MinGW lib - this fixes -lglfw not found - opengl32 - gdi32 - user32 + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/vendor ) -# Copy entire folder (textures/, shaders/, models/, etc.) +if(glfw3_FOUND) + target_link_libraries(Engine2026 PRIVATE glfw OpenGL::GL) +else() + target_link_libraries(Engine2026 PRIVATE + ${GLFW_LIB} + opengl32 + gdi32 + user32 + ) +endif() + +# Copy assets to build dir add_custom_command( TARGET Engine2026 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - "${CMAKE_CURRENT_SOURCE_DIR}/assets" # adjust to your folder name - "$/assets" - COMMENT "Copying textures to output directory" -) - -# Repeat for other folders, e.g. shaders -add_custom_command( - TARGET Engine2026 POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - "${CMAKE_CURRENT_SOURCE_DIR}/assets" - "$/assets" + ${CMAKE_CURRENT_SOURCE_DIR}/assets + $/assets + COMMENT "Copying assets to output directory" ) \ No newline at end of file diff --git a/assets/shaders/basicFragment.frag b/assets/shaders/basicFragment.frag index 9c521ac..49c55db 100644 --- a/assets/shaders/basicFragment.frag +++ b/assets/shaders/basicFragment.frag @@ -1,4 +1,4 @@ -#version 330 core +#version 330 core out vec4 FragColor; in vec3 ourColor; diff --git a/assets/shaders/basicVertex.vert b/assets/shaders/basicVertex.vert index f85924e..1e7e64c 100644 --- a/assets/shaders/basicVertex.vert +++ b/assets/shaders/basicVertex.vert @@ -1,4 +1,4 @@ -#version 330 core +#version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec3 aColor; layout (location = 2) in vec2 aTexCoord; diff --git a/Engine/mesh.h b/engine/mesh.h similarity index 100% rename from Engine/mesh.h rename to engine/mesh.h diff --git a/Engine/shader.h b/engine/shader.h similarity index 99% rename from Engine/shader.h rename to engine/shader.h index f697db2..a9c0051 100644 --- a/Engine/shader.h +++ b/engine/shader.h @@ -23,22 +23,22 @@ public: vertexFile.exceptions (std::ifstream::failbit | std::ifstream::badbit); fragmentFile.exceptions (std::ifstream::failbit | std::ifstream::badbit); - + try { // Open the files vertexFile.open(vertexPath); fragmentFile.open(fragmentPath); std::stringstream vertexStream, fragmentStream; - + // Save the contents to our streams vertexStream << vertexFile.rdbuf(); fragmentStream << fragmentFile.rdbuf(); - + // Close files vertexFile.close(); fragmentFile.close(); - + // Save the contents to our strings vertexCode = vertexStream.str(); fragmentCode = fragmentStream.str(); diff --git a/Engine/texture.h b/engine/texture.h similarity index 100% rename from Engine/texture.h rename to engine/texture.h diff --git a/main.cpp b/main.cpp index 9d298cd..a2c713d 100644 --- a/main.cpp +++ b/main.cpp @@ -1,3 +1,4 @@ + #include #include