light/modules/renderer/private/vertex_layout.cpp

45 lines
1.1 KiB
C++
Raw Normal View History

2025-07-20 04:46:15 +03:30
#include <lt_debug/assertions.hpp>
#include <renderer/gl/vertex_layout.hpp>
#include <renderer/vertex_layout.hpp>
2025-07-05 13:28:41 +03:30
#ifdef LIGHT_PLATFORM_WINDOWS
#include <renderer/dx/shared_context.hpp>
#include <renderer/dx/vertex_layout.hpp>
2025-07-05 13:28:41 +03:30
#endif
#include <renderer/graphics_context.hpp>
2025-07-05 13:28:41 +03:30
2025-07-11 00:05:48 +03:30
namespace lt {
2025-07-05 13:28:41 +03:30
2025-07-06 14:02:50 +03:30
auto VertexLayout::create(
const Ref<VertexBuffer> &vertexBuffer,
const Ref<Shader> & /*shader*/,
2025-07-05 13:28:41 +03:30
const std::vector<std::pair<std::string, VertexElementType>> &elements,
const Ref<SharedContext> & /*sharedContext*/
2025-07-06 14:02:50 +03:30
) -> Ref<VertexLayout>
2025-07-05 13:28:41 +03:30
{
switch (GraphicsContext::get_graphics_api())
2025-07-05 13:28:41 +03:30
{
case GraphicsAPI::OpenGL: return create_ref<glVertexLayout>(vertexBuffer, elements);
2025-07-05 13:28:41 +03:30
case GraphicsAPI::DirectX:
2025-07-11 14:05:59 +03:30
lt_win(
return create_ref<dxVertexLayout>(
shader,
elements,
std::static_pointer_cast<dxSharedContext>(sharedContext)
);
)
2025-07-05 13:28:41 +03:30
2025-07-06 14:02:50 +03:30
default
2025-07-11 02:12:55 +03:30
: ensure(
2025-07-06 14:02:50 +03:30
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
2025-07-05 13:28:41 +03:30
return nullptr;
}
}
2025-07-11 00:05:48 +03:30
} // namespace lt