SDL: Fixed build errors when OpenGL isn't enabled

From d3bcc3f0577ce82b4ed620769b493890ca9737ec Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 5 Aug 2023 00:25:12 -0700
Subject: [PATCH] Fixed build errors when OpenGL isn't enabled

---
 src/core/android/SDL_android.c |  3 +--
 src/video/haiku/SDL_BWin.h     | 14 ++++++++++----
 src/video/x11/SDL_x11window.c  |  2 +-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 28a9b047357a..6b3e029f95be 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -1151,7 +1151,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(JNIEnv *env,
     SDL_LockMutex(Android_ActivityMutex);
 
     if (Android_Window) {
-        SDL_VideoDevice *_this = SDL_GetVideoDevice();
         SDL_WindowData *data = Android_Window->driverdata;
 
         /* Wait for Main thread being paused and context un-activated to release 'egl_surface' */
@@ -1168,7 +1167,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(JNIEnv *env,
 
 #ifdef SDL_VIDEO_OPENGL_EGL
         if (data->egl_surface != EGL_NO_SURFACE) {
-            SDL_EGL_DestroySurface(_this, data->egl_surface);
+            SDL_EGL_DestroySurface(SDL_GetVideoDevice(), data->egl_surface);
             data->egl_surface = EGL_NO_SURFACE;
         }
 #endif
diff --git a/src/video/haiku/SDL_BWin.h b/src/video/haiku/SDL_BWin.h
index 9ca1b5da5af5..e053f483c3b7 100644
--- a/src/video/haiku/SDL_BWin.h
+++ b/src/video/haiku/SDL_BWin.h
@@ -155,9 +155,12 @@ class SDL_BWin : public BWindow
 
     void UpdateCurrentView()
     {
+#ifdef SDL_VIDEO_OPENGL
         if (_SDL_GLView != NULL) {
             SetCurrentView(_SDL_GLView);
-        } else if (_SDL_View != NULL) {
+        } else
+#endif
+        if (_SDL_View != NULL) {
             SetCurrentView(_SDL_View);
         } else {
             SetCurrentView(NULL);
@@ -454,10 +457,13 @@ class SDL_BWin : public BWindow
                 delete pendingMessage;
             }
             if (_bitmap != NULL) {
-                if (_SDL_View != NULL && _cur_view == _SDL_View)
-                    _SDL_View->Draw(Bounds());
-                else if (_SDL_GLView != NULL && _cur_view == _SDL_GLView) {
+#ifdef SDL_VIDEO_OPENGL
+                if (_SDL_GLView != NULL && _cur_view == _SDL_GLView) {
                     _SDL_GLView->CopyPixelsIn(_bitmap, B_ORIGIN);
+                } else
+#endif
+                if (_SDL_View != NULL && _cur_view == _SDL_View) {
+                    _SDL_View->Draw(Bounds());
                 }
             }
             break;
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index e7d04a8ccb89..2eb231bced7e 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -423,7 +423,6 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
     SDL_WindowData *windowdata;
     Display *display = data->display;
     int screen = displaydata->screen;
-    const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE;
     Visual *visual;
     int depth;
     XSetWindowAttributes xattr;
@@ -443,6 +442,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
     SDL_bool undefined_position = SDL_FALSE;
 
 #if defined(SDL_VIDEO_OPENGL_GLX) || defined(SDL_VIDEO_OPENGL_EGL)
+    const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE;
     const char *forced_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_WINDOW_VISUALID);
 
     if (forced_visual_id != NULL && forced_visual_id[0] != '\0') {