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

Feature request: xboxone uwp target #457

Open
madrazo opened this issue Mar 3, 2017 · 30 comments
Open

Feature request: xboxone uwp target #457

madrazo opened this issue Mar 3, 2017 · 30 comments
Assignees

Comments

@madrazo
Copy link
Contributor

madrazo commented Mar 3, 2017

http://www.gamespot.com/articles/xbox-one-may-soon-see-a-flood-of-new-games/1100-6448335/
https://docs.microsoft.com/en-us/windows/uwp/xbox-apps/
https://developer.microsoft.com/en-us/games/xbox/xboxlive/creator

I'm sure that this can be done since hxcpp supports it.
This is kind of low priority for us now but we are willing to help if someone is interested.

@madrazo
Copy link
Contributor Author

madrazo commented Mar 22, 2017

I was trying to run NME with Angle. I almost got it but I'm not sure why it couldnt compile the shaders. I tried the Google version, so I may give a shot to the Microsoft version instead.

for reference, I added some lines to ToolkitBuild (toolkit has support for angle)

   <set name="NATIVE_TOOLKIT_SDL_ANGLE" value="1" if="NME_SDL_ANGLE" />

    <section if="windows">
          <compilerflag value="-DNATIVE_TOOLKIT_SDL_ANGLE" if="NATIVE_TOOLKIT_SDL_ANGLE" />
          <compilerflag value="-DNME_SDL_ANGLE" if="NME_SDL_ANGLE" />
          <compilerflag value="-DANGLE_ENABLE_DEBUG_TRACE" if="NME_SDL_ANGLE" />
          <compilerflag value="-I${NME_ROOT}include/angle" if="NME_SDL_ANGLE"/>
...
            <lib name="libEGL.lib" if="NME_SDL_ANGLE"/>
            <lib name="libGLESv2.lib" if="NME_SDL_ANGLE"/>
            <lib name="preprocessor.lib" if="NME_SDL_ANGLE"/>
            <lib name="translator.lib" if="NME_SDL_ANGLE"/>

In OGL.h

#ifdef NME_SDL_ANGLE

   #define NME_GLES
   #define GL_GLEXT_PROTOTYPES
   #include <windows.h>
   #include <angle_gl.h>
   #define GL_BGRA GL_BGRA_EXT
   #define FORCE_NON_PO2

#elif ...

one more thing. In SDL2Stage.cpp, in InitSDL(), after SDL_Init() add this to select the opengl version to use.

int err = SDL_Init(SDL_INIT_VIDEO | audioFlag | SDL_INIT_TIMER);

#ifdef NATIVE_TOOLKIT_SDL_ANGLE
   //GLES 2.0
   //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
   //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

   //GLES 3.1
   SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
   SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);

   SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
      SDL_GL_CONTEXT_PROFILE_ES);
#endif

@hughsando
Copy link
Member

This looks like a pretty worthwhile project.
Not sure about the shaders - may have to do some research.
There is the "precision mediump float" stuff we add for GLES. Maybe this is not required, or is required and not getting added.

@madrazo
Copy link
Contributor Author

madrazo commented Mar 29, 2017

I'm missing in SDL2Stage.cpp
SDL_SetHint (SDL_HINT_VIDEO_WIN_D3DCOMPILER, "d3dcompiler_47.dll");

and add d3dcompiler_47.dll

Edit: Still not working but found this to show the OutputDebugString's https://technet.microsoft.com/en-us/sysinternals/bb896647.aspx

@madrazo
Copy link
Contributor Author

madrazo commented Apr 28, 2017

Tried NME_ANGLE on Windows 10 with the nme-toolkit 6.1.0, Visual Studio 2015 update 3, Windows SDK 10.0.14393.33,
and got the following errors

D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(87): error C2787: 'IDCompositionDevice': no GUID has been associated with this object
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(88): error C2198: 'PFN_DCOMPOSITION_CREATE_DEVICE': too few arguments for call
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(100): error C2027: use of undefined type 'IDCompositionDevice'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src\libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h(14): note: see declaration of 'IDCompositionDevice'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(100): error C2227: left of '->CreateTargetForHwnd' must point to class/struct/union/generic type
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(109): error C2027: use of undefined type 'IDCompositionDevice'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src\libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h(14): note: see declaration of 'IDCompositionDevice'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(109): error C2227: left of '->CreateVisual' must point to class/struct/union/generic type
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(139): error C2027: use of undefined type 'IDCompositionVisual'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src\libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h(16): note: see declaration of 'IDCompositionVisual'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(139): error C2227: left of '->SetContent' must point to class/struct/union/generic type
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(140): error C2027: use of undefined type 'IDCompositionTarget'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src\libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h(15): note: see declaration of 'IDCompositionTarget'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(140): error C2227: left of '->SetRoot' must point to class/struct/union/generic type
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(206): error C2027: use of undefined type 'IDCompositionDevice'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src\libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.h(14): note: see declaration of 'IDCompositionDevice'
D:/haxe/lib/nme-toolkit/6,1,0/angle/src/libANGLE/renderer/d3d/d3d11/win32/NativeWindow11Win32.cpp(206): error C2227: left of '->Commit' must point to class/struct/union/generic type

@hughsando
Copy link
Member

hughsando commented Apr 28, 2017 via email

@madrazo
Copy link
Contributor Author

madrazo commented Apr 28, 2017

Maybe I need to add the lib path directory? In my case it seems to be C:\Program Files (x86)\Windows Kits\10\Lib\10.0.14393.0\um\x86

I can build libAngle on Visual Studio project. For reference, it uses the following compile options

Debug:

/GS /analyze- /W4 /wd"4100" /wd"4127" /wd"4718" /wd"4251" /Gy /Zc:wchar_t /I"." /I"..\include" /I"third_party\khronos" /I"D:\angle\src\Debug_Win32\obj\global_intermediate\angle" /I"..\src" /I"..\src\common\third_party\numerics" /I"..\third_party\glslang-angle\src\glslang\Public" /I"..\third_party\glslang-angle\src" /I"..\third_party\vulkan-validation-layers\src\include" /I"..\third_party\vulkan-validation-layers\src\loader" /Zi /Gm- /Od /Fd"D:\angle\src\Debug_Win32\obj\libANGLE\libANGLE.pdb" /Zc:inline /fp:precise /D "_CRT_SECURE_NO_DEPRECATE" /D "_SCL_SECURE_NO_WARNINGS" /D "_HAS_EXCEPTIONS=0" /D "NOMINMAX" /D "LIBANGLE_IMPLEMENTATION" /D "ANGLE_STANDALONE_BUILD" /D "ANGLE_ENABLE_ESSL" /D "ANGLE_ENABLE_GLSL" /D "ANGLE_ENABLE_HLSL" /D "ANGLE_ENABLE_VULKAN" /D "ANGLE_ENABLE_D3D11" /D "ANGLE_ENABLE_D3D9" /D "ANGLE_ENABLE_OPENGL" /D "ANGLE_ENABLE_NULL" /D "VK_USE_PLATFORM_WIN32_KHR" /D "_DEBUG" /D "ANGLE_ENABLE_DEBUG_ANNOTATIONS" /D "_MBCS" /errorReport:prompt /WX /Zc:forScope /RTC1 /GR /Gd /Oy- /MTd /Fa"D:\angle\src\Debug_Win32\obj\libANGLE" /nologo /Fo"D:\angle\src\Debug_Win32\obj\libANGLE" /Fp"D:\angle\src\Debug_Win32\obj\libANGLE\libANGLE.pch"

Release:

/GS /analyze- /W4 /wd"4100" /wd"4127" /wd"4718" /wd"4251" /Gy /Zc:wchar_t /I"." /I"..\include" /I"third_party\khronos" /I"D:\angle\src\Release_Win32\obj\global_intermediate\angle" /I"..\src" /I"..\src\common\third_party\numerics" /I"..\third_party\glslang-angle\src\glslang\Public" /I"..\third_party\glslang-angle\src" /I"..\third_party\vulkan-validation-layers\src\include" /I"..\third_party\vulkan-validation-layers\src\loader" /Zi /Gm- /O2 /Fd"D:\angle\src\Release_Win32\obj\libANGLE\libANGLE.pdb" /Zc:inline /fp:precise /D "_CRT_SECURE_NO_DEPRECATE" /D "_SCL_SECURE_NO_WARNINGS" /D "_HAS_EXCEPTIONS=0" /D "NOMINMAX" /D "LIBANGLE_IMPLEMENTATION" /D "ANGLE_STANDALONE_BUILD" /D "ANGLE_ENABLE_ESSL" /D "ANGLE_ENABLE_GLSL" /D "ANGLE_ENABLE_HLSL" /D "ANGLE_ENABLE_VULKAN" /D "ANGLE_ENABLE_D3D11" /D "ANGLE_ENABLE_D3D9" /D "ANGLE_ENABLE_OPENGL" /D "ANGLE_ENABLE_NULL" /D "VK_USE_PLATFORM_WIN32_KHR" /D "NDEBUG" /D "_MBCS" /errorReport:prompt /WX /Zc:forScope /GR- /Gd /Oy- /MT /Fa"D:\angle\src\Release_Win32\obj\libANGLE" /nologo /Fo"D:\angle\src\Release_Win32\obj\libANGLE" /Fp"D:\angle\src\Release_Win32\obj\libANGLE\libANGLE.pch"

@madrazo
Copy link
Contributor Author

madrazo commented May 12, 2017

Sorry, finally got it working. I had the following extra define flags on my msvc-toolchain.xml

   <flag value="-DWINVER=0x0601"/>
   <flag value="-D_WIN32_WINNT=0x0601"/>

(reference: https://msdn.microsoft.com/en-us/library/6sehtctf.aspx)
which we use on xaudio and xinput extensions to use the Windows7+ versions.

@madrazo
Copy link
Contributor Author

madrazo commented Jun 3, 2017

It's compiling now for winrt. I'm checking https://docs.microsoft.com/en-us/windows/uwp/xbox-apps/automate-launching-uwp-apps for launching the app

@hughsando
Copy link
Member

This is good stuff. I have to get my windows system up and working with VS 2017 and getting UWP going at the same time seems like a good idea.

@madrazo
Copy link
Contributor Author

madrazo commented Jun 6, 2017

I'm still using 2015

@madrazo
Copy link
Contributor Author

madrazo commented Jun 8, 2017

@hughsando I'mworking on this branch https://github.com/madrazo/nme/tree/winrt_tools. Added the winrt target which sets some defines such as NME_ANGLE and static_link automatically. Also added a templates/winrt/static/Main.cpp for a custom winrt Main. SDL says to call SDL_WinRTRunApp but it has a C++ main as a parameter. When linking, it can't be found since It has s static linking.

https://github.com/madrazo/nme/blob/winrt_tools/templates/winrt/static/Main.cpp#L101

Please let me know if you have an idea on how to fix this Main.

Compile DisplayingABitmap with nme winrt

Manually copy templates/winrt/Appx in the exe directory and follow these Instructions for registering an running it from command line in https://github.com/madrazo/nme/blob/winrt_tools/tools/nme/src/platforms/WindowsPlatform.hx#L112

Thanks

@madrazo
Copy link
Contributor Author

madrazo commented Jun 8, 2017

@hughsando sorry. Got it working
displayingabitmap

@hughsando
Copy link
Member

Nice!

@madrazo
Copy link
Contributor Author

madrazo commented Jun 13, 2017

Most of the samples are working on winrt (still no font and sound available).
HerokuShaders compiles and runs now but the shaders are not compiling. It seems that it does not work with NME_ANGLE, also with the windows version.

There was this issue on OpenFL a while ago http://community.openfl.org/t/how-to-use-angle-library-on-old-machines/1158/9

I'm not sure if we need to include the DLLs.
https://github.com/openfl/lime/tree/develop/dependencies/angle

I have tried some things without luck. I tried with the ms version as well (https://github.com/madrazo/angle-ms)

EDIT: including the DLLs (libGLESv2.dll) would need DYNAMIC_OGL
http://community.openfl.org/t/how-to-use-angle-library-on-old-machines/1158/20

https://github.com/openfl/lime/blob/a7bf8bfb35aa0a94c1c6b72f886cb1824ec89345/project/src/graphics/opengl/OpenGL.h#L66
right?

@madrazo
Copy link
Contributor Author

madrazo commented Jun 14, 2017

Actually, it seems to be only an issue with the functions that are inside OGLExport . Maybe becase of the nme namespace, and we need to declare them in OGLExtensions.h?

@madrazo
Copy link
Contributor Author

madrazo commented Jun 16, 2017

native-toolkit/libsdl#10 fixes nme angle

@madrazo
Copy link
Contributor Author

madrazo commented Jun 16, 2017

Tried HerokuShaders with nme winrt. It works without issue.
requires #478 , git versions of png, angle, sdl (with the previous mentioned commit)

@madrazo
Copy link
Contributor Author

madrazo commented Jul 3, 2017

I'm almost getting audio working with the 06-Sound sample but requires update of the SDL-mixer lib

@madrazo
Copy link
Contributor Author

madrazo commented Jul 7, 2017

To be able to see the logs:
Open Visual Sudio (2015) with a uwp project. Right-click the project in Solution Explorer, and select Properties. In Debugging, Debugger Type, select Managed and Native.

Run app from debugger: In Debug, Other Debug Targets, Debug Installed App Package. Select the app, type Mixed, and press Start. The logs will be in the Output window.

Edit: this may be improved by using a LoggingChannel class
https://blogs.windows.com/buildingapps/2016/06/10/using-device-portal-to-view-debug-logs-for-uwp/#d8rW38Fm7rme4PWP.97

https://docs.microsoft.com/en-us/uwp/api/windows.foundation.diagnostics.loggingchannel

https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/Logging/cpp/LoggingSessionScenario.cpp#L34

@madrazo
Copy link
Contributor Author

madrazo commented Jul 11, 2017

Winrt Sound is working with an updated SDL Mixer (https://github.com/madrazo/sdl-mixer/tree/winrt), except midi. I'm not sending this PR because it's development (git) version of sdl-mixer. Instead, I'll try to see if patching the current one with HX_WINRT defines also works.

Edit2: I had enabled sound since it worked with few changes on sdl-mixer that should not affect other targets native-toolkit/libsdl-mixer#1

For the To-do list, there are more parameters that could be added from the XML (for AppManifest) such as
DefaultLanguage / Language
TargetDeviceFamily ("Universal", "Mobile", "Desktop", "Xbox", "Holographic", "IoT", or "IoTHeadless")
WindowsTargetPlatformVersion / MaxVersionTested
WindowsTargetPlatformMinVersion / MinVersion

Better control on the Splash screen, icons

Platform for Xbox should be x64
Deploy to Xbox using C:\Program Files (x86)\Windows Kits\10\bin\x86\WinAppDeployCmd.exe or WDP (rest api) https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/device-portal

Edit: To deal with certificates (create and apply)
https://docs.microsoft.com/en-us/windows/uwp/packaging/create-certificate-package-signing

Edit2: now the certificate xml tag can be used to sign the resulting Appx with a .pfx file. If the certificate does not exist in the path, a new one is created using the provided password using a powershell script (makes it easier). Currently I tried it with
<certificate path="Export/winrt/NME_Example.pfx" password="nmeexample" /> and works but I need to test other paths and other passwords just to be sure. An extra step has to be done to install the Appx on Windows: Double click the pfx and add it to Local Machine, and to the Trusted People store. Then double click the Appx and should be able to install.

@madrazo
Copy link
Contributor Author

madrazo commented Jul 19, 2017

Now I feel it can be considered a "beta" version. Samples are running ok with font and sound and creates the Appx correctly.

I almost forgot that there is still stuff to implement on project/src/windows/System.cpp and maybe on common/Utils.cpp

@madrazo
Copy link
Contributor Author

madrazo commented Aug 7, 2017

Every UWP app goes fullscreen using Shift+WindowsKey+Enter.
It's not posible to implement ALt+Enter without modifying SDL (https://github.com/native-toolkit/sdl/blob/master/src/video/winrt/SDL_winrtkeyboard.cpp#L354 to check isMenuKeyDown or use AcceleratorKeyActivated) , so I'm not going to do that

Furthermore, adding the Fullscreen button on the title bar requires XAML so I'm not doing that either.

@madrazo
Copy link
Contributor Author

madrazo commented Aug 20, 2017

@hughsando sorry, I forgot to add this one native-toolkit/libmodplug#2
I still need to test this on an actual xbox one 😊 Hopefully this week

@jaimedominguez
Copy link

I have the XBOX devkit. And I made haxe compilation work in HTML5 + UWP. Performance is poor and I think there was no sound. So I'm after making it work with hxcpp and openFL/lime.

I'm far too new into toolchains but I guess I could get this working with a little bit of guidance with my setup.

Can somebody help me?

@madrazo
Copy link
Contributor Author

madrazo commented Oct 18, 2018

@jaimedominguez NME compiles into UWP, C++ not HTML5. However, I had never actually tried it on an XBOXONE. It should run on a Retail XBOXONE in Developer Mode. Also the DevKit should be able to run it. Please try the DisplayingABitmap sample:

nme create DisplayingABitmap
cd DisplayingABitmap
nme winrt

If you have some errors, please try it with PR #520 but I'll also check it if it is still needed

If you success to build the UWP Appx, there is a way to send it to the XBOXONE* and try it https://docs.microsoft.com/en-us/windows/uwp/xbox-apps/getting-started

EDIT: worked for me, hxcpp git, nme git, haxe 4 preview 5, Windows SDK 10.0.10240. Needed #520 otherwise crashes at startup. I wil try on a second PC with fresh install. By the way, nme does not uses lime. Use nme command only.

*By XBOX Device Portal https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/device-portal-xbox

@madrazo
Copy link
Contributor Author

madrazo commented Oct 24, 2018

As for October 2018, Microsoft requires VS 2017 15.7 or higher and the Windows SDK 10.0.17134 or higher for UWP development on XB1

#include <sdkddkver.h>
#if !defined(NTDDI_WIN10_RS4)
    #error Windows 10.0.17134 .0 SDK is required
#endif

@madrazo
Copy link
Contributor Author

madrazo commented Apr 9, 2019

MS has moved the bin directory of their tools, so a little update will be required to generate the appx. I still had not the chance to test this on a real xbox one

@madrazo
Copy link
Contributor Author

madrazo commented Apr 11, 2019

Finally tested the APPX on an XboxOne and its all good.
I needed to edit libmodplug/stdafx.h in nme-toolkit to remove the declaration of getenv since it is now declared
I still need to update the newer bin directories from C:\Program Files (x86)\Windows Kits\10\bin\x64 to C:\Program Files (x86)\Windows Kits\10\10.0.XXXXX.0\x64
either
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0
or
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0

@madrazo
Copy link
Contributor Author

madrazo commented Apr 11, 2019

Appx can be automatically deployed with the command
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\WinAppDeployCmd.exe" install -file "DisplayingABitmap.Appx" -dependency "Microsoft.VCLibs.x64.14.00.appx" -ip xx.xx.xx.xx
the first time asks for the -pin

I am not sure how to generate "Microsoft.VCLibs.x64.14.00.appx"

@madrazo
Copy link
Contributor Author

madrazo commented Apr 18, 2019

@hughsando modplug in native toolkit fixes winrt compilation but the one in nme is not up to date https://github.com/native-toolkit/modplug
(avoid redefining getenv in stdafx.h native-toolkit/libmodplug@ad0e291#diff-d293888b7f3dd23a57a57ddfd6223109L60)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants