├── .gitattributes ├── .gitignore ├── .gitmodules ├── AppProcessAngle ├── App.cpp ├── App.h ├── AppProcessAngle.vcxproj ├── AppProcessAngle.vcxproj.filters ├── AppProcessAngle_TemporaryKey.pfx ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png ├── MathHelper.h ├── Package.appxmanifest ├── SimpleRenderer.cpp ├── SimpleRenderer.h ├── WinDebugMonitor.cpp ├── WinDebugMonitor.h ├── pch.cpp └── pch.h ├── Bridge.sln ├── ProcessHost ├── Assets │ ├── SplashScreen.png │ ├── Square150x150Logo.png │ ├── Square44x44Logo.png │ ├── StoreLogo.png │ └── Wide310x150Logo.png ├── Package.appxmanifest ├── ProcessHost.cpp ├── ProcessHost.h ├── ProcessHost.vcxproj ├── ProcessHost.vcxproj.filters ├── ProcessHost_TemporaryKey.pfx ├── pch.cpp ├── pch.h └── targetver.h ├── README.md └── appveyor.yml /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "FLinux"] 2 | path = FLinux 3 | url = https://github.com/DroidOnUWP/flinux.git 4 | [submodule "Angle"] 5 | path = Angle 6 | url = https://github.com/Microsoft/angle.git 7 | [submodule "Android/lib"] 8 | path = Android/lib 9 | url = https://github.com/DroidOnUWP/AndroidLibs.git 10 | branch = 7.1.1 11 | [submodule "AppProcessAngle/root"] 12 | path = AppProcessAngle/root 13 | url = https://github.com/DroidOnUWP/AndroidImage.git 14 | branch = 7.1.1 15 | [submodule "BridgeLib"] 16 | path = BridgeLib 17 | url = https://github.com/DroidOnUWP/BridgeLib.git 18 | -------------------------------------------------------------------------------- /AppProcessAngle/App.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // This file demonstrates how to initialize EGL in a Windows Store app, using ICoreWindow. 3 | // 4 | 5 | #include "pch.h" 6 | #include "app.h" 7 | #include "SimpleRenderer.h" 8 | #include "android_init.h" 9 | #include "WinDebugMonitor.h" 10 | 11 | using namespace Windows::ApplicationModel::Core; 12 | using namespace Windows::ApplicationModel::Activation; 13 | using namespace Windows::UI::Core; 14 | using namespace Windows::UI::Input; 15 | using namespace Windows::Foundation; 16 | using namespace Windows::Foundation::Collections; 17 | using namespace Windows::Graphics::Display; 18 | using namespace Windows::Storage; 19 | using namespace Windows::ApplicationModel; 20 | using namespace Microsoft::WRL; 21 | using namespace Platform; 22 | using namespace Windows::System::Threading; 23 | using namespace AppProcessAngle; 24 | 25 | // Helper to convert a length in device-independent pixels (DIPs) to a length in physical pixels. 26 | inline float ConvertDipsToPixels(float dips, float dpi) 27 | { 28 | static const float dipsPerInch = 96.0f; 29 | return floor(dips * dpi / dipsPerInch + 0.5f); // Round to nearest integer. 30 | } 31 | 32 | // Implementation of the IFrameworkViewSource interface, necessary to run our app. 33 | ref class SimpleApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource 34 | { 35 | public: 36 | virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView() 37 | { 38 | return ref new App(); 39 | } 40 | }; 41 | 42 | // The main function creates an IFrameworkViewSource for our app, and runs the app. 43 | [Platform::MTAThread] 44 | int main(Platform::Array^) 45 | { 46 | auto simpleApplicationSource = ref new SimpleApplicationSource(); 47 | CoreApplication::Run(simpleApplicationSource); 48 | return 0; 49 | } 50 | 51 | App::App() : 52 | mWindowClosed(false), 53 | mWindowVisible(true), 54 | mEglDisplay(EGL_NO_DISPLAY), 55 | mEglContext(EGL_NO_CONTEXT), 56 | mEglSurface(EGL_NO_SURFACE) 57 | { 58 | } 59 | 60 | // The first method called when the IFrameworkView is being created. 61 | void App::Initialize(CoreApplicationView^ applicationView) 62 | { 63 | // Register event handlers for app lifecycle. This example includes Activated, so that we 64 | // can make the CoreWindow active and start rendering on the window. 65 | applicationView->Activated += 66 | ref new TypedEventHandler(this, &App::OnActivated); 67 | 68 | // Logic for other event handlers could go here. 69 | // Information about the Suspending and Resuming event handlers can be found here: 70 | // http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh994930.aspx 71 | } 72 | 73 | // Called when the CoreWindow object is created (or re-created). 74 | void App::SetWindow(CoreWindow^ window) 75 | { 76 | window->VisibilityChanged += 77 | ref new TypedEventHandler(this, &App::OnVisibilityChanged); 78 | 79 | window->Closed += 80 | ref new TypedEventHandler(this, &App::OnWindowClosed); 81 | 82 | // The CoreWindow has been created, so EGL can be initialized. 83 | InitializeEGL(window); 84 | } 85 | 86 | // Initializes scene resources 87 | void App::Load(Platform::String^ entryPoint) 88 | { 89 | StorageFolder^ localFolder = ApplicationData::Current->LocalFolder; 90 | 91 | StorageFolder^ packageFolder = Package::Current->InstalledLocation; 92 | 93 | 94 | Platform::String^ packageFolderPath = Platform::String::Concat(L"\\\\?\\", packageFolder->Path); 95 | Platform::String^ localFolderPath = Platform::String::Concat(L"\\\\?\\", localFolder->Path); 96 | 97 | packageFolderPath = Platform::String::Concat(packageFolderPath, L"\\root"); 98 | 99 | flinit(packageFolderPath->Data(), localFolderPath->Data()); 100 | 101 | RecreateRenderer(); 102 | 103 | 104 | auto workItem = ref new WorkItemHandler( 105 | [this](IAsyncAction^ workItem) 106 | { 107 | CWinDebugMonitor m_debugMonitor; 108 | std::string strA; 109 | 110 | while (!m_debugMonitor.IsStopped()) 111 | { 112 | const char* str = m_debugMonitor.GetDebugString(); 113 | 114 | if (str != NULL) 115 | { 116 | //strA.append(str); 117 | strA = "host:"; 118 | strA += str; 119 | m_debugMonitor.BufferReady(); 120 | 121 | OutputDebugStringA(strA.c_str()); 122 | 123 | /*std::wstring strW(strA.begin(), strA.end()); 124 | 125 | Platform::String^ pStr = ref new Platform::String(strW.data()); 126 | 127 | Windows::ApplicationModel::Core::CoreApplication::MainView->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this, pStr]() 128 | { 129 | OutputDebugStringW(pStr->Data()); 130 | 131 | } 132 | ));*/ 133 | } 134 | } 135 | 136 | }); 137 | 138 | m_workItem = ThreadPool::RunAsync(workItem, WorkItemPriority::High, WorkItemOptions::TimeSliced); 139 | 140 | 141 | 142 | 143 | call_main(L"app_process32.dll"); 144 | //call_main(L"patchoat.dll"); 145 | //call_main(L"libtest_syscalls"); 146 | 147 | } 148 | 149 | void App::RecreateRenderer() 150 | { 151 | if (!mCubeRenderer) 152 | { 153 | mCubeRenderer.reset(new SimpleRenderer()); 154 | } 155 | } 156 | 157 | // This method is called after the window becomes active. 158 | void App::Run() 159 | { 160 | while (!mWindowClosed) 161 | { 162 | if (mWindowVisible) 163 | { 164 | CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); 165 | 166 | EGLint panelWidth = 0; 167 | EGLint panelHeight = 0; 168 | eglQuerySurface(mEglDisplay, mEglSurface, EGL_WIDTH, &panelWidth); 169 | eglQuerySurface(mEglDisplay, mEglSurface, EGL_HEIGHT, &panelHeight); 170 | 171 | // Logic to update the scene could go here 172 | mCubeRenderer->UpdateWindowSize(panelWidth, panelHeight); 173 | mCubeRenderer->Draw(); 174 | 175 | // The call to eglSwapBuffers might not be successful (e.g. due to Device Lost) 176 | // If the call fails, then we must reinitialize EGL and the GL resources. 177 | if (eglSwapBuffers(mEglDisplay, mEglSurface) != GL_TRUE) 178 | { 179 | mCubeRenderer.reset(nullptr); 180 | CleanupEGL(); 181 | 182 | InitializeEGL(CoreWindow::GetForCurrentThread()); 183 | RecreateRenderer(); 184 | } 185 | } 186 | else 187 | { 188 | CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); 189 | } 190 | } 191 | 192 | CleanupEGL(); 193 | } 194 | 195 | // Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView 196 | // class is torn down while the app is in the foreground. 197 | void App::Uninitialize() 198 | { 199 | } 200 | 201 | // Application lifecycle event handler. 202 | void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) 203 | { 204 | // Run() won't start until the CoreWindow is activated. 205 | CoreWindow::GetForCurrentThread()->Activate(); 206 | } 207 | 208 | // Window event handlers. 209 | void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) 210 | { 211 | mWindowVisible = args->Visible; 212 | } 213 | 214 | void App::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) 215 | { 216 | mWindowClosed = true; 217 | } 218 | 219 | void App::InitializeEGL(CoreWindow^ window) 220 | { 221 | const EGLint configAttributes[] = 222 | { 223 | EGL_RED_SIZE, 8, 224 | EGL_GREEN_SIZE, 8, 225 | EGL_BLUE_SIZE, 8, 226 | EGL_ALPHA_SIZE, 8, 227 | EGL_DEPTH_SIZE, 8, 228 | EGL_STENCIL_SIZE, 8, 229 | EGL_NONE 230 | }; 231 | 232 | const EGLint contextAttributes[] = 233 | { 234 | EGL_CONTEXT_CLIENT_VERSION, 2, 235 | EGL_NONE 236 | }; 237 | 238 | const EGLint surfaceAttributes[] = 239 | { 240 | // EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above). 241 | // If you have compilation issues with it then please update your Visual Studio templates. 242 | EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL_TRUE, 243 | EGL_NONE 244 | }; 245 | 246 | const EGLint defaultDisplayAttributes[] = 247 | { 248 | // These are the default display attributes, used to request ANGLE's D3D11 renderer. 249 | // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+. 250 | EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 251 | 252 | // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. 253 | // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. 254 | EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, 255 | 256 | // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call 257 | // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. 258 | // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement. 259 | EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, 260 | EGL_NONE, 261 | }; 262 | 263 | const EGLint fl9_3DisplayAttributes[] = 264 | { 265 | // These can be used to request ANGLE's D3D11 renderer, with D3D11 Feature Level 9_3. 266 | // These attributes are used if the call to eglInitialize fails with the default display attributes. 267 | EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 268 | EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, 269 | EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, 270 | EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, 271 | EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, 272 | EGL_NONE, 273 | }; 274 | 275 | const EGLint warpDisplayAttributes[] = 276 | { 277 | // These attributes can be used to request D3D11 WARP. 278 | // They are used if eglInitialize fails with both the default display attributes and the 9_3 display attributes. 279 | EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 280 | EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE, 281 | EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, 282 | EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, 283 | EGL_NONE, 284 | }; 285 | 286 | EGLConfig config = NULL; 287 | 288 | // eglGetPlatformDisplayEXT is an alternative to eglGetDisplay. It allows us to pass in display attributes, used to configure D3D11. 289 | PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast(eglGetProcAddress("eglGetPlatformDisplayEXT")); 290 | if (!eglGetPlatformDisplayEXT) 291 | { 292 | throw Exception::CreateException(E_FAIL, L"Failed to get function eglGetPlatformDisplayEXT"); 293 | } 294 | 295 | // 296 | // To initialize the display, we make three sets of calls to eglGetPlatformDisplayEXT and eglInitialize, with varying 297 | // parameters passed to eglGetPlatformDisplayEXT: 298 | // 1) The first calls uses "defaultDisplayAttributes" as a parameter. This corresponds to D3D11 Feature Level 10_0+. 299 | // 2) If eglInitialize fails for step 1 (e.g. because 10_0+ isn't supported by the default GPU), then we try again 300 | // using "fl9_3DisplayAttributes". This corresponds to D3D11 Feature Level 9_3. 301 | // 3) If eglInitialize fails for step 2 (e.g. because 9_3+ isn't supported by the default GPU), then we try again 302 | // using "warpDisplayAttributes". This corresponds to D3D11 Feature Level 11_0 on WARP, a D3D11 software rasterizer. 303 | // 304 | 305 | // This tries to initialize EGL to D3D11 Feature Level 10_0+. See above comment for details. 306 | mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, defaultDisplayAttributes); 307 | if (mEglDisplay == EGL_NO_DISPLAY) 308 | { 309 | throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); 310 | } 311 | 312 | if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) 313 | { 314 | // This tries to initialize EGL to D3D11 Feature Level 9_3, if 10_0+ is unavailable (e.g. on some mobile devices). 315 | mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, fl9_3DisplayAttributes); 316 | if (mEglDisplay == EGL_NO_DISPLAY) 317 | { 318 | throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); 319 | } 320 | 321 | if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) 322 | { 323 | // This initializes EGL to D3D11 Feature Level 11_0 on WARP, if 9_3+ is unavailable on the default GPU. 324 | mEglDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, EGL_DEFAULT_DISPLAY, warpDisplayAttributes); 325 | if (mEglDisplay == EGL_NO_DISPLAY) 326 | { 327 | throw Exception::CreateException(E_FAIL, L"Failed to get EGL display"); 328 | } 329 | 330 | if (eglInitialize(mEglDisplay, NULL, NULL) == EGL_FALSE) 331 | { 332 | // If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred. 333 | throw Exception::CreateException(E_FAIL, L"Failed to initialize EGL"); 334 | } 335 | } 336 | } 337 | 338 | EGLint numConfigs = 0; 339 | if ((eglChooseConfig(mEglDisplay, configAttributes, &config, 1, &numConfigs) == EGL_FALSE) || (numConfigs == 0)) 340 | { 341 | throw Exception::CreateException(E_FAIL, L"Failed to choose first EGLConfig"); 342 | } 343 | 344 | // Create a PropertySet and initialize with the EGLNativeWindowType. 345 | PropertySet^ surfaceCreationProperties = ref new PropertySet(); 346 | surfaceCreationProperties->Insert(ref new String(EGLNativeWindowTypeProperty), window); 347 | 348 | // You can configure the surface to render at a lower resolution and be scaled up to 349 | // the full window size. This scaling is often free on mobile hardware. 350 | // 351 | // One way to configure the SwapChainPanel is to specify precisely which resolution it should render at. 352 | // Size customRenderSurfaceSize = Size(800, 600); 353 | // surfaceCreationProperties->Insert(ref new String(EGLRenderSurfaceSizeProperty), PropertyValue::CreateSize(customRenderSurfaceSize)); 354 | // 355 | // Another way is to tell the SwapChainPanel to render at a certain scale factor compared to its size. 356 | // e.g. if the SwapChainPanel is 1920x1280 then setting a factor of 0.5f will make the app render at 960x640 357 | // float customResolutionScale = 0.5f; 358 | // surfaceCreationProperties->Insert(ref new String(EGLRenderResolutionScaleProperty), PropertyValue::CreateSingle(customResolutionScale)); 359 | 360 | mEglSurface = eglCreateWindowSurface(mEglDisplay, config, reinterpret_cast(surfaceCreationProperties), surfaceAttributes); 361 | if (mEglSurface == EGL_NO_SURFACE) 362 | { 363 | throw Exception::CreateException(E_FAIL, L"Failed to create EGL fullscreen surface"); 364 | } 365 | 366 | mEglContext = eglCreateContext(mEglDisplay, config, EGL_NO_CONTEXT, contextAttributes); 367 | if (mEglContext == EGL_NO_CONTEXT) 368 | { 369 | throw Exception::CreateException(E_FAIL, L"Failed to create EGL context"); 370 | } 371 | 372 | if (eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext) == EGL_FALSE) 373 | { 374 | throw Exception::CreateException(E_FAIL, L"Failed to make fullscreen EGLSurface current"); 375 | } 376 | } 377 | 378 | void App::CleanupEGL() 379 | { 380 | if (mEglDisplay != EGL_NO_DISPLAY && mEglSurface != EGL_NO_SURFACE) 381 | { 382 | eglDestroySurface(mEglDisplay, mEglSurface); 383 | mEglSurface = EGL_NO_SURFACE; 384 | } 385 | 386 | if (mEglDisplay != EGL_NO_DISPLAY && mEglContext != EGL_NO_CONTEXT) 387 | { 388 | eglDestroyContext(mEglDisplay, mEglContext); 389 | mEglContext = EGL_NO_CONTEXT; 390 | } 391 | 392 | if (mEglDisplay != EGL_NO_DISPLAY) 393 | { 394 | eglTerminate(mEglDisplay); 395 | mEglDisplay = EGL_NO_DISPLAY; 396 | } 397 | } -------------------------------------------------------------------------------- /AppProcessAngle/App.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "pch.h" 6 | #include "SimpleRenderer.h" 7 | 8 | namespace AppProcessAngle 9 | { 10 | ref class App sealed : public Windows::ApplicationModel::Core::IFrameworkView 11 | { 12 | public: 13 | App(); 14 | 15 | // IFrameworkView Methods. 16 | virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); 17 | virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); 18 | virtual void Load(Platform::String^ entryPoint); 19 | virtual void Run(); 20 | virtual void Uninitialize(); 21 | 22 | private: 23 | void RecreateRenderer(); 24 | 25 | // Application lifecycle event handlers. 26 | void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); 27 | 28 | // Window event handlers. 29 | void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); 30 | void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args); 31 | 32 | void InitializeEGL(Windows::UI::Core::CoreWindow^ window); 33 | void CleanupEGL(); 34 | 35 | bool mWindowClosed; 36 | bool mWindowVisible; 37 | 38 | EGLDisplay mEglDisplay; 39 | EGLContext mEglContext; 40 | EGLSurface mEglSurface; 41 | 42 | std::unique_ptr mCubeRenderer; 43 | Windows::Foundation::IAsyncAction^ m_workItem; 44 | }; 45 | 46 | } -------------------------------------------------------------------------------- /AppProcessAngle/AppProcessAngle.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 005f5de9-f76e-4424-a2df-a22b0a8b71f8 6 | bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png 7 | 8 | 9 | dll; 10 | 11 | 12 | Assets 13 | 14 | 15 | Assets 16 | 17 | 18 | Assets 19 | 20 | 21 | Assets 22 | 23 | 24 | Assets 25 | 26 | 27 | Assets 28 | 29 | 30 | {91ca9e56-428e-477e-8244-96e8b15792a6} 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Assets 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | Binaries 58 | 59 | 60 | Binaries 61 | 62 | 63 | 64 | Binaries 65 | 66 | 67 | Binaries 68 | 69 | 70 | Binaries 71 | 72 | 73 | Binaries 74 | 75 | 76 | Binaries 77 | 78 | 79 | Binaries 80 | 81 | 82 | Binaries 83 | 84 | 85 | Binaries 86 | 87 | 88 | Binaries 89 | 90 | 91 | Binaries 92 | 93 | 94 | Binaries 95 | 96 | 97 | Binaries 98 | 99 | 100 | Binaries 101 | 102 | 103 | Binaries 104 | 105 | 106 | Binaries 107 | 108 | 109 | Binaries 110 | 111 | 112 | Binaries 113 | 114 | 115 | Binaries 116 | 117 | 118 | Binaries 119 | 120 | 121 | Binaries 122 | 123 | 124 | Binaries 125 | 126 | 127 | Binaries 128 | 129 | 130 | Binaries 131 | 132 | 133 | Binaries 134 | 135 | 136 | Binaries 137 | 138 | 139 | Binaries 140 | 141 | 142 | Binaries 143 | 144 | 145 | Binaries 146 | 147 | 148 | Binaries 149 | 150 | 151 | Binaries 152 | 153 | 154 | Binaries 155 | 156 | 157 | Binaries 158 | 159 | 160 | Binaries 161 | 162 | 163 | Binaries 164 | 165 | 166 | Binaries 167 | 168 | 169 | Binaries 170 | 171 | 172 | Binaries 173 | 174 | 175 | Binaries 176 | 177 | 178 | Binaries 179 | 180 | 181 | Binaries 182 | 183 | 184 | Binaries 185 | 186 | 187 | Binaries 188 | 189 | 190 | Binaries 191 | 192 | 193 | Binaries 194 | 195 | 196 | Binaries 197 | 198 | 199 | Binaries 200 | 201 | 202 | Binaries 203 | 204 | 205 | Binaries 206 | 207 | 208 | Binaries 209 | 210 | 211 | Binaries 212 | 213 | 214 | Binaries 215 | 216 | 217 | Binaries 218 | 219 | 220 | Binaries 221 | 222 | 223 | Binaries 224 | 225 | 226 | Binaries 227 | 228 | 229 | Binaries 230 | 231 | 232 | Binaries 233 | 234 | 235 | Binaries 236 | 237 | 238 | Binaries 239 | 240 | 241 | Binaries 242 | 243 | 244 | Binaries 245 | 246 | 247 | Binaries 248 | 249 | 250 | Binaries 251 | 252 | 253 | Binaries 254 | 255 | 256 | 257 | Binaries 258 | 259 | 260 | Binaries 261 | 262 | 263 | Binaries 264 | 265 | 266 | Binaries 267 | 268 | 269 | Binaries 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | Binaries 278 | 279 | 280 | Binaries 281 | 282 | 283 | Binaries 284 | 285 | 286 | Binaries 287 | 288 | 289 | Binaries 290 | 291 | 292 | Binaries 293 | 294 | 295 | Binaries 296 | 297 | 298 | Binaries 299 | 300 | 301 | Binaries 302 | 303 | 304 | Binaries 305 | 306 | 307 | Binaries 308 | 309 | 310 | Binaries 311 | 312 | 313 | Binaries 314 | 315 | 316 | Binaries 317 | 318 | 319 | Binaries 320 | 321 | 322 | 323 | Binaries 324 | 325 | 326 | Binaries 327 | 328 | 329 | Binaries 330 | 331 | 332 | Binaries 333 | 334 | 335 | 336 | Binaries 337 | 338 | 339 | Binaries 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | Binaries 361 | 362 | 363 | Binaries 364 | 365 | 366 | Binaries 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | Binaries 436 | 437 | 438 | Binaries 439 | 440 | 441 | Binaries 442 | 443 | 444 | Binaries 445 | 446 | 447 | Binaries 448 | 449 | 450 | Binaries 451 | 452 | 453 | Binaries 454 | 455 | 456 | Binaries 457 | 458 | 459 | Binaries 460 | 461 | 462 | Binaries 463 | 464 | 465 | Binaries 466 | 467 | 468 | Binaries 469 | 470 | 471 | Binaries 472 | 473 | 474 | Binaries 475 | 476 | 477 | Binaries 478 | 479 | 480 | Binaries 481 | 482 | 483 | Binaries 484 | 485 | 486 | Binaries 487 | 488 | 489 | Binaries 490 | 491 | 492 | Binaries 493 | 494 | 495 | Binaries 496 | 497 | 498 | Binaries 499 | 500 | 501 | Binaries 502 | 503 | 504 | Binaries 505 | 506 | 507 | Binaries 508 | 509 | 510 | Binaries 511 | 512 | 513 | Binaries 514 | 515 | 516 | Binaries 517 | 518 | 519 | Binaries 520 | 521 | 522 | Binaries 523 | 524 | 525 | Binaries 526 | 527 | 528 | Binaries 529 | 530 | 531 | Binaries 532 | 533 | 534 | Binaries 535 | 536 | 537 | Binaries 538 | 539 | 540 | Binaries 541 | 542 | 543 | Binaries 544 | 545 | 546 | Binaries 547 | 548 | 549 | Binaries 550 | 551 | 552 | Binaries 553 | 554 | 555 | Binaries 556 | 557 | 558 | Binaries 559 | 560 | 561 | Binaries 562 | 563 | 564 | Binaries 565 | 566 | 567 | Binaries 568 | 569 | 570 | Binaries 571 | 572 | 573 | Binaries 574 | 575 | 576 | Binaries 577 | 578 | 579 | Binaries 580 | 581 | 582 | Binaries 583 | 584 | 585 | Binaries 586 | 587 | 588 | Binaries 589 | 590 | 591 | Binaries 592 | 593 | 594 | Binaries 595 | 596 | 597 | Binaries 598 | 599 | 600 | Binaries 601 | 602 | 603 | Binaries 604 | 605 | 606 | Binaries 607 | 608 | 609 | Binaries 610 | 611 | 612 | Binaries 613 | 614 | 615 | Binaries 616 | 617 | 618 | Binaries 619 | 620 | 621 | Binaries 622 | 623 | 624 | Binaries 625 | 626 | 627 | Binaries 628 | 629 | 630 | Binaries 631 | 632 | 633 | Binaries 634 | 635 | 636 | Binaries 637 | 638 | 639 | Binaries 640 | 641 | 642 | Binaries 643 | 644 | 645 | Binaries 646 | 647 | 648 | Binaries 649 | 650 | 651 | Binaries 652 | 653 | 654 | Binaries 655 | 656 | 657 | Binaries 658 | 659 | 660 | Binaries 661 | 662 | 663 | Binaries 664 | 665 | 666 | Binaries 667 | 668 | 669 | Binaries 670 | 671 | 672 | Binaries 673 | 674 | 675 | Binaries 676 | 677 | 678 | Binaries 679 | 680 | 681 | Binaries 682 | 683 | 684 | Binaries 685 | 686 | 687 | Binaries 688 | 689 | 690 | Binaries 691 | 692 | 693 | Binaries 694 | 695 | 696 | Binaries 697 | 698 | 699 | Binaries 700 | 701 | 702 | Binaries 703 | 704 | 705 | Binaries 706 | 707 | 708 | Binaries 709 | 710 | 711 | Binaries 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | -------------------------------------------------------------------------------- /AppProcessAngle/AppProcessAngle_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/AppProcessAngle/AppProcessAngle_TemporaryKey.pfx -------------------------------------------------------------------------------- /AppProcessAngle/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/AppProcessAngle/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /AppProcessAngle/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/AppProcessAngle/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /AppProcessAngle/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/AppProcessAngle/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /AppProcessAngle/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/AppProcessAngle/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /AppProcessAngle/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/AppProcessAngle/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /AppProcessAngle/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/AppProcessAngle/Assets/StoreLogo.png -------------------------------------------------------------------------------- /AppProcessAngle/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/AppProcessAngle/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /AppProcessAngle/MathHelper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // These are some simple math helpers to enable the template to render a spinning cube. It is not a complete math library. 4 | // You can replace this with your favorite math library that's suitable for your target platforms, e.g. DirectXMath or GLM. 5 | 6 | #include 7 | 8 | namespace MathHelper 9 | { 10 | 11 | struct Matrix4 12 | { 13 | Matrix4(float m00, float m01, float m02, float m03, 14 | float m10, float m11, float m12, float m13, 15 | float m20, float m21, float m22, float m23, 16 | float m30, float m31, float m32, float m33) 17 | { 18 | m[0][0] = m00; m[0][1] = m01; m[0][2] = m02; m[0][3] = m03; 19 | m[1][0] = m10; m[1][1] = m11; m[1][2] = m12; m[1][3] = m13; 20 | m[2][0] = m20; m[2][1] = m21; m[2][2] = m22; m[2][3] = m23; 21 | m[3][0] = m30; m[3][1] = m31; m[3][2] = m32; m[3][3] = m33; 22 | } 23 | 24 | float m[4][4]; 25 | }; 26 | 27 | inline static Matrix4 SimpleModelMatrix(float radians) 28 | { 29 | float cosine = cosf(radians); 30 | float sine = sinf(radians); 31 | 32 | return Matrix4(cosine, 0.0f, -sine, 0.0f, 33 | 0.0f, 1.0f, 0.0f, 0.0f, 34 | sine, 0.0f, cosine, 0.0f, 35 | 0.0f, 0.0f, 0.0f, 1.0f); 36 | } 37 | 38 | inline static Matrix4 SimpleViewMatrix() 39 | { 40 | // Camera is at 60 degrees to the ground, in the YZ plane. 41 | // Camera Look-At is hardcoded to (0, 0, 0). 42 | // Camera Up is hardcoded to (0, 1, 0). 43 | const float sqrt3over2 = 0.86603f; 44 | const float cameraDistance = 5.0f; 45 | 46 | return Matrix4(1.0f, 0.0f, 0.0f, 0.0f, 47 | 0.0f, sqrt3over2, 0.5f, 0.0f, 48 | 0.0f, -0.5f, sqrt3over2, 0.0f, 49 | 0.0f, 0.0f, -cameraDistance, 1.0f); 50 | } 51 | 52 | inline static Matrix4 SimpleProjectionMatrix(float aspectRatio) 53 | { 54 | // Far plane is at 50.0f, near plane is at 1.0f. 55 | // FoV is hardcoded to pi/3. 56 | const float cotangent = 1 / tanf(3.14159f / 6.0f); 57 | 58 | return Matrix4(cotangent / aspectRatio, 0.0f, 0.0f, 0.0f, 59 | 0.0f, cotangent, 0.0f, 0.0f, 60 | 0.0f, 0.0f, -50.0f / (50.0f - 1.0f), (-50.0f * 1.0f) / (50.0f - 1.0f), 61 | 0.0f, 0.0f, -1.0f, 0.0f); 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /AppProcessAngle/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | AppProcessAngle 7 | Václav 8 | Assets\StoreLogo.png 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /AppProcessAngle/SimpleRenderer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // This file is used by the template to render a basic scene using GL. 3 | // 4 | 5 | #include "pch.h" 6 | #include "SimpleRenderer.h" 7 | #include "MathHelper.h" 8 | 9 | // These are used by the shader compilation methods. 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace Platform; 15 | 16 | using namespace AppProcessAngle; 17 | 18 | #define STRING(s) #s 19 | 20 | GLuint CompileShader(GLenum type, const std::string &source) 21 | { 22 | GLuint shader = glCreateShader(type); 23 | 24 | const char *sourceArray[1] = { source.c_str() }; 25 | glShaderSource(shader, 1, sourceArray, NULL); 26 | glCompileShader(shader); 27 | 28 | GLint compileResult; 29 | glGetShaderiv(shader, GL_COMPILE_STATUS, &compileResult); 30 | 31 | if (compileResult == 0) 32 | { 33 | GLint infoLogLength; 34 | glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength); 35 | 36 | std::vector infoLog(infoLogLength); 37 | glGetShaderInfoLog(shader, (GLsizei)infoLog.size(), NULL, infoLog.data()); 38 | 39 | std::wstring errorMessage = std::wstring(L"Shader compilation failed: "); 40 | errorMessage += std::wstring(infoLog.begin(), infoLog.end()); 41 | 42 | throw Exception::CreateException(E_FAIL, ref new Platform::String(errorMessage.c_str())); 43 | } 44 | 45 | return shader; 46 | } 47 | 48 | GLuint CompileProgram(const std::string &vsSource, const std::string &fsSource) 49 | { 50 | GLuint program = glCreateProgram(); 51 | 52 | if (program == 0) 53 | { 54 | throw Exception::CreateException(E_FAIL, L"Program creation failed"); 55 | } 56 | 57 | GLuint vs = CompileShader(GL_VERTEX_SHADER, vsSource); 58 | GLuint fs = CompileShader(GL_FRAGMENT_SHADER, fsSource); 59 | 60 | if (vs == 0 || fs == 0) 61 | { 62 | glDeleteShader(fs); 63 | glDeleteShader(vs); 64 | glDeleteProgram(program); 65 | return 0; 66 | } 67 | 68 | glAttachShader(program, vs); 69 | glDeleteShader(vs); 70 | 71 | glAttachShader(program, fs); 72 | glDeleteShader(fs); 73 | 74 | glLinkProgram(program); 75 | 76 | GLint linkStatus; 77 | glGetProgramiv(program, GL_LINK_STATUS, &linkStatus); 78 | 79 | if (linkStatus == 0) 80 | { 81 | GLint infoLogLength; 82 | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength); 83 | 84 | std::vector infoLog(infoLogLength); 85 | glGetProgramInfoLog(program, (GLsizei)infoLog.size(), NULL, infoLog.data()); 86 | 87 | std::wstring errorMessage = std::wstring(L"Program link failed: "); 88 | errorMessage += std::wstring(infoLog.begin(), infoLog.end()); 89 | 90 | throw Exception::CreateException(E_FAIL, ref new Platform::String(errorMessage.c_str())); 91 | } 92 | 93 | return program; 94 | } 95 | 96 | SimpleRenderer::SimpleRenderer() : 97 | mWindowWidth(0), 98 | mWindowHeight(0), 99 | mDrawCount(0) 100 | { 101 | // Vertex Shader source 102 | const std::string vs = STRING 103 | ( 104 | uniform mat4 uModelMatrix; 105 | uniform mat4 uViewMatrix; 106 | uniform mat4 uProjMatrix; 107 | attribute vec4 aPosition; 108 | attribute vec4 aColor; 109 | varying vec4 vColor; 110 | void main() 111 | { 112 | gl_Position = uProjMatrix * uViewMatrix * uModelMatrix * aPosition; 113 | vColor = aColor; 114 | } 115 | ); 116 | 117 | // Fragment Shader source 118 | const std::string fs = STRING 119 | ( 120 | precision mediump float; 121 | varying vec4 vColor; 122 | void main() 123 | { 124 | gl_FragColor = vColor; 125 | } 126 | ); 127 | 128 | // Set up the shader and its uniform/attribute locations. 129 | mProgram = CompileProgram(vs, fs); 130 | mPositionAttribLocation = glGetAttribLocation(mProgram, "aPosition"); 131 | mColorAttribLocation = glGetAttribLocation(mProgram, "aColor"); 132 | mModelUniformLocation = glGetUniformLocation(mProgram, "uModelMatrix"); 133 | mViewUniformLocation = glGetUniformLocation(mProgram, "uViewMatrix"); 134 | mProjUniformLocation = glGetUniformLocation(mProgram, "uProjMatrix"); 135 | 136 | // Then set up the cube geometry. 137 | GLfloat vertexPositions[] = 138 | { 139 | -1.0f, -1.0f, -1.0f, 140 | -1.0f, -1.0f, 1.0f, 141 | -1.0f, 1.0f, -1.0f, 142 | -1.0f, 1.0f, 1.0f, 143 | 1.0f, -1.0f, -1.0f, 144 | 1.0f, -1.0f, 1.0f, 145 | 1.0f, 1.0f, -1.0f, 146 | 1.0f, 1.0f, 1.0f, 147 | }; 148 | 149 | glGenBuffers(1, &mVertexPositionBuffer); 150 | glBindBuffer(GL_ARRAY_BUFFER, mVertexPositionBuffer); 151 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, GL_STATIC_DRAW); 152 | 153 | GLfloat vertexColors[] = 154 | { 155 | 0.0f, 0.0f, 0.0f, 156 | 0.0f, 0.0f, 1.0f, 157 | 0.0f, 1.0f, 0.0f, 158 | 0.0f, 1.0f, 1.0f, 159 | 1.0f, 0.0f, 0.0f, 160 | 1.0f, 0.0f, 1.0f, 161 | 1.0f, 1.0f, 0.0f, 162 | 1.0f, 1.0f, 1.0f, 163 | }; 164 | 165 | glGenBuffers(1, &mVertexColorBuffer); 166 | glBindBuffer(GL_ARRAY_BUFFER, mVertexColorBuffer); 167 | glBufferData(GL_ARRAY_BUFFER, sizeof(vertexColors), vertexColors, GL_STATIC_DRAW); 168 | 169 | short indices[] = 170 | { 171 | 0, 1, 2, // -x 172 | 1, 3, 2, 173 | 174 | 4, 6, 5, // +x 175 | 5, 6, 7, 176 | 177 | 0, 5, 1, // -y 178 | 0, 4, 5, 179 | 180 | 2, 7, 6, // +y 181 | 2, 3, 7, 182 | 183 | 0, 6, 4, // -z 184 | 0, 2, 6, 185 | 186 | 1, 7, 3, // +z 187 | 1, 5, 7, 188 | }; 189 | 190 | glGenBuffers(1, &mIndexBuffer); 191 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer); 192 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); 193 | } 194 | 195 | SimpleRenderer::~SimpleRenderer() 196 | { 197 | if (mProgram != 0) 198 | { 199 | glDeleteProgram(mProgram); 200 | mProgram = 0; 201 | } 202 | 203 | if (mVertexPositionBuffer != 0) 204 | { 205 | glDeleteBuffers(1, &mVertexPositionBuffer); 206 | mVertexPositionBuffer = 0; 207 | } 208 | 209 | if (mVertexColorBuffer != 0) 210 | { 211 | glDeleteBuffers(1, &mVertexColorBuffer); 212 | mVertexColorBuffer = 0; 213 | } 214 | 215 | if (mIndexBuffer != 0) 216 | { 217 | glDeleteBuffers(1, &mIndexBuffer); 218 | mIndexBuffer = 0; 219 | } 220 | } 221 | 222 | void SimpleRenderer::Draw() 223 | { 224 | glEnable(GL_DEPTH_TEST); 225 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 226 | 227 | if (mProgram == 0) 228 | return; 229 | 230 | glUseProgram(mProgram); 231 | 232 | glBindBuffer(GL_ARRAY_BUFFER, mVertexPositionBuffer); 233 | glEnableVertexAttribArray(mPositionAttribLocation); 234 | glVertexAttribPointer(mPositionAttribLocation, 3, GL_FLOAT, GL_FALSE, 0, 0); 235 | 236 | glBindBuffer(GL_ARRAY_BUFFER, mVertexColorBuffer); 237 | glEnableVertexAttribArray(mColorAttribLocation); 238 | glVertexAttribPointer(mColorAttribLocation, 3, GL_FLOAT, GL_FALSE, 0, 0); 239 | 240 | MathHelper::Matrix4 modelMatrix = MathHelper::SimpleModelMatrix((float)mDrawCount / 50.0f); 241 | glUniformMatrix4fv(mModelUniformLocation, 1, GL_FALSE, &(modelMatrix.m[0][0])); 242 | 243 | MathHelper::Matrix4 viewMatrix = MathHelper::SimpleViewMatrix(); 244 | glUniformMatrix4fv(mViewUniformLocation, 1, GL_FALSE, &(viewMatrix.m[0][0])); 245 | 246 | MathHelper::Matrix4 projectionMatrix = MathHelper::SimpleProjectionMatrix(float(mWindowWidth) / float(mWindowHeight)); 247 | glUniformMatrix4fv(mProjUniformLocation, 1, GL_FALSE, &(projectionMatrix.m[0][0])); 248 | 249 | // Draw 36 indices: six faces, two triangles per face, 3 indices per triangle 250 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer); 251 | glDrawElements(GL_TRIANGLES, (6 * 2) * 3, GL_UNSIGNED_SHORT, 0); 252 | 253 | mDrawCount += 1; 254 | } 255 | 256 | void SimpleRenderer::UpdateWindowSize(GLsizei width, GLsizei height) 257 | { 258 | glViewport(0, 0, width, height); 259 | mWindowWidth = width; 260 | mWindowHeight = height; 261 | } 262 | -------------------------------------------------------------------------------- /AppProcessAngle/SimpleRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pch.h" 4 | 5 | namespace AppProcessAngle 6 | { 7 | class SimpleRenderer 8 | { 9 | public: 10 | SimpleRenderer(); 11 | ~SimpleRenderer(); 12 | void Draw(); 13 | void UpdateWindowSize(GLsizei width, GLsizei height); 14 | 15 | private: 16 | GLuint mProgram; 17 | GLsizei mWindowWidth; 18 | GLsizei mWindowHeight; 19 | 20 | GLint mPositionAttribLocation; 21 | GLint mColorAttribLocation; 22 | 23 | GLint mModelUniformLocation; 24 | GLint mViewUniformLocation; 25 | GLint mProjUniformLocation; 26 | 27 | GLuint mVertexPositionBuffer; 28 | GLuint mVertexColorBuffer; 29 | GLuint mIndexBuffer; 30 | 31 | int mDrawCount; 32 | }; 33 | } -------------------------------------------------------------------------------- /AppProcessAngle/WinDebugMonitor.cpp: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////// 2 | // 3 | // File: WinDebugMonitor.cpp 4 | // Description: Implementation of class CWinDebugMonitor 5 | // Created: 2007-12-6 6 | // Author: Ken Zhang 7 | // E-Mail: cpp.china@hotmail.com 8 | // 9 | ////////////////////////////////////////////////////////////// 10 | #include "pch.h"" 11 | 12 | #include "WinDebugMonitor.h" 13 | #include 14 | 15 | // ---------------------------------------------------------------------------- 16 | // PROPERTIES OF OBJECTS 17 | // ---------------------------------------------------------------------------- 18 | // NAME | DBWinMutex DBWIN_BUFFER_READY DBWIN_DATA_READY 19 | // ---------------------------------------------------------------------------- 20 | // TYPE | Mutex Event Event 21 | // ACCESS | All All Sync 22 | // INIT STATE | ? Signaled Nonsignaled 23 | // PROPERTY | ? Auto-Reset Auto-Reset 24 | // ---------------------------------------------------------------------------- 25 | 26 | CWinDebugMonitor::CWinDebugMonitor() 27 | { 28 | if (Initialize() != 0) { 29 | ::OutputDebugString(L"CWinDebugMonitor::Initialize failed.\n"); 30 | } 31 | } 32 | 33 | CWinDebugMonitor::~CWinDebugMonitor() 34 | { 35 | Unintialize(); 36 | } 37 | 38 | DWORD CWinDebugMonitor::Initialize() 39 | { 40 | DWORD errorCode = 0; 41 | BOOL bSuccessful = FALSE; 42 | 43 | SetLastError(0); 44 | 45 | // Mutex: DBWin 46 | // --------------------------------------------------------- 47 | m_hDBWinMutex = ::OpenMutex( 48 | MUTEX_ALL_ACCESS, 49 | FALSE, 50 | L"DBWinMutex" 51 | ); 52 | 53 | if (m_hDBWinMutex == NULL) { 54 | errorCode = GetLastError(); 55 | return errorCode; 56 | } 57 | 58 | // Event: buffer ready 59 | // --------------------------------------------------------- 60 | m_hEventBufferReady = ::OpenEvent( 61 | EVENT_ALL_ACCESS, 62 | FALSE, 63 | L"DBWIN_BUFFER_READY" 64 | ); 65 | 66 | if (m_hEventBufferReady == NULL) { 67 | m_hEventBufferReady = ::CreateEvent( 68 | NULL, 69 | FALSE, // auto-reset 70 | TRUE, // initial state: signaled 71 | L"DBWIN_BUFFER_READY" 72 | ); 73 | 74 | if (m_hEventBufferReady == NULL) { 75 | errorCode = GetLastError(); 76 | return errorCode; 77 | } 78 | } 79 | 80 | // Event: data ready 81 | // --------------------------------------------------------- 82 | m_hEventDataReady = ::OpenEvent( 83 | SYNCHRONIZE, 84 | FALSE, 85 | L"DBWIN_DATA_READY" 86 | ); 87 | 88 | if (m_hEventDataReady == NULL) { 89 | m_hEventDataReady = ::CreateEvent( 90 | NULL, 91 | FALSE, // auto-reset 92 | FALSE, // initial state: nonsignaled 93 | L"DBWIN_DATA_READY" 94 | ); 95 | 96 | if (m_hEventDataReady == NULL) { 97 | errorCode = GetLastError(); 98 | return errorCode; 99 | } 100 | } 101 | 102 | // Shared memory 103 | // --------------------------------------------------------- 104 | m_hDBMonBuffer = ::OpenFileMapping( 105 | FILE_MAP_READ, 106 | FALSE, 107 | L"DBWIN_BUFFER" 108 | ); 109 | 110 | if (m_hDBMonBuffer == NULL) { 111 | m_hDBMonBuffer = ::CreateFileMapping( 112 | INVALID_HANDLE_VALUE, 113 | NULL, 114 | PAGE_READWRITE, 115 | 0, 116 | sizeof(struct dbwin_buffer), 117 | L"DBWIN_BUFFER" 118 | ); 119 | 120 | if (m_hDBMonBuffer == NULL) { 121 | errorCode = GetLastError(); 122 | return errorCode; 123 | } 124 | } 125 | 126 | m_pDBBuffer = (struct dbwin_buffer *)::MapViewOfFile( 127 | m_hDBMonBuffer, 128 | SECTION_MAP_READ, 129 | 0, 130 | 0, 131 | 0 132 | ); 133 | 134 | if (m_pDBBuffer == NULL) { 135 | errorCode = GetLastError(); 136 | return errorCode; 137 | } 138 | 139 | m_bWinDebugMonStopped = false; 140 | 141 | return errorCode; 142 | } 143 | 144 | void CWinDebugMonitor::Unintialize() 145 | { 146 | if (m_hWinDebugMonitorThread != NULL) { 147 | m_bWinDebugMonStopped = TRUE; 148 | ::WaitForSingleObject(m_hWinDebugMonitorThread, INFINITE); 149 | } 150 | 151 | if (m_hDBWinMutex != NULL) { 152 | CloseHandle(m_hDBWinMutex); 153 | m_hDBWinMutex = NULL; 154 | } 155 | 156 | if (m_hDBMonBuffer != NULL) { 157 | ::UnmapViewOfFile(m_pDBBuffer); 158 | CloseHandle(m_hDBMonBuffer); 159 | m_hDBMonBuffer = NULL; 160 | } 161 | 162 | if (m_hEventBufferReady != NULL) { 163 | CloseHandle(m_hEventBufferReady); 164 | m_hEventBufferReady = NULL; 165 | } 166 | 167 | if (m_hEventDataReady != NULL) { 168 | CloseHandle(m_hEventDataReady); 169 | m_hEventDataReady = NULL; 170 | } 171 | 172 | m_pDBBuffer = NULL; 173 | } 174 | 175 | const char* CWinDebugMonitor::GetDebugString() 176 | { 177 | DWORD ret = 0; 178 | 179 | // wait for data ready 180 | ret = ::WaitForSingleObject(m_hEventDataReady, TIMEOUT_WIN_DEBUG); 181 | 182 | if (ret == WAIT_OBJECT_0) { 183 | return m_pDBBuffer->data; 184 | } 185 | 186 | return NULL; 187 | } 188 | 189 | 190 | void CWinDebugMonitor::BufferReady() 191 | { 192 | // signal buffer ready 193 | SetEvent(m_hEventBufferReady); 194 | 195 | } 196 | 197 | -------------------------------------------------------------------------------- /AppProcessAngle/WinDebugMonitor.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////// 2 | // 3 | // File: WinDebugMonitor.h 4 | // Description: Interface of class CWinDebugMonitor 5 | // Created: 2007-12-6 6 | // Author: Ken Zhang 7 | // E-Mail: cpp.china@hotmail.com 8 | // 9 | ////////////////////////////////////////////////////////////// 10 | 11 | #ifndef __WIN_DEBUG_BUFFER_H__ 12 | #define __WIN_DEBUG_BUFFER_H__ 13 | #include "pch.h"" 14 | 15 | class CWinDebugMonitor 16 | { 17 | private: 18 | enum { 19 | TIMEOUT_WIN_DEBUG = 200, 20 | }; 21 | 22 | struct dbwin_buffer 23 | { 24 | DWORD dwProcessId; 25 | char data[4096-sizeof(DWORD)]; 26 | }; 27 | 28 | private: 29 | HANDLE m_hDBWinMutex; 30 | HANDLE m_hDBMonBuffer; 31 | HANDLE m_hEventBufferReady; 32 | HANDLE m_hEventDataReady; 33 | 34 | HANDLE m_hWinDebugMonitorThread; 35 | BOOL m_bWinDebugMonStopped; 36 | struct dbwin_buffer *m_pDBBuffer; 37 | 38 | private: 39 | void Unintialize(); 40 | 41 | public: 42 | CWinDebugMonitor(); 43 | ~CWinDebugMonitor(); 44 | 45 | DWORD Initialize(); 46 | const char* GetDebugString(); 47 | void BufferReady(); 48 | 49 | BOOL IsStopped() 50 | { 51 | return m_bWinDebugMonStopped; 52 | } 53 | 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /AppProcessAngle/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /AppProcessAngle/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // Enable function definitions in the GL headers below 7 | #define GL_GLEXT_PROTOTYPES 8 | 9 | // OpenGL ES includes 10 | #include 11 | #include 12 | 13 | // EGL includes 14 | #include 15 | #include 16 | #include 17 | 18 | // ANGLE include for Windows Store 19 | #include -------------------------------------------------------------------------------- /Bridge.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 14 3 | VisualStudioVersion = 14.0.25420.1 4 | MinimumVisualStudioVersion = 10.0.40219.1 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppProcessAngle", "AppProcessAngle\AppProcessAngle.vcxproj", "{FD085EFC-DE70-41A4-9145-A0DFC65CC31F}" 6 | EndProject 7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BridgeLib", "BridgeLib\BridgeLib.vcxproj", "{A9739085-6A90-4F28-9883-645F97BE59E2}" 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FLinux", "FLinux\FLinux.vcxproj", "{FE232EB9-7404-4FD0-B1DA-5D8E4650F782}" 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProcessHost", "ProcessHost\ProcessHost.vcxproj", "{73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|ARM = Debug|ARM 16 | Debug|x86 = Debug|x86 17 | Release|ARM = Release|ARM 18 | Release|x86 = Release|x86 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Debug|ARM.ActiveCfg = Debug|ARM 22 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Debug|ARM.Build.0 = Debug|ARM 23 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Debug|ARM.Deploy.0 = Debug|ARM 24 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Debug|x86.ActiveCfg = Debug|Win32 25 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Debug|x86.Build.0 = Debug|Win32 26 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Release|ARM.ActiveCfg = Release|ARM 27 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Release|ARM.Build.0 = Release|ARM 28 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Release|ARM.Deploy.0 = Release|ARM 29 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Release|x86.ActiveCfg = Release|Win32 30 | {FD085EFC-DE70-41A4-9145-A0DFC65CC31F}.Release|x86.Build.0 = Release|Win32 31 | {A9739085-6A90-4F28-9883-645F97BE59E2}.Debug|ARM.ActiveCfg = Debug|ARM 32 | {A9739085-6A90-4F28-9883-645F97BE59E2}.Debug|ARM.Build.0 = Debug|ARM 33 | {A9739085-6A90-4F28-9883-645F97BE59E2}.Debug|x86.ActiveCfg = Debug|Win32 34 | {A9739085-6A90-4F28-9883-645F97BE59E2}.Debug|x86.Build.0 = Debug|Win32 35 | {A9739085-6A90-4F28-9883-645F97BE59E2}.Release|ARM.ActiveCfg = Release|ARM 36 | {A9739085-6A90-4F28-9883-645F97BE59E2}.Release|ARM.Build.0 = Release|ARM 37 | {A9739085-6A90-4F28-9883-645F97BE59E2}.Release|x86.ActiveCfg = Release|Win32 38 | {A9739085-6A90-4F28-9883-645F97BE59E2}.Release|x86.Build.0 = Release|Win32 39 | {FE232EB9-7404-4FD0-B1DA-5D8E4650F782}.Debug|ARM.ActiveCfg = Debug|ARM 40 | {FE232EB9-7404-4FD0-B1DA-5D8E4650F782}.Debug|ARM.Build.0 = Debug|ARM 41 | {FE232EB9-7404-4FD0-B1DA-5D8E4650F782}.Debug|x86.ActiveCfg = Debug|Win32 42 | {FE232EB9-7404-4FD0-B1DA-5D8E4650F782}.Debug|x86.Build.0 = Debug|Win32 43 | {FE232EB9-7404-4FD0-B1DA-5D8E4650F782}.Release|ARM.ActiveCfg = Release|ARM 44 | {FE232EB9-7404-4FD0-B1DA-5D8E4650F782}.Release|ARM.Build.0 = Release|ARM 45 | {FE232EB9-7404-4FD0-B1DA-5D8E4650F782}.Release|x86.ActiveCfg = Release|Win32 46 | {FE232EB9-7404-4FD0-B1DA-5D8E4650F782}.Release|x86.Build.0 = Release|Win32 47 | {73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}.Debug|ARM.ActiveCfg = Debug|ARM 48 | {73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}.Debug|ARM.Build.0 = Debug|ARM 49 | {73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}.Debug|x86.ActiveCfg = Debug|Win32 50 | {73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}.Debug|x86.Build.0 = Debug|Win32 51 | {73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}.Release|ARM.ActiveCfg = Release|ARM 52 | {73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}.Release|ARM.Build.0 = Release|ARM 53 | {73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}.Release|x86.ActiveCfg = Release|Win32 54 | {73128E2A-8BF8-4E22-96FF-5AC6E6926E7D}.Release|x86.Build.0 = Release|Win32 55 | EndGlobalSection 56 | GlobalSection(SolutionProperties) = preSolution 57 | HideSolutionNode = FALSE 58 | EndGlobalSection 59 | EndGlobal 60 | -------------------------------------------------------------------------------- /ProcessHost/Assets/SplashScreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/ProcessHost/Assets/SplashScreen.png -------------------------------------------------------------------------------- /ProcessHost/Assets/Square150x150Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/ProcessHost/Assets/Square150x150Logo.png -------------------------------------------------------------------------------- /ProcessHost/Assets/Square44x44Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/ProcessHost/Assets/Square44x44Logo.png -------------------------------------------------------------------------------- /ProcessHost/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/ProcessHost/Assets/StoreLogo.png -------------------------------------------------------------------------------- /ProcessHost/Assets/Wide310x150Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/ProcessHost/Assets/Wide310x150Logo.png -------------------------------------------------------------------------------- /ProcessHost/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | AppProcessAngle 7 | Václav 8 | Assets\StoreLogo.png 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ProcessHost/ProcessHost.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ProcessHost.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "android_init.h" 9 | extern "C" 10 | { 11 | #include "../FLinux/src/ntdll.h" 12 | } 13 | 14 | 15 | 16 | void DebugLog(char* pszFormat, ...) { 17 | 18 | static char s_acBuf[2048]; // this here is a caveat! 19 | 20 | va_list args; 21 | 22 | va_start(args, pszFormat); 23 | 24 | vsnprintf(s_acBuf, 2048, pszFormat, args); 25 | 26 | OutputDebugStringA(s_acBuf); 27 | 28 | va_end(args); 29 | } 30 | 31 | struct intstack15 32 | { 33 | intptr_t pos[15]; 34 | }; 35 | 36 | 37 | typedef void(*entrypoint_t)(...); 38 | 39 | std::wstring atow(const char* str) 40 | { 41 | size_t len = strlen(str); 42 | std::wstring ws(len, L' '); // Overestimate number of code points. 43 | ws.resize(std::mbstowcs(&ws[0], str, len)); // Shrink to fit. 44 | return ws; 45 | } 46 | 47 | int filterException(int code, PEXCEPTION_POINTERS ex) { 48 | DebugLog("Filtering 0x%x", code); 49 | DebugLog("Exception code 0x%x", ex->ExceptionRecord->ExceptionCode); 50 | return EXCEPTION_EXECUTE_HANDLER; 51 | } 52 | 53 | void init(const wchar_t* root) 54 | { 55 | __try 56 | { 57 | flinit(root, NULL); 58 | } 59 | __except (filterException(GetExceptionCode(), GetExceptionInformation())) { 60 | DebugLog("caught\n"); 61 | } 62 | 63 | } 64 | 65 | int start() 66 | { 67 | DebugLog("loading dll\n"); 68 | 69 | HMODULE app_process = LoadPackagedLibrary(L"patchoat.dll", 0); 70 | 71 | DebugLog("module handle: 0x%x\n", app_process); 72 | 73 | if (app_process != 0) 74 | { 75 | entrypoint_t _module_entry_point = (entrypoint_t)::GetProcAddress(app_process, "_module_entry_point_"); 76 | 77 | 78 | DebugLog("module entry point 0x%x", _module_entry_point); 79 | 80 | intstack15 stack_params; 81 | 82 | int i = 0; 83 | /*int j = 0; 84 | stack_params.pos[i++] = argc; 85 | for (; j <= argc; i++, j++) 86 | stack_params.pos[i] = (intptr_t)argv[j]; 87 | 88 | stack_params.pos[i++] = 0; 89 | 90 | j = 0; 91 | for (; j < envc; i++, j++) 92 | stack_params.pos[i] = (intptr_t)envp[j];*/ 93 | 94 | stack_params.pos[i++] = 0; 95 | 96 | _module_entry_point( 97 | #ifdef _M_ARM 98 | 0, 0, 0, 0, //skip register params on ARM, we need copy all params to stack 99 | #endif 100 | stack_params); 101 | 102 | return 0; 103 | 104 | } 105 | 106 | return -1; 107 | 108 | } 109 | 110 | int main() 111 | { 112 | //__debugbreak(); 113 | /*HMODULE mod; 114 | RTL_USER_PROCESS_INFORMATION process_info; 115 | NTSTATUS result; 116 | 117 | result = RtlCloneUserProcess(RTL_CLONE_PROCESS_FLAGS_CREATE_SUSPENDED | RTL_CLONE_PROCESS_FLAGS_INHERIT_HANDLES, NULL, NULL, NULL, &process_info); 118 | 119 | 120 | if (result == RTL_CLONE_PARENT) 121 | { 122 | DebugLog("parent\n"); 123 | ResumeThread(process_info.Thread); 124 | } 125 | else if(result == RTL_CLONE_CHILD) 126 | { 127 | DebugLog("child\n"); 128 | } 129 | HANDLE me = GetCurrentProcess();*/ 130 | 131 | 132 | LPCSTR cmdLine = GetCommandLineA(); 133 | DebugLog("command line: %s\n", cmdLine); 134 | 135 | 136 | std::wstring wroot; 137 | int argc = 0; 138 | 139 | int i = 0; 140 | int bufferSize = strlen(cmdLine) + 1; 141 | char* buffer = new char[bufferSize]; 142 | 143 | strcpy_s(buffer, bufferSize, cmdLine); 144 | 145 | while (i < bufferSize && buffer[i] == '-' && buffer[i + 1] == '-') 146 | { 147 | i += 2; //skip -- 148 | 149 | if (!strncmp(buffer + i, "root=", 5)) 150 | { 151 | i += 5; 152 | int strindex = i; 153 | while (buffer[i] != ' ' && buffer[i] != 0) 154 | i++; 155 | buffer[i++] = 0; 156 | wroot = atow(buffer + strindex); 157 | 158 | } 159 | else if (!strncmp(buffer + i, "params=", 7)) 160 | { 161 | i += 7; 162 | argc = atoi(buffer + i); 163 | break; 164 | } 165 | 166 | } 167 | 168 | 169 | 170 | /* HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, GetCurrentProcessId()); 171 | 172 | char sid[100]; 173 | DWORD outLen; 174 | 175 | 176 | if (GetTokenInformation(hProcess, TOKEN_INFORMATION_CLASS::TokenOwner, sid, 100, &outLen)) 177 | { 178 | DebugLog("process handle"); 179 | DebugLog(" %s\n", sid); 180 | }*/ 181 | 182 | init(wroot.c_str()); 183 | 184 | 185 | return start(); 186 | } 187 | -------------------------------------------------------------------------------- /ProcessHost/ProcessHost.h: -------------------------------------------------------------------------------- 1 | #pragma once -------------------------------------------------------------------------------- /ProcessHost/ProcessHost.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | ARM 7 | 8 | 9 | Debug 10 | Win32 11 | 12 | 13 | Release 14 | ARM 15 | 16 | 17 | Release 18 | Win32 19 | 20 | 21 | 22 | {73128e2a-8bf8-4e22-96ff-5ac6e6926e7d} 23 | DynamicLibrary 24 | ProcessHost 25 | en-US 26 | 14.0 27 | true 28 | Windows Store 29 | 10.0.14393.0 30 | 10.0.10586.0 31 | 10.0 32 | 33 | 34 | 35 | Application 36 | true 37 | v140 38 | 39 | 40 | Application 41 | true 42 | v140 43 | 44 | 45 | Application 46 | false 47 | true 48 | v140 49 | 50 | 51 | Application 52 | false 53 | true 54 | v140 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | ProcessHost_TemporaryKey.pfx 76 | True 77 | Never 78 | x86|arm 79 | 1F9F66ACA860BE03752F95CB27443C4E4D825DD5 80 | 81 | 82 | false 83 | false 84 | 85 | 86 | false 87 | false 88 | 89 | 90 | false 91 | false 92 | 93 | 94 | false 95 | false 96 | 97 | 98 | 99 | Use 100 | false 101 | ..\BridgeLib\include\android;%(AdditionalIncludeDirectories) 102 | 103 | 104 | Console 105 | false 106 | false 107 | WindowsApp.lib;OneCoreUAP.Lib;ntdll.lib;%(AdditionalDependencies) 108 | 2097152 109 | 2097152 110 | true 111 | 112 | 113 | 114 | 115 | Use 116 | false 117 | ..\BridgeLib\include\android;%(AdditionalIncludeDirectories) 118 | 119 | 120 | Console 121 | false 122 | false 123 | WindowsApp.lib;OneCoreUAP.Lib;ntdll.lib;%(AdditionalDependencies) 124 | 2097152 125 | 2097152 126 | true 127 | 128 | 129 | 130 | 131 | Use 132 | false 133 | ..\BridgeLib\include\android;%(AdditionalIncludeDirectories) 134 | 135 | 136 | Console 137 | false 138 | false 139 | WindowsApp.lib;OneCoreUAP.Lib;ntdll.lib;%(AdditionalDependencies) 140 | 2097152 141 | 2097152 142 | true 143 | 144 | 145 | 146 | 147 | Use 148 | false 149 | ..\Bridgelib\include\android;%(AdditionalIncludeDirectories) 150 | 151 | 152 | Console 153 | false 154 | false 155 | WindowsApp.lib;OneCoreUAP.Lib;ntdll.lib;%(AdditionalDependencies) 156 | 2097152 157 | 2097152 158 | true 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | Create 170 | Create 171 | Create 172 | Create 173 | 174 | 175 | 176 | 177 | {a9739085-6a90-4f28-9883-645f97be59e2} 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | Manifest 194 | Designer 195 | 196 | 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /ProcessHost/ProcessHost.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Resource Files 21 | 22 | 23 | Resource Files 24 | 25 | 26 | Resource Files 27 | 28 | 29 | Resource Files 30 | 31 | 32 | Resource Files 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /ProcessHost/ProcessHost_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DroidOnUWP/Bridge/2855b4bfe8a42218ee1cd578d0d8849838a877bf/ProcessHost/ProcessHost_TemporaryKey.pfx -------------------------------------------------------------------------------- /ProcessHost/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /ProcessHost/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define _CRT_SECURE_NO_WARNINGS 4 | 5 | 6 | #include "targetver.h" 7 | 8 | #ifndef WIN32_LEAN_AND_MEAN 9 | #define WIN32_LEAN_AND_MEAN 10 | #endif 11 | 12 | #include 13 | -------------------------------------------------------------------------------- /ProcessHost/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android bridge for UWP applications 2 | Allows run Android Runtime as an UWP app. 3 | 4 | [![Build status](https://ci.appveyor.com/api/projects/status/h0a9b5qfy3rq4amf/branch/master?svg=true)](https://ci.appveyor.com/project/WallyCZ/bridge/branch/master) 5 | 6 | [![Join the chat at https://gitter.im/DroidOnUWP/Bridge](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/DroidOnUWP/Bridge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 7 | 8 | 9 | # Status 10 | - currently only ARM7 is supported 11 | - fork does not work correctly - needs to do some more research and find way, that works under UWP 12 | - Android Runtime initializes, but than it crashes when launching app 13 | - Android 7.1.1 r13 is used 14 | - Visual Studio 2015 supported 15 | 16 | # Build 17 | 1. Clone repo including submodules 18 | 2. Install Angle templates(run Angle\templates\install.bat) and build Angle solution (Angle\winrt\10\gyp\All.vcxproj) separately 19 | 3. Open Bridge.sln 20 | 4. Choose target ARM device 21 | 5. Build 22 | 23 | # FAQ 24 | Q: When debugging in Visual Studio Access violation exception occurs. How to fix it? 25 | A: Uncheck "Break when this exception type is thrown", so FLinux exception handler can work correctly -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: Visual Studio 2015 3 | configuration: 4 | - Debug 5 | - Release 6 | platform: 7 | - x86 8 | - ARM 9 | environment: 10 | AngleRootPath: '%APPVEYOR_BUILD_FOLDER%\angle' 11 | install: 12 | - cmd: >- 13 | git submodule update --init --recursive 14 | 15 | set 16 | before_build: 17 | - cmd: >- 18 | SET ANGLE_PLATFORM=%Platform% 19 | 20 | IF %ANGLE_PLATFORM%==x86 SET ANGLE_PLATFORM=Win32 21 | 22 | msbuild Angle\winrt\10\src\angle.sln /verbosity:minimal /p:configuration=%Configuration% /p:platform=%ANGLE_PLATFORM% 23 | build: 24 | project: Bridge.sln 25 | verbosity: minimal 26 | artifacts: 27 | - path: AppPackages\AppProcessAngle\AppProcessAngle_*\AppProcessAngle_*.appx 28 | name: AppProcessAngle_appx 29 | - path: AppPackages\AppProcessAngle\AppProcessAngle_*\AppProcessAngle_*.appxsym 30 | name: AppProcessAngle_appxsym --------------------------------------------------------------------------------