mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-01-08 12:28:10 -05:00
Fixed texture loads on imgui
This commit is contained in:
parent
fdd613f41e
commit
a790638bf5
@ -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);
|
||||
|
@ -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*);
|
||||
|
@ -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) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user