Skip to content

Commit

Permalink
GL: fixed includes/macros
Browse files Browse the repository at this point in the history
Avoid using UG-specific platform macros (HAVE_LINUX/MAVE_MACOSX/WIN32)
and use a generic ones instead. This allows removeing config_*.h.

Also removed unused includes and sorted.
  • Loading branch information
MartinPulec committed Jan 15, 2024
1 parent d4f80ef commit 25e8c8d
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/video_display/gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,22 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config_unix.h"
#include "config_win32.h"
#endif

#include <assert.h>
#ifdef HAVE_MACOSX
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <OpenGL/OpenGL.h> // CGL
#include <OpenGL/glext.h>
#else
#include <GL/glew.h>
#endif /* HAVE_MACOSX */
#endif /* __APPLE__ */
#include <GLFW/glfw3.h>

#include "spout_sender.h"
#include "syphon_server.h"

#include <array>
#include <algorithm>
#include <array>
#include <cassert>
#include <condition_variable>
#include <csetjmp>
#include <fstream>
#include <iostream>
#include <mutex>
Expand All @@ -70,6 +63,9 @@
#include <unordered_map>

#include "color.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "debug.h"
#include "gl_context.h"
#include "host.h"
Expand Down Expand Up @@ -852,7 +848,7 @@ static void screenshot(struct video_frame *frame)
t = time(NULL);
struct tm *time_ptr;

#ifdef WIN32
#ifdef _WIN32
time_ptr = localtime(&t);
#else
struct tm time_tmp;
Expand Down Expand Up @@ -1336,7 +1332,7 @@ static void display_gl_render_last(GLFWwindow *win) {
display_gl_putf(s, f, PUTF_NONBLOCK);
}

#if defined HAVE_LINUX || defined WIN32
#if defined __linux__ || defined _WIN32
#ifndef GLEW_ERROR_NO_GLX_DISPLAY
#define GLEW_ERROR_NO_GLX_DISPLAY 4
#endif
Expand All @@ -1349,7 +1345,7 @@ static const char *glewGetError(GLenum err) {
default: return (const char *) glewGetErrorString(err);
}
}
#endif // defined HAVE_LINUX || defined WIN32
#endif // defined __linux__ || defined _WIN32

static void glfw_print_error(int error_code, const char* description) {
LOG(LOG_LEVEL_ERROR) << "GLFW error " << error_code << ": " << description << "\n";
Expand Down Expand Up @@ -1538,14 +1534,14 @@ static bool display_gl_init_opengl(struct state_gl *s)
glfwSetFramebufferSizeCallback(s->window, gl_resize);
glfwSetWindowRefreshCallback(s->window, display_gl_render_last);

#if defined HAVE_LINUX || defined WIN32
#if defined __linux__ || defined _WIN32
if (GLenum err = glewInit()) {
log_msg(LOG_LEVEL_ERROR, MOD_NAME "GLEW Error: %s (err %d)\n", glewGetError(err), err);
if (err != GLEW_ERROR_NO_GLX_DISPLAY) { // do not fail on error 4 (on Wayland), which can be suppressed
return false;
}
}
#endif /* HAVE_LINUX */
#endif
if (!display_gl_check_gl_version()) {
glfwDestroyWindow(s->window);
s->window = nullptr;
Expand Down

0 comments on commit 25e8c8d

Please sign in to comment.