mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Replace sentinel values with std::optional
This commit is contained in:
parent
8805b93c57
commit
735f2d972d
@ -701,12 +701,12 @@ public:
|
|||||||
|
|
||||||
if ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) && (surfaceSupported == VK_TRUE))
|
if ((queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) && (surfaceSupported == VK_TRUE))
|
||||||
{
|
{
|
||||||
queueFamilyIndex = static_cast<int>(i);
|
queueFamilyIndex = static_cast<std::uint32_t>(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queueFamilyIndex < 0)
|
if (!queueFamilyIndex.has_value())
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -717,7 +717,7 @@ public:
|
|||||||
VkDeviceQueueCreateInfo deviceQueueCreateInfo = VkDeviceQueueCreateInfo();
|
VkDeviceQueueCreateInfo deviceQueueCreateInfo = VkDeviceQueueCreateInfo();
|
||||||
deviceQueueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
deviceQueueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||||
deviceQueueCreateInfo.queueCount = 1;
|
deviceQueueCreateInfo.queueCount = 1;
|
||||||
deviceQueueCreateInfo.queueFamilyIndex = static_cast<std::uint32_t>(queueFamilyIndex);
|
deviceQueueCreateInfo.queueFamilyIndex = *queueFamilyIndex;
|
||||||
deviceQueueCreateInfo.pQueuePriorities = &queuePriority;
|
deviceQueueCreateInfo.pQueuePriorities = &queuePriority;
|
||||||
|
|
||||||
// Enable the swapchain extension
|
// Enable the swapchain extension
|
||||||
@ -743,7 +743,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve a handle to the logical device command queue
|
// Retrieve a handle to the logical device command queue
|
||||||
vkGetDeviceQueue(device, static_cast<std::uint32_t>(queueFamilyIndex), 0, &queue);
|
vkGetDeviceQueue(device, *queueFamilyIndex, 0, &queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query surface formats and set up swapchain
|
// Query surface formats and set up swapchain
|
||||||
@ -1277,7 +1277,7 @@ public:
|
|||||||
// We want to be able to reset command buffers after submitting them
|
// We want to be able to reset command buffers after submitting them
|
||||||
VkCommandPoolCreateInfo commandPoolCreateInfo = VkCommandPoolCreateInfo();
|
VkCommandPoolCreateInfo commandPoolCreateInfo = VkCommandPoolCreateInfo();
|
||||||
commandPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
commandPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
||||||
commandPoolCreateInfo.queueFamilyIndex = static_cast<std::uint32_t>(queueFamilyIndex);
|
commandPoolCreateInfo.queueFamilyIndex = *queueFamilyIndex;
|
||||||
commandPoolCreateInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
commandPoolCreateInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
|
||||||
|
|
||||||
// Create our command pool
|
// Create our command pool
|
||||||
@ -2586,7 +2586,7 @@ private:
|
|||||||
VkDebugReportCallbackEXT debugReportCallback{};
|
VkDebugReportCallbackEXT debugReportCallback{};
|
||||||
VkSurfaceKHR surface{};
|
VkSurfaceKHR surface{};
|
||||||
VkPhysicalDevice gpu{};
|
VkPhysicalDevice gpu{};
|
||||||
int queueFamilyIndex{-1};
|
std::optional<std::uint32_t> queueFamilyIndex;
|
||||||
VkDevice device{};
|
VkDevice device{};
|
||||||
VkQueue queue{};
|
VkQueue queue{};
|
||||||
VkSurfaceFormatKHR swapchainFormat{};
|
VkSurfaceFormatKHR swapchainFormat{};
|
||||||
|
@ -53,9 +53,9 @@ namespace
|
|||||||
{
|
{
|
||||||
struct TouchSlot
|
struct TouchSlot
|
||||||
{
|
{
|
||||||
int oldId{-1};
|
std::optional<unsigned int> oldId;
|
||||||
int id{-1};
|
std::optional<unsigned int> id;
|
||||||
sf::Vector2i pos;
|
sf::Vector2i pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::recursive_mutex inputMutex; // threadsafe? maybe...
|
std::recursive_mutex inputMutex; // threadsafe? maybe...
|
||||||
@ -327,14 +327,14 @@ void processSlots()
|
|||||||
{
|
{
|
||||||
if (slot.oldId == slot.id)
|
if (slot.oldId == slot.id)
|
||||||
{
|
{
|
||||||
pushEvent(sf::Event::TouchMoved{static_cast<unsigned int>(slot.id), slot.pos});
|
pushEvent(sf::Event::TouchMoved{*slot.id, slot.pos});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (slot.oldId != -1)
|
if (slot.oldId.has_value())
|
||||||
pushEvent(sf::Event::TouchEnded{static_cast<unsigned int>(slot.oldId), slot.pos});
|
pushEvent(sf::Event::TouchEnded{*slot.oldId, slot.pos});
|
||||||
if (slot.id != -1)
|
if (slot.id.has_value())
|
||||||
pushEvent(sf::Event::TouchBegan{static_cast<unsigned int>(slot.id), slot.pos});
|
pushEvent(sf::Event::TouchBegan{*slot.id, slot.pos});
|
||||||
|
|
||||||
slot.oldId = slot.id;
|
slot.oldId = slot.id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user