2025-07-10 13:29:03 +03:30
|
|
|
#include <logger/logger.hpp>
|
|
|
|
#include <renderer/gl/texture.hpp>
|
|
|
|
#include <renderer/texture.hpp>
|
2025-07-05 13:28:41 +03:30
|
|
|
|
|
|
|
#ifdef LIGHT_PLATFORM_WINDOWS
|
2025-07-10 13:29:03 +03:30
|
|
|
#include <renderer/dx/shared_context.hpp>
|
|
|
|
#include <renderer/dx/texture.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-06 16:52:50 +03:30
|
|
|
#include <utility>
|
2025-07-05 13:28:41 +03:30
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
2025-07-06 14:02:50 +03:30
|
|
|
auto Texture::create(
|
2025-07-05 13:28:41 +03:30
|
|
|
unsigned int width,
|
|
|
|
unsigned int height,
|
|
|
|
unsigned int components,
|
|
|
|
unsigned char *pixels,
|
2025-07-10 13:29:03 +03:30
|
|
|
const Ref<SharedContext> & /*sharedContext*/,
|
2025-07-05 13:28:41 +03:30
|
|
|
const std::string &filePath
|
2025-07-06 14:02:50 +03:30
|
|
|
) -> Ref<Texture>
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
2025-07-05 15:36:53 +03:30
|
|
|
switch (GraphicsContext::get_graphics_api())
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
|
|
|
case GraphicsAPI::OpenGL:
|
2025-07-05 15:36:53 +03:30
|
|
|
return create_ref<glTexture>(width, height, components, pixels, filePath);
|
2025-07-05 13:28:41 +03:30
|
|
|
|
|
|
|
case GraphicsAPI::DirectX:
|
2025-07-05 15:36:53 +03:30
|
|
|
lt_win(return create_ref<dxTexture>(
|
2025-07-05 13:28:41 +03:30
|
|
|
width,
|
|
|
|
height,
|
|
|
|
components,
|
|
|
|
pixels,
|
|
|
|
std::static_pointer_cast<dxSharedContext>(sharedContext),
|
|
|
|
filePath
|
|
|
|
);)
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-07-06 16:52:50 +03:30
|
|
|
Texture::Texture(std::string filePath): m_file_path(std::move(filePath))
|
2025-07-05 13:28:41 +03:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Light
|