mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Added modernize-use-nullptr check
Addressed review comments Fixed Vulkan.cpp clang-tidy issues Used default-constructed objects instead of 0 More fun with OSX clang-tidy Try casting a nullptr to see if clang-tidy can live with it Revert "Try casting a nullptr to see if clang-tidy can live with it" This reverts commit e217a1d8be45e3fd27dc73e1c7043be921d3830b. Restored deleted line
This commit is contained in:
parent
badb388507
commit
39dd630f07
@ -2,6 +2,7 @@ Checks: >
|
|||||||
-*,
|
-*,
|
||||||
clang-analyzer-*,
|
clang-analyzer-*,
|
||||||
modernize-concat-nested-namespaces,
|
modernize-concat-nested-namespaces,
|
||||||
|
modernize-use-nullptr,
|
||||||
readability-identifier-naming,
|
readability-identifier-naming,
|
||||||
-clang-analyzer-core.NonNullParamChecker,
|
-clang-analyzer-core.NonNullParamChecker,
|
||||||
-clang-analyzer-core.NullDereference,
|
-clang-analyzer-core.NullDereference,
|
||||||
|
@ -209,36 +209,36 @@ public:
|
|||||||
maxFramesInFlight(2),
|
maxFramesInFlight(2),
|
||||||
currentFrame(0),
|
currentFrame(0),
|
||||||
swapchainOutOfDate(false),
|
swapchainOutOfDate(false),
|
||||||
instance(0),
|
instance(),
|
||||||
debugReportCallback(0),
|
debugReportCallback(),
|
||||||
surface(0),
|
surface(),
|
||||||
gpu(0),
|
gpu(),
|
||||||
queueFamilyIndex(-1),
|
queueFamilyIndex(-1),
|
||||||
device(0),
|
device(),
|
||||||
queue(0),
|
queue(),
|
||||||
swapchainFormat(),
|
swapchainFormat(),
|
||||||
swapchainExtent(),
|
swapchainExtent(),
|
||||||
swapchain(0),
|
swapchain(),
|
||||||
depthFormat(VK_FORMAT_UNDEFINED),
|
depthFormat(VK_FORMAT_UNDEFINED),
|
||||||
depthImage(0),
|
depthImage(),
|
||||||
depthImageMemory(0),
|
depthImageMemory(),
|
||||||
depthImageView(0),
|
depthImageView(),
|
||||||
vertexShaderModule(0),
|
vertexShaderModule(),
|
||||||
fragmentShaderModule(0),
|
fragmentShaderModule(),
|
||||||
descriptorSetLayout(0),
|
descriptorSetLayout(),
|
||||||
pipelineLayout(0),
|
pipelineLayout(),
|
||||||
renderPass(0),
|
renderPass(),
|
||||||
graphicsPipeline(0),
|
graphicsPipeline(),
|
||||||
commandPool(0),
|
commandPool(),
|
||||||
vertexBuffer(0),
|
vertexBuffer(),
|
||||||
vertexBufferMemory(0),
|
vertexBufferMemory(),
|
||||||
indexBuffer(0),
|
indexBuffer(),
|
||||||
indexBufferMemory(0),
|
indexBufferMemory(),
|
||||||
textureImage(0),
|
textureImage(),
|
||||||
textureImageMemory(0),
|
textureImageMemory(),
|
||||||
textureImageView(0),
|
textureImageView(),
|
||||||
textureSampler(0),
|
textureSampler(),
|
||||||
descriptorPool(0)
|
descriptorPool()
|
||||||
{
|
{
|
||||||
// Vulkan setup procedure
|
// Vulkan setup procedure
|
||||||
if (vulkanAvailable)
|
if (vulkanAvailable)
|
||||||
@ -316,70 +316,70 @@ public:
|
|||||||
|
|
||||||
// Vulkan teardown procedure
|
// Vulkan teardown procedure
|
||||||
for (VkFence fence : fences)
|
for (VkFence fence : fences)
|
||||||
vkDestroyFence(device, fence, 0);
|
vkDestroyFence(device, fence, nullptr);
|
||||||
|
|
||||||
for (VkSemaphore renderFinishedSemaphore : renderFinishedSemaphores)
|
for (VkSemaphore renderFinishedSemaphore : renderFinishedSemaphores)
|
||||||
vkDestroySemaphore(device, renderFinishedSemaphore, 0);
|
vkDestroySemaphore(device, renderFinishedSemaphore, nullptr);
|
||||||
|
|
||||||
for (VkSemaphore imageAvailableSemaphore : imageAvailableSemaphores)
|
for (VkSemaphore imageAvailableSemaphore : imageAvailableSemaphores)
|
||||||
vkDestroySemaphore(device, imageAvailableSemaphore, 0);
|
vkDestroySemaphore(device, imageAvailableSemaphore, nullptr);
|
||||||
|
|
||||||
if (descriptorPool)
|
if (descriptorPool)
|
||||||
vkDestroyDescriptorPool(device, descriptorPool, 0);
|
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
|
||||||
|
|
||||||
for (VkDeviceMemory i : uniformBuffersMemory)
|
for (VkDeviceMemory i : uniformBuffersMemory)
|
||||||
vkFreeMemory(device, i, 0);
|
vkFreeMemory(device, i, nullptr);
|
||||||
|
|
||||||
for (VkBuffer uniformBuffer : uniformBuffers)
|
for (VkBuffer uniformBuffer : uniformBuffers)
|
||||||
vkDestroyBuffer(device, uniformBuffer, 0);
|
vkDestroyBuffer(device, uniformBuffer, nullptr);
|
||||||
|
|
||||||
if (textureSampler)
|
if (textureSampler)
|
||||||
vkDestroySampler(device, textureSampler, 0);
|
vkDestroySampler(device, textureSampler, nullptr);
|
||||||
|
|
||||||
if (textureImageView)
|
if (textureImageView)
|
||||||
vkDestroyImageView(device, textureImageView, 0);
|
vkDestroyImageView(device, textureImageView, nullptr);
|
||||||
|
|
||||||
if (textureImageMemory)
|
if (textureImageMemory)
|
||||||
vkFreeMemory(device, textureImageMemory, 0);
|
vkFreeMemory(device, textureImageMemory, nullptr);
|
||||||
|
|
||||||
if (textureImage)
|
if (textureImage)
|
||||||
vkDestroyImage(device, textureImage, 0);
|
vkDestroyImage(device, textureImage, nullptr);
|
||||||
|
|
||||||
if (indexBufferMemory)
|
if (indexBufferMemory)
|
||||||
vkFreeMemory(device, indexBufferMemory, 0);
|
vkFreeMemory(device, indexBufferMemory, nullptr);
|
||||||
|
|
||||||
if (indexBuffer)
|
if (indexBuffer)
|
||||||
vkDestroyBuffer(device, indexBuffer, 0);
|
vkDestroyBuffer(device, indexBuffer, nullptr);
|
||||||
|
|
||||||
if (vertexBufferMemory)
|
if (vertexBufferMemory)
|
||||||
vkFreeMemory(device, vertexBufferMemory, 0);
|
vkFreeMemory(device, vertexBufferMemory, nullptr);
|
||||||
|
|
||||||
if (vertexBuffer)
|
if (vertexBuffer)
|
||||||
vkDestroyBuffer(device, vertexBuffer, 0);
|
vkDestroyBuffer(device, vertexBuffer, nullptr);
|
||||||
|
|
||||||
if (commandPool)
|
if (commandPool)
|
||||||
vkDestroyCommandPool(device, commandPool, 0);
|
vkDestroyCommandPool(device, commandPool, nullptr);
|
||||||
|
|
||||||
if (descriptorSetLayout)
|
if (descriptorSetLayout)
|
||||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, 0);
|
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
||||||
|
|
||||||
if (fragmentShaderModule)
|
if (fragmentShaderModule)
|
||||||
vkDestroyShaderModule(device, fragmentShaderModule, 0);
|
vkDestroyShaderModule(device, fragmentShaderModule, nullptr);
|
||||||
|
|
||||||
if (vertexShaderModule)
|
if (vertexShaderModule)
|
||||||
vkDestroyShaderModule(device, vertexShaderModule, 0);
|
vkDestroyShaderModule(device, vertexShaderModule, nullptr);
|
||||||
|
|
||||||
if (device)
|
if (device)
|
||||||
vkDestroyDevice(device, 0);
|
vkDestroyDevice(device, nullptr);
|
||||||
|
|
||||||
if (surface)
|
if (surface)
|
||||||
vkDestroySurfaceKHR(instance, surface, 0);
|
vkDestroySurfaceKHR(instance, surface, nullptr);
|
||||||
|
|
||||||
if (debugReportCallback)
|
if (debugReportCallback)
|
||||||
vkDestroyDebugReportCallbackEXT(instance, debugReportCallback, 0);
|
vkDestroyDebugReportCallbackEXT(instance, debugReportCallback, nullptr);
|
||||||
|
|
||||||
if (instance)
|
if (instance)
|
||||||
vkDestroyInstance(instance, 0);
|
vkDestroyInstance(instance, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup swapchain
|
// Cleanup swapchain
|
||||||
@ -395,35 +395,35 @@ public:
|
|||||||
commandBuffers.clear();
|
commandBuffers.clear();
|
||||||
|
|
||||||
for (VkFramebuffer swapchainFramebuffer : swapchainFramebuffers)
|
for (VkFramebuffer swapchainFramebuffer : swapchainFramebuffers)
|
||||||
vkDestroyFramebuffer(device, swapchainFramebuffer, 0);
|
vkDestroyFramebuffer(device, swapchainFramebuffer, nullptr);
|
||||||
|
|
||||||
swapchainFramebuffers.clear();
|
swapchainFramebuffers.clear();
|
||||||
|
|
||||||
if (graphicsPipeline)
|
if (graphicsPipeline)
|
||||||
vkDestroyPipeline(device, graphicsPipeline, 0);
|
vkDestroyPipeline(device, graphicsPipeline, nullptr);
|
||||||
|
|
||||||
if (renderPass)
|
if (renderPass)
|
||||||
vkDestroyRenderPass(device, renderPass, 0);
|
vkDestroyRenderPass(device, renderPass, nullptr);
|
||||||
|
|
||||||
if (pipelineLayout)
|
if (pipelineLayout)
|
||||||
vkDestroyPipelineLayout(device, pipelineLayout, 0);
|
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
||||||
|
|
||||||
if (depthImageView)
|
if (depthImageView)
|
||||||
vkDestroyImageView(device, depthImageView, 0);
|
vkDestroyImageView(device, depthImageView, nullptr);
|
||||||
|
|
||||||
if (depthImageMemory)
|
if (depthImageMemory)
|
||||||
vkFreeMemory(device, depthImageMemory, 0);
|
vkFreeMemory(device, depthImageMemory, nullptr);
|
||||||
|
|
||||||
if (depthImage)
|
if (depthImage)
|
||||||
vkDestroyImage(device, depthImage, 0);
|
vkDestroyImage(device, depthImage, nullptr);
|
||||||
|
|
||||||
for (VkImageView swapchainImageView : swapchainImageViews)
|
for (VkImageView swapchainImageView : swapchainImageViews)
|
||||||
vkDestroyImageView(device, swapchainImageView, 0);
|
vkDestroyImageView(device, swapchainImageView, nullptr);
|
||||||
|
|
||||||
swapchainImageViews.clear();
|
swapchainImageViews.clear();
|
||||||
|
|
||||||
if (swapchain)
|
if (swapchain)
|
||||||
vkDestroySwapchainKHR(device, swapchain, 0);
|
vkDestroySwapchainKHR(device, swapchain, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup and recreate swapchain
|
// Cleanup and recreate swapchain
|
||||||
@ -462,7 +462,7 @@ public:
|
|||||||
void setupInstance()
|
void setupInstance()
|
||||||
{
|
{
|
||||||
// Load bootstrap entry points
|
// Load bootstrap entry points
|
||||||
gladLoadVulkan(0, getVulkanFunction);
|
gladLoadVulkan({}, getVulkanFunction);
|
||||||
|
|
||||||
if (!vkCreateInstance)
|
if (!vkCreateInstance)
|
||||||
{
|
{
|
||||||
@ -475,7 +475,7 @@ public:
|
|||||||
|
|
||||||
std::vector<VkLayerProperties> layers;
|
std::vector<VkLayerProperties> layers;
|
||||||
|
|
||||||
if (vkEnumerateInstanceLayerProperties(&objectCount, 0) != VK_SUCCESS)
|
if (vkEnumerateInstanceLayerProperties(&objectCount, nullptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -537,7 +537,7 @@ public:
|
|||||||
instanceCreateInfo.ppEnabledExtensionNames = requiredExtentions.data();
|
instanceCreateInfo.ppEnabledExtensionNames = requiredExtentions.data();
|
||||||
|
|
||||||
// Try to create a Vulkan instance with debug report enabled
|
// Try to create a Vulkan instance with debug report enabled
|
||||||
VkResult result = vkCreateInstance(&instanceCreateInfo, 0, &instance);
|
VkResult result = vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
|
||||||
|
|
||||||
// If an extension is missing, try disabling debug report
|
// If an extension is missing, try disabling debug report
|
||||||
if (result == VK_ERROR_EXTENSION_NOT_PRESENT)
|
if (result == VK_ERROR_EXTENSION_NOT_PRESENT)
|
||||||
@ -547,7 +547,7 @@ public:
|
|||||||
instanceCreateInfo.enabledExtensionCount = static_cast<std::uint32_t>(requiredExtentions.size());
|
instanceCreateInfo.enabledExtensionCount = static_cast<std::uint32_t>(requiredExtentions.size());
|
||||||
instanceCreateInfo.ppEnabledExtensionNames = requiredExtentions.data();
|
instanceCreateInfo.ppEnabledExtensionNames = requiredExtentions.data();
|
||||||
|
|
||||||
result = vkCreateInstance(&instanceCreateInfo, 0, &instance);
|
result = vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If instance creation still fails, give up
|
// If instance creation still fails, give up
|
||||||
@ -558,7 +558,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load instance entry points
|
// Load instance entry points
|
||||||
gladLoadVulkan(0, getVulkanFunction);
|
gladLoadVulkan({}, getVulkanFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup our debug callback function to be called by Vulkan
|
// Setup our debug callback function to be called by Vulkan
|
||||||
@ -576,7 +576,8 @@ public:
|
|||||||
debugReportCallbackCreateInfo.pfnCallback = debugCallback;
|
debugReportCallbackCreateInfo.pfnCallback = debugCallback;
|
||||||
|
|
||||||
// Create the debug callback
|
// Create the debug callback
|
||||||
if (vkCreateDebugReportCallbackEXT(instance, &debugReportCallbackCreateInfo, 0, &debugReportCallback) != VK_SUCCESS)
|
if (vkCreateDebugReportCallbackEXT(instance, &debugReportCallbackCreateInfo, nullptr, &debugReportCallback) !=
|
||||||
|
VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -605,7 +606,7 @@ public:
|
|||||||
|
|
||||||
std::vector<VkPhysicalDevice> devices;
|
std::vector<VkPhysicalDevice> devices;
|
||||||
|
|
||||||
if (vkEnumeratePhysicalDevices(instance, &objectCount, 0) != VK_SUCCESS)
|
if (vkEnumeratePhysicalDevices(instance, &objectCount, nullptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -627,7 +628,7 @@ public:
|
|||||||
|
|
||||||
std::vector<VkExtensionProperties> extensions;
|
std::vector<VkExtensionProperties> extensions;
|
||||||
|
|
||||||
if (vkEnumerateDeviceExtensionProperties(dev, 0, &objectCount, 0) != VK_SUCCESS)
|
if (vkEnumerateDeviceExtensionProperties(dev, nullptr, &objectCount, nullptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -635,7 +636,7 @@ public:
|
|||||||
|
|
||||||
extensions.resize(objectCount);
|
extensions.resize(objectCount);
|
||||||
|
|
||||||
if (vkEnumerateDeviceExtensionProperties(dev, 0, &objectCount, extensions.data()) != VK_SUCCESS)
|
if (vkEnumerateDeviceExtensionProperties(dev, nullptr, &objectCount, extensions.data()) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -718,7 +719,7 @@ public:
|
|||||||
|
|
||||||
std::vector<VkQueueFamilyProperties> queueFamilyProperties;
|
std::vector<VkQueueFamilyProperties> queueFamilyProperties;
|
||||||
|
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(gpu, &objectCount, 0);
|
vkGetPhysicalDeviceQueueFamilyProperties(gpu, &objectCount, nullptr);
|
||||||
|
|
||||||
queueFamilyProperties.resize(objectCount);
|
queueFamilyProperties.resize(objectCount);
|
||||||
|
|
||||||
@ -767,7 +768,7 @@ public:
|
|||||||
deviceCreateInfo.pEnabledFeatures = &physicalDeviceFeatures;
|
deviceCreateInfo.pEnabledFeatures = &physicalDeviceFeatures;
|
||||||
|
|
||||||
// Create our logical device
|
// Create our logical device
|
||||||
if (vkCreateDevice(gpu, &deviceCreateInfo, 0, &device) != VK_SUCCESS)
|
if (vkCreateDevice(gpu, &deviceCreateInfo, nullptr, &device) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -785,7 +786,7 @@ public:
|
|||||||
|
|
||||||
std::vector<VkSurfaceFormatKHR> surfaceFormats;
|
std::vector<VkSurfaceFormatKHR> surfaceFormats;
|
||||||
|
|
||||||
if (vkGetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, &objectCount, 0) != VK_SUCCESS)
|
if (vkGetPhysicalDeviceSurfaceFormatsKHR(gpu, surface, &objectCount, nullptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -830,7 +831,7 @@ public:
|
|||||||
// Select a swapchain present mode
|
// Select a swapchain present mode
|
||||||
std::vector<VkPresentModeKHR> presentModes;
|
std::vector<VkPresentModeKHR> presentModes;
|
||||||
|
|
||||||
if (vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, surface, &objectCount, 0) != VK_SUCCESS)
|
if (vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, surface, &objectCount, nullptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -891,7 +892,7 @@ public:
|
|||||||
swapchainCreateInfo.oldSwapchain = VK_NULL_HANDLE;
|
swapchainCreateInfo.oldSwapchain = VK_NULL_HANDLE;
|
||||||
|
|
||||||
// Create the swapchain
|
// Create the swapchain
|
||||||
if (vkCreateSwapchainKHR(device, &swapchainCreateInfo, 0, &swapchain) != VK_SUCCESS)
|
if (vkCreateSwapchainKHR(device, &swapchainCreateInfo, nullptr, &swapchain) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -904,7 +905,7 @@ public:
|
|||||||
// Retrieve swapchain images
|
// Retrieve swapchain images
|
||||||
std::uint32_t objectCount = 0;
|
std::uint32_t objectCount = 0;
|
||||||
|
|
||||||
if (vkGetSwapchainImagesKHR(device, swapchain, &objectCount, 0) != VK_SUCCESS)
|
if (vkGetSwapchainImagesKHR(device, swapchain, &objectCount, nullptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -938,7 +939,7 @@ public:
|
|||||||
{
|
{
|
||||||
imageViewCreateInfo.image = swapchainImages[i];
|
imageViewCreateInfo.image = swapchainImages[i];
|
||||||
|
|
||||||
if (vkCreateImageView(device, &imageViewCreateInfo, 0, &swapchainImageViews[i]) != VK_SUCCESS)
|
if (vkCreateImageView(device, &imageViewCreateInfo, nullptr, &swapchainImageViews[i]) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -973,7 +974,7 @@ public:
|
|||||||
shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(std::uint32_t);
|
shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(std::uint32_t);
|
||||||
shaderModuleCreateInfo.pCode = buffer.data();
|
shaderModuleCreateInfo.pCode = buffer.data();
|
||||||
|
|
||||||
if (vkCreateShaderModule(device, &shaderModuleCreateInfo, 0, &vertexShaderModule) != VK_SUCCESS)
|
if (vkCreateShaderModule(device, &shaderModuleCreateInfo, nullptr, &vertexShaderModule) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1001,7 +1002,7 @@ public:
|
|||||||
shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(std::uint32_t);
|
shaderModuleCreateInfo.codeSize = buffer.size() * sizeof(std::uint32_t);
|
||||||
shaderModuleCreateInfo.pCode = buffer.data();
|
shaderModuleCreateInfo.pCode = buffer.data();
|
||||||
|
|
||||||
if (vkCreateShaderModule(device, &shaderModuleCreateInfo, 0, &fragmentShaderModule) != VK_SUCCESS)
|
if (vkCreateShaderModule(device, &shaderModuleCreateInfo, nullptr, &fragmentShaderModule) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1082,7 +1083,7 @@ public:
|
|||||||
renderPassCreateInfo.pDependencies = &subpassDependency;
|
renderPassCreateInfo.pDependencies = &subpassDependency;
|
||||||
|
|
||||||
// Create the renderpass
|
// Create the renderpass
|
||||||
if (vkCreateRenderPass(device, &renderPassCreateInfo, 0, &renderPass) != VK_SUCCESS)
|
if (vkCreateRenderPass(device, &renderPassCreateInfo, nullptr, &renderPass) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1114,7 +1115,7 @@ public:
|
|||||||
descriptorSetLayoutCreateInfo.pBindings = descriptorSetLayoutBindings;
|
descriptorSetLayoutCreateInfo.pBindings = descriptorSetLayoutBindings;
|
||||||
|
|
||||||
// Create descriptor set layout
|
// Create descriptor set layout
|
||||||
if (vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCreateInfo, 0, &descriptorSetLayout) != VK_SUCCESS)
|
if (vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCreateInfo, nullptr, &descriptorSetLayout) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1130,7 +1131,7 @@ public:
|
|||||||
pipelineLayoutCreateInfo.pSetLayouts = &descriptorSetLayout;
|
pipelineLayoutCreateInfo.pSetLayouts = &descriptorSetLayout;
|
||||||
|
|
||||||
// Create pipeline layout
|
// Create pipeline layout
|
||||||
if (vkCreatePipelineLayout(device, &pipelineLayoutCreateInfo, 0, &pipelineLayout) != VK_SUCCESS)
|
if (vkCreatePipelineLayout(device, &pipelineLayoutCreateInfo, nullptr, &pipelineLayout) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1265,7 +1266,7 @@ public:
|
|||||||
graphicsPipelineCreateInfo.subpass = 0;
|
graphicsPipelineCreateInfo.subpass = 0;
|
||||||
|
|
||||||
// Create our graphics pipeline
|
// Create our graphics pipeline
|
||||||
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &graphicsPipelineCreateInfo, 0, &graphicsPipeline) !=
|
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &graphicsPipelineCreateInfo, nullptr, &graphicsPipeline) !=
|
||||||
VK_SUCCESS)
|
VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
@ -1294,7 +1295,7 @@ public:
|
|||||||
framebufferCreateInfo.pAttachments = attachments;
|
framebufferCreateInfo.pAttachments = attachments;
|
||||||
|
|
||||||
// Create the framebuffer
|
// Create the framebuffer
|
||||||
if (vkCreateFramebuffer(device, &framebufferCreateInfo, 0, &swapchainFramebuffers[i]) != VK_SUCCESS)
|
if (vkCreateFramebuffer(device, &framebufferCreateInfo, nullptr, &swapchainFramebuffers[i]) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1312,7 +1313,7 @@ public:
|
|||||||
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
|
||||||
if (vkCreateCommandPool(device, &commandPoolCreateInfo, 0, &commandPool) != VK_SUCCESS)
|
if (vkCreateCommandPool(device, &commandPoolCreateInfo, nullptr, &commandPool) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1334,7 +1335,7 @@ public:
|
|||||||
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
|
|
||||||
// Create the buffer, this does not allocate any memory for it yet
|
// Create the buffer, this does not allocate any memory for it yet
|
||||||
if (vkCreateBuffer(device, &bufferCreateInfo, 0, &buffer) != VK_SUCCESS)
|
if (vkCreateBuffer(device, &bufferCreateInfo, nullptr, &buffer) != VK_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check what kind of memory we need to request from the GPU
|
// Check what kind of memory we need to request from the GPU
|
||||||
@ -1363,7 +1364,7 @@ public:
|
|||||||
memoryAllocateInfo.memoryTypeIndex = memoryType;
|
memoryAllocateInfo.memoryTypeIndex = memoryType;
|
||||||
|
|
||||||
// Allocate the memory out of the GPU pool for the required memory type
|
// Allocate the memory out of the GPU pool for the required memory type
|
||||||
if (vkAllocateMemory(device, &memoryAllocateInfo, 0, &memory) != VK_SUCCESS)
|
if (vkAllocateMemory(device, &memoryAllocateInfo, nullptr, &memory) != VK_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Bind the allocated memory to our buffer object
|
// Bind the allocated memory to our buffer object
|
||||||
@ -1476,8 +1477,8 @@ public:
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// Create a staging buffer that is writable by the CPU
|
// Create a staging buffer that is writable by the CPU
|
||||||
VkBuffer stagingBuffer = 0;
|
VkBuffer stagingBuffer = {};
|
||||||
VkDeviceMemory stagingBufferMemory = 0;
|
VkDeviceMemory stagingBufferMemory = {};
|
||||||
|
|
||||||
if (!createBuffer(sizeof(vertexData),
|
if (!createBuffer(sizeof(vertexData),
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||||
@ -1494,8 +1495,8 @@ public:
|
|||||||
// Map the buffer into our address space
|
// Map the buffer into our address space
|
||||||
if (vkMapMemory(device, stagingBufferMemory, 0, sizeof(vertexData), 0, &ptr) != VK_SUCCESS)
|
if (vkMapMemory(device, stagingBufferMemory, 0, sizeof(vertexData), 0, &ptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1514,8 +1515,8 @@ public:
|
|||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
vertexBufferMemory))
|
vertexBufferMemory))
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1525,8 +1526,8 @@ public:
|
|||||||
vulkanAvailable = copyBuffer(vertexBuffer, stagingBuffer, sizeof(vertexData));
|
vulkanAvailable = copyBuffer(vertexBuffer, stagingBuffer, sizeof(vertexData));
|
||||||
|
|
||||||
// Free the staging buffer and its memory
|
// Free the staging buffer and its memory
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create our index buffer and upload its data
|
// Create our index buffer and upload its data
|
||||||
@ -1555,8 +1556,8 @@ public:
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
// Create a staging buffer that is writable by the CPU
|
// Create a staging buffer that is writable by the CPU
|
||||||
VkBuffer stagingBuffer = 0;
|
VkBuffer stagingBuffer = {};
|
||||||
VkDeviceMemory stagingBufferMemory = 0;
|
VkDeviceMemory stagingBufferMemory = {};
|
||||||
|
|
||||||
if (!createBuffer(sizeof(indexData),
|
if (!createBuffer(sizeof(indexData),
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||||
@ -1573,8 +1574,8 @@ public:
|
|||||||
// Map the buffer into our address space
|
// Map the buffer into our address space
|
||||||
if (vkMapMemory(device, stagingBufferMemory, 0, sizeof(indexData), 0, &ptr) != VK_SUCCESS)
|
if (vkMapMemory(device, stagingBufferMemory, 0, sizeof(indexData), 0, &ptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1593,8 +1594,8 @@ public:
|
|||||||
indexBuffer,
|
indexBuffer,
|
||||||
indexBufferMemory))
|
indexBufferMemory))
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1604,8 +1605,8 @@ public:
|
|||||||
vulkanAvailable = copyBuffer(indexBuffer, stagingBuffer, sizeof(indexData));
|
vulkanAvailable = copyBuffer(indexBuffer, stagingBuffer, sizeof(indexData));
|
||||||
|
|
||||||
// Free the staging buffer and its memory
|
// Free the staging buffer and its memory
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create our uniform buffer but don't upload any data yet
|
// Create our uniform buffer but don't upload any data yet
|
||||||
@ -1614,8 +1615,8 @@ public:
|
|||||||
// Create a uniform buffer for every frame that might be in flight to prevent clobbering
|
// Create a uniform buffer for every frame that might be in flight to prevent clobbering
|
||||||
for (std::size_t i = 0; i < swapchainImages.size(); ++i)
|
for (std::size_t i = 0; i < swapchainImages.size(); ++i)
|
||||||
{
|
{
|
||||||
uniformBuffers.push_back(0);
|
uniformBuffers.push_back({});
|
||||||
uniformBuffersMemory.push_back(0);
|
uniformBuffersMemory.push_back({});
|
||||||
|
|
||||||
// The uniform buffer will be host visible and coherent since we use it for streaming data every frame
|
// The uniform buffer will be host visible and coherent since we use it for streaming data every frame
|
||||||
if (!createBuffer(sizeof(Matrix) * 3,
|
if (!createBuffer(sizeof(Matrix) * 3,
|
||||||
@ -1657,7 +1658,7 @@ public:
|
|||||||
imageCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
imageCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
|
|
||||||
// Create the image, this does not allocate any memory for it yet
|
// Create the image, this does not allocate any memory for it yet
|
||||||
if (vkCreateImage(device, &imageCreateInfo, 0, &image) != VK_SUCCESS)
|
if (vkCreateImage(device, &imageCreateInfo, nullptr, &image) != VK_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check what kind of memory we need to request from the GPU
|
// Check what kind of memory we need to request from the GPU
|
||||||
@ -1686,7 +1687,7 @@ public:
|
|||||||
memoryAllocateInfo.memoryTypeIndex = memoryType;
|
memoryAllocateInfo.memoryTypeIndex = memoryType;
|
||||||
|
|
||||||
// Allocate the memory out of the GPU pool for the required memory type
|
// Allocate the memory out of the GPU pool for the required memory type
|
||||||
if (vkAllocateMemory(device, &memoryAllocateInfo, 0, &imageMemory) != VK_SUCCESS)
|
if (vkAllocateMemory(device, &memoryAllocateInfo, nullptr, &imageMemory) != VK_SUCCESS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Bind the allocated memory to our image object
|
// Bind the allocated memory to our image object
|
||||||
@ -1768,9 +1769,9 @@ public:
|
|||||||
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
nullptr,
|
||||||
0,
|
0,
|
||||||
0,
|
nullptr,
|
||||||
0,
|
|
||||||
1,
|
1,
|
||||||
&barrier);
|
&barrier);
|
||||||
|
|
||||||
@ -1821,7 +1822,7 @@ public:
|
|||||||
imageViewCreateInfo.subresourceRange.layerCount = 1;
|
imageViewCreateInfo.subresourceRange.layerCount = 1;
|
||||||
|
|
||||||
// Create the depth image view
|
// Create the depth image view
|
||||||
if (vkCreateImageView(device, &imageViewCreateInfo, 0, &depthImageView) != VK_SUCCESS)
|
if (vkCreateImageView(device, &imageViewCreateInfo, nullptr, &depthImageView) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1843,8 +1844,8 @@ public:
|
|||||||
// Create a staging buffer to transfer the data with
|
// Create a staging buffer to transfer the data with
|
||||||
VkDeviceSize imageSize = imageData.getSize().x * imageData.getSize().y * 4;
|
VkDeviceSize imageSize = imageData.getSize().x * imageData.getSize().y * 4;
|
||||||
|
|
||||||
VkBuffer stagingBuffer;
|
VkBuffer stagingBuffer = {};
|
||||||
VkDeviceMemory stagingBufferMemory;
|
VkDeviceMemory stagingBufferMemory = {};
|
||||||
createBuffer(imageSize,
|
createBuffer(imageSize,
|
||||||
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
|
||||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||||
@ -1856,8 +1857,8 @@ public:
|
|||||||
// Map the buffer into our address space
|
// Map the buffer into our address space
|
||||||
if (vkMapMemory(device, stagingBufferMemory, 0, imageSize, 0, &ptr) != VK_SUCCESS)
|
if (vkMapMemory(device, stagingBufferMemory, 0, imageSize, 0, &ptr) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1879,8 +1880,8 @@ public:
|
|||||||
textureImage,
|
textureImage,
|
||||||
textureImageMemory))
|
textureImageMemory))
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1897,8 +1898,8 @@ public:
|
|||||||
|
|
||||||
if (vkAllocateCommandBuffers(device, &commandBufferAllocateInfo, &commandBuffer) != VK_SUCCESS)
|
if (vkAllocateCommandBuffers(device, &commandBufferAllocateInfo, &commandBuffer) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1918,8 +1919,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1941,14 +1942,23 @@ public:
|
|||||||
barrier.srcAccessMask = 0;
|
barrier.srcAccessMask = 0;
|
||||||
barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
|
|
||||||
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, 0, 0, 0, 1, &barrier);
|
vkCmdPipelineBarrier(commandBuffer,
|
||||||
|
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||||
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
nullptr,
|
||||||
|
1,
|
||||||
|
&barrier);
|
||||||
|
|
||||||
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
|
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1958,8 +1968,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1970,8 +1980,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -1982,8 +1992,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2012,8 +2022,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2023,8 +2033,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2035,8 +2045,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2047,8 +2057,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2065,9 +2075,9 @@ public:
|
|||||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
nullptr,
|
||||||
0,
|
0,
|
||||||
0,
|
nullptr,
|
||||||
0,
|
|
||||||
1,
|
1,
|
||||||
&barrier);
|
&barrier);
|
||||||
|
|
||||||
@ -2076,8 +2086,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2087,8 +2097,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2099,8 +2109,8 @@ public:
|
|||||||
{
|
{
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
|
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2109,8 +2119,8 @@ public:
|
|||||||
// Free the command buffer
|
// Free the command buffer
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
|
|
||||||
vkFreeMemory(device, stagingBufferMemory, 0);
|
vkFreeMemory(device, stagingBufferMemory, nullptr);
|
||||||
vkDestroyBuffer(device, stagingBuffer, 0);
|
vkDestroyBuffer(device, stagingBuffer, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an image view for our texture
|
// Create an image view for our texture
|
||||||
@ -2128,7 +2138,7 @@ public:
|
|||||||
imageViewCreateInfo.subresourceRange.layerCount = 1;
|
imageViewCreateInfo.subresourceRange.layerCount = 1;
|
||||||
|
|
||||||
// Create our texture image view
|
// Create our texture image view
|
||||||
if (vkCreateImageView(device, &imageViewCreateInfo, 0, &textureImageView) != VK_SUCCESS)
|
if (vkCreateImageView(device, &imageViewCreateInfo, nullptr, &textureImageView) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2158,7 +2168,7 @@ public:
|
|||||||
samplerCreateInfo.maxLod = 0.0f;
|
samplerCreateInfo.maxLod = 0.0f;
|
||||||
|
|
||||||
// Create our sampler
|
// Create our sampler
|
||||||
if (vkCreateSampler(device, &samplerCreateInfo, 0, &textureSampler) != VK_SUCCESS)
|
if (vkCreateSampler(device, &samplerCreateInfo, nullptr, &textureSampler) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2186,7 +2196,7 @@ public:
|
|||||||
descriptorPoolCreateInfo.maxSets = static_cast<std::uint32_t>(swapchainImages.size());
|
descriptorPoolCreateInfo.maxSets = static_cast<std::uint32_t>(swapchainImages.size());
|
||||||
|
|
||||||
// Create the descriptor pool
|
// Create the descriptor pool
|
||||||
if (vkCreateDescriptorPool(device, &descriptorPoolCreateInfo, 0, &descriptorPool) != VK_SUCCESS)
|
if (vkCreateDescriptorPool(device, &descriptorPoolCreateInfo, nullptr, &descriptorPool) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
return;
|
return;
|
||||||
@ -2251,7 +2261,7 @@ public:
|
|||||||
writeDescriptorSets[1].pImageInfo = &descriptorImageInfo;
|
writeDescriptorSets[1].pImageInfo = &descriptorImageInfo;
|
||||||
|
|
||||||
// Update the desciptor set
|
// Update the desciptor set
|
||||||
vkUpdateDescriptorSets(device, 2, writeDescriptorSets, 0, 0);
|
vkUpdateDescriptorSets(device, 2, writeDescriptorSets, 0, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2343,7 +2353,7 @@ public:
|
|||||||
1,
|
1,
|
||||||
&descriptorSets[i],
|
&descriptorSets[i],
|
||||||
0,
|
0,
|
||||||
0);
|
nullptr);
|
||||||
|
|
||||||
// Draw our primitives
|
// Draw our primitives
|
||||||
vkCmdDrawIndexed(commandBuffers[i], 36, 1, 0, 0, 0);
|
vkCmdDrawIndexed(commandBuffers[i], 36, 1, 0, 0, 0);
|
||||||
@ -2369,9 +2379,9 @@ public:
|
|||||||
// Create a semaphore to track when an swapchain image is available for each frame in flight
|
// Create a semaphore to track when an swapchain image is available for each frame in flight
|
||||||
for (std::size_t i = 0; i < maxFramesInFlight; ++i)
|
for (std::size_t i = 0; i < maxFramesInFlight; ++i)
|
||||||
{
|
{
|
||||||
imageAvailableSemaphores.push_back(0);
|
imageAvailableSemaphores.push_back({});
|
||||||
|
|
||||||
if (vkCreateSemaphore(device, &semaphoreCreateInfo, 0, &imageAvailableSemaphores[i]) != VK_SUCCESS)
|
if (vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &imageAvailableSemaphores[i]) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
imageAvailableSemaphores.pop_back();
|
imageAvailableSemaphores.pop_back();
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
@ -2382,9 +2392,9 @@ public:
|
|||||||
// Create a semaphore to track when rendering is complete for each frame in flight
|
// Create a semaphore to track when rendering is complete for each frame in flight
|
||||||
for (std::size_t i = 0; i < maxFramesInFlight; ++i)
|
for (std::size_t i = 0; i < maxFramesInFlight; ++i)
|
||||||
{
|
{
|
||||||
renderFinishedSemaphores.push_back(0);
|
renderFinishedSemaphores.push_back({});
|
||||||
|
|
||||||
if (vkCreateSemaphore(device, &semaphoreCreateInfo, 0, &renderFinishedSemaphores[i]) != VK_SUCCESS)
|
if (vkCreateSemaphore(device, &semaphoreCreateInfo, nullptr, &renderFinishedSemaphores[i]) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
renderFinishedSemaphores.pop_back();
|
renderFinishedSemaphores.pop_back();
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
@ -2404,9 +2414,9 @@ public:
|
|||||||
// Create a fence to track when queue submission is complete for each frame in flight
|
// Create a fence to track when queue submission is complete for each frame in flight
|
||||||
for (std::size_t i = 0; i < maxFramesInFlight; ++i)
|
for (std::size_t i = 0; i < maxFramesInFlight; ++i)
|
||||||
{
|
{
|
||||||
fences.push_back(0);
|
fences.push_back({});
|
||||||
|
|
||||||
if (vkCreateFence(device, &fenceCreateInfo, 0, &fences[i]) != VK_SUCCESS)
|
if (vkCreateFence(device, &fenceCreateInfo, nullptr, &fences[i]) != VK_SUCCESS)
|
||||||
{
|
{
|
||||||
fences.pop_back();
|
fences.pop_back();
|
||||||
vulkanAvailable = false;
|
vulkanAvailable = false;
|
||||||
|
@ -737,7 +737,7 @@ void Shader::bind(const Shader* shader)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Bind no shader
|
// Bind no shader
|
||||||
glCheck(GLEXT_glUseProgramObject(0));
|
glCheck(GLEXT_glUseProgramObject({}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ HIDInputManager::HIDInputManager()
|
|||||||
TISInputSourceRef tis = TISCopyCurrentKeyboardLayoutInputSource();
|
TISInputSourceRef tis = TISCopyCurrentKeyboardLayoutInputSource();
|
||||||
m_layoutData = static_cast<CFDataRef>(TISGetInputSourceProperty(tis, kTISPropertyUnicodeKeyLayoutData));
|
m_layoutData = static_cast<CFDataRef>(TISGetInputSourceProperty(tis, kTISPropertyUnicodeKeyLayoutData));
|
||||||
|
|
||||||
if (m_layoutData == 0)
|
if (m_layoutData == nil)
|
||||||
{
|
{
|
||||||
sf::err() << "Cannot get the keyboard layout" << std::endl;
|
sf::err() << "Cannot get the keyboard layout" << std::endl;
|
||||||
freeUp();
|
freeUp();
|
||||||
@ -303,16 +303,16 @@ void HIDInputManager::freeUp()
|
|||||||
{
|
{
|
||||||
m_isValid = false;
|
m_isValid = false;
|
||||||
|
|
||||||
if (m_layoutData != 0)
|
if (m_layoutData != nil)
|
||||||
CFRelease(m_layoutData);
|
CFRelease(m_layoutData);
|
||||||
|
|
||||||
m_layoutData = 0;
|
m_layoutData = nil;
|
||||||
|
|
||||||
// Do not release m_layout! It is owned by m_layoutData.
|
// Do not release m_layout! It is owned by m_layoutData.
|
||||||
if (m_manager != 0)
|
if (m_manager != nil)
|
||||||
CFRelease(m_manager);
|
CFRelease(m_manager);
|
||||||
|
|
||||||
m_manager = 0;
|
m_manager = nil;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < Keyboard::KeyCount; ++i)
|
for (unsigned int i = 0; i < Keyboard::KeyCount; ++i)
|
||||||
{
|
{
|
||||||
@ -333,7 +333,7 @@ CFSetRef HIDInputManager::copyDevices(UInt32 page, UInt32 usage)
|
|||||||
IOHIDManagerSetDeviceMatching(m_manager, mask);
|
IOHIDManagerSetDeviceMatching(m_manager, mask);
|
||||||
|
|
||||||
CFRelease(mask);
|
CFRelease(mask);
|
||||||
mask = 0;
|
mask = nil;
|
||||||
|
|
||||||
CFSetRef devices = IOHIDManagerCopyDevices(m_manager);
|
CFSetRef devices = IOHIDManagerCopyDevices(m_manager);
|
||||||
if (devices == nullptr)
|
if (devices == nullptr)
|
||||||
@ -360,7 +360,7 @@ bool HIDInputManager::isPressed(IOHIDElements& elements)
|
|||||||
|
|
||||||
for (auto it = elements.begin(); it != elements.end(); /* noop */)
|
for (auto it = elements.begin(); it != elements.end(); /* noop */)
|
||||||
{
|
{
|
||||||
IOHIDValueRef value = 0;
|
IOHIDValueRef value = nil;
|
||||||
|
|
||||||
IOHIDDeviceRef device = IOHIDElementGetDevice(*it);
|
IOHIDDeviceRef device = IOHIDElementGetDevice(*it);
|
||||||
IOHIDDeviceGetValue(device, *it, &value);
|
IOHIDDeviceGetValue(device, *it, &value);
|
||||||
|
@ -101,8 +101,8 @@ HIDJoystickManager::~HIDJoystickManager()
|
|||||||
{
|
{
|
||||||
IOHIDManagerUnscheduleFromRunLoop(m_manager, CFRunLoopGetCurrent(), runLoopMode);
|
IOHIDManagerUnscheduleFromRunLoop(m_manager, CFRunLoopGetCurrent(), runLoopMode);
|
||||||
|
|
||||||
IOHIDManagerRegisterDeviceMatchingCallback(m_manager, nullptr, 0);
|
IOHIDManagerRegisterDeviceMatchingCallback(m_manager, nullptr, nullptr);
|
||||||
IOHIDManagerRegisterDeviceRemovalCallback(m_manager, nullptr, 0);
|
IOHIDManagerRegisterDeviceRemovalCallback(m_manager, nullptr, nullptr);
|
||||||
|
|
||||||
IOHIDManagerClose(m_manager, kIOHIDOptionsTypeNone);
|
IOHIDManagerClose(m_manager, kIOHIDOptionsTypeNone);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ SFOpenGLView* getSFOpenGLViewFromSFMLWindow(const WindowBase& window)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (nsHandle != 0)
|
if (nsHandle != nil)
|
||||||
sf::err() << "The system handle is neither a <NSWindow*> nor <NSView*>"
|
sf::err() << "The system handle is neither a <NSWindow*> nor <NSView*>"
|
||||||
<< "object. This shouldn't happen." << std::endl;
|
<< "object. This shouldn't happen." << std::endl;
|
||||||
// Else: this probably means the SFML window was previously closed.
|
// Else: this probably means the SFML window was previously closed.
|
||||||
|
@ -202,15 +202,15 @@ bool JoystickImpl::open(unsigned int index)
|
|||||||
CFSetGetValues(devices, devicesArray.data());
|
CFSetGetValues(devices, devicesArray.data());
|
||||||
|
|
||||||
// Get the desired joystick.
|
// Get the desired joystick.
|
||||||
IOHIDDeviceRef self = 0;
|
IOHIDDeviceRef self = nil;
|
||||||
for (CFIndex i(0); self == 0 && i < joysticksCount; ++i)
|
for (CFIndex i(0); self == nil && i < joysticksCount; ++i)
|
||||||
{
|
{
|
||||||
IOHIDDeviceRef d = static_cast<IOHIDDeviceRef>(const_cast<void*>(devicesArray[static_cast<std::size_t>(i)]));
|
IOHIDDeviceRef d = static_cast<IOHIDDeviceRef>(const_cast<void*>(devicesArray[static_cast<std::size_t>(i)]));
|
||||||
if (deviceLoc == HIDInputManager::getLocationID(d))
|
if (deviceLoc == HIDInputManager::getLocationID(d))
|
||||||
self = d;
|
self = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self == 0)
|
if (self == nil)
|
||||||
{
|
{
|
||||||
CFRelease(devices);
|
CFRelease(devices);
|
||||||
return false;
|
return false;
|
||||||
@ -440,7 +440,7 @@ JoystickState JoystickImpl::update()
|
|||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (auto it = m_buttons.begin(); it != m_buttons.end(); ++it, ++i)
|
for (auto it = m_buttons.begin(); it != m_buttons.end(); ++it, ++i)
|
||||||
{
|
{
|
||||||
IOHIDValueRef value = 0;
|
IOHIDValueRef value = nil;
|
||||||
IOHIDDeviceGetValue(IOHIDElementGetDevice(*it), *it, &value);
|
IOHIDDeviceGetValue(IOHIDElementGetDevice(*it), *it, &value);
|
||||||
|
|
||||||
// Check for plug out.
|
// Check for plug out.
|
||||||
@ -456,7 +456,7 @@ JoystickState JoystickImpl::update()
|
|||||||
// Update axes' state
|
// Update axes' state
|
||||||
for (const auto& [axis, iohidElementRef] : m_axis)
|
for (const auto& [axis, iohidElementRef] : m_axis)
|
||||||
{
|
{
|
||||||
IOHIDValueRef value = 0;
|
IOHIDValueRef value = nil;
|
||||||
IOHIDDeviceGetValue(IOHIDElementGetDevice(iohidElementRef), iohidElementRef, &value);
|
IOHIDDeviceGetValue(IOHIDElementGetDevice(iohidElementRef), iohidElementRef, &value);
|
||||||
|
|
||||||
// Check for plug out.
|
// Check for plug out.
|
||||||
@ -493,7 +493,7 @@ JoystickState JoystickImpl::update()
|
|||||||
//
|
//
|
||||||
if (m_hat != nullptr)
|
if (m_hat != nullptr)
|
||||||
{
|
{
|
||||||
IOHIDValueRef value = 0;
|
IOHIDValueRef value = nil;
|
||||||
IOHIDDeviceGetValue(IOHIDElementGetDevice(m_hat), m_hat, &value);
|
IOHIDDeviceGetValue(IOHIDElementGetDevice(m_hat), m_hat, &value);
|
||||||
|
|
||||||
// Check for plug out.
|
// Check for plug out.
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
{
|
{
|
||||||
// Create an empty image representation.
|
// Create an empty image representation.
|
||||||
NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc]
|
NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc]
|
||||||
initWithBitmapDataPlanes:0 // if 0: only allocate memory
|
initWithBitmapDataPlanes:nil // if nil: only allocate memory
|
||||||
pixelsWide:(static_cast<NSInteger>(size.width))pixelsHigh
|
pixelsWide:(static_cast<NSInteger>(size.width))pixelsHigh
|
||||||
:(static_cast<NSInteger>(size.height))bitsPerSample:8 // The number of bits used to specify
|
:(static_cast<NSInteger>(size.height))bitsPerSample:8 // The number of bits used to specify
|
||||||
// one pixel in a single component of the data.
|
// one pixel in a single component of the data.
|
||||||
|
@ -113,7 +113,7 @@ GlFunctionPointer SFContext::getFunction(const char* name)
|
|||||||
if (!image)
|
if (!image)
|
||||||
image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
|
image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
|
||||||
|
|
||||||
return (image ? reinterpret_cast<GlFunctionPointer>(reinterpret_cast<intptr_t>(dlsym(image, name))) : 0);
|
return (image ? reinterpret_cast<GlFunctionPointer>(reinterpret_cast<intptr_t>(dlsym(image, name))) : nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
// Transmit to non-SFML responder
|
// Transmit to non-SFML responder
|
||||||
[[self nextResponder] keyDown:theEvent];
|
[[self nextResponder] keyDown:theEvent];
|
||||||
|
|
||||||
if (m_requester == 0)
|
if (m_requester == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Handle key down event
|
// Handle key down event
|
||||||
@ -153,7 +153,7 @@
|
|||||||
// Transmit to non-SFML responder
|
// Transmit to non-SFML responder
|
||||||
[[self nextResponder] keyUp:theEvent];
|
[[self nextResponder] keyUp:theEvent];
|
||||||
|
|
||||||
if (m_requester == 0)
|
if (m_requester == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
|
sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
|
||||||
@ -169,7 +169,7 @@
|
|||||||
// Transmit to non-SFML responder
|
// Transmit to non-SFML responder
|
||||||
[[self nextResponder] flagsChanged:theEvent];
|
[[self nextResponder] flagsChanged:theEvent];
|
||||||
|
|
||||||
if (m_requester == 0)
|
if (m_requester == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NSUInteger modifiers = [theEvent modifierFlags];
|
NSUInteger modifiers = [theEvent modifierFlags];
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
m_mouseIsIn = [self isMouseInside];
|
m_mouseIsIn = [self isMouseInside];
|
||||||
|
|
||||||
// Send event if needed.
|
// Send event if needed.
|
||||||
if (m_requester != 0)
|
if (m_requester != nil)
|
||||||
{
|
{
|
||||||
if (mouseWasIn && !m_mouseIsIn)
|
if (mouseWasIn && !m_mouseIsIn)
|
||||||
m_requester->mouseMovedOut();
|
m_requester->mouseMovedOut();
|
||||||
@ -133,7 +133,7 @@
|
|||||||
{
|
{
|
||||||
sf::Mouse::Button button = [SFOpenGLView mouseButtonFromEvent:theEvent];
|
sf::Mouse::Button button = [SFOpenGLView mouseButtonFromEvent:theEvent];
|
||||||
|
|
||||||
if (m_requester != 0)
|
if (m_requester != nil)
|
||||||
{
|
{
|
||||||
NSPoint loc = [self cursorPositionFromEvent:theEvent];
|
NSPoint loc = [self cursorPositionFromEvent:theEvent];
|
||||||
|
|
||||||
@ -178,7 +178,7 @@
|
|||||||
{
|
{
|
||||||
sf::Mouse::Button button = [SFOpenGLView mouseButtonFromEvent:theEvent];
|
sf::Mouse::Button button = [SFOpenGLView mouseButtonFromEvent:theEvent];
|
||||||
|
|
||||||
if (m_requester != 0)
|
if (m_requester != nil)
|
||||||
{
|
{
|
||||||
NSPoint loc = [self cursorPositionFromEvent:theEvent];
|
NSPoint loc = [self cursorPositionFromEvent:theEvent];
|
||||||
|
|
||||||
@ -243,7 +243,7 @@
|
|||||||
// (mouseEntered: and mouseExited: are not immediately called
|
// (mouseEntered: and mouseExited: are not immediately called
|
||||||
// when the mouse is dragged. That would be too easy!)
|
// when the mouse is dragged. That would be too easy!)
|
||||||
[self updateMouseState];
|
[self updateMouseState];
|
||||||
if ((m_requester != 0) && m_mouseIsIn)
|
if ((m_requester != nil) && m_mouseIsIn)
|
||||||
m_requester->mouseMovedAt(static_cast<int>(loc.x), static_cast<int>(loc.y));
|
m_requester->mouseMovedAt(static_cast<int>(loc.x), static_cast<int>(loc.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +299,7 @@
|
|||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
- (void)scrollWheel:(NSEvent*)theEvent
|
- (void)scrollWheel:(NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
if (m_requester != 0)
|
if (m_requester != nil)
|
||||||
{
|
{
|
||||||
NSPoint loc = [self cursorPositionFromEvent:theEvent];
|
NSPoint loc = [self cursorPositionFromEvent:theEvent];
|
||||||
m_requester->mouseWheelScrolledAt(static_cast<float>([theEvent deltaX]),
|
m_requester->mouseWheelScrolledAt(static_cast<float>([theEvent deltaX]),
|
||||||
|
@ -101,7 +101,7 @@
|
|||||||
{
|
{
|
||||||
if ((self = [super initWithFrame:frameRect]))
|
if ((self = [super initWithFrame:frameRect]))
|
||||||
{
|
{
|
||||||
[self setRequesterTo:0];
|
[self setRequesterTo:nullptr];
|
||||||
[self enableKeyRepeat];
|
[self enableKeyRepeat];
|
||||||
|
|
||||||
// Register for mouse move event
|
// Register for mouse move event
|
||||||
@ -242,7 +242,7 @@
|
|||||||
m_scaleFactor = m_highDpi ? [screen backingScaleFactor] : 1.0;
|
m_scaleFactor = m_highDpi ? [screen backingScaleFactor] : 1.0;
|
||||||
|
|
||||||
// Send a resize event if the scaling factor changed
|
// Send a resize event if the scaling factor changed
|
||||||
if ((m_scaleFactor != oldScaleFactor) && (m_requester != 0))
|
if ((m_scaleFactor != oldScaleFactor) && (m_requester != nullptr))
|
||||||
{
|
{
|
||||||
NSSize newSize = [self frame].size;
|
NSSize newSize = [self frame].size;
|
||||||
m_requester->windowResized({static_cast<unsigned int>(newSize.width), static_cast<unsigned int>(newSize.height)});
|
m_requester->windowResized({static_cast<unsigned int>(newSize.width), static_cast<unsigned int>(newSize.height)});
|
||||||
@ -272,7 +272,7 @@
|
|||||||
[self update];
|
[self update];
|
||||||
|
|
||||||
// Send an event
|
// Send an event
|
||||||
if (m_requester == 0)
|
if (m_requester == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// The new size
|
// The new size
|
||||||
@ -319,7 +319,7 @@
|
|||||||
[self addTrackingArea:m_trackingArea];
|
[self addTrackingArea:m_trackingArea];
|
||||||
|
|
||||||
// Fire an mouse entered event if needed
|
// Fire an mouse entered event if needed
|
||||||
if (!m_mouseIsIn && (m_requester != 0))
|
if (!m_mouseIsIn && (m_requester != nullptr))
|
||||||
m_requester->mouseMovedIn();
|
m_requester->mouseMovedIn();
|
||||||
|
|
||||||
// Update status
|
// Update status
|
||||||
@ -333,7 +333,7 @@
|
|||||||
[self removeTrackingArea:m_trackingArea];
|
[self removeTrackingArea:m_trackingArea];
|
||||||
|
|
||||||
// Fire an mouse left event if needed
|
// Fire an mouse left event if needed
|
||||||
if (m_mouseIsIn && (m_requester != 0))
|
if (m_mouseIsIn && (m_requester != nullptr))
|
||||||
m_requester->mouseMovedOut();
|
m_requester->mouseMovedOut();
|
||||||
|
|
||||||
// Update status
|
// Update status
|
||||||
@ -359,7 +359,7 @@
|
|||||||
[m_silentResponder release];
|
[m_silentResponder release];
|
||||||
[m_trackingArea release];
|
[m_trackingArea release];
|
||||||
|
|
||||||
[self setRequesterTo:0];
|
[self setRequesterTo:nullptr];
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
m_requester = 0;
|
m_requester = nullptr;
|
||||||
|
|
||||||
// Retain the view for our own use.
|
// Retain the view for our own use.
|
||||||
m_view = [view retain];
|
m_view = [view retain];
|
||||||
@ -261,7 +261,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we don't have a requester we don't fetch event.
|
// If we don't have a requester we don't fetch event.
|
||||||
if (m_requester != 0)
|
if (m_requester != nullptr)
|
||||||
[SFApplication processEvent];
|
[SFApplication processEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
{
|
{
|
||||||
m_window = nil;
|
m_window = nil;
|
||||||
m_oglView = nil;
|
m_oglView = nil;
|
||||||
m_requester = 0;
|
m_requester = nil;
|
||||||
m_fullscreen = NO; // assuming this is the case... too hard to handle anyway.
|
m_fullscreen = NO; // assuming this is the case... too hard to handle anyway.
|
||||||
m_restoreResize = NO;
|
m_restoreResize = NO;
|
||||||
m_highDpi = NO;
|
m_highDpi = NO;
|
||||||
@ -152,7 +152,7 @@
|
|||||||
{
|
{
|
||||||
m_window = nil;
|
m_window = nil;
|
||||||
m_oglView = nil;
|
m_oglView = nil;
|
||||||
m_requester = 0;
|
m_requester = nil;
|
||||||
m_fullscreen = ((style & sf::Style::Fullscreen) != 0) ? YES : NO;
|
m_fullscreen = ((style & sf::Style::Fullscreen) != 0) ? YES : NO;
|
||||||
m_restoreResize = NO;
|
m_restoreResize = NO;
|
||||||
m_highDpi = NO;
|
m_highDpi = NO;
|
||||||
@ -465,7 +465,7 @@
|
|||||||
height = static_cast<unsigned int>(maxVisibleHeight);
|
height = static_cast<unsigned int>(maxVisibleHeight);
|
||||||
|
|
||||||
// The size is not the requested one, we fire an event
|
// The size is not the requested one, we fire an event
|
||||||
if (m_requester != 0)
|
if (m_requester != nil)
|
||||||
m_requester->windowResized({width, height - static_cast<unsigned int>([self titlebarHeight])});
|
m_requester->windowResized({width, height - static_cast<unsigned int>([self titlebarHeight])});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,7 +506,7 @@
|
|||||||
[self applyContext:nil];
|
[self applyContext:nil];
|
||||||
[m_window close];
|
[m_window close];
|
||||||
[m_window setDelegate:nil];
|
[m_window setDelegate:nil];
|
||||||
[self setRequesterTo:0];
|
[self setRequesterTo:nil];
|
||||||
[SFApplication processEvent];
|
[SFApplication processEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,7 +570,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we don't have a requester we don't fetch event.
|
// If we don't have a requester we don't fetch event.
|
||||||
if (m_requester != 0)
|
if (m_requester != nil)
|
||||||
[SFApplication processEvent];
|
[SFApplication processEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +592,7 @@
|
|||||||
{
|
{
|
||||||
(void)sender;
|
(void)sender;
|
||||||
|
|
||||||
if (m_requester == 0)
|
if (m_requester == nil)
|
||||||
return YES;
|
return YES;
|
||||||
|
|
||||||
m_requester->windowClosed();
|
m_requester->windowClosed();
|
||||||
|
@ -139,7 +139,7 @@ WindowImplCocoa::~WindowImplCocoa()
|
|||||||
// Tell the window/view controller (and the OpenGL view) that the delegate
|
// Tell the window/view controller (and the OpenGL view) that the delegate
|
||||||
// (this object) no longer exists to prevent events being sent to the window
|
// (this object) no longer exists to prevent events being sent to the window
|
||||||
// after it has been deleted.
|
// after it has been deleted.
|
||||||
[m_delegate setRequesterTo:0];
|
[m_delegate setRequesterTo:nil];
|
||||||
[m_delegate release];
|
[m_delegate release];
|
||||||
|
|
||||||
// Put the next window in front, if any.
|
// Put the next window in front, if any.
|
||||||
|
@ -216,7 +216,7 @@ void ClipboardImpl::processEvent(XEvent& windowEvent)
|
|||||||
int format;
|
int format;
|
||||||
unsigned long items;
|
unsigned long items;
|
||||||
unsigned long remainingBytes;
|
unsigned long remainingBytes;
|
||||||
unsigned char* data = 0;
|
unsigned char* data = nullptr;
|
||||||
|
|
||||||
// The selection owner should have wrote the selection
|
// The selection owner should have wrote the selection
|
||||||
// data to the specified window property
|
// data to the specified window property
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
udev* udevContext = 0;
|
udev* udevContext = nullptr;
|
||||||
udev_monitor* udevMonitor = 0;
|
udev_monitor* udevMonitor = nullptr;
|
||||||
|
|
||||||
struct JoystickRecord
|
struct JoystickRecord
|
||||||
{
|
{
|
||||||
@ -459,7 +459,7 @@ void JoystickImpl::initialize()
|
|||||||
<< error << std::endl;
|
<< error << std::endl;
|
||||||
|
|
||||||
udev_monitor_unref(udevMonitor);
|
udev_monitor_unref(udevMonitor);
|
||||||
udevMonitor = 0;
|
udevMonitor = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -471,7 +471,7 @@ void JoystickImpl::initialize()
|
|||||||
<< error << std::endl;
|
<< error << std::endl;
|
||||||
|
|
||||||
udev_monitor_unref(udevMonitor);
|
udev_monitor_unref(udevMonitor);
|
||||||
udevMonitor = 0;
|
udevMonitor = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,14 +488,14 @@ void JoystickImpl::cleanup()
|
|||||||
if (udevMonitor)
|
if (udevMonitor)
|
||||||
{
|
{
|
||||||
udev_monitor_unref(udevMonitor);
|
udev_monitor_unref(udevMonitor);
|
||||||
udevMonitor = 0;
|
udevMonitor = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unreference the udev context to destroy it
|
// Unreference the udev context to destroy it
|
||||||
if (udevContext)
|
if (udevContext)
|
||||||
{
|
{
|
||||||
udev_unref(udevContext);
|
udev_unref(udevContext);
|
||||||
udevContext = 0;
|
udevContext = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,11 +127,11 @@ bool VulkanImplX11::isAvailable(bool requireGraphics)
|
|||||||
|
|
||||||
std::uint32_t extensionCount = 0;
|
std::uint32_t extensionCount = 0;
|
||||||
|
|
||||||
wrapper.vkEnumerateInstanceExtensionProperties(0, &extensionCount, nullptr);
|
wrapper.vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
|
||||||
|
|
||||||
extensionProperties.resize(extensionCount);
|
extensionProperties.resize(extensionCount);
|
||||||
|
|
||||||
wrapper.vkEnumerateInstanceExtensionProperties(0, &extensionCount, extensionProperties.data());
|
wrapper.vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensionProperties.data());
|
||||||
|
|
||||||
// Check if the necessary extensions are available
|
// Check if the necessary extensions are available
|
||||||
bool hasVkKhrSurface = false;
|
bool hasVkKhrSurface = false;
|
||||||
@ -165,7 +165,7 @@ bool VulkanImplX11::isAvailable(bool requireGraphics)
|
|||||||
VulkanFunctionPointer VulkanImplX11::getFunction(const char* name)
|
VulkanFunctionPointer VulkanImplX11::getFunction(const char* name)
|
||||||
{
|
{
|
||||||
if (!isAvailable(false))
|
if (!isAvailable(false))
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
return reinterpret_cast<VulkanFunctionPointer>(dlsym(wrapper.library, name));
|
return reinterpret_cast<VulkanFunctionPointer>(dlsym(wrapper.library, name));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user