Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added integration with volk. Need to test further #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ fabric.properties
*.app

bin
lib
lib
include
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
29 changes: 17 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -111,3 +113,6 @@ execute:

clean:
$(RM) $(call platformpth, $(buildDir)/*)
$(RM) lib
$(RM) bin
$(RM) include
10 changes: 8 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#define GLFW_INCLUDE_VULKAN
#include <vulkan/vulkan.h>
#define VOLK_IMPLEMENTATION
#include <volk.h>
#include <GLFW/glfw3.h>
#include <iostream>

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);
Expand Down
1 change: 1 addition & 0 deletions vendor/Vulkan-Headers
Submodule Vulkan-Headers added at 0873a2
1 change: 1 addition & 0 deletions vendor/volk
Submodule volk added at 713ab8