aboutsummaryrefslogtreecommitdiff
path: root/src/Rendering/VertexArray.cpp
blob: bca1f4af652f21f16f406e1d6a4d42b8db5bea3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "VertexArray.h"
#include "Renderer.h"

#include "Platform/OpenGL/OpenGLVertexArray.h"
#include "Platform/Vulkan/VulkanVertexArray.h"

namespace Donut
{
    uint32_t VertexBufferElement::GetSizeOfType(uint32_t type)
    {
        switch (type) 
        {
            case 0x1406: return 4; // GL_FLOAT
            case 0x1405: return 4; // GL_UNSIGNED_INT
            case 0x1401: return 1; // GL_UNSIGNED_BYTE
            default: return 0;
        }
    }

    Ref<VertexArray> VertexArray::Create() 
    {
        switch (Renderer::GetAPI()) 
        {
            case RendererAPI::API::OpenGL:
                return CreateRef<OpenGLVertexArray>();
            case RendererAPI::API::Vulkan:
                return CreateRef<VulkanVertexArray>();
            default:
                return nullptr;
        }
    }
};