Fix: 中文贴图不加载

main
wuyize 2024-01-14 15:06:57 +08:00
parent 34524a4319
commit 567510cbb5
2 changed files with 6 additions and 2 deletions

View File

@ -32,6 +32,8 @@ CentralWidget::CentralWidget(QWidget* parent) : QWidget(parent)
ui.stackedWidget->setCurrentWidget(ui.editorWidget); ui.stackedWidget->setCurrentWidget(ui.editorWidget);
ui.editorWidget->handleOpenPaintingFile(path); ui.editorWidget->handleOpenPaintingFile(path);
}); });
//navigationBarWidget->tabs->setCurrentTab(2);
//navigationBarWidget->hide();
} }
CentralWidget::~CentralWidget() CentralWidget::~CentralWidget()

View File

@ -231,11 +231,13 @@ GLuint Model::loadMaterialTextures(aiMaterial* mat, aiTextureType type)
if (iter != texturesLoaded.end()) if (iter != texturesLoaded.end())
return iter->second.textureId(); return iter->second.textureId();
QImage data(directory.filePath(path.c_str())); auto qPath = QString::fromUtf8(QByteArray::fromPercentEncoding(path.c_str()));
//qDebug() << qPath;
//qDebug() << "Loading" << str.C_Str();
QImage data(directory.filePath(qPath));
if (data.isNull()) if (data.isNull())
return 0; return 0;
//qDebug() << "Loading" << path.c_str();
auto [it, _] = texturesLoaded.emplace(path, QOpenGLTexture::Target2D); auto [it, _] = texturesLoaded.emplace(path, QOpenGLTexture::Target2D);
auto& texture = it->second; auto& texture = it->second;
texture.create(); texture.create();