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/=CppNoDiscardExpression/@EntryIndexedValue" value="WARNING" type="string" />
|
||||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@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/=CppNonExceptionSafeResourceAcquisition/@EntryIndexedValue" value="HINT" type="string" />
|
||||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@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="HINT" 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/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
|
||||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@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" />
|
<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
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace PB::Renderer
|
namespace PB::Renderer
|
||||||
{
|
{
|
||||||
struct Color
|
struct Color
|
||||||
@@ -17,4 +19,16 @@ namespace PB::Renderer
|
|||||||
constexpr Color cyan = {0.0f, 1.0f, 1.0f, 1.0f};
|
constexpr Color cyan = {0.0f, 1.0f, 1.0f, 1.0f};
|
||||||
constexpr Color magenta = {1.0f, 0.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;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
50
src/main.cpp
50
src/main.cpp
@@ -32,35 +32,37 @@ int main()
|
|||||||
CleanupAllAndExit(EXIT_FAILURE);
|
CleanupAllAndExit(EXIT_FAILURE);
|
||||||
|
|
||||||
/* Adds runtime objects */
|
/* Adds runtime objects */
|
||||||
VulkanManager::CreateNewRenderObject
|
{
|
||||||
(
|
VulkanManager::CreateNewRenderObject
|
||||||
Colors::red, Mesh
|
(
|
||||||
{
|
Colors::red, Mesh
|
||||||
.vertices =
|
|
||||||
{
|
{
|
||||||
0.0f, -0.5f,
|
.vertices =
|
||||||
0.5f, 0.9f,
|
{
|
||||||
-0.5f, 0.5f
|
0.0f, -0.5f,
|
||||||
},
|
0.5f, 0.9f,
|
||||||
|
-0.5f, 0.5f
|
||||||
|
},
|
||||||
|
|
||||||
.indices = { 0, 1, 2 }
|
.indices = { 0, 1, 2 }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
VulkanManager::CreateNewRenderObject
|
VulkanManager::CreateNewRenderObject
|
||||||
(
|
(
|
||||||
Colors::yellow, Mesh
|
Colors::yellow, Mesh
|
||||||
{
|
|
||||||
.vertices =
|
|
||||||
{
|
{
|
||||||
-0.9f, 0.0f,
|
.vertices =
|
||||||
-0.9f, -0.9f,
|
{
|
||||||
0.0f, -0.9f
|
-0.9f, 0.0f,
|
||||||
},
|
-0.9f, -0.9f,
|
||||||
|
0.0f, -0.9f
|
||||||
|
},
|
||||||
|
|
||||||
.indices = { 0, 1, 2 }
|
.indices = { 0, 1, 2 }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/* Polls window events whilst it is still open */
|
/* Polls window events whilst it is still open */
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace PB::Renderer
|
|||||||
*/
|
*/
|
||||||
static bool RenderPass(GLFWwindow* window);
|
static bool RenderPass(GLFWwindow* window);
|
||||||
|
|
||||||
static void CreateNewRenderObject(Color color, Mesh mesh);
|
static void CreateNewRenderObject(Color color, const Mesh& mesh);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// === Internal helper structs === //
|
// === Internal helper structs === //
|
||||||
@@ -141,9 +141,9 @@ namespace PB::Renderer
|
|||||||
|
|
||||||
// === Vulkan init helpers === //
|
// === Vulkan init helpers === //
|
||||||
|
|
||||||
static bool IsDeviceSuitable(const VkPhysicalDevice& device);
|
static bool IsDeviceSuitable(VulkanHandle device);
|
||||||
static QueueFamilyIndices FindQueueFamilies(const VkPhysicalDevice& device);
|
static QueueFamilyIndices FindQueueFamilies(VulkanHandle device);
|
||||||
static bool CheckDeviceExtensionSupport(const VkPhysicalDevice& device);
|
static bool CheckDeviceExtensionSupport(VulkanHandle device);
|
||||||
|
|
||||||
static SwapChainSupportDetails QuerySwapChainSupport();
|
static SwapChainSupportDetails QuerySwapChainSupport();
|
||||||
static VkSurfaceFormatKHR ChooseSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
|
static VkSurfaceFormatKHR ChooseSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ namespace PB::Renderer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VulkanManager::IsDeviceSuitable(const VkPhysicalDevice& device)
|
bool VulkanManager::IsDeviceSuitable(VulkanHandle device)
|
||||||
{
|
{
|
||||||
const QueueFamilyIndices indices = FindQueueFamilies(device);
|
const QueueFamilyIndices indices = FindQueueFamilies(device);
|
||||||
|
|
||||||
@@ -281,7 +281,7 @@ namespace PB::Renderer
|
|||||||
return indices.Complete() && swapChainAdequate && discreteGPU;
|
return indices.Complete() && swapChainAdequate && discreteGPU;
|
||||||
}
|
}
|
||||||
|
|
||||||
VulkanManager::QueueFamilyIndices VulkanManager::FindQueueFamilies(const VkPhysicalDevice& device)
|
VulkanManager::QueueFamilyIndices VulkanManager::FindQueueFamilies(VulkanHandle device)
|
||||||
{
|
{
|
||||||
QueueFamilyIndices indices;
|
QueueFamilyIndices indices;
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ namespace PB::Renderer
|
|||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VulkanManager::CheckDeviceExtensionSupport(const VkPhysicalDevice& device)
|
bool VulkanManager::CheckDeviceExtensionSupport(VulkanHandle device)
|
||||||
{
|
{
|
||||||
const std::vector REQUIRED_EXTENSIONS = {
|
const std::vector REQUIRED_EXTENSIONS = {
|
||||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
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{};
|
RenderObject obj{};
|
||||||
obj.IndexCount = mesh.indices.size();
|
obj.IndexCount = mesh.indices.size();
|
||||||
|
|||||||
Reference in New Issue
Block a user