26 [[maybe_unused]]
int result = glfwInit();
27 assert(result == GLFW_TRUE);
29 if (!glfwVulkanSupported()) {
31 fprintf(stderr,
"Vulkan is not supported on this platform.\n");
36 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
39 glfwCreateWindow(800, 600,
"Impeller Example (Vulkan)", NULL, NULL);
40 assert(window != NULL);
45 ImpellerContext context =
47 assert(context != NULL);
50 [[maybe_unused]]
bool info_result =
52 assert(!!info_result);
54 if (glfwGetPhysicalDevicePresentationSupport(
58 fprintf(stderr,
"Queue does not support presentation.\n");
63 VkSurfaceKHR vulkan_surface_khr;
64 VkResult error = glfwCreateWindowSurface(info.
vk_instance, window, NULL,
68 fprintf(stderr,
"Could not create Vulkan surface for presentation.\n");
73 int framebuffer_width, framebuffer_height;
74 glfwGetFramebufferSize(window, &framebuffer_width, &framebuffer_height);
75 ImpellerVulkanSwapchain swapchain =
77 assert(swapchain != NULL);
79 ImpellerDisplayList dl = NULL;
104 while (!glfwWindowShouldClose(window)) {
107 ImpellerSurface surface =
109 assert(surface != NULL);
119 glfwMakeContextCurrent(NULL);
121 glfwDestroyWindow(window);
void * ProcAddressCallback(void *vulkan_instance, const char *vulkan_proc_name, void *user_data)
void GLFWErrorCallback(int error, const char *description)
IMPELLER_EXPORT void ImpellerPaintRelease(ImpellerPaint IMPELLER_NULLABLE paint)
Release a previously retained reference to the object. The object can be NULL in which case this meth...
IMPELLER_EXPORT bool ImpellerSurfacePresent(ImpellerSurface IMPELLER_NONNULL surface)
Present the surface to the underlying window system.
IMPELLER_EXPORT void ImpellerSurfaceRelease(ImpellerSurface IMPELLER_NULLABLE surface)
Release a previously retained reference to the object. The object can be NULL in which case this meth...
IMPELLER_EXPORT void ImpellerDisplayListBuilderDrawRect(ImpellerDisplayListBuilder IMPELLER_NONNULL builder, const ImpellerRect *IMPELLER_NONNULL rect, ImpellerPaint IMPELLER_NONNULL paint)
Draws a rectangle.
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerPaint IMPELLER_NULLABLE ImpellerPaintNew()
Create a new paint with default values.
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerDisplayList IMPELLER_NULLABLE ImpellerDisplayListBuilderCreateDisplayListNew(ImpellerDisplayListBuilder IMPELLER_NONNULL builder)
Create a new display list using the rendering intent already encoded in the builder....
IMPELLER_EXPORT void ImpellerDisplayListBuilderRelease(ImpellerDisplayListBuilder IMPELLER_NULLABLE builder)
Release a previously retained reference to the object. The object can be NULL in which case this meth...
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerSurface IMPELLER_NULLABLE ImpellerVulkanSwapchainAcquireNextSurfaceNew(ImpellerVulkanSwapchain IMPELLER_NONNULL swapchain)
A potentially blocking operation, acquires the next surface to render to. Since this may block,...
IMPELLER_EXPORT void ImpellerPaintSetColor(ImpellerPaint IMPELLER_NONNULL paint, const ImpellerColor *IMPELLER_NONNULL color)
Set the paint color.
IMPELLER_EXPORT bool ImpellerContextGetVulkanInfo(ImpellerContext IMPELLER_NONNULL context, ImpellerContextVulkanInfo *IMPELLER_NONNULL out_vulkan_info)
Get internal Vulkan handles managed by the given Vulkan context. Ownership of the handles is still ma...
IMPELLER_EXPORT void ImpellerDisplayListRelease(ImpellerDisplayList IMPELLER_NULLABLE display_list)
Release a previously retained reference to the object. The object can be NULL in which case this meth...
IMPELLER_EXPORT bool ImpellerSurfaceDrawDisplayList(ImpellerSurface IMPELLER_NONNULL surface, ImpellerDisplayList IMPELLER_NONNULL display_list)
Draw a display list onto the surface. The same display list can be drawn multiple times to different ...
IMPELLER_EXPORT void ImpellerDisplayListBuilderDrawPaint(ImpellerDisplayListBuilder IMPELLER_NONNULL builder, ImpellerPaint IMPELLER_NONNULL paint)
Fills the current clip with the specified paint.
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerVulkanSwapchain IMPELLER_NULLABLE ImpellerVulkanSwapchainCreateNew(ImpellerContext IMPELLER_NONNULL context, void *IMPELLER_NONNULL vulkan_surface_khr)
Create a new Vulkan swapchain using a VkSurfaceKHR instance. Ownership of the surface is transferred ...
IMPELLER_EXPORT void ImpellerContextRelease(ImpellerContext IMPELLER_NULLABLE context)
Release a previously retained reference to the object. The object can be NULL in which case this meth...
IMPELLER_EXPORT void ImpellerVulkanSwapchainRelease(ImpellerVulkanSwapchain IMPELLER_NULLABLE swapchain)
Release a previously retained reference to the object. The object can be NULL in which case this meth...
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerDisplayListBuilder IMPELLER_NULLABLE ImpellerDisplayListBuilderNew(const ImpellerRect *IMPELLER_NULLABLE cull_rect)
Create a new display list builder.
IMPELLER_EXPORT IMPELLER_NODISCARD ImpellerContext IMPELLER_NULLABLE ImpellerContextCreateVulkanNew(uint32_t version, const ImpellerContextVulkanSettings *IMPELLER_NONNULL settings)
Create a Vulkan context using the provided Vulkan Settings.
uint32_t graphics_queue_family_index
void *IMPELLER_NULLABLE vk_instance
void *IMPELLER_NULLABLE vk_physical_device
ImpellerVulkanProcAddressCallback IMPELLER_NONNULL proc_address_callback
bool enable_vulkan_validation