//
// Created by sfd on 25-4-21.
//

#include "Buffer.h"

#include <Hazel/Core/Log.h>

#include "Renderer.h"
#include "Platform/OpenGL/OpenGLBuffer.h"

namespace Hazel
{
    Ref<VertexBuffer> VertexBuffer::Create(uint32_t size)
    {
        switch (Renderer::GetAPI())
        {
            case RendererAPI::API::NONE:
                HZ_CORE_ERROR("NONE is not Support!");
                return nullptr;
        case RendererAPI::API::OPENGL:
                // return std::make_shared<VertexBuffer>(OpenGLVertexBuffer(vertices, size));
                return std::make_shared<OpenGLVertexBuffer>(size);
            default:
                break;
        }

        HZ_CORE_ERROR("Unknown RendererAPI!");
        return nullptr;
    }

    // std::shared_ptr<VertexBuffer> VertexBuffer::Create(float* vertices, uint32_t size)
    Ref<VertexBuffer> VertexBuffer::Create(float* vertices, uint32_t size)
    {
        switch (Renderer::GetAPI())
        {
            case RendererAPI::API::NONE:
                HZ_CORE_ERROR("NONE is not Support!");
                return nullptr;
        case RendererAPI::API::OPENGL:
                // return std::make_shared<VertexBuffer>(OpenGLVertexBuffer(vertices, size));
                return std::make_shared<OpenGLVertexBuffer>(vertices, size);
            default:
                break;
        }

        HZ_CORE_ERROR("Unknown RendererAPI!");
        return nullptr;
    }

    Ref<IndexBuffer> IndexBuffer::Create(uint32_t* indices, uint32_t count)
    {
        switch (Renderer::GetAPI())
        {
            case RendererAPI::API::NONE:
                HZ_CORE_ERROR("NONE is not Support!");
                return nullptr;
        case RendererAPI::API::OPENGL:
                return std::make_shared<OpenGLIndexBuffer>(indices, count);
                break;
            default:
                break;
        }

        HZ_CORE_ERROR("Unknown RendererAPI!");
        return nullptr;
    }
}
