diff --git a/.gitignore b/.gitignore index f0fb676..b677b52 100644 --- a/.gitignore +++ b/.gitignore @@ -124,4 +124,5 @@ fabric.properties *.app bin -lib \ No newline at end of file +lib +include \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index e1235e9..f3557a5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ [submodule "vendor/glfw"] path = vendor/glfw url = https://github.com/glfw/glfw.git +[submodule "vendor/Vulkan-Headers"] + path = vendor/Vulkan-Headers + url = https://github.com/KhronosGroup/Vulkan-Headers.git +[submodule "vendor/volk"] + path = vendor/volk + url = https://github.com/zeux/volk.git diff --git a/Makefile b/Makefile index bc84f08..b0944e0 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,12 @@ sources := $(call rwildcard,src/,*.cpp) objects := $(patsubst src/%, $(buildDir)/%, $(patsubst %.cpp, %.o, $(sources))) depends := $(patsubst %.o, %.d, $(objects)) -includes := -I vendor/glfw/include -I $(VULKAN_SDK)/include +includes := -I vendor/glfw/include -I vendor/Vulkan-Headers/include -I include linkFlags = -L lib/$(platform) -lglfw3 compileFlags := -std=c++17 $(includes) +osMacros := + ifeq ($(OS),Windows_NT) LIB_EXT = .lib @@ -29,6 +31,8 @@ ifeq ($(OS),Windows_NT) MKDIR := -mkdir -p RM := -del /q COPY = -robocopy "$(call platformpth,$1)" "$(call platformpth,$2)" $3 + + osMacros = VK_USE_PLATFORM_WIN32_KHR else UNAMEOS := $(shell uname) ifeq ($(UNAMEOS), Linux) @@ -43,22 +47,19 @@ else platform := Linux CXX ?= g++ linkFlags += $(vulkanLink) -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi + + osMacros = VK_USE_PLATFORM_XLIB_KHR endif ifeq ($(UNAMEOS), Darwin) - - LIB_EXT := .dylib - - vulkanLib := vulkan.1 - vulkanLibVersion := $(patsubst %.0,%,$(VK_VERSION)) - vulkanLink := -l $(vulkanLib) -l vulkan.$(vulkanLibVersion) vulkanExports := export export VK_ICD_FILENAMES=$(VULKAN_SDK)/share/vulkan/icd.d/MoltenVK_icd.json; \ export VK_LAYER_PATH=$(VULKAN_SDK)/share/vulkan/explicit_layer.d - macOSVulkanLib = $(call COPY, $(VULKAN_SDK)/lib, lib/$(platform),libvulkan.$(vulkanLibVersion)$(LIB_EXT)) platform := macOS CXX ?= clang++ - linkFlags += $(vulkanLink) -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL + linkFlags += -framework CoreVideo -framework IOKit -framework Cocoa -framework GLUT -framework OpenGL + + osMacros = VK_USE_PLATFORM_MACOS_MVK endif vulkanLibDir := lib @@ -87,9 +88,10 @@ setup: submodules lib lib: cd vendor/glfw $(THEN) $(CMAKE_CMD) $(THEN) "$(MAKE)" $(MKDIR) $(call platformpth, lib/$(platform)) + $(MKDIR) $(call platformpth, include) $(call COPY,vendor/glfw/src,lib/$(platform),libglfw3.a) - $(call COPY,$(VULKAN_SDK)/$(vulkanLibDir),lib/$(platform),$(vulkanLibPrefix)$(vulkanLib)$(LIB_EXT)) - $(macOSVulkanLib) + $(call COPY,vendor/volk,include,volk.c) + $(call COPY,vendor/volk,include,volk.h) # Link the program and create the executable $(target): $(objects) @@ -101,7 +103,7 @@ $(target): $(objects) # Compile objects to the build directory $(buildDir)/%.o: src/%.cpp Makefile $(MKDIR) $(call platformpth, $(@D)) - $(CXX) -MMD -MP -c $(compileFlags) $< -o $@ $(CXXFLAGS) + $(CXX) -MMD -MP -c $(compileFlags) $< -o $@ $(CXXFLAGS) -D $(osMacros) clear: clear; @@ -111,3 +113,6 @@ execute: clean: $(RM) $(call platformpth, $(buildDir)/*) + $(RM) lib + $(RM) bin + $(RM) include diff --git a/src/main.cpp b/src/main.cpp index 5ee8ff8..be4a8d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,16 @@ -#define GLFW_INCLUDE_VULKAN -#include +#define VOLK_IMPLEMENTATION +#include #include #include int main() { + VkResult result = volkInitialize(); + + VkInstance instance; + + volkLoadInstance(instance); + glfwInit(); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); GLFWwindow* window = glfwCreateWindow(800, 600, "Test Window", nullptr, nullptr); diff --git a/vendor/Vulkan-Headers b/vendor/Vulkan-Headers new file mode 160000 index 0000000..0873a22 --- /dev/null +++ b/vendor/Vulkan-Headers @@ -0,0 +1 @@ +Subproject commit 0873a22a11ec7e3f13762900ad0da39206189886 diff --git a/vendor/volk b/vendor/volk new file mode 160000 index 0000000..713ab8b --- /dev/null +++ b/vendor/volk @@ -0,0 +1 @@ +Subproject commit 713ab8bfcd9d8e5fe78ccf85806c0b4e5c566f71