2025-07-05 13:28:41 +03:30
|
|
|
#include <engine/graphics/shader.hpp>
|
|
|
|
#include <engine/platform/graphics/opengl/shader.hpp>
|
|
|
|
|
|
|
|
#ifdef LIGHT_PLATFORM_WINDOWS
|
|
|
|
#include <engine/platform/graphics/directx/shader.hpp>
|
|
|
|
#include <engine/platform/graphics/directx/shared_context.hpp>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <engine/graphics/graphics_context.hpp>
|
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
2025-07-05 15:36:53 +03:30
|
|
|
Ref<Shader> Shader::create(
|
2025-07-05 16:07:51 +03:30
|
|
|
BasicFileHandle vertexFile,
|
|
|
|
BasicFileHandle pixelFile,
|
2025-07-05 13:28:41 +03:30
|
|
|
Ref<SharedContext> sharedContext
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// 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-05 15:36:53 +03:30
|
|
|
case GraphicsAPI::OpenGL: return create_ref<glShader>(vertexFile, pixelFile);
|
2025-07-05 13:28:41 +03:30
|
|
|
|
|
|
|
case GraphicsAPI::DirectX:
|
2025-07-05 15:36:53 +03:30
|
|
|
lt_win(return create_ref<dxShader>(
|
2025-07-05 13:28:41 +03:30
|
|
|
vertexFile,
|
|
|
|
pixelFile,
|
|
|
|
std::static_pointer_cast<dxSharedContext>(sharedContext)
|
|
|
|
);)
|
|
|
|
|
|
|
|
default:
|
2025-07-05 15:36:53 +03:30
|
|
|
lt_assert(
|
2025-07-05 13:28:41 +03:30
|
|
|
false,
|
|
|
|
"Invalid/unsupported 'GraphicsAPI' {}",
|
2025-07-05 15:36:53 +03:30
|
|
|
static_cast<uint32_t>(GraphicsContext::get_graphics_api())
|
2025-07-05 13:28:41 +03:30
|
|
|
);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Light
|