From 20d396102dd3443083b2761a8d920b2bcbfc671e Mon Sep 17 00:00:00 2001
From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
Date: Thu, 12 Oct 2023 07:41:20 +0200
Subject: [PATCH 2/4] Remove obsoleted gfx code

---
 HPL2/core/include/impl/LowLevelGraphicsSDL.h  |  5 --
 .../core/sources/impl/LowLevelGraphicsSDL.cpp | 22 ------
 amnesia/src/launcher/Main.cpp                 | 79 -------------------
 3 files changed, 106 deletions(-)

diff --git a/HPL2/core/include/impl/LowLevelGraphicsSDL.h b/HPL2/core/include/impl/LowLevelGraphicsSDL.h
index b526170..2c17c6d 100644
--- a/HPL2/core/include/impl/LowLevelGraphicsSDL.h
+++ b/HPL2/core/include/impl/LowLevelGraphicsSDL.h
@@ -36,11 +36,6 @@
 #include "SDL/SDL.h"
 #endif
 
-// Include these AFTER SDL
-#if defined(__linux__) || defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__)
-#include <GL/glx.h>
-#endif
-
 #include "graphics/LowLevelGraphics.h"
 #include "math/MathTypes.h"
 
diff --git a/HPL2/core/sources/impl/LowLevelGraphicsSDL.cpp b/HPL2/core/sources/impl/LowLevelGraphicsSDL.cpp
index 61facfb..8cffad5 100644
--- a/HPL2/core/sources/impl/LowLevelGraphicsSDL.cpp
+++ b/HPL2/core/sources/impl/LowLevelGraphicsSDL.cpp
@@ -700,29 +700,7 @@ namespace hpl {
 	void cLowLevelGraphicsSDL::SetVsyncActive(bool abX, bool abAdaptive)
 	{
         ;
-#if SDL_VERSION_ATLEAST(2, 0, 0)
         SDL_GL_SetSwapInterval(abX ? (abAdaptive ? -1 : 1) : 0);
-#elif defined(WIN32)
-		if(WGLEW_EXT_swap_control)
-		{
-			wglSwapIntervalEXT(abX ? (abAdaptive ? -1 : 1) : 0);
-		}
-#elif defined(__linux__) || defined(__FreeBSD__)
-		if (GLX_SGI_swap_control)
-		{
-			GLXSWAPINTERVALPROC glXSwapInterval = (GLXSWAPINTERVALPROC)glXGetProcAddress((GLubyte*)"glXSwapIntervalSGI");
-			glXSwapInterval(abX ? (abAdaptive ? -1 : 1) : 0);
-		}
-		else if (GLX_MESA_swap_control)
-		{
-			GLXSWAPINTERVALPROC glXSwapInterval = (GLXSWAPINTERVALPROC)glXGetProcAddress((GLubyte*)"glXSwapIntervalMESA");
-			glXSwapInterval(abX ? (abAdaptive ? -1 : 1) : 0);
-		}
-#elif defined(__APPLE__)
-		CGLContextObj ctx = CGLGetCurrentContext();
-		GLint swap = abX ? 1 : 0;
-		CGLSetParameter(ctx, kCGLCPSwapInterval, &swap);
-#endif
 	}
 
 	//-----------------------------------------------------------------------
diff --git a/amnesia/src/launcher/Main.cpp b/amnesia/src/launcher/Main.cpp
index c76da41..3f89443 100644
--- a/amnesia/src/launcher/Main.cpp
+++ b/amnesia/src/launcher/Main.cpp
@@ -32,9 +32,6 @@
 #include <SDL2/SDL.h>
 #elif defined WIN32
 #include "glut.h"
-#elif defined __linux__
-#include <GL/glx.h>
-#endif
 
 
 using namespace hpl;
@@ -255,7 +252,6 @@ bool LoadLanguage(cEngine* apEngine, const tString& asName, bool abForceReload)
 	return true;
 }
 
-#if USE_SDL2
 #include <SDL2/SDL.h>
 
 tString SDL2GetRenderer() {
@@ -279,81 +275,6 @@ tString SDL2GetRenderer() {
     SDL_DestroyWindow(sdlwin);
     return ret;
 }
-#elif defined __linux__
-tString LinuxGetRenderer() {
-	Display *dpy = XOpenDisplay(NULL);
-	if (!dpy) {
-		fprintf(stderr, "Error: unable to open the display %s\n", XDisplayName(NULL));
-		return "";
-	}
-
-	int attributeSingle[] = {
-		GLX_RGBA,
-		GLX_RED_SIZE, 1,
-		GLX_GREEN_SIZE, 1,
-		GLX_BLUE_SIZE, 1,
-		None };
-	int attributeDouble[] = {
-		GLX_RGBA,
-		GLX_RED_SIZE, 1,
-		GLX_GREEN_SIZE, 1,
-		GLX_BLUE_SIZE, 1,
-		GLX_DOUBLEBUFFER,
-		None };
-
-	XVisualInfo *visinfo;
-	GLXContext ctx = NULL;
-
-	visinfo = glXChooseVisual(dpy,0, attributeSingle);
-	if (!visinfo)
-		visinfo = glXChooseVisual(dpy, 0, attributeDouble);
-
-	if (visinfo)
-		ctx = glXCreateContext(dpy, visinfo, NULL, True);
-
-	if (!visinfo) {
-		fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
-		return "";
-	}
-
-	if (!ctx) {
-		fprintf(stderr, "Error: glXCreateContext failed\n");
-		XFree(visinfo);
-		return "";
-	}
-
-	XSetWindowAttributes attr;
-	unsigned long mask;
-	Window root, win;
-	int width = 100, height = 100;
-
-	root = RootWindow(dpy, 0);
-
-	attr.background_pixel = 0;
-	attr.border_pixel = 0;
-	attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
-	attr.event_mask = StructureNotifyMask | ExposureMask;
-	mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
-	win = XCreateWindow(dpy, root, 0, 0, width, height,
-						0, visinfo->depth, InputOutput,
-						visinfo->visual, mask, &attr);
-
-	tString ret = "";
-	if (glXMakeCurrent(dpy, win, ctx)) {
-		const char *pCardString = (const char *)glGetString(GL_RENDERER);
-		if (pCardString) {
-			ret = tString(pCardString);
-		}
-	}
-
-	glXDestroyContext(dpy, ctx);
-	XFree(visinfo);
-	XDestroyWindow(dpy, win);
-	XCloseDisplay(dpy);
-
-	return ret;
-}
-#endif
 //--------------------------------------------------------------------------------
 
 int hplMain(const tString &asCommandLine)
-- 
2.52.0

