summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Halase <jordan@halase.me>2019-10-27 15:02:42 -0500
committerJordan Halase <jordan@halase.me>2019-10-27 15:02:42 -0500
commit25168e79f33cb51625c150e0819268f0da16b67f (patch)
tree4de0d6c4d767e7dbc9a362412a349d86a9f8c1a8
parentb9b804e59c983f9f21f695f51577da93b92ebb0f (diff)
Begin adding Windows support
-rw-r--r--Makefile2
-rw-r--r--main.c12
2 files changed, 12 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index c2d96e6..e7ba5db 100644
--- a/Makefile
+++ b/Makefile
@@ -4,11 +4,13 @@ FEATURE=-DHAVE_MSAA
GLSLC=glslc
CFLAGS=-I$(VULKAN_SDK)/include $(FEATURE) $(DEBUG) $(WARN)
+CXXFLAGS=$(CFLAGS) -std=c++14
LDFLAGS=-L$(VULKAN_SDK)/lib -lvulkan
# XXX: Pugl branch location
CFLAGS+=-I../pugl
LDFLAGS+=-L../pugl/build -lpugl_x11
+#LDFLAGS+=-L../pugl/build -lpugl_win
all: main shaders
diff --git a/main.c b/main.c
index 98863b1..59afa2c 100644
--- a/main.c
+++ b/main.c
@@ -277,6 +277,14 @@ static VkDeviceSize getNearestAlignment(const VkDeviceSize offset, const VkDevic
return offset;
}
+#if defined(__linux__)
+#define PLATFORM_SURFACE VK_KHR_XLIB_SURFACE_EXTENSION_NAME
+#elif defined(__WIN32)
+#define PLATFORM_SURFACE VK_KHR_WIN32_SURFACE_EXTENSION_NAME
+#else
+#error "Unknown Vulkan surface extension for this platform"
+#endif
+
static void createInstance()
{
const VkApplicationInfo appInfo = {
@@ -301,7 +309,7 @@ static void createInstance()
// This could be negotiated at a later time.
static const char *const additional[] = {
VK_KHR_SURFACE_EXTENSION_NAME,
- VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
+ PLATFORM_SURFACE,
VK_EXT_DEBUG_REPORT_EXTENSION_NAME
};
const unsigned nAdditional = sizeof(additional)/sizeof(additional[0]);
@@ -987,7 +995,7 @@ static void createSurface()
const VkWin32SurfaceCreateInfoKHR createInfo = {
.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR,
.hinstance = GetModuleHandle(NULL), // FIXME: whole process scope
- .hwnd = puglGetNativeWindow(view)
+ .hwnd = (HWND)puglGetNativeWindow(view)
};
VkResult result;
if ((result = vkCreateWin32SurfaceKHR(instance, &createInfo, NULL, &surface))) {