Browse Source

Merge SDL 2.0.4

- Revert back commits from PR #191. The media keys support on Linux/x11 platform will be reinvestigated later.
- Add additional include dir for RPI platform. This change is to keep the original SDL/src/video/raspberry/SDL_rpivideo.h header file happy. Previously we were using a slightly altered header file.
- Merge changes from SDL's android-project template.
- Add new source files for Android platform into SDL's CMakeLists.txt. Use new SDL hint to separate mouse and touch events on Android platform. Strangely though a similar hint does not exist on iOS platform, so we retain our local changes to suppress emulated events on iOS platform.
- Adjust OSX and iOS linker flags to include more frameworks.
- Turn ARC on when compiling Objective-C on iOS platform.
- Enable SDL_WINDOW_ALLOW_HIGHDPI on all Apple platforms. Replace all the SDL_WindowGetSize() call with SDL_GL_GetDrawableSize() call in all the graphics backend implementation classes. The former now returns the number in screen coordinates while the latter returns the number in pixels suitable for setting up the glViewport.
- Always use fullscreen mode for iOS platform. Revert back local changes in SDL src/video/uikit/SDL_uikitviewcontroller.m.
Yao Wei Tjong 姚伟忠 10 years ago
parent
commit
5bcd5e4b1d

+ 22 - 10
Android/AndroidManifest.xml

@@ -2,16 +2,29 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.github.urho3d"
     android:versionCode="1"
-    android:versionName="1.0">
-    <uses-permission android:name="android.permission.INTERNET" />
+    android:versionName="1.0"
+    android:installLocation="auto">
+
+    <!-- Android 2.3.3 -->
+    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="12" />
+
+    <!-- OpenGL ES 2.0 -->
     <uses-feature android:glEsVersion="0x00020000" />
-    <uses-sdk android:targetSdkVersion="12" android:minSdkVersion="10" />
-    <application android:label="@string/app_name" android:icon="@drawable/icon">
-        <activity
-            android:name=".SampleLauncher"
-            android:configChanges="keyboardHidden|orientation"
-            android:noHistory="true"
-            android:screenOrientation="portrait">
+
+    <!-- Allow writing to external storage -->
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+    <!-- Allow openning network sockets -->
+    <uses-permission android:name="android.permission.INTERNET" />
+
+    <application android:label="@string/app_name"
+                 android:icon="@drawable/icon"
+                 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+                 android:hardwareAccelerated="true">
+        <activity android:name=".SampleLauncher"
+                  android:configChanges="keyboardHidden|orientation"
+                  android:noHistory="true"
+                  android:screenOrientation="portrait">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
@@ -19,7 +32,6 @@
         </activity>
         <activity android:name=".Urho3D"
                   android:label="@string/app_name"
-                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                   android:configChanges="keyboardHidden|orientation"
                   android:screenOrientation="landscape">
         </activity>

File diff suppressed because it is too large
+ 554 - 84
Android/src/org/libsdl/app/SDLActivity.java


+ 1 - 1
CMake/Modules/FindVideoCore.cmake

@@ -42,7 +42,7 @@ find_library (BCM_VC_LIB_GLES2 GLESv2 PATHS ${BCM_VC_LIB_SEARCH_PATH} PATH_SUFFI
 include (FindPackageHandleStandardArgs)
 find_package_handle_standard_args (VideoCore REQUIRED_VARS BCM_VC_LIB_BCM_HOST BCM_VC_LIB_EGL BCM_VC_LIB_GLES2 VIDEOCORE_INCLUDE_DIRS FAIL_MESSAGE "Could NOT find Broadcom VideoCore firmware")
 if (VIDEOCORE_FOUND)
-    list (APPEND VIDEOCORE_INCLUDE_DIRS ${VIDEOCORE_INCLUDE_DIRS}/interface/vcos/pthreads)  # Note: variable change to list context after this
+    list (APPEND VIDEOCORE_INCLUDE_DIRS ${VIDEOCORE_INCLUDE_DIRS}/interface/vcos/pthreads ${VIDEOCORE_INCLUDE_DIRS}/interface/vmcs_host/linux)  # Note: variable change to list context after this
     set (VIDEOCORE_LIBRARIES ${BCM_VC_LIB_BCM_HOST} ${BCM_VC_LIB_EGL} ${BCM_VC_LIB_GLES2})
 endif ()
 

+ 3 - 2
CMake/Modules/Urho3D-CMake-common.cmake

@@ -54,6 +54,7 @@ if (IOS)
     if (IPHONEOS_DEPLOYMENT_TARGET)
         set (CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${IPHONEOS_DEPLOYMENT_TARGET})
     endif ()
+    set (CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
     if (DEFINED ENV{TRAVIS})
         # TODO: recheck this again later
         # Ensure the CMAKE_OSX_DEPLOYMENT_TARGET is set to empty, something is wrong with Travis-CI OSX worker
@@ -541,7 +542,7 @@ if (APPLE)
         else ()
             set (CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT))
         endif ()
-        set (LINKER_FLAGS "-framework AudioToolbox -framework CoreAudio -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit")  # Need to stringify to keep it as a string instead of as a list
+        set (LINKER_FLAGS "-framework AudioToolbox -framework CoreAudio -framework CoreGraphics -framework CoreMotion -framework Foundation -framework GameController -framework OpenGLES -framework QuartzCore -framework UIKit")  # Need to stringify to keep it as a string instead of as a list
     else ()
         if (XCODE)
             # OSX-specific setup
@@ -555,7 +556,7 @@ if (APPLE)
                 set (CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT))
             endif ()
         endif ()
-        set (LINKER_FLAGS "-framework AudioUnit -framework Carbon -framework Cocoa -framework CoreAudio -framework ForceFeedback -framework IOKit -framework OpenGL -framework CoreServices")
+        set (LINKER_FLAGS "-framework AudioUnit -framework Carbon -framework Cocoa -framework CoreAudio -framework CoreServices -framework CoreVideo -framework ForceFeedback -framework IOKit -framework OpenGL")
     endif ()
     set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
     set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")

+ 1 - 1
Docs/Urho3D.dox

@@ -169,7 +169,7 @@ Urho3D uses the following third-party libraries:
 - rapidjson 0.11 (https://code.google.com/p/rapidjson/)
 - pugixml 1.5 (http://pugixml.org/)
 - Recast/Detour (http://code.google.com/p/recastnavigation/)
-- SDL 2.0.3 (http://www.libsdl.org/)
+- SDL 2.0.4 (http://www.libsdl.org/)
 - StanHull (http://codesuppository.blogspot.com/2006/03/john-ratcliffs-code-suppository-blog.html)
 - stb_image 2.10 (http://nothings.org/)
 - stb_image_write 1.01 (http://nothings.org/)

+ 1 - 1
README.md

@@ -130,7 +130,7 @@ Urho3D uses the following third-party libraries:
 - pugixml 1.5 (http://pugixml.org/)
 - rapidjson 0.11 (https://code.google.com/p/rapidjson/)
 - Recast/Detour (https://github.com/memononen/recastnavigation/)
-- SDL 2.0.3 (http://www.libsdl.org/)
+- SDL 2.0.4 (http://www.libsdl.org/)
 - StanHull (http://codesuppository.blogspot.com/2006/03/
   john-ratcliffs-code-suppository-blog.html)
 - stb_image 2.10 (http://nothings.org/)

+ 5 - 5
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -431,7 +431,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
     if (maximize)
     {
         Maximize();
-        SDL_GetWindowSize(impl_->window_, &width, &height);
+        SDL_GL_GetDrawableSize(impl_->window_, &width, &height);
     }
 
     if (!impl_->device_ || multiSample_ != multiSample)
@@ -620,7 +620,7 @@ bool Graphics::BeginFrame()
     {
         int width, height;
 
-        SDL_GetWindowSize(impl_->window_, &width, &height);
+        SDL_GL_GetDrawableSize(impl_->window_, &width, &height);
         if (width != width_ || height != height_)
             SetMode(width, height);
     }
@@ -1849,7 +1849,7 @@ void Graphics::WindowResized()
 
     int newWidth, newHeight;
 
-    SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
+    SDL_GL_GetDrawableSize(impl_->window_, &newWidth, &newHeight);
     if (newWidth == width_ && newHeight == height_)
         return;
 
@@ -2202,7 +2202,7 @@ void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen,
         if (!newWidth || !newHeight)
         {
             SDL_MaximizeWindow(impl_->window_);
-            SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
+            SDL_GL_GetDrawableSize(impl_->window_, &newWidth, &newHeight);
         }
         else
             SDL_SetWindowSize(impl_->window_, newWidth, newHeight);
@@ -2213,7 +2213,7 @@ void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen,
     else
     {
         // If external window, must ask its dimensions instead of trying to set them
-        SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
+        SDL_GL_GetDrawableSize(impl_->window_, &newWidth, &newHeight);
         newFullscreen = false;
     }
 }

+ 4 - 4
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.h

@@ -249,10 +249,10 @@ public:
     /// Return window position.
     IntVector2 GetWindowPosition() const;
 
-    /// Return window width.
+    /// Return window width in pixels.
     int GetWidth() const { return width_; }
 
-    /// Return window height.
+    /// Return window height in pixels.
     int GetHeight() const { return height_; }
 
     /// Return multisample mode (1 = no multisampling.)
@@ -523,9 +523,9 @@ private:
     Image* windowIcon_;
     /// External window, null if not in use (default.)
     void* externalWindow_;
-    /// Window width.
+    /// Window width in pixels.
     int width_;
-    /// Window height.
+    /// Window height in pixels.
     int height_;
     /// Window position.
     IntVector2 position_;

+ 5 - 5
Source/Urho3D/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -464,7 +464,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
     if (maximize)
     {
         Maximize();
-        SDL_GetWindowSize(impl_->window_, &width, &height);
+        SDL_GL_GetDrawableSize(impl_->window_, &width, &height);
     }
 
     if (fullscreen)
@@ -728,7 +728,7 @@ bool Graphics::BeginFrame()
     {
         int width, height;
 
-        SDL_GetWindowSize(impl_->window_, &width, &height);
+        SDL_GL_GetDrawableSize(impl_->window_, &width, &height);
         if (width != width_ || height != height_)
             SetMode(width, height);
     }
@@ -2048,7 +2048,7 @@ void Graphics::WindowResized()
 
     int newWidth, newHeight;
 
-    SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
+    SDL_GL_GetDrawableSize(impl_->window_, &newWidth, &newHeight);
     if (newWidth == width_ && newHeight == height_)
         return;
 
@@ -2409,7 +2409,7 @@ void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen,
         if (!newWidth || !newHeight)
         {
             SDL_MaximizeWindow(impl_->window_);
-            SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
+            SDL_GL_GetDrawableSize(impl_->window_, &newWidth, &newHeight);
         }
         else
             SDL_SetWindowSize(impl_->window_, newWidth, newHeight);
@@ -2420,7 +2420,7 @@ void Graphics::AdjustWindow(int& newWidth, int& newHeight, bool& newFullscreen,
     else
     {
         // If external window, must ask its dimensions instead of trying to set them
-        SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
+        SDL_GL_GetDrawableSize(impl_->window_, &newWidth, &newHeight);
         newFullscreen = false;
     }
 }

+ 4 - 4
Source/Urho3D/Graphics/Direct3D9/D3D9Graphics.h

@@ -245,10 +245,10 @@ public:
     /// Return window position.
     IntVector2 GetWindowPosition() const;
 
-    /// Return window width.
+    /// Return window width in pixels.
     int GetWidth() const { return width_; }
 
-    /// Return window height.
+    /// Return window height in pixels.
     int GetHeight() const { return height_; }
 
     /// Return multisample mode (1 = no multisampling.)
@@ -523,9 +523,9 @@ private:
     Image* windowIcon_;
     /// External window, null if not in use (default.)
     void* externalWindow_;
-    /// Window width.
+    /// Window width in pixels.
     int width_;
-    /// Window height.
+    /// Window height in pixels.
     int height_;
     /// Window position.
     IntVector2 position_;

+ 12 - 4
Source/Urho3D/Graphics/OpenGL/OGLGraphics.cpp

@@ -326,6 +326,11 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
 
     bool maximize = false;
 
+#if defined(IOS) || defined(TVOS)
+    // iOS and tvOS app always take the fullscreen (and with status bar hidden)
+    fullscreen = true;
+#endif
+
     // Fullscreen or Borderless can not be resizable
     if (fullscreen || borderless)
         resizable = false;
@@ -458,6 +463,9 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
             flags |= SDL_WINDOW_RESIZABLE;
         if (borderless)
             flags |= SDL_WINDOW_BORDERLESS;
+#ifdef __APPLE__
+            flags |= SDL_WINDOW_ALLOW_HIGHDPI;
+#endif
 
         SDL_SetHint(SDL_HINT_ORIENTATIONS, orientations_.CString());
 
@@ -498,7 +506,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
         if (maximize)
         {
             Maximize();
-            SDL_GetWindowSize(impl_->window_, &width, &height);
+            SDL_GL_GetDrawableSize(impl_->window_, &width, &height);
         }
 
         // Create/restore context and GPU objects and set initial renderstate
@@ -524,7 +532,7 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool borderless,
     tripleBuffer_ = tripleBuffer;
     multiSample_ = multiSample;
 
-    SDL_GetWindowSize(impl_->window_, &width_, &height_);
+    SDL_GL_GetDrawableSize(impl_->window_, &width_, &height_);
     if (!fullscreen)
         SDL_GetWindowPosition(impl_->window_, &position_.x_, &position_.y_);
 
@@ -637,7 +645,7 @@ bool Graphics::BeginFrame()
     {
         int width, height;
 
-        SDL_GetWindowSize(impl_->window_, &width, &height);
+        SDL_GL_GetDrawableSize(impl_->window_, &width, &height);
         if (width != width_ || height != height_)
             SetMode(width, height);
     }
@@ -2144,7 +2152,7 @@ void Graphics::WindowResized()
 
     int newWidth, newHeight;
 
-    SDL_GetWindowSize(impl_->window_, &newWidth, &newHeight);
+    SDL_GL_GetDrawableSize(impl_->window_, &newWidth, &newHeight);
     if (newWidth == width_ && newHeight == height_)
         return;
 

+ 4 - 4
Source/Urho3D/Graphics/OpenGL/OGLGraphics.h

@@ -248,10 +248,10 @@ public:
     /// Return window position.
     IntVector2 GetWindowPosition() const;
 
-    /// Return window width.
+    /// Return window width in pixels.
     int GetWidth() const { return width_; }
 
-    /// Return window height.
+    /// Return window height in pixels.
     int GetHeight() const { return height_; }
 
     /// Return multisample mode (1 = no multisampling.)
@@ -555,9 +555,9 @@ private:
     Image* windowIcon_;
     /// External window, null if not in use (default.)
     void* externalWindow_;
-    /// Window width.
+    /// Window width in pixels.
     int width_;
-    /// Window height.
+    /// Window height in pixels.
     int height_;
     /// Window position.
     IntVector2 position_;

+ 8 - 7
Source/Urho3D/Input/Input.cpp

@@ -230,7 +230,9 @@ Input::Input(Context* context) :
 
     SubscribeToEvent(E_SCREENMODE, URHO3D_HANDLER(Input, HandleScreenMode));
 
-#ifdef __EMSCRIPTEN__
+#if defined(ANDROID)
+    SDL_SetHint(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, "1");
+#elif defined(__EMSCRIPTEN__)
     emscriptenInput_ = new EmscriptenInput(this);
 #endif
 
@@ -1393,7 +1395,7 @@ void Input::SetMouseButton(int button, bool newState)
     SendEvent(newState ? E_MOUSEBUTTONDOWN : E_MOUSEBUTTONUP, eventData);
 }
 
-void Input::SetKey(int key, int scancode, unsigned raw, bool newState)
+void Input::SetKey(int key, int scancode, bool newState)
 {
     bool repeat = false;
 
@@ -1423,7 +1425,6 @@ void Input::SetKey(int key, int scancode, unsigned raw, bool newState)
     VariantMap& eventData = GetEventDataMap();
     eventData[P_KEY] = key;
     eventData[P_SCANCODE] = scancode;
-    eventData[P_RAW] = raw;
     eventData[P_BUTTONS] = mouseButtonDown_;
     eventData[P_QUALIFIERS] = GetQualifiers();
     if (newState)
@@ -1491,17 +1492,17 @@ void Input::HandleSDLEvent(void* sdlEvent)
     case SDL_KEYDOWN:
         // Convert to uppercase to match Win32 virtual key codes
 #ifdef __EMSCRIPTEN__
-        SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, 0, true);
+        SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, true);
 #else
-        SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, evt.key.keysym.raw, true);
+        SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, true);
 #endif
         break;
 
     case SDL_KEYUP:
 #ifdef __EMSCRIPTEN__
-        SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, 0, false);
+        SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, false);
 #else
-        SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, evt.key.keysym.raw, false);
+        SetKey(ConvertSDLKeyCode(evt.key.keysym.sym, evt.key.keysym.scancode), evt.key.keysym.scancode, false);
 #endif
         break;
 

+ 1 - 1
Source/Urho3D/Input/Input.h

@@ -321,7 +321,7 @@ private:
     /// Handle a mouse button change.
     void SetMouseButton(int button, bool newState);
     /// Handle a key change.
-    void SetKey(int key, int scancode, unsigned raw, bool newState);
+    void SetKey(int key, int scancode, bool newState);
 #ifdef __EMSCRIPTEN__
     /// Set whether the operating system mouse cursor is visible (Emscripten platform only).
     void SetMouseVisibleEmscripten(bool enable);

+ 0 - 2
Source/Urho3D/Input/InputEvents.h

@@ -72,7 +72,6 @@ URHO3D_EVENT(E_KEYDOWN, KeyDown)
 {
     URHO3D_PARAM(P_KEY, Key);                      // int
     URHO3D_PARAM(P_SCANCODE, Scancode);            // int
-    URHO3D_PARAM(P_RAW, Raw);                      // uint
     URHO3D_PARAM(P_BUTTONS, Buttons);              // int
     URHO3D_PARAM(P_QUALIFIERS, Qualifiers);        // int
     URHO3D_PARAM(P_REPEAT, Repeat);                // bool
@@ -83,7 +82,6 @@ URHO3D_EVENT(E_KEYUP, KeyUp)
 {
     URHO3D_PARAM(P_KEY, Key);                      // int
     URHO3D_PARAM(P_SCANCODE, Scancode);            // int
-    URHO3D_PARAM(P_RAW, Raw);                      // uint
     URHO3D_PARAM(P_BUTTONS, Buttons);              // int
     URHO3D_PARAM(P_QUALIFIERS, Qualifiers);        // int
 }

Some files were not shown because too many files changed in this diff