mirror of
https://github.com/Poikilos/b3view.git
synced 2023-10-03 07:58:48 -07:00
Fix reload texture by calling removeTexture...
...and use OUT_BIN in the shell build as the target.
This commit is contained in:
parent
059b61805f
commit
b615b8c314
1
.gitignore
vendored
1
.gitignore
vendored
@ -49,3 +49,4 @@ err.txt
|
||||
*.blend1
|
||||
/projects/meshes/penguin-lowpoly-poikilos-redochanges-messupback.blend
|
||||
/projects/meshes/penguin-lowpoly-poikilos-redochanges.blend
|
||||
/build/debug/b3view
|
||||
|
15
Engine.cpp
15
Engine.cpp
@ -716,21 +716,30 @@ bool Engine::reloadTexture()
|
||||
bool result = false;
|
||||
if (this->m_LoadedTexturePath.length() > 0) {
|
||||
if (wcslen(this->m_UserInterface->texturePathEditBox->getText()) == 0)
|
||||
result = loadTexture(this->m_UserInterface->texturePathEditBox->getText());
|
||||
result = loadTexture(this->m_UserInterface->texturePathEditBox->getText(), true);
|
||||
else
|
||||
result = loadTexture(this->m_LoadedTexturePath);
|
||||
result = loadTexture(this->m_LoadedTexturePath, true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Engine::loadTexture(const wstring& fileName)
|
||||
bool Engine::loadTexture(const wstring& fileName, bool reload)
|
||||
{
|
||||
bool ret = false;
|
||||
if (m_LoadedMesh != nullptr) {
|
||||
ITexture* texture = this->m_Driver->getTexture(fileName.c_str());
|
||||
if (reload) {
|
||||
// The texture may already have been read from storage, so:
|
||||
this->m_Driver->removeTexture(texture);
|
||||
texture = this->m_Driver->getTexture(fileName.c_str());
|
||||
}
|
||||
if (texture != nullptr) {
|
||||
m_LoadedMesh->setMaterialTexture(0, texture);
|
||||
ret = true;
|
||||
debug() << "* loaded " << "" << std::endl;
|
||||
}
|
||||
else {
|
||||
debug() << "* failed to load " << "" << std::endl;
|
||||
}
|
||||
this->m_LoadedTexturePath = fileName;
|
||||
std::cerr << "Setting texture path box to " << Utility::toString(this->m_LoadedTexturePath) << std::endl;
|
||||
|
2
Engine.h
2
Engine.h
@ -86,7 +86,7 @@ public:
|
||||
bool reloadMesh();
|
||||
std::wstring saveMesh(const irr::io::path path, const std::string& nameOrBlank, const std::string& extension);
|
||||
bool reloadTexture();
|
||||
bool loadTexture(const std::wstring& fileName);
|
||||
bool loadTexture(const std::wstring& fileName, bool reload);
|
||||
void setMeshDisplayMode(bool wireframe = false, bool lighting = false, bool textureInterpolation = true);
|
||||
bool isAnimating();
|
||||
void playAnimation();
|
||||
|
@ -796,11 +796,11 @@ bool UserInterface::loadNextTexture(int direction)
|
||||
if (lastTexture.length() > 0) {
|
||||
if (direction < 0) {
|
||||
cerr << "loading the previous texture...";
|
||||
ret = this->m_Engine->loadTexture(prevTexture);
|
||||
ret = this->m_Engine->loadTexture(prevTexture, false);
|
||||
}
|
||||
else if (direction > 0) {
|
||||
cerr << "loading the next texture...";
|
||||
ret = this->m_Engine->loadTexture(nextTexture);
|
||||
ret = this->m_Engine->loadTexture(nextTexture, false);
|
||||
}
|
||||
else {
|
||||
// If direction is 0 (such as when a model is loaded that has
|
||||
@ -808,12 +808,13 @@ bool UserInterface::loadNextTexture(int direction)
|
||||
if (this->m_Engine->m_LoadedTexturePath.length() > 0) {
|
||||
cerr << "using a specified texture...";
|
||||
ret = this->m_Engine->loadTexture(
|
||||
this->m_Engine->m_LoadedTexturePath
|
||||
this->m_Engine->m_LoadedTexturePath,
|
||||
false
|
||||
);
|
||||
}
|
||||
else if (this->m_MatchingTextures.size() >= 1) {
|
||||
cerr << "loading matching texture...";
|
||||
ret = this->m_Engine->loadTexture(firstTexture);
|
||||
ret = this->m_Engine->loadTexture(firstTexture, false);
|
||||
}
|
||||
else {
|
||||
ret = true;
|
||||
@ -824,7 +825,8 @@ bool UserInterface::loadNextTexture(int direction)
|
||||
else if (this->m_Engine->m_LoadedTexturePath.length() > 0) {
|
||||
cerr << "loading the first texture...";
|
||||
ret = this->m_Engine->loadTexture(
|
||||
this->m_Engine->m_LoadedTexturePath
|
||||
this->m_Engine->m_LoadedTexturePath,
|
||||
false
|
||||
);
|
||||
}
|
||||
} else
|
||||
@ -1156,7 +1158,7 @@ bool UserInterface::OnEvent(const SEvent& event)
|
||||
case UIE_LOADTEXTUREDIALOG:
|
||||
{
|
||||
IGUIFileOpenDialog* fileOpenDialog = static_cast<IGUIFileOpenDialog*>(ge->Caller);
|
||||
m_Engine->loadTexture(fileOpenDialog->getFileName());
|
||||
m_Engine->loadTexture(fileOpenDialog->getFileName(), true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -1191,7 +1193,7 @@ bool UserInterface::OnEvent(const SEvent& event)
|
||||
break;
|
||||
case UIE_TEXTUREPATHEDITBOX:
|
||||
if (this->m_Engine->m_LoadedMesh != nullptr) {
|
||||
this->m_Engine->loadTexture(texturePathEditBox->getText());
|
||||
this->m_Engine->loadTexture(texturePathEditBox->getText(), false);
|
||||
}
|
||||
break;
|
||||
case UIE_FPSEDITBOX:
|
||||
|
2
build.sh
2
build.sh
@ -91,7 +91,7 @@ if [ -f "$$OUT_BIN" ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
g++ -o build/b3view $OBJDIR/main.o $OBJDIR/Engine.o $OBJDIR/EventHandler.o $OBJDIR/UserInterface.o $OBJDIR/Debug.o $OBJDIR/View.o $OBJDIR/CGUITTFont.o $OBJDIR/Utility.o $OBJDIR/settings.o -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype
|
||||
g++ -o $OUT_BIN $OBJDIR/main.o $OBJDIR/Engine.o $OBJDIR/EventHandler.o $OBJDIR/UserInterface.o $OBJDIR/Debug.o $OBJDIR/View.o $OBJDIR/CGUITTFont.o $OBJDIR/Utility.o $OBJDIR/settings.o -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype
|
||||
if [ $? -ne 0 ]; then
|
||||
cat <<END
|
||||
Error: Linking failed. Ensure you have installed:
|
||||
|
Loading…
x
Reference in New Issue
Block a user