light/modules/renderer/src/shader.cpp
light7734 1247b1ac69
Some checks failed
continuous-integration/drone/push Build is failing
ci: add static_analysis (#2)
Reviewed-on: #2
Co-authored-by: light7734 <light7734@tuta.io>
Co-committed-by: light7734 <light7734@tuta.io>
2025-07-14 08:45:09 +00:00

47 lines
1.1 KiB
C++

#include <asset_parser/assets/text.hpp>
#include <renderer/gl/shader.hpp>
#include <renderer/shader.hpp>
#ifdef LIGHT_PLATFORM_WINDOWS
#include <renderer/dx/shader.hpp>
#include <renderer/dx/shared_context.hpp>
#endif
#include <renderer/graphics_context.hpp>
namespace lt {
/* static */ auto Shader::create(
const Ref<Assets::TextAsset>& vertex_asset,
const Ref<Assets::TextAsset>& pixel_asset,
const Ref<SharedContext> &shared_context
) -> Ref<Shader>
{
std::ignore = shared_context;
// load shader source
switch (GraphicsContext::get_graphics_api())
{
case GraphicsAPI::OpenGL:
return create_ref<glShader>(std::move(vertex_asset), std::move(pixel_asset));
case GraphicsAPI::DirectX:
lt_win(
return create_ref<dxShader>(
vertex_asset,
pixel_asset,
std::static_pointer_cast<dxSharedContext>(sharedContext)
);
);
default:
ensure(
false,
"Invalid/unsupported 'GraphicsAPI' {}",
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
);
return nullptr;
}
}
} // namespace lt