mirror of
https://github.com/open-goal/jak-project.git
synced 2024-11-27 16:31:14 +00:00
40e2f113e6
## Problem OpenGOAL uses OpenGL 4.3. Apple stopped upgrading OpenGL after 4.1, so the way OpenGOAL currently works will never be playable on Macs using OpenGL. ## Solution Luckily, downgrading to OpenGL 4.1 is not a huge change (at least it doesn't seem like it to my untrained eyes). ## Changes * set hints for OpenGL 4.1 instead of 4.3 for __APPLE__ * skip the OpenGL debugging callback setup for macOS (requires 4.3) * bump down the version string for all shaders * stop using the `binding` layout qualifier in shader code * move the `flat` qualifier first (not sure if this is a 4.1 thing or just Macs being more strict) * don't mix signed and unsigned ints in shaders (not sure if this is a 4.1 thing or just Macs being more strict) * add some hacky CPP to the Shader constructor for binding texture units and bones buffers based on variable names in the shader code ## Results ![image](https://github.com/open-goal/jak-project/assets/33322/dd487c2a-61ac-4e36-a595-976204302977) ![Skärmavbild 2023-07-07 kl 13 10 30](https://github.com/open-goal/jak-project/assets/33322/7976d411-0604-4046-9e8a-123106cedf57) ![Skärmavbild 2023-07-07 kl 13 13 48](https://github.com/open-goal/jak-project/assets/33322/78db4f0c-da31-4889-995c-8f54e56deb5c)
54 lines
1.7 KiB
C++
54 lines
1.7 KiB
C++
#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);
|
|
#ifdef __APPLE__
|
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
|
#endif
|
|
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
|