Commit e213f37a450ca6b0746aa3acd2e5e76635e13468

vanfanel 2021-03-15T12:53:16

[KMSDRM] Enable full OpenGL detection (MESA/libglvnd) on both the make and cmake buildsystems.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d4b9f2..4fef447 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1197,6 +1197,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS)
     # Need to check EGL before checking KMSDRM because KMSDRM depends on it.
     CheckEGLKMSDRM()
     CheckKMSDRM()
+    CheckOpenGLKMSDRM()
   endif()
 
   if(UNIX)
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index 364cdb3..64089c6 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -778,6 +778,22 @@ macro(CheckVivante)
 endmacro(CheckVivante)
 
 # Requires:
+# - libglvnd
+macro(CheckOpenGLKMSDRM)
+  if(VIDEO_OPENGL AND HAVE_VIDEO_KMSDRM)
+    check_c_source_compiles("
+        #include <GL/gl.h>
+        int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL)
+
+    if(HAVE_VIDEO_OPENGL)
+      set(HAVE_VIDEO_OPENGL TRUE)
+      set(SDL_VIDEO_OPENGL 1)
+      set(SDL_VIDEO_RENDER_OGL 1)
+    endif()
+  endif()
+endmacro()
+
+# Requires:
 # - nada
 macro(CheckOpenGLX11)
   if(VIDEO_OPENGL)
diff --git a/configure.ac b/configure.ac
index 30d17a1..4d0a980 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2384,6 +2384,27 @@ CheckOpenGLX11()
     fi
 }
 
+dnl Find KMSDRM OpenGL (GLVND)
+CheckOpenGLKMSDRM()
+{
+    if test x$enable_video = xyes -a x$enable_video_opengl = xyes -a x$enable_video_kmsdrm = xyes; then
+        AC_MSG_CHECKING(for OpenGL (GLVND) support)
+        video_opengl=no
+        AC_TRY_COMPILE([
+         #include <GL/gl.h>
+        ],[  
+        ],[  
+        video_opengl=yes
+        ])   
+        AC_MSG_RESULT($video_opengl)
+        if test x$video_opengl = xyes; then 
+            AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ]) 
+            AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ]) 
+            SUMMARY_video="${SUMMARY_video} opengl"
+        fi   
+    fi   
+}
+
 dnl Check to see if OpenGL ES support is desired
 AC_ARG_ENABLE(video-opengles,
 [AS_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [default=yes]])],
@@ -3656,6 +3677,7 @@ case "$host" in
         # Need to check for EGL first because KMSDRM depends on it.
         CheckEGLKMSDRM
         CheckKMSDRM
+        CheckOpenGLKMSDRM
         CheckOpenGLX11
         CheckOpenGLESX11
         CheckVulkan