diff --git a/example/main.c b/example/main.c index 70e3733..b8e0ebf 100644 --- a/example/main.c +++ b/example/main.c @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */ -/* Updated: 2024/01/08 22:17:57 by maldavid ### ########.fr */ +/* Updated: 2024/01/08 22:30:39 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,8 +32,8 @@ int update(void *param) mlx = (t_mlx *)param; mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->logo, 100, 100); mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->img, 150, 60); - //if (i == 0) - // mlx_set_font_scale(mlx->mlx, mlx->win, "font.ttf", 16.f); + if (i == 0) + mlx_set_font_scale(mlx->mlx, mlx->win, "font.ttf", 16.f); mlx_string_put(mlx->mlx, mlx->win, 20, 50, 0xFFFFFFFF, "that's a text"); j = 0; k = 0; diff --git a/src/renderer/core/vk_device.cpp b/src/renderer/core/vk_device.cpp index f10c599..0772839 100644 --- a/src/renderer/core/vk_device.cpp +++ b/src/renderer/core/vk_device.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/08 19:14:29 by maldavid #+# #+# */ -/* Updated: 2023/12/30 23:29:41 by maldavid ### ########.fr */ +/* Updated: 2024/01/08 23:48:53 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -91,9 +91,6 @@ namespace mlx return std::make_pair(deviceScore(device, surface), device); }); - vkDestroySurfaceKHR(Render_Core::get().getInstance().get(), surface, nullptr); - SDL_DestroyWindow(window); - using device_pair = std::pair; std::sort(devices_score.begin(), devices_score.end(), [](const device_pair& a, const device_pair& b) { @@ -110,6 +107,9 @@ namespace mlx vkGetPhysicalDeviceProperties(_physicalDevice, &props); core::error::report(e_kind::message, "Vulkan : picked a physical device, %s", props.deviceName); #endif + Render_Core::get().getQueue().findQueueFamilies(_physicalDevice, surface); // update queue indicies to current physical device + vkDestroySurfaceKHR(Render_Core::get().getInstance().get(), surface, nullptr); + SDL_DestroyWindow(window); } int Device::deviceScore(VkPhysicalDevice device, VkSurfaceKHR surface) diff --git a/src/renderer/core/vk_queues.cpp b/src/renderer/core/vk_queues.cpp index 937cc25..4c79962 100644 --- a/src/renderer/core/vk_queues.cpp +++ b/src/renderer/core/vk_queues.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/08 19:02:42 by maldavid #+# #+# */ -/* Updated: 2022/12/18 22:52:04 by maldavid ### ########.fr */ +/* Updated: 2024/01/08 23:46:36 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,7 +38,7 @@ namespace mlx _families->presentFamily = i; if(_families->isComplete()) - break; + return *_families; i++; } diff --git a/src/renderer/core/vk_queues.h b/src/renderer/core/vk_queues.h index 268f4fe..4def156 100644 --- a/src/renderer/core/vk_queues.h +++ b/src/renderer/core/vk_queues.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/08 19:01:49 by maldavid #+# #+# */ -/* Updated: 2024/01/03 15:26:31 by maldavid ### ########.fr */ +/* Updated: 2024/01/08 23:46:23 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,7 @@ #include #include #include +#include namespace mlx { @@ -37,7 +38,13 @@ namespace mlx inline VkQueue& getGraphic() noexcept { return _graphicsQueue; } inline VkQueue& getPresent() noexcept { return _presentQueue; } - inline QueueFamilyIndices getFamilies() noexcept { return *_families; } + inline QueueFamilyIndices getFamilies() noexcept + { + if(_families.has_value()) + return *_families; + core::error::report(e_kind::fatal_error, "Vulkan : cannot get queue families, not init"); + return {}; // just to avoid warnings + } private: VkQueue _graphicsQueue;