-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
game: Improve OpenGL version detection and make requirement errors mo…
…re obvious to the user (#2787)
- Loading branch information
Showing
17 changed files
with
6,837 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "dialogs.h" | ||
|
||
namespace dialogs { | ||
// char const * const aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */ | ||
// char const * const aIconType , /* "info" "warning" "error" "question" */ | ||
// int const aDefaultButton ) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */ | ||
void create_error_message_dialog(const std::string& title, const std::string& message) { | ||
tinyfd_messageBox(title.data(), message.data(), "ok", "error", 1); | ||
} | ||
} // namespace dialogs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "third-party/libtinyfiledialogs/tinyfiledialogs.h" | ||
|
||
namespace dialogs { | ||
void create_error_message_dialog(const std::string& title, const std::string& message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "gfx_test.h" | ||
|
||
#include "game/system/hid/sdl_util.h" | ||
|
||
namespace tests { | ||
void to_json(json& j, const GPUTestOutput& obj) { | ||
j = json{ | ||
{"success", obj.success}, | ||
{"error", obj.error}, | ||
{"errorCause", obj.errorCause}, | ||
}; | ||
} | ||
|
||
GPUTestOutput run_gpu_test(const std::string& test_type) { | ||
lg::info("Running GPU Test - {}", test_type); | ||
GPUTestOutput output = {false, "", ""}; | ||
if (test_type == "opengl") { | ||
if (SDL_Init(SDL_INIT_VIDEO) < 0) { | ||
output = {false, "SDL initialization failed", | ||
sdl_util::log_and_return_error("SDL initialization failed")}; | ||
return output; | ||
} | ||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); | ||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); | ||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); | ||
SDL_Window* window = | ||
SDL_CreateWindow("OpenGL Version", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, | ||
600, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN); | ||
if (!window) { | ||
output = {false, "SDL window creation failed", | ||
sdl_util::log_and_return_error("SDL initialization failed")}; | ||
SDL_Quit(); | ||
return output; | ||
} | ||
SDL_GLContext glContext = SDL_GL_CreateContext(window); | ||
if (!glContext) { | ||
output = {false, "Required OpenGL Version is not supported", | ||
sdl_util::log_and_return_error("SDL initialization failed")}; | ||
} else { | ||
output = {true, "", ""}; | ||
SDL_GL_DeleteContext(glContext); | ||
} | ||
SDL_DestroyWindow(window); | ||
SDL_Quit(); | ||
} else { | ||
lg::error("Invalid GPU test type - {}", test_type); | ||
} | ||
return output; | ||
} | ||
}; // namespace tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "common/util/json_util.h" | ||
|
||
namespace tests { | ||
struct GPUTestOutput { | ||
bool success; | ||
std::string error; | ||
std::string errorCause; | ||
}; | ||
void to_json(json& j, const GPUTestOutput& obj); | ||
|
||
GPUTestOutput run_gpu_test(const std::string& test_type); | ||
} // namespace tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.