light/modules/engine/src/graphics/vertex_layout.cpp

42 lines
1.1 KiB
C++
Raw Normal View History

2025-07-05 13:28:41 +03:30
#include <engine/graphics/vertex_layout.hpp>
#include <engine/platform/graphics/opengl/vertex_layout.hpp>
#ifdef LIGHT_PLATFORM_WINDOWS
#include <engine/platform/graphics/directx/shared_context.hpp>
#include <engine/platform/graphics/directx/vertex_layout.hpp>
#endif
#include <engine/graphics/graphics_context.hpp>
namespace Light {
2025-07-06 14:02:50 +03:30
auto VertexLayout::create(
2025-07-06 16:52:50 +03:30
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,
2025-07-06 16:52:50 +03:30
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:
lt_win(return create_ref<dxVertexLayout>(
2025-07-05 13:28:41 +03:30
shader,
elements,
std::static_pointer_cast<dxSharedContext>(sharedContext)
);)
2025-07-06 14:02:50 +03:30
default
: lt_assert(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
2025-07-05 13:28:41 +03:30
return nullptr;
}
}
} // namespace Light