shithub: wipeout

Download patch

ref: 13d1463112e7088e4d289d536d913c48b3962ab9
parent: cb2a1eded3f7048f05615b0981b8eb17d7ed23e4
author: vanfanel <redwindwanderer@gmail.com>
date: Tue Aug 15 08:37:01 EDT 2023

Add modern GLVND and explicit GLES2 support in GNU/Linux

--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@
 EMCC ?= emcc
 UNAME_S := $(shell uname -s)
 RENDERER ?= GL
+USE_GLX ?= false
 DEBUG ?= false
 
 L_FLAGS ?= -lm -rdynamic
@@ -23,6 +24,9 @@
 $(error Unknown RENDERER)
 endif
 
+ifeq ($(GL_VERSION), GLES2)
+	C_FLAGS := $(C_FLAGS) -DUSE_GLES2
+endif
 
 
 
@@ -44,7 +48,14 @@
 
 else ifeq ($(UNAME_S), Linux)
 	ifeq ($(RENDERER), GL)
-		L_FLAGS := $(L_FLAGS) -lGLEW -lGL
+		L_FLAGS := $(L_FLAGS) -lGLEW
+
+		# Prefer modern GLVND instead of legacy X11-only GLX
+		ifeq ($(USE_GLX), true)
+			L_FLAGS := $(L_FLAGS) -lGL
+		else
+			L_FLAGS := $(L_FLAGS) -lOpenGL
+		endif
 	endif
 
 	L_FLAGS_SDL = -lSDL2
--- a/src/platform_sdl.c
+++ b/src/platform_sdl.c
@@ -219,6 +219,12 @@
 	SDL_GLContext platform_gl;
 
 	void platform_video_init() {
+                #if defined(USE_GLES2)
+                SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
+                SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
+                SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
+                #endif
+
 		platform_gl = SDL_GL_CreateContext(window);
 		SDL_GL_SetSwapInterval(1);
 	}
--- a/src/render_gl.c
+++ b/src/render_gl.c
@@ -55,7 +55,7 @@
 #define TEXTURES_MAX 1024
 
 
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__) || defined(USE_GLES2)
 	// WebGL (GLES) needs the `precision` to be set, wheras OpenGL 2 
 	// doesn't like that...
 	#define SHADER_SOURCE(...) "precision highp float;" #__VA_ARGS__