Added VulkanHandle
This commit is contained in:
4
.idea/editor.xml
generated
4
.idea/editor.xml
generated
@@ -132,8 +132,8 @@
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNoDiscardExpression/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExceptionSafeResourceAcquisition/@EntryIndexedValue" value="HINT" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexedValue" value="HINT" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexedValue" value="HINT" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
|
||||
7
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
7
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="CppNonExplicitConversionOperator" enabled="false" level="HINT" enabled_by_default="false" />
|
||||
<inspection_tool class="CppNonExplicitConvertingConstructor" enabled="false" level="HINT" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace PB::Renderer
|
||||
{
|
||||
struct Color
|
||||
@@ -17,4 +19,16 @@ namespace PB::Renderer
|
||||
constexpr Color cyan = {0.0f, 1.0f, 1.0f, 1.0f};
|
||||
constexpr Color magenta = {1.0f, 0.0f, 1.0f, 1.0f};
|
||||
}
|
||||
|
||||
class VulkanHandle
|
||||
{
|
||||
public:
|
||||
VulkanHandle(void* _handle) : handle(_handle) {}
|
||||
|
||||
template<typename Ty> operator Ty() { return static_cast<Ty>(handle); }
|
||||
void* get() const { return handle; }
|
||||
|
||||
private:
|
||||
void* handle = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ int main()
|
||||
CleanupAllAndExit(EXIT_FAILURE);
|
||||
|
||||
/* Adds runtime objects */
|
||||
{
|
||||
VulkanManager::CreateNewRenderObject
|
||||
(
|
||||
Colors::red, Mesh
|
||||
@@ -61,6 +62,7 @@ int main()
|
||||
.indices = { 0, 1, 2 }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/* Polls window events whilst it is still open */
|
||||
while (!glfwWindowShouldClose(window))
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace PB::Renderer
|
||||
*/
|
||||
static bool RenderPass(GLFWwindow* window);
|
||||
|
||||
static void CreateNewRenderObject(Color color, Mesh mesh);
|
||||
static void CreateNewRenderObject(Color color, const Mesh& mesh);
|
||||
|
||||
private:
|
||||
// === Internal helper structs === //
|
||||
@@ -141,9 +141,9 @@ namespace PB::Renderer
|
||||
|
||||
// === Vulkan init helpers === //
|
||||
|
||||
static bool IsDeviceSuitable(const VkPhysicalDevice& device);
|
||||
static QueueFamilyIndices FindQueueFamilies(const VkPhysicalDevice& device);
|
||||
static bool CheckDeviceExtensionSupport(const VkPhysicalDevice& device);
|
||||
static bool IsDeviceSuitable(VulkanHandle device);
|
||||
static QueueFamilyIndices FindQueueFamilies(VulkanHandle device);
|
||||
static bool CheckDeviceExtensionSupport(VulkanHandle device);
|
||||
|
||||
static SwapChainSupportDetails QuerySwapChainSupport();
|
||||
static VkSurfaceFormatKHR ChooseSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace PB::Renderer
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VulkanManager::IsDeviceSuitable(const VkPhysicalDevice& device)
|
||||
bool VulkanManager::IsDeviceSuitable(VulkanHandle device)
|
||||
{
|
||||
const QueueFamilyIndices indices = FindQueueFamilies(device);
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace PB::Renderer
|
||||
return indices.Complete() && swapChainAdequate && discreteGPU;
|
||||
}
|
||||
|
||||
VulkanManager::QueueFamilyIndices VulkanManager::FindQueueFamilies(const VkPhysicalDevice& device)
|
||||
VulkanManager::QueueFamilyIndices VulkanManager::FindQueueFamilies(VulkanHandle device)
|
||||
{
|
||||
QueueFamilyIndices indices;
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace PB::Renderer
|
||||
return indices;
|
||||
}
|
||||
|
||||
bool VulkanManager::CheckDeviceExtensionSupport(const VkPhysicalDevice& device)
|
||||
bool VulkanManager::CheckDeviceExtensionSupport(VulkanHandle device)
|
||||
{
|
||||
const std::vector REQUIRED_EXTENSIONS = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace PB::Renderer
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanManager::CreateNewRenderObject(const Color color, Mesh mesh)
|
||||
void VulkanManager::CreateNewRenderObject(const Color color, const Mesh& mesh)
|
||||
{
|
||||
RenderObject obj{};
|
||||
obj.IndexCount = mesh.indices.size();
|
||||
|
||||
Reference in New Issue
Block a user