2025-07-10 21:51:17 +03:30
|
|
|
#include <asset_parser/assets/text.hpp>
|
2025-07-10 13:29:03 +03:30
|
|
|
#include <renderer/gl/shader.hpp>
|
2025-07-10 21:51:17 +03:30
|
|
|
#include <renderer/shader.hpp>
|
2025-07-05 13:28:41 +03:30
|
|
|
|
|
|
|
#ifdef LIGHT_PLATFORM_WINDOWS
|
2025-07-10 13:29:03 +03:30
|
|
|
#include <renderer/dx/shader.hpp>
|
|
|
|
#include <renderer/dx/shared_context.hpp>
|
2025-07-05 13:28:41 +03:30
|
|
|
#endif
|
|
|
|
|
2025-07-10 13:29:03 +03:30
|
|
|
#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-10 21:51:17 +03:30
|
|
|
/* static */ auto Shader::create(
|
2025-07-15 16:31:46 +03:30
|
|
|
const Ref<Assets::TextAsset> &vertex_asset,
|
|
|
|
const Ref<Assets::TextAsset> &pixel_asset,
|
2025-07-09 21:30:17 +03:30
|
|
|
const Ref<SharedContext> &shared_context
|
2025-07-06 14:02:50 +03:30
|
|
|
) -> Ref<Shader>
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-09 21:30:17 +03:30
|
|
|
std::ignore = shared_context;
|
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
// load shader source
|
2025-07-05 15:36:53 +03:30
|
|
|
switch (GraphicsContext::get_graphics_api())
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-09 21:30:17 +03:30
|
|
|
case GraphicsAPI::OpenGL:
|
2025-07-10 21:51:17 +03:30
|
|
|
return create_ref<glShader>(std::move(vertex_asset), std::move(pixel_asset));
|
2025-07-05 13:28:41 +03:30
|
|
|
|
|
|
|
case GraphicsAPI::DirectX:
|
2025-07-11 14:05:59 +03:30
|
|
|
lt_win(
|
|
|
|
return create_ref<dxShader>(
|
|
|
|
vertex_asset,
|
|
|
|
pixel_asset,
|
|
|
|
std::static_pointer_cast<dxSharedContext>(sharedContext)
|
|
|
|
);
|
|
|
|
);
|
2025-07-05 13:28:41 +03:30
|
|
|
|
2025-07-06 16:30:38 +03:30
|
|
|
default:
|
2025-07-11 02:12:55 +03:30
|
|
|
ensure(
|
2025-07-06 16:30:38 +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
|