swp/sur extensions + surface
This commit is contained in:
parent
084d8950d6
commit
5a331578b5
1 changed files with 31 additions and 25 deletions
56
src/main.cpp
56
src/main.cpp
|
|
@ -1,6 +1,12 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#define UNICODE
|
||||
|
||||
#ifdef _WIN32
|
||||
#define VK_USE_PLATFORM_WIN32_KHR
|
||||
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
#define VK_USE_PLATFORM_WAYLAND_KHR
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
|
|
@ -110,23 +116,23 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int n
|
|||
app_info.engineVersion = 1;
|
||||
app_info.apiVersion = VK_API_VERSION_1_0;
|
||||
|
||||
|
||||
// initialize the VkInstanceCreateInfo structure with appropiate SURFACE extensions
|
||||
std::vector<const char*> instanceExtensionNames;
|
||||
instanceExtensionNames.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
/*
|
||||
* #ifdef _WIN32
|
||||
* instanceExtensionNames.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||
* #elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
* instanceExtensionNames.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
|
||||
* #endif
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
instanceExtensionNames.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
||||
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
instanceExtensionNames.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME);
|
||||
#endif
|
||||
VkInstanceCreateInfo inst_info = {};
|
||||
inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
inst_info.pNext = NULL;
|
||||
inst_info.flags = 0;
|
||||
inst_info.pApplicationInfo = &app_info;
|
||||
inst_info.enabledExtensionCount = 0;//2;
|
||||
inst_info.ppEnabledExtensionNames = NULL;//instanceExtensionName.data();
|
||||
inst_info.enabledExtensionCount = 2;
|
||||
inst_info.ppEnabledExtensionNames = instanceExtensionNames.data();
|
||||
inst_info.enabledLayerCount = 0;
|
||||
inst_info.ppEnabledLayerNames = NULL;
|
||||
|
||||
|
|
@ -187,8 +193,8 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int n
|
|||
deviceInfo.pNext = NULL;
|
||||
deviceInfo.queueCreateInfoCount = 1;
|
||||
deviceInfo.pQueueCreateInfos = &queueInfo;
|
||||
deviceInfo.enabledExtensionCount = 0;//1;
|
||||
deviceInfo.ppEnabledExtensionNames = NULL;//deviceExtensionNames.data();
|
||||
deviceInfo.enabledExtensionCount = 1;
|
||||
deviceInfo.ppEnabledExtensionNames = deviceExtensionNames.data();
|
||||
deviceInfo.enabledLayerCount = 0;
|
||||
deviceInfo.ppEnabledLayerNames = NULL;
|
||||
deviceInfo.pEnabledFeatures = NULL;
|
||||
|
|
@ -220,16 +226,16 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int n
|
|||
assert(result == VK_SUCCESS);
|
||||
|
||||
//Swapchain setup (requires Instance SURFACEs and Device SWAPCHAIN extensions)
|
||||
/*
|
||||
* VkSurfaceKHR surface;
|
||||
* #ifdef _WIN32
|
||||
* VkWin32SurfaceCreateInfoKHR createInfo = {};
|
||||
* createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
* createInfo.pNext = NULL;
|
||||
* createInfo.hinstance = hInstance;
|
||||
* createInfo.hwnd = hwnd;
|
||||
* result = vkCreateWin32SurfaceKHR(inst, &createInfo, NULL, &surface);
|
||||
*/
|
||||
|
||||
VkSurfaceKHR surface;
|
||||
#ifdef _WIN32
|
||||
VkWin32SurfaceCreateInfoKHR createInfo = {};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||
createInfo.pNext = NULL;
|
||||
createInfo.hinstance = hInstance;
|
||||
createInfo.hwnd = hwnd;
|
||||
result = vkCreateWin32SurfaceKHR(inst, &createInfo, NULL, &surface);
|
||||
|
||||
/*
|
||||
* #elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
* VkWaylandSurfaceCreateInfoKHR createInfo = {};
|
||||
|
|
@ -238,11 +244,11 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int n
|
|||
* createInfo.display = info.display;
|
||||
* createInfo.surface = info.window;
|
||||
* res = vkCreateWaylandSurfaceKHR(inst, &createInfo, NULL, &surface);
|
||||
*
|
||||
* #endif
|
||||
* assert(result == VK_SUCCESS);
|
||||
*/
|
||||
//
|
||||
#endif
|
||||
assert(result == VK_SUCCESS);
|
||||
|
||||
|
||||
|
||||
|
||||
//Window show and event loop
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue