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))
|
||||
{
|
||||
queueFamilyIndex = static_cast<int>(i);
|
||||
queueFamilyIndex = static_cast<std::uint32_t>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (queueFamilyIndex < 0)
|
||||
if (!queueFamilyIndex.has_value())
|
||||
{
|
||||
vulkanAvailable = false;
|
||||
return;
|
||||
@ -717,7 +717,7 @@ public:
|
||||
VkDeviceQueueCreateInfo deviceQueueCreateInfo = VkDeviceQueueCreateInfo();
|
||||
deviceQueueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
|
||||
deviceQueueCreateInfo.queueCount = 1;
|
||||
deviceQueueCreateInfo.queueFamilyIndex = static_cast<std::uint32_t>(queueFamilyIndex);
|
||||
deviceQueueCreateInfo.queueFamilyIndex = *queueFamilyIndex;
|
||||
deviceQueueCreateInfo.pQueuePriorities = &queuePriority;
|
||||
|
||||
// Enable the swapchain extension
|
||||
@ -743,7 +743,7 @@ public:
|
||||
}
|
||||
|
||||
// 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
|
||||
@ -1277,7 +1277,7 @@ public:
|
||||
// We want to be able to reset command buffers after submitting them
|
||||
VkCommandPoolCreateInfo commandPoolCreateInfo = VkCommandPoolCreateInfo();
|
||||
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;
|
||||
|
||||
// Create our command pool
|
||||
@ -2586,7 +2586,7 @@ private:
|
||||
VkDebugReportCallbackEXT debugReportCallback{};
|
||||
VkSurfaceKHR surface{};
|
||||
VkPhysicalDevice gpu{};
|
||||
int queueFamilyIndex{-1};
|
||||
std::optional<std::uint32_t> queueFamilyIndex;
|
||||
VkDevice device{};
|
||||
VkQueue queue{};
|
||||
VkSurfaceFormatKHR swapchainFormat{};
|
||||
|
@ -53,8 +53,8 @@ namespace
|
||||
{
|
||||
struct TouchSlot
|
||||
{
|
||||
int oldId{-1};
|
||||
int id{-1};
|
||||
std::optional<unsigned int> oldId;
|
||||
std::optional<unsigned int> id;
|
||||
sf::Vector2i pos;
|
||||
};
|
||||
|
||||
@ -327,14 +327,14 @@ void processSlots()
|
||||
{
|
||||
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
|
||||
{
|
||||
if (slot.oldId != -1)
|
||||
pushEvent(sf::Event::TouchEnded{static_cast<unsigned int>(slot.oldId), slot.pos});
|
||||
if (slot.id != -1)
|
||||
pushEvent(sf::Event::TouchBegan{static_cast<unsigned int>(slot.id), slot.pos});
|
||||
if (slot.oldId.has_value())
|
||||
pushEvent(sf::Event::TouchEnded{*slot.oldId, slot.pos});
|
||||
if (slot.id.has_value())
|
||||
pushEvent(sf::Event::TouchBegan{*slot.id, slot.pos});
|
||||
|
||||
slot.oldId = slot.id;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user