Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More iOS fixes #208

Merged
merged 15 commits into from
Nov 5, 2018
Merged
1 change: 1 addition & 0 deletions FNA.Core.csproj
Expand Up @@ -325,6 +325,7 @@
<Compile Include="src\Utilities\AssemblyHelper.cs" />
<Compile Include="src\Utilities\FileHelpers.cs" />
<Compile Include="src\Utilities\FNAInternalExtensions.cs" />
<Compile Include="src\Utilities\XamarinHelper.cs" />
<Compile Include="src\Vector2.cs" />
<Compile Include="src\Vector3.cs" />
<Compile Include="src\Vector4.cs" />
Expand Down
1 change: 1 addition & 0 deletions FNA.csproj
Expand Up @@ -393,6 +393,7 @@
<Compile Include="src\Utilities\AssemblyHelper.cs" />
<Compile Include="src\Utilities\FileHelpers.cs" />
<Compile Include="src\Utilities\FNAInternalExtensions.cs" />
<Compile Include="src\Utilities\XamarinHelper.cs" />
<Compile Include="src\Vector2.cs" />
<Compile Include="src\Vector3.cs" />
<Compile Include="src\Vector4.cs" />
Expand Down
6 changes: 6 additions & 0 deletions FNA.dll.config
Expand Up @@ -9,4 +9,10 @@
<dllmap dll="SDL2_image" os="osx" target="libSDL2_image-2.0.0.dylib"/>
<dllmap dll="SDL2_image" os="linux,freebsd,netbsd" target="libSDL2_image-2.0.so.0"/>
<dllmap dll="SDL2_image" os="openbsd" target="libSDL2_image.so.0"/>

<dllmap dll="SDL2" os="osx" cpu="armv8" target="__Internal"/>
<dllmap dll="SDL2_image" os="osx" cpu="armv8" target="__Internal"/>
<dllmap dll="mojoshader" os="osx" cpu="armv8" target="__Internal"/>
<dllmap dll="FAudio" os="osx" cpu="armv8" target="__Internal"/>
<dllmap dll="libtheorafile" os="osx" cpu="armv8" target="__Internal"/>
</configuration>
33 changes: 14 additions & 19 deletions src/FNAPlatform/OpenGLDevice.cs
Expand Up @@ -441,8 +441,8 @@ public IGLBackbuffer Backbuffer

private GLenum backbufferScaleMode;

private uint realBackbufferFBO;
private uint realBackbufferRBO;
private uint realBackbufferFBO = 0;
private uint realBackbufferRBO = 0;

#endregion

Expand Down Expand Up @@ -523,6 +523,7 @@ public VertexAttribute()

private bool effectApplied = false;

[ObjCRuntime.MonoPInvokeCallback(typeof(MojoShader.MOJOSHADER_glGetProcAddress))]
private static IntPtr glGetProcAddress(IntPtr name, IntPtr d)
{
return SDL.SDL_GL_GetProcAddress(name);
Expand Down Expand Up @@ -605,23 +606,6 @@ GraphicsAdapter adapter
throw new NotSupportedException("Unrecognized window depth/stencil format!");
}

// UIKit needs special treatment for backbuffer behavior
SDL.SDL_SysWMinfo wmInfo = new SDL.SDL_SysWMinfo();
SDL.SDL_GetWindowWMInfo(
presentationParameters.DeviceWindowHandle,
ref wmInfo
);
if (wmInfo.subsystem == SDL.SDL_SYSWM_TYPE.SDL_SYSWM_UIKIT)
{
realBackbufferFBO = wmInfo.info.uikit.framebuffer;
realBackbufferRBO = wmInfo.info.uikit.colorbuffer;
}
else
{
realBackbufferFBO = 0;
realBackbufferRBO = 0;
}

// Init threaded GL crap where applicable
InitThreadedGL(
presentationParameters.DeviceWindowHandle
Expand Down Expand Up @@ -663,6 +647,17 @@ ref wmInfo
MojoShader.MOJOSHADER_glMakeContextCurrent(shaderContext);
FNALoggerEXT.LogInfo("MojoShader Profile: " + shaderProfile);

// UIKit needs special treatment for backbuffer behavior
if (SDL.SDL_GetPlatform() == "iOS" || SDL.SDL_GetPlatform() == "tvOS")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the wminfo data inaccurate? If possible I'd like to get the GLuint handles from SysWMInfo instead, but if something's not right with it then we can do this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it always returned 0 for both the Framebuffer and Renderbuffer handles, which just put us back where we started.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it’s this part here: https://hg.libsdl.org/SDL/file/80f861112154/src/video/uikit/SDL_uikitwindow.m#l357

Depending on the reason for these results this may be an SDL bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm an idiot, we need to initialize the version info first:

d69709a

The UIKit stuff in master should work now...

{
int fbo, rbo;
glGetIntegerv(GLenum.GL_RENDERBUFFER_BINDING, out fbo);
glGetIntegerv(GLenum.GL_FRAMEBUFFER_BINDING, out rbo);

realBackbufferFBO = (uint)fbo;
realBackbufferRBO = (uint)rbo;
}

// Some users might want pixely upscaling...
backbufferScaleMode = Environment.GetEnvironmentVariable(
"FNA_OPENGL_BACKBUFFER_SCALE_NEAREST"
Expand Down
2 changes: 2 additions & 0 deletions src/FNAPlatform/OpenGLDevice_GL.cs
Expand Up @@ -175,6 +175,8 @@ internal enum GLenum : int
GL_MAX_VERTEX_ATTRIBS = 0x8869,
// Render targets
GL_FRAMEBUFFER = 0x8D40,
GL_FRAMEBUFFER_BINDING = 0x8CA6,
GL_RENDERBUFFER_BINDING = 0x8CA7,
GL_READ_FRAMEBUFFER = 0x8CA8,
GL_DRAW_FRAMEBUFFER = 0x8CA9,
GL_RENDERBUFFER = 0x8D41,
Expand Down
7 changes: 3 additions & 4 deletions src/FrameworkDispatcher.cs
Expand Up @@ -12,7 +12,6 @@

using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;
TheSpydog marked this conversation as resolved.
Show resolved Hide resolved
#endregion

namespace Microsoft.Xna.Framework
Expand Down Expand Up @@ -51,15 +50,15 @@ public static void Update()
}
}

MediaPlayer.Update();
Media.MediaPlayer.Update();
if (ActiveSongChanged)
{
MediaPlayer.OnActiveSongChanged();
Media.MediaPlayer.OnActiveSongChanged();
ActiveSongChanged = false;
}
if (MediaStateChanged)
{
MediaPlayer.OnMediaStateChanged();
Media.MediaPlayer.OnMediaStateChanged();
MediaStateChanged = false;
}

Expand Down
25 changes: 25 additions & 0 deletions src/Utilities/XamarinHelper.cs
@@ -0,0 +1,25 @@
#region License
/* FNA - XNA4 Reimplementation for Desktop Platforms
* Copyright 2009-2018 Ethan Lee and the MonoGame Team
*
* Released under the Microsoft Public License.
* See LICENSE for details.
*/
#endregion

#region Using Statements
using System;
#endregion

// This is a dummy namespace needed for Xamarin iOS/tvOS AOT compilation
namespace ObjCRuntime
{
[AttributeUsage(AttributeTargets.Method)]
class MonoPInvokeCallbackAttribute : Attribute
{
public MonoPInvokeCallbackAttribute(Type t)
{

}
}
}