New folder structure

This commit is contained in:
matthias@arch 2022-10-16 23:41:11 +02:00
parent 5767428fd3
commit a812c60587
32 changed files with 34 additions and 26 deletions

View File

@ -1,54 +1,57 @@
CXX = /usr/bin/g++ CXX = /usr/bin/g++
CXXFLAGS = -std=c++20 -MMD -MP -Wextra #-O3: optimierungsstufe 3, -MMD .d files, -MP leeres Target, Wextra alle Warnungen CXXFLAGS = -std=c++20 -MMD -MP -Wextra #-include pch.hpp #-O3: optimierungsstufe 3, -MMD .d files, -MP leeres Target, Wextra alle Warnungen
# CXXFLAGS += -ftemplate-backtrace-limit=4 #-fno-pretty-templates
# most stuff glfw deps
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi -lgzutil -lfreetype LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi -lgzutil -lfreetype
IFLAGS = -I/usr/include/freetype2
OBJECT_DIR = build SRCDIRS = $(wildcard */)
EXEC = vulkan_test 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) OBJECTS = $($(notdir SRC):%.cpp=$(OBJECT_DIR)/%.o)
OBJECT_DIRS = $(foreach dir,$(SRCDIRS), $(OBJECT_DIR)/$(dir))
DEPENDS = ${OBJECTS:.o=.d} DEPENDS = ${OBJECTS:.o=.d}
CXXFLAGS += $(IFLAGS)
default: $(EXEC) default: $(EXEC)
echo $(OBJECTS) echo $(OBJECTS)
# TODO: REMOVE -g! .PHONY: release
release: CXXFLAGS += -O3 release: CXXFLAGS += -O3
release : default release : default
# rule for the executable # rule for the executable
$(EXEC): $(OBJECTS) $(EXEC): $(OBJECT_DIRS) $(OBJECTS)
$(CXX) $(OBJECTS) -o $@ $(CXXFLAGS) $(LDFLAGS) $(CXX) $(OBJECTS) -o $@ $(CXXFLAGS) $(LDFLAGS)
# include the makefiles generated by the -M flag # include the makefiles generated by the -M flag
-include $(DEPENDS) -include $(DEPENDS)
# rule for all ../build/*.o files # rule for all ../build/*.o files
$(OBJECT_DIR)/%.o: %.cpp $(OBJECT_DIR)/.dirstamp $(OBJECT_DIR)/%.o: $(shell echo $<) %.cpp
$(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS) $(CXX) -c $< -o $@ $(CXXFLAGS) $(LDFLAGS)
# if build dir does not exist, create and put stamp inside $(OBJECT_DIRS):
$(OBJECT_DIR)/.dirstamp: mkdir -p $@
mkdir -p $(OBJECT_DIR)
touch $@
# #
# Extras Options # Extras Options
# #
# with debug flags # with debug flags
.PHONY += debug run gdb pch clean docs
debug: CXXFLAGS += -g # -DDEBUG debug: CXXFLAGS += -g # -DDEBUG
debug: default debug: default
# make with debug flags and run afterwards # make with debug flags and run afterwards
run: CXXFLAGS += -g run: CXXFLAGS += -g
run: default run: default
$(CXX) $(OBJECTS) -o $(EXEC) $(CXXFLAGS) $(LDFLAGS) -pwd; cd $(shell dirname $(EXEC)); pwd; ./$(shell basename $(EXEC))
./$(EXEC)
# with debug flags and run gnu debugger # with debug flags and run gnu debugger
gdb: CXXFLAGS += -g gdb: CXXFLAGS += -g
@ -61,6 +64,6 @@ pch:
# remove all object and dependecy files # remove all object and dependecy files
clean: clean:
# -rm -f $(OBJECT_DIR)/*.o
# -rm -f $(OBJECT_DIR)/*.d
-rm -r $(OBJECT_DIR) -rm -r $(OBJECT_DIR)
docs:
doxygen .doxygen_config

View File

@ -30,9 +30,9 @@ namespace gz::vk {
*/ */
template<GLM_vec2_or_3 PosVec> template<GLM_vec2_or_3 PosVec>
struct Vertex { struct Vertex {
PosVec pos; PosVec pos = PosVec(0);
glm::vec3 color; glm::vec3 color = { 0, 0, 0 };
glm::vec2 texCoord; glm::vec2 texCoord = { 0, 0 };
std::string toString() const; std::string toString() const;
bool operator==(const Vertex& other) const; bool operator==(const Vertex& other) const;
static VkVertexInputBindingDescription getBindingDescription(); static VkVertexInputBindingDescription getBindingDescription();

View File

@ -1881,7 +1881,7 @@ void VulkanInstance::loadModel() {
std::unordered_map<Vertex3D, uint32_t> uniqueVertices; std::unordered_map<Vertex3D, uint32_t> uniqueVertices;
for (const auto& shape : shapes) { for (const auto& shape : shapes) {
for (const auto& index : shape.mesh.indices) { for (const auto& index : shape.mesh.indices) {
Vertex3D vertex{}; Vertex3D vertex;
vertex.pos = { vertex.pos = {
attrib.vertices[3 * index.vertex_index + 0], attrib.vertices[3 * index.vertex_index + 0],
attrib.vertices[3 * index.vertex_index + 1], attrib.vertices[3 * index.vertex_index + 1],
@ -1894,7 +1894,7 @@ void VulkanInstance::loadModel() {
}; };
vertex.color = { 1.0f, 1.0f, 1.0f }; vertex.color = { 1.0f, 1.0f, 1.0f };
if (!uniqueVertices.contains(vertex)) { 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);
} }
/* model.vertices.push_back(vertex); */ /* model.vertices.push_back(vertex); */

View File

@ -463,12 +463,16 @@ namespace gz::vk {
// //
// UTILITY // UTILITY
// //
/**
* @name Debugging
*/
/// @{
/** /**
* @name Handle ownership * @name Handle ownership
* @brief Retrieve the owner of a vulkan handle * @brief Retrieve the owner of a vulkan handle
* @see ObjectUsingVulkan * @see ObjectUsingVulkan
* @{
*/ */
/// @{
static std::vector<ObjectUsingVulkan> objectsUsingVulkan; static std::vector<ObjectUsingVulkan> objectsUsingVulkan;
static void registerObjectUsingVulkan(const ObjectUsingVulkan& obj); static void registerObjectUsingVulkan(const ObjectUsingVulkan& obj);
static void getHandleOwnerString(std::string_view message); static void getHandleOwnerString(std::string_view message);
@ -490,6 +494,7 @@ namespace gz::vk {
VkDebugUtilsMessageTypeFlagsEXT messageType, VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData); void* pUserData);
/// @}
template<typename T, typename... Args> template<typename T, typename... Args>