light/modules/renderer/src/shader.cpp

45 lines
1,008 B
C++
Raw Normal View History

#include <renderer/shader.hpp>
#include <renderer/gl/shader.hpp>
2025-07-05 13:28:41 +03:30
#ifdef LIGHT_PLATFORM_WINDOWS
#include <renderer/dx/shader.hpp>
#include <renderer/dx/shared_context.hpp>
2025-07-05 13:28:41 +03:30
#endif
#include <renderer/graphics_context.hpp>
2025-07-05 13:28:41 +03:30
namespace Light {
2025-07-06 14:02:50 +03:30
auto Shader::create(
Assets::Blob vertex_blob,
Assets::Blob pixel_blob,
const Ref<SharedContext> &shared_context
2025-07-06 14:02:50 +03:30
) -> Ref<Shader>
2025-07-05 13:28:41 +03:30
{
std::ignore = shared_context;
2025-07-05 13:28:41 +03:30
// load shader source
switch (GraphicsContext::get_graphics_api())
2025-07-05 13:28:41 +03:30
{
case GraphicsAPI::OpenGL:
return create_ref<glShader>(std::move(vertex_blob), std::move(pixel_blob));
2025-07-05 13:28:41 +03:30
case GraphicsAPI::DirectX:
lt_win(return create_ref<dxShader>(
2025-07-05 13:28:41 +03:30
vertexFile,
pixelFile,
std::static_pointer_cast<dxSharedContext>(sharedContext)
2025-07-06 16:30:38 +03:30
););
2025-07-05 13:28:41 +03:30
2025-07-06 16:30:38 +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