Skip to content

Commit d341c66

Browse files
Merge pull request #552 from lethal-guitar/gl-robustness
OpenGl robustness
2 parents 7846d91 + 8bc55ed commit d341c66

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/game_main.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,7 @@ void showErrorMessage(SDL_Window* pWindow, const std::string& error) {
227227
ImGui::OpenPopup("Error!");
228228
}
229229

230-
const auto flags =
231-
ImGuiWindowFlags_NoResize |
232-
ImGuiWindowFlags_NoMove;
233-
if (ImGui::BeginPopupModal("Error!", &boxIsVisible, flags)) {
230+
if (ImGui::BeginPopupModal("Error!", &boxIsVisible, 0)) {
234231
ImGui::Text("%s", error.c_str());
235232

236233
if (ImGui::Button("Ok")) {

src/renderer/opengl.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "opengl.hpp"
1818

19+
#include "sdl_utils/error.hpp"
20+
1921
RIGEL_DISABLE_WARNINGS
2022
#include <SDL_video.h>
2123
RIGEL_RESTORE_WARNINGS
@@ -26,9 +28,13 @@ RIGEL_RESTORE_WARNINGS
2628
void rigel::renderer::loadGlFunctions() {
2729
int result = 0;
2830
#ifdef RIGEL_USE_GL_ES
29-
result = gladLoadGLES2Loader(SDL_GL_GetProcAddress);
31+
result = gladLoadGLES2Loader([](const char* proc) {
32+
return sdl_utils::check(SDL_GL_GetProcAddress(proc));
33+
});
3034
#else
31-
result = gladLoadGLLoader(SDL_GL_GetProcAddress);
35+
result = gladLoadGLLoader([](const char* proc) {
36+
return sdl_utils::check(SDL_GL_GetProcAddress(proc));
37+
});
3238
#endif
3339

3440
if (!result) {

src/renderer/renderer.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ precision mediump float;
6060

6161
#else
6262

63+
// We generally want to stick to GLSL version 130 (from OpenGL 3.0) in order to
64+
// maximize compatibility with older graphics cards. Unfortunately, Mac OS only
65+
// supports GLSL 150 (from OpenGL 3.2), even when requesting a OpenGL 3.0
66+
// context. Therefore, we use different GLSL versions depending on the
67+
// platform.
68+
#if defined(__APPLE__)
6369
const auto SHADER_PREAMBLE = R"shd(
6470
#version 150
6571
@@ -71,6 +77,19 @@ const auto SHADER_PREAMBLE = R"shd(
7177
#define OUTPUT_COLOR_DECLARATION out vec4 outputColor;
7278
#define SET_POINT_SIZE
7379
)shd";
80+
#else
81+
const auto SHADER_PREAMBLE = R"shd(
82+
#version 130
83+
84+
#define ATTRIBUTE in
85+
#define OUT out
86+
#define IN in
87+
#define TEXTURE_LOOKUP texture2D
88+
#define OUTPUT_COLOR outputColor
89+
#define OUTPUT_COLOR_DECLARATION out vec4 outputColor;
90+
#define SET_POINT_SIZE
91+
)shd";
92+
#endif
7493

7594
#endif
7695

0 commit comments

Comments
 (0)