Fixed texture loads on imgui

This commit is contained in:
KiritoDev 2022-05-12 09:26:32 -05:00 committed by louist103
parent fdd613f41e
commit a790638bf5
3 changed files with 3 additions and 12 deletions

View File

@ -257,7 +257,7 @@ namespace SohImGui {
void LoadTexture(const std::string& name, const std::string& path) {
GfxRenderingAPI* api = gfx_get_current_rendering_api();
const auto res = GlobalCtx2::GetInstance()->GetResourceManager()->LoadFile(normalize(path));
const auto res = GlobalCtx2::GetInstance()->GetResourceManager()->LoadFile(path);
const auto asset = new GameAsset{ api->new_texture() };
uint8_t* img_data = stbi_load_from_memory(reinterpret_cast<const stbi_uc*>(res->buffer.get()), res->dwBufferSize, &asset->width, &asset->height, nullptr, 4);
@ -277,7 +277,7 @@ namespace SohImGui {
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint) {
GfxRenderingAPI* api = gfx_get_current_rendering_api();
const auto res = static_cast<Ship::Texture*>(GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(normalize(path)).get());
const auto res = static_cast<Ship::Texture*>(GlobalCtx2::GetInstance()->GetResourceManager()->LoadResource(path)).get());
std::vector<uint8_t> texBuffer;
texBuffer.reserve(res->width * res->height * 4);

View File

@ -43,7 +43,7 @@ namespace Ship {
if (raw_path == nullptr) return;
const auto api = BIND_PTR("gfx_api", GfxRenderingAPI*);
const auto path = normalize(raw_path) + ".png";
const auto path = raw_path + ".png";
const auto node = BIND_PTR("node", TextureCacheNode**);
const auto fmt = BIND_VAR("fmt", uint32_t*);
const auto siz = BIND_VAR("siz", uint32_t*);

View File

@ -36,15 +36,6 @@ namespace Ship {
void Hook_InvalidateTexture(HookEvent event);
};
inline std::string normalize(std::string path) {
#ifdef _WIN32
std::ranges::replace(path, '/', '\\');
#else
std::replace(path.begin(), path.end(), '\\', '/');
#endif
return path;
}
inline void GrayOutTexture(uint8_t* data, int width, int height) {
for (int x = 0; x < width * height * 4; x += 4) {