Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return to the main menu if a shader compilation fails #14256

Merged
merged 6 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/client/clientlauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
error_message = gettext("Connection error (timed out?)");
errorstream << error_message << std::endl;
}
catch (ShaderException &e) {
error_message = e.what();
errorstream << error_message << std::endl;
}

#ifdef NDEBUG
catch (std::exception &e) {
Expand Down
9 changes: 6 additions & 3 deletions src/client/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IShaderConstantSetCallBack.h>
#include "client/renderingengine.h"
#include "EShaderTypes.h"
#include "gettext.h"
#include "log.h"
#include "gamedef.h"
#include "client/tile.h"
Expand Down Expand Up @@ -588,8 +589,8 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,

video::IVideoDriver *driver = RenderingEngine::get_video_driver();
if (!driver->queryFeature(video::EVDF_ARB_GLSL)) {
errorstream << "Shaders are enabled but GLSL is not supported by the driver\n";
return shaderinfo;
throw ShaderException(gettext("Shaders are enabled but GLSL is not "
"supported by the driver."));
}
video::IGPUProgrammingServices *gpu = driver->getGPUProgrammingServices();

Expand Down Expand Up @@ -790,7 +791,9 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
dumpShaderProgram(warningstream, "Vertex", vertex_shader);
dumpShaderProgram(warningstream, "Fragment", fragment_shader);
dumpShaderProgram(warningstream, "Geometry", geometry_shader);
return shaderinfo;
throw ShaderException(
fmtgettext("Failed to compile the \"%s\" shader.", name.c_str()) +
strgettext("\nCheck debug.txt for details."));
}

// Apply the newly created material type
Expand Down
5 changes: 5 additions & 0 deletions src/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ class PrngException : public BaseException {
PrngException(const std::string &s): BaseException(s) {}
};

class ShaderException : public BaseException {
public:
ShaderException(const std::string &s): BaseException(s) {}
};

class ModError : public BaseException {
public:
ModError(const std::string &s): BaseException(s) {}
Expand Down