diff --git a/Makefile b/src/Makefile similarity index 52% rename from Makefile rename to src/Makefile index ff30056..e5c4a88 100755 --- a/Makefile +++ b/src/Makefile @@ -1,54 +1,57 @@ CXX = /usr/bin/g++ -CXXFLAGS = -std=c++20 -MMD -MP -Wextra #-O3: optimierungsstufe 3, -MMD .d files, -MP leeres Target, Wextra alle Warnungen -# CXXFLAGS += -ftemplate-backtrace-limit=4 #-fno-pretty-templates -# most stuff glfw deps +CXXFLAGS = -std=c++20 -MMD -MP -Wextra #-include pch.hpp #-O3: optimierungsstufe 3, -MMD .d files, -MP leeres Target, Wextra alle Warnungen LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi -lgzutil -lfreetype -IFLAGS = -I/usr/include/freetype2 -OBJECT_DIR = build -EXEC = vulkan_test +SRCDIRS = $(wildcard */) +IFLAGS = $(foreach dir,$(SRCDIRS), -I$(dir)) +IFLAGS += $(foreach dir,$(SRCDIRS), -I../$(dir)) +IFLAGS += -I../ -I./ +IFLAGS += -I/usr/include/freetype2 +CXXFLAGS += $(IFLAGS) -SRC = $(wildcard *.cpp) + +OBJECT_DIR = ../build +EXEC = ../vulkan_test + +SRC = $(wildcard *.cpp) $(wildcard */*.cpp) +# OBJECTS = $(SRC:%.cpp=$(OBJECT_DIR)/%.o) OBJECTS = $($(notdir SRC):%.cpp=$(OBJECT_DIR)/%.o) +OBJECT_DIRS = $(foreach dir,$(SRCDIRS), $(OBJECT_DIR)/$(dir)) DEPENDS = ${OBJECTS:.o=.d} -CXXFLAGS += $(IFLAGS) - default: $(EXEC) echo $(OBJECTS) -# TODO: REMOVE -g! +.PHONY: release release: CXXFLAGS += -O3 release : default # rule for the executable -$(EXEC): $(OBJECTS) +$(EXEC): $(OBJECT_DIRS) $(OBJECTS) $(CXX) $(OBJECTS) -o $@ $(CXXFLAGS) $(LDFLAGS) # include the makefiles generated by the -M flag -include $(DEPENDS) # rule for all ../build/*.o files -$(OBJECT_DIR)/%.o: %.cpp $(OBJECT_DIR)/.dirstamp +$(OBJECT_DIR)/%.o: $(shell echo $<) %.cpp $(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS) -# if build dir does not exist, create and put stamp inside -$(OBJECT_DIR)/.dirstamp: - mkdir -p $(OBJECT_DIR) - touch $@ +$(OBJECT_DIRS): + mkdir -p $@ # # Extras Options # # with debug flags +.PHONY += debug run gdb pch clean docs debug: CXXFLAGS += -g # -DDEBUG debug: default # make with debug flags and run afterwards run: CXXFLAGS += -g run: default - $(CXX) $(OBJECTS) -o $(EXEC) $(CXXFLAGS) $(LDFLAGS) - ./$(EXEC) + -pwd; cd $(shell dirname $(EXEC)); pwd; ./$(shell basename $(EXEC)) # with debug flags and run gnu debugger gdb: CXXFLAGS += -g @@ -61,6 +64,6 @@ pch: # remove all object and dependecy files clean: - # -rm -f $(OBJECT_DIR)/*.o - # -rm -f $(OBJECT_DIR)/*.d -rm -r $(OBJECT_DIR) +docs: + doxygen .doxygen_config diff --git a/font.cpp b/src/font.cpp similarity index 100% rename from font.cpp rename to src/font.cpp diff --git a/font.hpp b/src/font.hpp similarity index 100% rename from font.hpp rename to src/font.hpp diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp diff --git a/main.hpp b/src/main.hpp similarity index 100% rename from main.hpp rename to src/main.hpp diff --git a/renderer.cpp b/src/renderer/renderer.cpp similarity index 100% rename from renderer.cpp rename to src/renderer/renderer.cpp diff --git a/renderer.hpp b/src/renderer/renderer.hpp similarity index 100% rename from renderer.hpp rename to src/renderer/renderer.hpp diff --git a/renderer2D.cpp b/src/renderer/renderer2D.cpp similarity index 100% rename from renderer2D.cpp rename to src/renderer/renderer2D.cpp diff --git a/renderer2D.hpp b/src/renderer/renderer2D.hpp similarity index 100% rename from renderer2D.hpp rename to src/renderer/renderer2D.hpp diff --git a/renderer3D.cpp b/src/renderer/renderer3D.cpp similarity index 100% rename from renderer3D.cpp rename to src/renderer/renderer3D.cpp diff --git a/renderer3D.hpp b/src/renderer/renderer3D.hpp similarity index 100% rename from renderer3D.hpp rename to src/renderer/renderer3D.hpp diff --git a/shader.frag b/src/shader/shader.frag similarity index 100% rename from shader.frag rename to src/shader/shader.frag diff --git a/shader.vert b/src/shader/shader.vert similarity index 100% rename from shader.vert rename to src/shader/shader.vert diff --git a/shader2D.frag b/src/shader/shader2D.frag similarity index 100% rename from shader2D.frag rename to src/shader/shader2D.frag diff --git a/shader2D.vert b/src/shader/shader2D.vert similarity index 100% rename from shader2D.vert rename to src/shader/shader2D.vert diff --git a/shape.cpp b/src/shape.cpp similarity index 100% rename from shape.cpp rename to src/shape.cpp diff --git a/shape.hpp b/src/shape.hpp similarity index 100% rename from shape.hpp rename to src/shape.hpp diff --git a/exceptions.cpp b/src/utility/exceptions.cpp similarity index 100% rename from exceptions.cpp rename to src/utility/exceptions.cpp diff --git a/exceptions.hpp b/src/utility/exceptions.hpp similarity index 100% rename from exceptions.hpp rename to src/utility/exceptions.hpp diff --git a/texture_atlas.cpp b/src/utility/texture_atlas.cpp similarity index 100% rename from texture_atlas.cpp rename to src/utility/texture_atlas.cpp diff --git a/texture_atlas.hpp b/src/utility/texture_atlas.hpp similarity index 100% rename from texture_atlas.hpp rename to src/utility/texture_atlas.hpp diff --git a/texture_manager.cpp b/src/utility/texture_manager.cpp similarity index 100% rename from texture_manager.cpp rename to src/utility/texture_manager.cpp diff --git a/texture_manager.hpp b/src/utility/texture_manager.hpp similarity index 100% rename from texture_manager.hpp rename to src/utility/texture_manager.hpp diff --git a/vulkan_util.cpp b/src/utility/vulkan_util.cpp similarity index 100% rename from vulkan_util.cpp rename to src/utility/vulkan_util.cpp diff --git a/vulkan_util.hpp b/src/utility/vulkan_util.hpp similarity index 100% rename from vulkan_util.hpp rename to src/utility/vulkan_util.hpp diff --git a/vertex.cpp b/src/vertex.cpp similarity index 100% rename from vertex.cpp rename to src/vertex.cpp diff --git a/vertex.hpp b/src/vertex.hpp similarity index 93% rename from vertex.hpp rename to src/vertex.hpp index 99ccd50..d6b2b9f 100644 --- a/vertex.hpp +++ b/src/vertex.hpp @@ -30,9 +30,9 @@ namespace gz::vk { */ template struct Vertex { - PosVec pos; - glm::vec3 color; - glm::vec2 texCoord; + PosVec pos = PosVec(0); + glm::vec3 color = { 0, 0, 0 }; + glm::vec2 texCoord = { 0, 0 }; std::string toString() const; bool operator==(const Vertex& other) const; static VkVertexInputBindingDescription getBindingDescription(); diff --git a/vk_convert.cpp b/src/vk_convert.cpp similarity index 100% rename from vk_convert.cpp rename to src/vk_convert.cpp diff --git a/vk_convert.hpp b/src/vk_convert.hpp similarity index 100% rename from vk_convert.hpp rename to src/vk_convert.hpp diff --git a/vk_layer_settings.txt b/src/vk_layer_settings.txt similarity index 100% rename from vk_layer_settings.txt rename to src/vk_layer_settings.txt diff --git a/vulkan_instance.cpp b/src/vulkan_instance.cpp similarity index 99% rename from vulkan_instance.cpp rename to src/vulkan_instance.cpp index 6ed68f2..c8f746a 100644 --- a/vulkan_instance.cpp +++ b/src/vulkan_instance.cpp @@ -1881,7 +1881,7 @@ void VulkanInstance::loadModel() { std::unordered_map uniqueVertices; for (const auto& shape : shapes) { for (const auto& index : shape.mesh.indices) { - Vertex3D vertex{}; + Vertex3D vertex; vertex.pos = { attrib.vertices[3 * index.vertex_index + 0], attrib.vertices[3 * index.vertex_index + 1], @@ -1894,7 +1894,7 @@ void VulkanInstance::loadModel() { }; vertex.color = { 1.0f, 1.0f, 1.0f }; if (!uniqueVertices.contains(vertex)) { - uniqueVertices[vertex] = model.vertices.size(); + uniqueVertices.insert({ vertex, model.vertices.size() }); model.vertices.push_back(vertex); } /* model.vertices.push_back(vertex); */ diff --git a/vulkan_instance.hpp b/src/vulkan_instance.hpp similarity index 99% rename from vulkan_instance.hpp rename to src/vulkan_instance.hpp index 5fc8bbf..9c3ae47 100644 --- a/vulkan_instance.hpp +++ b/src/vulkan_instance.hpp @@ -463,12 +463,16 @@ namespace gz::vk { // // UTILITY // + /** + * @name Debugging + */ + /// @{ /** * @name Handle ownership * @brief Retrieve the owner of a vulkan handle * @see ObjectUsingVulkan - * @{ */ + /// @{ static std::vector objectsUsingVulkan; static void registerObjectUsingVulkan(const ObjectUsingVulkan& obj); static void getHandleOwnerString(std::string_view message); @@ -490,6 +494,7 @@ namespace gz::vk { VkDebugUtilsMessageTypeFlagsEXT messageType, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData); + /// @} template