Browse Source

Added SDL tweaks from 'Mark'

Search '//!\\' tag to find changes.
seyhajin 6 years ago
parent
commit
8d1d4edf53

+ 15 - 4
modules/sdl2/SDL/include/SDL_config.h

@@ -28,21 +28,32 @@
  *  \file SDL_config.h
  *  \file SDL_config.h
  */
  */
 
 
+//!\\ Platforms : 
+//!\\       add(LINUX, RASPBIAN, EMSCRIPTEN), 
+//!\\       remove(WINRT, PSP)
+
 /* Add any platform that doesn't build using the configure system. */
 /* Add any platform that doesn't build using the configure system. */
 #if defined(__WIN32__)
 #if defined(__WIN32__)
 #include "SDL_config_windows.h"
 #include "SDL_config_windows.h"
-#elif defined(__WINRT__)
-#include "SDL_config_winrt.h"
+//#elif defined(__WINRT__)
+//#include "SDL_config_winrt.h"
 #elif defined(__MACOSX__)
 #elif defined(__MACOSX__)
 #include "SDL_config_macosx.h"
 #include "SDL_config_macosx.h"
 #elif defined(__IPHONEOS__)
 #elif defined(__IPHONEOS__)
 #include "SDL_config_iphoneos.h"
 #include "SDL_config_iphoneos.h"
 #elif defined(__ANDROID__)
 #elif defined(__ANDROID__)
 #include "SDL_config_android.h"
 #include "SDL_config_android.h"
-#elif defined(__PSP__)
-#include "SDL_config_psp.h"
+//#elif defined(__PSP__)
+//#include "SDL_config_psp.h"
 #elif defined(__OS2__)
 #elif defined(__OS2__)
 #include "SDL_config_os2.h"
 #include "SDL_config_os2.h"
+#elif defined(__LINUX__)
+#ifdef __arm__
+#include "SDL_config_raspbian.h" //!\\To created
+#else
+#include "SDL_config_linux.h" //!\\To created
+#elif defined(EMSCRIPTEN)
+#include "SDL_config_emscripten.h" //!\\ To created
 #else
 #else
 /* This is a minimal configuration just to get SDL running on new platforms. */
 /* This is a minimal configuration just to get SDL running on new platforms. */
 #include "SDL_config_minimal.h"
 #include "SDL_config_minimal.h"

+ 3 - 3
modules/sdl2/SDL/include/SDL_config_android.h

@@ -154,11 +154,11 @@
 #define SDL_VIDEO_DRIVER_ANDROID 1
 #define SDL_VIDEO_DRIVER_ANDROID 1
 
 
 /* Enable OpenGL ES */
 /* Enable OpenGL ES */
-#define SDL_VIDEO_OPENGL_ES 1
+#define SDL_VIDEO_OPENGL_ES 0 //!\\ from 1 to 0
 #define SDL_VIDEO_OPENGL_ES2 1
 #define SDL_VIDEO_OPENGL_ES2 1
 #define SDL_VIDEO_OPENGL_EGL 1
 #define SDL_VIDEO_OPENGL_EGL 1
-#define SDL_VIDEO_RENDER_OGL_ES 1
-#define SDL_VIDEO_RENDER_OGL_ES2    1
+#define SDL_VIDEO_RENDER_OGL_ES 0 //!\\ from 1 to 0
+#define SDL_VIDEO_RENDER_OGL_ES2    0 //!\\ from 1 to 0
 
 
 /* Enable Vulkan support */
 /* Enable Vulkan support */
 /* Android does not support Vulkan in native code using the "armeabi" ABI. */
 /* Android does not support Vulkan in native code using the "armeabi" ABI. */

+ 8 - 8
modules/sdl2/SDL/include/SDL_config_windows.h

@@ -184,16 +184,16 @@ typedef unsigned int uintptr_t;
 #endif
 #endif
 
 
 /* Enable various audio drivers */
 /* Enable various audio drivers */
-#define SDL_AUDIO_DRIVER_WASAPI 1
+#define SDL_AUDIO_DRIVER_WASAPI 0 //!\\ sey was here! (from 1 to 0)
 #define SDL_AUDIO_DRIVER_DSOUND 1
 #define SDL_AUDIO_DRIVER_DSOUND 1
-#define SDL_AUDIO_DRIVER_WINMM  1
-#define SDL_AUDIO_DRIVER_DISK   1
+#define SDL_AUDIO_DRIVER_WINMM  0 //!\\ sey was here! (from 1 to 0)
+#define SDL_AUDIO_DRIVER_DISK   0 //!\\ sey was here! (from 1 to 0)
 #define SDL_AUDIO_DRIVER_DUMMY  1
 #define SDL_AUDIO_DRIVER_DUMMY  1
 
 
 /* Enable various input drivers */
 /* Enable various input drivers */
 #define SDL_JOYSTICK_DINPUT 1
 #define SDL_JOYSTICK_DINPUT 1
 #define SDL_JOYSTICK_XINPUT 1
 #define SDL_JOYSTICK_XINPUT 1
-#define SDL_JOYSTICK_HIDAPI 1
+#define SDL_JOYSTICK_HIDAPI 0 //!\\ sey was here! (from 1 to 0)
 #define SDL_HAPTIC_DINPUT   1
 #define SDL_HAPTIC_DINPUT   1
 #define SDL_HAPTIC_XINPUT   1
 #define SDL_HAPTIC_XINPUT   1
 
 
@@ -210,11 +210,11 @@ typedef unsigned int uintptr_t;
 #define SDL_TIMER_WINDOWS   1
 #define SDL_TIMER_WINDOWS   1
 
 
 /* Enable various video drivers */
 /* Enable various video drivers */
-#define SDL_VIDEO_DRIVER_DUMMY  1
+#define SDL_VIDEO_DRIVER_DUMMY  0 //!\\ sey was here! (from 1 to 0)
 #define SDL_VIDEO_DRIVER_WINDOWS    1
 #define SDL_VIDEO_DRIVER_WINDOWS    1
 
 
 #ifndef SDL_VIDEO_RENDER_D3D
 #ifndef SDL_VIDEO_RENDER_D3D
-#define SDL_VIDEO_RENDER_D3D    1
+#define SDL_VIDEO_RENDER_D3D    0 //!\\ sey was here! (from 1 to 0)
 #endif
 #endif
 #ifndef SDL_VIDEO_RENDER_D3D11
 #ifndef SDL_VIDEO_RENDER_D3D11
 #define SDL_VIDEO_RENDER_D3D11  0
 #define SDL_VIDEO_RENDER_D3D11  0
@@ -228,10 +228,10 @@ typedef unsigned int uintptr_t;
 #define SDL_VIDEO_OPENGL_WGL    1
 #define SDL_VIDEO_OPENGL_WGL    1
 #endif
 #endif
 #ifndef SDL_VIDEO_RENDER_OGL
 #ifndef SDL_VIDEO_RENDER_OGL
-#define SDL_VIDEO_RENDER_OGL    1
+#define SDL_VIDEO_RENDER_OGL    0 //!\\ sey was here! (from 1 to 0)
 #endif
 #endif
 #ifndef SDL_VIDEO_RENDER_OGL_ES2
 #ifndef SDL_VIDEO_RENDER_OGL_ES2
-#define SDL_VIDEO_RENDER_OGL_ES2    1
+#define SDL_VIDEO_RENDER_OGL_ES2    0 //!\\ sey was here! (from 1 to 0)
 #endif
 #endif
 #ifndef SDL_VIDEO_OPENGL_ES2
 #ifndef SDL_VIDEO_OPENGL_ES2
 #define SDL_VIDEO_OPENGL_ES2    1
 #define SDL_VIDEO_OPENGL_ES2    1

+ 3 - 1
modules/sdl2/SDL/include/SDL_egl.h

@@ -24,7 +24,9 @@
  *
  *
  *  This is a simple file to encapsulate the EGL API headers.
  *  This is a simple file to encapsulate the EGL API headers.
  */
  */
-#if !defined(_MSC_VER) && !defined(__ANDROID__)
+//!\\ Mark was here! #ifndef _MSC_VER, but we don't want mingw to be dependant on egl.h
+//#if !defined(_MSC_VER) && !defined(__ANDROID__)
+#ifndef _WIN32
 
 
 #include <EGL/egl.h>
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
 #include <EGL/eglext.h>

+ 3 - 0
modules/sdl2/SDL/include/begin_code.h

@@ -33,6 +33,9 @@
 #endif
 #endif
 #define _begin_code_h
 #define _begin_code_h
 
 
+//!\\ Mark was here! Prevents SDL generating dll funcs.
+#define DECLSPEC
+
 #ifndef SDL_DEPRECATED
 #ifndef SDL_DEPRECATED
 #  if (__GNUC__ >= 4)  /* technically, this arrived in gcc 3.1, but oh well. */
 #  if (__GNUC__ >= 4)  /* technically, this arrived in gcc 3.1, but oh well. */
 #    define SDL_DEPRECATED __attribute__((deprecated))
 #    define SDL_DEPRECATED __attribute__((deprecated))

+ 27 - 0
modules/sdl2/SDL/src/core/android/SDL_android.c

@@ -1411,6 +1411,33 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
     return SDL_FALSE;
     return SDL_FALSE;
 }
 }
 
 
+//!\\ Mark was here! Added 'Android_JNI_GetAssetManager' function
+AAssetManager *Android_JNI_GetAssetManager(){
+
+    static AAssetManager *assetManager;
+    
+    if( assetManager ) return assetManager;
+
+    JNIEnv *mEnv = Android_JNI_GetEnv();
+    
+    /* context = SDLActivity.getContext(); */
+    jmethodID mid = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
+            "getContext","()Landroid/content/Context;");
+    jobject context = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, mid);
+
+
+    /* assetManager = context.getAssets(); */
+    mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context),
+            "getAssets", "()Landroid/content/res/AssetManager;");
+    jobject jassetManager = (*mEnv)->CallObjectMethod(mEnv, context, mid);
+    
+    jassetManager=(*mEnv)->NewGlobalRef(mEnv, jassetManager);
+    
+    assetManager=AAssetManager_fromJava( mEnv,jassetManager );
+    
+    return assetManager;
+}
+
 static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
 static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx)
 {
 {
     struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
     struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);

+ 3 - 0
modules/sdl2/SDL/src/core/android/SDL_android.h

@@ -30,6 +30,7 @@ extern "C" {
 
 
 #include <EGL/eglplatform.h>
 #include <EGL/eglplatform.h>
 #include <android/native_window_jni.h>
 #include <android/native_window_jni.h>
+#include <android/asset_manager.h> //!\\ Mark was here
 
 
 #include "SDL_audio.h"
 #include "SDL_audio.h"
 #include "SDL_rect.h"
 #include "SDL_rect.h"
@@ -100,6 +101,8 @@ int Android_JNI_GetTouchDeviceIds(int **ids);
 JNIEnv *Android_JNI_GetEnv(void);
 JNIEnv *Android_JNI_GetEnv(void);
 int Android_JNI_SetupThread(void);
 int Android_JNI_SetupThread(void);
 
 
+AAssetManager* Android_JNI_GetAssetManager(void); //!\\ Mark was here!
+
 /* Generic messages */
 /* Generic messages */
 int Android_JNI_SendMessage(int command, int param);
 int Android_JNI_SendMessage(int command, int param);
 
 

+ 3 - 2
modules/sdl2/SDL/src/dynapi/SDL_dynapi_procs.h

@@ -65,8 +65,9 @@ SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFP,(void *a, SDL_bool b),(a,b),return)
 #ifdef __WIN32__
 #ifdef __WIN32__
 SDL_DYNAPI_PROC(int,SDL_RegisterApp,(char *a, Uint32 b, void *c),(a,b,c),return)
 SDL_DYNAPI_PROC(int,SDL_RegisterApp,(char *a, Uint32 b, void *c),(a,b,c),return)
 SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),)
 SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),)
-SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(int a),(a),return)
-SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_RenderGetD3D9Device,(SDL_Renderer *a),(a),return)
+//!\\ ***** Mark was here! ***** 'Commented next two lines
+//SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(int a),(a),return)
+//SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_RenderGetD3D9Device,(SDL_Renderer *a),(a),return)
 #endif
 #endif
 
 
 #ifdef __IPHONEOS__
 #ifdef __IPHONEOS__

+ 18 - 1
modules/sdl2/SDL/src/events/SDL_events.c

@@ -33,6 +33,12 @@
 #include "../video/SDL_sysvideo.h"
 #include "../video/SDL_sysvideo.h"
 #include "SDL_syswm.h"
 #include "SDL_syswm.h"
 
 
+//!\\ ***** Mark was here! *****
+#include <stdio.h>
+#include <SDL_mutex.h>
+static SDL_sem *sem;
+//!\\
+
 /*#define SDL_DEBUG_EVENTS 1*/
 /*#define SDL_DEBUG_EVENTS 1*/
 
 
 /* An arbitrary limit so we don't have unbounded growth */
 /* An arbitrary limit so we don't have unbounded growth */
@@ -530,7 +536,14 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
             for (i = 0; i < numevents; ++i) {
             for (i = 0; i < numevents; ++i) {
                 used += SDL_AddEvent(&events[i]);
                 used += SDL_AddEvent(&events[i]);
             }
             }
+
+            //!\\ ***** Mark was here! *****
+            if( sem ) SDL_SemPost( sem );
         } else {
         } else {
+
+            //!\\ ***** Mark was here! *****
+            if( sem ) while( SDL_SemValue( sem ) ) SDL_SemWait( sem );
+
             SDL_EventEntry *entry, *next;
             SDL_EventEntry *entry, *next;
             SDL_SysWMEntry *wmmsg, *wmmsg_next;
             SDL_SysWMEntry *wmmsg, *wmmsg_next;
             Uint32 type;
             Uint32 type;
@@ -705,7 +718,11 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
                 /* Timeout expired and no events */
                 /* Timeout expired and no events */
                 return 0;
                 return 0;
             }
             }
-            SDL_Delay(10);
+
+            //!\\ ***** Mark was here! *****
+            if( !sem ) sem=SDL_CreateSemaphore(0);
+            SDL_SemWaitTimeout( sem,10 );
+//          SDL_Delay(10);
             break;
             break;
         default:
         default:
             /* Has events */
             /* Has events */

+ 4 - 0
modules/sdl2/SDL/src/video/cocoa/SDL_cocoaopengl.m

@@ -416,6 +416,10 @@ Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
        threads try to swap at the same time, so put a mutex around it. */
        threads try to swap at the same time, so put a mutex around it. */
     SDL_LockMutex(videodata->swaplock);
     SDL_LockMutex(videodata->swaplock);
     [nscontext flushBuffer];
     [nscontext flushBuffer];
+
+    //!\\ ***** Mark was here! *****
+    //!\\ Fix for Mojave, which wasn't rendering until window moved.
+    //!\\ [nscontext update];//IfNeeded]; <--- Mark fix with this line
     [nscontext updateIfNeeded];
     [nscontext updateIfNeeded];
     SDL_UnlockMutex(videodata->swaplock);
     SDL_UnlockMutex(videodata->swaplock);
     return 0;
     return 0;

+ 1 - 0
modules/sdl2/SDL/src/video/uikit/SDL_uikitopengles.m

@@ -170,6 +170,7 @@ UIKit_GL_CreateContext(_THIS, SDL_Window * window)
              * dimensions of the screen rather than the dimensions in points. */
              * dimensions of the screen rather than the dimensions in points. */
 #ifdef __IPHONE_8_0
 #ifdef __IPHONE_8_0
             if ([data.uiwindow.screen respondsToSelector:@selector(nativeScale)]) {
             if ([data.uiwindow.screen respondsToSelector:@selector(nativeScale)]) {
+                //!\\ Mark was here! Always use screen.scale, ignore screen.nativeScale...TO TESTED with 2.0.9 else change to 'scale = data.uiwindow.screen.scale;'
                 scale = data.uiwindow.screen.nativeScale;
                 scale = data.uiwindow.screen.nativeScale;
             } else
             } else
 #endif
 #endif

+ 2 - 0
modules/sdl2/SDL/src/video/windows/SDL_windowsopengl.c

@@ -452,6 +452,8 @@ WIN_GL_InitExtensions(_THIS)
 
 
     /* Check for WGL_EXT_create_context_es2_profile */
     /* Check for WGL_EXT_create_context_es2_profile */
     if (HasExtension("WGL_EXT_create_context_es2_profile", extensions)) {
     if (HasExtension("WGL_EXT_create_context_es2_profile", extensions)) {
+        //!\\ ***** Mark was here! ***** TO TEST with 2.0.9
+        //_this->gl_data->HAS_WGL_EXT_create_context_es2_profile = SDL_TRUE;
         SDL_GL_DeduceMaxSupportedESProfile(
         SDL_GL_DeduceMaxSupportedESProfile(
             &_this->gl_data->es_profile_max_supported_version.major,
             &_this->gl_data->es_profile_max_supported_version.major,
             &_this->gl_data->es_profile_max_supported_version.minor
             &_this->gl_data->es_profile_max_supported_version.minor