Add modern GLVND and explicit GLES2 support in GNU/Linux

This commit is contained in:
vanfanel 2023-08-15 12:37:01 +01:00
parent cb2a1eded3
commit 13d1463112
3 changed files with 19 additions and 2 deletions

View file

@ -2,6 +2,7 @@ CC ?= gcc
EMCC ?= emcc
UNAME_S := $(shell uname -s)
RENDERER ?= GL
USE_GLX ?= false
DEBUG ?= false
L_FLAGS ?= -lm -rdynamic
@ -23,6 +24,9 @@ else
$(error Unknown RENDERER)
endif
ifeq ($(GL_VERSION), GLES2)
C_FLAGS := $(C_FLAGS) -DUSE_GLES2
endif
@ -44,7 +48,14 @@ ifeq ($(UNAME_S), Darwin)
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

View file

@ -219,6 +219,12 @@ void platform_set_audio_mix_cb(void (*cb)(float *buffer, uint32_t len)) {
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);
}

View file

@ -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__