Example #1
0
Surface createSurface(vk::Instance instance, Display& dpy, Window window)
{
	vk::XlibSurfaceCreateInfoKHR info;
    info.dpy = &dpy;
    info.window = window;

	vk::SurfaceKHR ret;
	VPP_PROC(instance, CreateXlibSurfaceKHR)(instance, &info, nullptr, &ret);
	return {instance, ret};
}
Example #2
0
Surface createSurface(vk::Instance instance, struct wl_display& dpy, struct wl_surface& surface)
{
	vk::WaylandSurfaceCreateInfoKHR info;
    info.display = &dpy;
    info.surface = &surface;

	vk::SurfaceKHR ret;
	VPP_PROC(instance, CreateWaylandSurfaceKHR)(instance, &info, nullptr, &ret);
	return {instance, ret};
}
Example #3
0
Window::Window(const vpp::Instance& instance)
{
	// create a simple winapi window
	constexpr auto name = "vpp::intro";
	constexpr auto width = 1200;
	constexpr auto height = 700;
	auto hinstance = ::GetModuleHandle(nullptr);

	WNDCLASSEX wndClass {};
	wndClass.cbSize = sizeof(WNDCLASSEX);
	wndClass.style = CS_HREDRAW | CS_VREDRAW;
	wndClass.lpfnWndProc = wndProc;
	wndClass.hInstance = hinstance;
	wndClass.hIcon = ::LoadIcon(NULL, IDI_APPLICATION);
	wndClass.hCursor = ::LoadCursor(NULL, IDC_ARROW);
	wndClass.lpszClassName = name;
	wndClass.hIconSm = ::LoadIcon(NULL, IDI_WINLOGO);

	if(!::RegisterClassEx(&wndClass))
		throw std::runtime_error("Failed to register window class");

	auto flags = WS_OVERLAPPEDWINDOW;
	window = ::CreateWindowEx(0, name, name, flags, CW_USEDEFAULT,
		CW_USEDEFAULT, width, height, nullptr, nullptr, hinstance, nullptr);

	if(!window)
		throw std::runtime_error("Failed to create window");

	::ShowWindow(window, SW_SHOW);
	::SetForegroundWindow(window);
	::SetFocus(window);
	::SetWindowLongPtr(window, GWLP_USERDATA, reinterpret_cast<ULONG_PTR>(this));

	// create the vulkan surface
	vk::Win32SurfaceCreateInfoKHR info;
	info.hinstance = hinstance;
	info.hwnd = window;

	vk::SurfaceKHR vksurf;
	VPP_PROC(instance, CreateWin32SurfaceKHR)(instance, &info, nullptr, &vksurf);
	surface = {instance, vksurf};
}