Adding Widows Phone 8 sample apps
Signed-off-by: Maxim Kostin <v-maxkos@microsoft.com>
87
samples/wp8/.gitignore
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
# Ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
|
||||
#ignore winrt copies of opencv files
|
||||
opencl_kernels.cpp
|
||||
opencl_kernels.hpp
|
||||
|
||||
# Ignore files build by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.aps
|
||||
*.vcproj.*.user
|
||||
*.vcxproj.user
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*.i
|
||||
*.icf
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
*.winmd
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.sbr
|
||||
*.sdf
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
ipch/
|
||||
*.opensdf
|
||||
Generated Files
|
||||
AppPackages
|
||||
SubmissionInfo
|
||||
*.hps
|
||||
|
||||
# Ignore files build by ndk and eclipse
|
||||
libs/
|
||||
bin/
|
||||
obj/
|
||||
gen/
|
||||
local.properties
|
||||
|
||||
# Ignore python compiled files
|
||||
*.pyc
|
||||
|
||||
# Ignore files build by airplay and marmalade
|
||||
build_*_xcode/
|
||||
build_*_vc10/
|
||||
|
||||
# Ignore files built by xcode
|
||||
*.mode*v*
|
||||
*.pbxuser
|
||||
*.xcbkptlist
|
||||
*.xcscheme
|
||||
*.xcworkspacedata
|
||||
*.xcuserstate
|
||||
xcschememanagement.plist
|
||||
build/
|
||||
.DS_Store
|
||||
._.*
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
*.xccheckout
|
||||
|
||||
# Ignore files built by bada
|
||||
.Simulator-Debug/
|
||||
.Target-Debug/
|
||||
.Target-Release/
|
||||
|
||||
# Ignore files built by blackberry
|
||||
Simulator/
|
||||
Device-Debug/
|
||||
Device-Release/
|
||||
|
||||
# Ignore vim swaps
|
||||
*.swp
|
||||
|
||||
# CTags
|
||||
tags
|
76
samples/wp8/OcvImageManipulation/ImageManipulation.sln
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcvImageManipulation", "PhoneXamlDirect3DApp1\PhoneXamlDirect3DApp1\OcvImageManipulation.csproj", "{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PhoneXamlDirect3DApp1Comp", "PhoneXamlDirect3DApp1\PhoneXamlDirect3DApp1Comp\PhoneXamlDirect3DApp1Comp.vcxproj", "{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|Mixed Platforms = Release|Mixed Platforms
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Win32.ActiveCfg = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Win32.Build.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Win32.Deploy.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|x86.Build.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|ARM.Build.0 = Release|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Win32.ActiveCfg = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Win32.Build.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Win32.Deploy.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|x86.ActiveCfg = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|x86.Build.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|x86.Deploy.0 = Release|x86
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|x86.Build.0 = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|ARM.Build.0 = Release|ARM
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Win32.Build.0 = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -0,0 +1,20 @@
|
||||
<Application
|
||||
x:Class="PhoneXamlDirect3DApp1.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
|
||||
|
||||
<!--Application Resources-->
|
||||
<Application.Resources>
|
||||
<local:LocalizedStrings xmlns:local="clr-namespace:PhoneXamlDirect3DApp1" x:Key="LocalizedStrings"/>
|
||||
</Application.Resources>
|
||||
|
||||
<Application.ApplicationLifetimeObjects>
|
||||
<!--Required object that handles lifetime events for the application-->
|
||||
<shell:PhoneApplicationService
|
||||
Launching="Application_Launching" Closing="Application_Closing"
|
||||
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||
</Application.ApplicationLifetimeObjects>
|
||||
|
||||
</Application>
|
@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Resources;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using PhoneXamlDirect3DApp1.Resources;
|
||||
|
||||
namespace PhoneXamlDirect3DApp1
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides easy access to the root frame of the Phone Application.
|
||||
/// </summary>
|
||||
/// <returns>The root frame of the Phone Application.</returns>
|
||||
public static PhoneApplicationFrame RootFrame { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Application object.
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
// Global handler for uncaught exceptions.
|
||||
UnhandledException += Application_UnhandledException;
|
||||
|
||||
// Standard XAML initialization
|
||||
InitializeComponent();
|
||||
|
||||
// Phone-specific initialization
|
||||
InitializePhoneApplication();
|
||||
|
||||
// Language display initialization
|
||||
InitializeLanguage();
|
||||
|
||||
// Show graphics profiling information while debugging.
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// Display the current frame rate counters.
|
||||
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||
|
||||
// Show the areas of the app that are being redrawn in each frame.
|
||||
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||
|
||||
// Enable non-production analysis visualization mode,
|
||||
// which shows areas of a page that are handed off to GPU with a colored overlay.
|
||||
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||
|
||||
// Prevent the screen from turning off while under the debugger by disabling
|
||||
// the application's idle detection.
|
||||
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
|
||||
// and consume battery power when the user is not using the phone.
|
||||
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Code to execute when the application is launching (eg, from Start)
|
||||
// This code will not execute when the application is reactivated
|
||||
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is activated (brought to foreground)
|
||||
// This code will not execute when the application is first launched
|
||||
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is deactivated (sent to background)
|
||||
// This code will not execute when the application is closing
|
||||
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is closing (eg, user hit Back)
|
||||
// This code will not execute when the application is deactivated
|
||||
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute if a navigation fails
|
||||
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// A navigation has failed; break into the debugger
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
// Code to execute on Unhandled Exceptions
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// An unhandled exception has occurred; break into the debugger
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
#region Phone application initialization
|
||||
|
||||
// Avoid double-initialization
|
||||
private bool phoneApplicationInitialized = false;
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void InitializePhoneApplication()
|
||||
{
|
||||
if (phoneApplicationInitialized)
|
||||
return;
|
||||
|
||||
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||
// screen to remain active until the application is ready to render.
|
||||
RootFrame = new PhoneApplicationFrame();
|
||||
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||
|
||||
// Handle navigation failures
|
||||
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||
|
||||
// Handle reset requests for clearing the backstack
|
||||
RootFrame.Navigated += CheckForResetNavigation;
|
||||
|
||||
// Ensure we don't initialize again
|
||||
phoneApplicationInitialized = true;
|
||||
}
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Set the root visual to allow the application to render
|
||||
if (RootVisual != RootFrame)
|
||||
RootVisual = RootFrame;
|
||||
|
||||
// Remove this handler since it is no longer needed
|
||||
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||
}
|
||||
|
||||
private void CheckForResetNavigation(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// If the app has received a 'reset' navigation, then we need to check
|
||||
// on the next navigation to see if the page stack should be reset
|
||||
if (e.NavigationMode == NavigationMode.Reset)
|
||||
RootFrame.Navigated += ClearBackStackAfterReset;
|
||||
}
|
||||
|
||||
private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Unregister the event so it doesn't get called again
|
||||
RootFrame.Navigated -= ClearBackStackAfterReset;
|
||||
|
||||
// Only clear the stack for 'new' (forward) and 'refresh' navigations
|
||||
if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh)
|
||||
return;
|
||||
|
||||
// For UI consistency, clear the entire page stack
|
||||
while (RootFrame.RemoveBackEntry() != null)
|
||||
{
|
||||
; // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Initialize the app's font and flow direction as defined in its localized resource strings.
|
||||
//
|
||||
// To ensure that the font of your application is aligned with its supported languages and that the
|
||||
// FlowDirection for each of those languages follows its traditional direction, ResourceLanguage
|
||||
// and ResourceFlowDirection should be initialized in each resx file to match these values with that
|
||||
// file's culture. For example:
|
||||
//
|
||||
// AppResources.es-ES.resx
|
||||
// ResourceLanguage's value should be "es-ES"
|
||||
// ResourceFlowDirection's value should be "LeftToRight"
|
||||
//
|
||||
// AppResources.ar-SA.resx
|
||||
// ResourceLanguage's value should be "ar-SA"
|
||||
// ResourceFlowDirection's value should be "RightToLeft"
|
||||
//
|
||||
// For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072.
|
||||
//
|
||||
private void InitializeLanguage()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Set the font to match the display language defined by the
|
||||
// ResourceLanguage resource string for each supported language.
|
||||
//
|
||||
// Fall back to the font of the neutral language if the Display
|
||||
// language of the phone is not supported.
|
||||
//
|
||||
// If a compiler error is hit then ResourceLanguage is missing from
|
||||
// the resource file.
|
||||
RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage);
|
||||
|
||||
// Set the FlowDirection of all elements under the root frame based
|
||||
// on the ResourceFlowDirection resource string for each
|
||||
// supported language.
|
||||
//
|
||||
// If a compiler error is hit then ResourceFlowDirection is missing from
|
||||
// the resource file.
|
||||
FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection);
|
||||
RootFrame.FlowDirection = flow;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// If an exception is caught here it is most likely due to either
|
||||
// ResourceLangauge not being correctly set to a supported language
|
||||
// code or ResourceFlowDirection is set to a value other than LeftToRight
|
||||
// or RightToLeft.
|
||||
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
Debugger.Break();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 9.7 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 3.6 KiB |
@ -0,0 +1,14 @@
|
||||
using PhoneXamlDirect3DApp1.Resources;
|
||||
|
||||
namespace PhoneXamlDirect3DApp1
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to string resources.
|
||||
/// </summary>
|
||||
public class LocalizedStrings
|
||||
{
|
||||
private static AppResources _localizedResources = new AppResources();
|
||||
|
||||
public AppResources LocalizedResources { get { return _localizedResources; } }
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<phone:PhoneApplicationPage
|
||||
x:Class="PhoneXamlDirect3DApp1.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<DrawingSurface x:Name="DrawingSurface" Loaded="DrawingSurface_Loaded" />
|
||||
<StackPanel Margin="40">
|
||||
<RadioButton x:Name="Normal" Content="Normal" GroupName="Group1"
|
||||
Checked="RadioButton_Checked" IsChecked="True"/>
|
||||
<RadioButton x:Name="Gray" Content="Gray" GroupName="Group1"
|
||||
Checked="RadioButton_Checked"/>
|
||||
<RadioButton x:Name="Canny" Content="Canny" GroupName="Group1"
|
||||
Checked="RadioButton_Checked"/>
|
||||
<RadioButton x:Name="Sepia" Content="Sepia" GroupName="Group1"
|
||||
Checked="RadioButton_Checked"/>
|
||||
<RadioButton x:Name="Features" Content="Features" GroupName="Group1"
|
||||
Checked="RadioButton_Checked"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0">
|
||||
<TextBlock Text="Memory: "/>
|
||||
<TextBlock x:Name="MemoryTextBlock"/>
|
||||
<TextBlock Text=" MB"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="20,0,0,0">
|
||||
<TextBlock Text="Peak Memory: "/>
|
||||
<TextBlock x:Name="PeakMemoryTextBlock"/>
|
||||
<TextBlock Text=" MB"/>
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</phone:PhoneApplicationPage>
|
@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using PhoneXamlDirect3DApp1Comp;
|
||||
using Microsoft.Phone.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Threading;
|
||||
using System.Windows.Resources;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Microsoft.Xna.Framework.Media;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.Phone.Info;
|
||||
|
||||
namespace PhoneXamlDirect3DApp1
|
||||
{
|
||||
public partial class MainPage : PhoneApplicationPage
|
||||
{
|
||||
private Direct3DInterop m_d3dInterop = new Direct3DInterop();
|
||||
private DispatcherTimer m_timer;
|
||||
|
||||
// Constructor
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
m_timer = new DispatcherTimer();
|
||||
m_timer.Interval = new TimeSpan(0, 0, 1);
|
||||
m_timer.Tick += new EventHandler(timer_Tick);
|
||||
m_timer.Start();
|
||||
}
|
||||
|
||||
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Set window bounds in dips
|
||||
m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
|
||||
(float)DrawingSurface.ActualWidth,
|
||||
(float)DrawingSurface.ActualHeight
|
||||
);
|
||||
|
||||
// Set native resolution in pixels
|
||||
m_d3dInterop.NativeResolution = new Windows.Foundation.Size(
|
||||
(float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
|
||||
(float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
|
||||
);
|
||||
|
||||
// Set render resolution to the full native resolution
|
||||
m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution;
|
||||
|
||||
// Hook-up native component to DrawingSurface
|
||||
DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider());
|
||||
DrawingSurface.SetManipulationHandler(m_d3dInterop);
|
||||
}
|
||||
|
||||
private void RadioButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RadioButton rb = sender as RadioButton;
|
||||
switch (rb.Name)
|
||||
{
|
||||
case "Normal":
|
||||
m_d3dInterop.SetAlgorithm(OCVFilterType.ePreview);
|
||||
break;
|
||||
|
||||
case "Gray":
|
||||
m_d3dInterop.SetAlgorithm(OCVFilterType.eGray);
|
||||
break;
|
||||
|
||||
case "Canny":
|
||||
m_d3dInterop.SetAlgorithm(OCVFilterType.eCanny);
|
||||
break;
|
||||
|
||||
case "Sepia":
|
||||
m_d3dInterop.SetAlgorithm(OCVFilterType.eSepia);
|
||||
break;
|
||||
|
||||
case "Features":
|
||||
m_d3dInterop.SetAlgorithm(OCVFilterType.eFindFeatures);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// These are TextBlock controls that are created in the page’s XAML file.
|
||||
float value = DeviceStatus.ApplicationCurrentMemoryUsage / (1024.0f * 1024.0f) ;
|
||||
MemoryTextBlock.Text = value.ToString();
|
||||
value = DeviceStatus.ApplicationPeakMemoryUsage / (1024.0f * 1024.0f);
|
||||
PeakMemoryTextBlock.Text = value.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MemoryTextBlock.Text = ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20506</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}</ProjectGuid>
|
||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PhoneXamlDirect3DApp1</RootNamespace>
|
||||
<AssemblyName>PhoneXamlDirect3DApp1</AssemblyName>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||
<SilverlightApplication>true</SilverlightApplication>
|
||||
<SupportedCultures>
|
||||
</SupportedCultures>
|
||||
<XapOutputs>true</XapOutputs>
|
||||
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||
<XapFilename>PhoneXamlDirect3DApp1_$(Configuration)_$(Platform).xap</XapFilename>
|
||||
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||
<SilverlightAppEntry>PhoneXamlDirect3DApp1.App</SilverlightAppEntry>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\x86\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\x86\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\ARM\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\ARM\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LocalizedStrings.cs" />
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resources\AppResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>AppResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AppManifest.xml" />
|
||||
<None Include="Properties\WMAppManifest.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\AlignmentGrid.png" />
|
||||
<Content Include="Assets\ApplicationIcon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\FlipCycleTileLarge.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\FlipCycleTileMedium.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\FlipCycleTileSmall.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\IconicTileMediumLarge.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\IconicTileSmall.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SplashScreenImage.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PhoneXamlDirect3DApp1Comp\PhoneXamlDirect3DApp1Comp.vcxproj">
|
||||
<Name>PhoneXamlDirect3DApp1Comp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\AppResources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ProjectExtensions />
|
||||
</Project>
|
@ -0,0 +1,6 @@
|
||||
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
>
|
||||
<Deployment.Parts>
|
||||
</Deployment.Parts>
|
||||
</Deployment>
|
@ -0,0 +1,37 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Resources;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PhoneXamlDirect3DApp1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PhoneXamlDirect3DApp1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8ca838f9-f7c6-4550-9b89-59e915a2cddb")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
|
||||
<DefaultLanguage xmlns="" code="en-US" />
|
||||
<App xmlns="" ProductID="{cc734b3d-d8f2-4528-b223-0e7b8a4f6cc7}" Title="OCVImageManipulation" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="Microsoft Open Technologies, Inc." Description="Sample description" Publisher="Microsoft Open Technologies, Inc." PublisherID="{4029c95e-d442-45ca-b556-33d7e3bde613}">
|
||||
<IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
|
||||
<Capabilities>
|
||||
<Capability Name="ID_CAP_SENSORS" />
|
||||
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
|
||||
<Capability Name="ID_CAP_NETWORKING" />
|
||||
<Capability Name="ID_CAP_ISV_CAMERA" />
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="PhoneXamlDirect3DApp1Token" TaskName="_default">
|
||||
<TemplateFlip>
|
||||
<SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
|
||||
<Count>0</Count>
|
||||
<BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
|
||||
<Title>OCVImageManipulation</Title>
|
||||
<BackContent>
|
||||
</BackContent>
|
||||
<BackBackgroundImageURI>
|
||||
</BackBackgroundImageURI>
|
||||
<BackTitle>
|
||||
</BackTitle>
|
||||
<DeviceLockImageURI>
|
||||
</DeviceLockImageURI>
|
||||
<HasLarge>
|
||||
</HasLarge>
|
||||
</TemplateFlip>
|
||||
</PrimaryToken>
|
||||
</Tokens>
|
||||
<ScreenResolutions>
|
||||
<ScreenResolution Name="ID_RESOLUTION_WVGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_WXGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_HD720P" />
|
||||
</ScreenResolutions>
|
||||
</App>
|
||||
</Deployment>
|
@ -0,0 +1,105 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17626
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PhoneXamlDirect3DApp1.Resources
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class AppResources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal AppResources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PhoneXamlDirect3DApp1.Resources.AppResources", typeof(AppResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to LeftToRight.
|
||||
/// </summary>
|
||||
public static string ResourceFlowDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to us-EN.
|
||||
/// </summary>
|
||||
public static string ResourceLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ResourceLanguage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to MY APPLICATION.
|
||||
/// </summary>
|
||||
public static string ApplicationTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ApplicationTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ResourceFlowDirection" xml:space="preserve">
|
||||
<value>LeftToRight</value>
|
||||
<comment>Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language</comment>
|
||||
</data>
|
||||
<data name="ResourceLanguage" xml:space="preserve">
|
||||
<value>en-US</value>
|
||||
<comment>Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.</comment>
|
||||
</data>
|
||||
<data name="ApplicationTitle" xml:space="preserve">
|
||||
<value>MY APPLICATION</value>
|
||||
</data>
|
||||
</root>
|
After Width: | Height: | Size: 118 KiB |
@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
#include <wrl.h>
|
||||
|
||||
// Helper class for basic timing.
|
||||
ref class BasicTimer sealed
|
||||
{
|
||||
public:
|
||||
// Initializes internal timer values.
|
||||
BasicTimer()
|
||||
{
|
||||
if (!QueryPerformanceFrequency(&m_frequency))
|
||||
{
|
||||
throw ref new Platform::FailureException();
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
// Reset the timer to initial values.
|
||||
void Reset()
|
||||
{
|
||||
Update();
|
||||
m_startTime = m_currentTime;
|
||||
m_total = 0.0f;
|
||||
m_delta = 1.0f / 60.0f;
|
||||
}
|
||||
|
||||
// Update the timer's internal values.
|
||||
void Update()
|
||||
{
|
||||
if (!QueryPerformanceCounter(&m_currentTime))
|
||||
{
|
||||
throw ref new Platform::FailureException();
|
||||
}
|
||||
|
||||
m_total = static_cast<float>(
|
||||
static_cast<double>(m_currentTime.QuadPart - m_startTime.QuadPart) /
|
||||
static_cast<double>(m_frequency.QuadPart)
|
||||
);
|
||||
|
||||
if (m_lastTime.QuadPart == m_startTime.QuadPart)
|
||||
{
|
||||
// If the timer was just reset, report a time delta equivalent to 60Hz frame time.
|
||||
m_delta = 1.0f / 60.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_delta = static_cast<float>(
|
||||
static_cast<double>(m_currentTime.QuadPart - m_lastTime.QuadPart) /
|
||||
static_cast<double>(m_frequency.QuadPart)
|
||||
);
|
||||
}
|
||||
|
||||
m_lastTime = m_currentTime;
|
||||
}
|
||||
|
||||
// Duration in seconds between the last call to Reset() and the last call to Update().
|
||||
property float Total
|
||||
{
|
||||
float get() { return m_total; }
|
||||
}
|
||||
|
||||
// Duration in seconds between the previous two calls to Update().
|
||||
property float Delta
|
||||
{
|
||||
float get() { return m_delta; }
|
||||
}
|
||||
|
||||
private:
|
||||
LARGE_INTEGER m_frequency;
|
||||
LARGE_INTEGER m_currentTime;
|
||||
LARGE_INTEGER m_startTime;
|
||||
LARGE_INTEGER m_lastTime;
|
||||
float m_total;
|
||||
float m_delta;
|
||||
};
|
@ -0,0 +1,162 @@
|
||||
#include "pch.h"
|
||||
#include "Direct3DBase.h"
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::Graphics::Display;
|
||||
|
||||
// Constructor.
|
||||
Direct3DBase::Direct3DBase()
|
||||
{
|
||||
}
|
||||
|
||||
// Initialize the Direct3D resources required to run.
|
||||
void Direct3DBase::Initialize()
|
||||
{
|
||||
CreateDeviceResources();
|
||||
}
|
||||
|
||||
// These are the resources that depend on the device.
|
||||
void Direct3DBase::CreateDeviceResources()
|
||||
{
|
||||
// This flag adds support for surfaces with a different color channel ordering
|
||||
// than the API default. It is required for compatibility with Direct2D.
|
||||
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
|
||||
|
||||
#if defined(_DEBUG)
|
||||
// If the project is in a debug build, enable debugging via SDK Layers with this flag.
|
||||
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
#endif
|
||||
|
||||
// This array defines the set of DirectX hardware feature levels this app will support.
|
||||
// Note the ordering should be preserved.
|
||||
// Don't forget to declare your application's minimum required feature level in its
|
||||
// description. All applications are assumed to support 9.1 unless otherwise stated.
|
||||
D3D_FEATURE_LEVEL featureLevels[] =
|
||||
{
|
||||
D3D_FEATURE_LEVEL_11_1,
|
||||
D3D_FEATURE_LEVEL_11_0,
|
||||
D3D_FEATURE_LEVEL_10_1,
|
||||
D3D_FEATURE_LEVEL_10_0,
|
||||
D3D_FEATURE_LEVEL_9_3
|
||||
};
|
||||
|
||||
// Create the Direct3D 11 API device object and a corresponding context.
|
||||
ComPtr<ID3D11Device> device;
|
||||
ComPtr<ID3D11DeviceContext> context;
|
||||
DX::ThrowIfFailed(
|
||||
D3D11CreateDevice(
|
||||
nullptr, // Specify nullptr to use the default adapter.
|
||||
D3D_DRIVER_TYPE_HARDWARE,
|
||||
nullptr,
|
||||
creationFlags, // Set set debug and Direct2D compatibility flags.
|
||||
featureLevels, // List of feature levels this app can support.
|
||||
ARRAYSIZE(featureLevels),
|
||||
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION.
|
||||
&device, // Returns the Direct3D device created.
|
||||
&m_featureLevel, // Returns feature level of device created.
|
||||
&context // Returns the device immediate context.
|
||||
)
|
||||
);
|
||||
|
||||
// Get the Direct3D 11.1 API device and context interfaces.
|
||||
DX::ThrowIfFailed(
|
||||
device.As(&m_d3dDevice)
|
||||
);
|
||||
|
||||
DX::ThrowIfFailed(
|
||||
context.As(&m_d3dContext)
|
||||
);
|
||||
}
|
||||
|
||||
// Allocate all memory resources that depend on the window size.
|
||||
void Direct3DBase::CreateWindowSizeDependentResources()
|
||||
{
|
||||
// Create a descriptor for the render target buffer.
|
||||
CD3D11_TEXTURE2D_DESC renderTargetDesc(
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
static_cast<UINT>(m_renderTargetSize.Width),
|
||||
static_cast<UINT>(m_renderTargetSize.Height),
|
||||
1,
|
||||
1,
|
||||
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE
|
||||
);
|
||||
renderTargetDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | D3D11_RESOURCE_MISC_SHARED_NTHANDLE;
|
||||
|
||||
// Allocate a 2-D surface as the render target buffer.
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateTexture2D(
|
||||
&renderTargetDesc,
|
||||
nullptr,
|
||||
&m_renderTarget
|
||||
)
|
||||
);
|
||||
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateRenderTargetView(
|
||||
m_renderTarget.Get(),
|
||||
nullptr,
|
||||
&m_renderTargetView
|
||||
)
|
||||
);
|
||||
|
||||
// Create a depth stencil view.
|
||||
CD3D11_TEXTURE2D_DESC depthStencilDesc(
|
||||
DXGI_FORMAT_D24_UNORM_S8_UINT,
|
||||
static_cast<UINT>(m_renderTargetSize.Width),
|
||||
static_cast<UINT>(m_renderTargetSize.Height),
|
||||
1,
|
||||
1,
|
||||
D3D11_BIND_DEPTH_STENCIL
|
||||
);
|
||||
|
||||
ComPtr<ID3D11Texture2D> depthStencil;
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateTexture2D(
|
||||
&depthStencilDesc,
|
||||
nullptr,
|
||||
&depthStencil
|
||||
)
|
||||
);
|
||||
|
||||
CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D);
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateDepthStencilView(
|
||||
depthStencil.Get(),
|
||||
&depthStencilViewDesc,
|
||||
&m_depthStencilView
|
||||
)
|
||||
);
|
||||
|
||||
// Set the rendering viewport to target the entire window.
|
||||
CD3D11_VIEWPORT viewport(
|
||||
0.0f,
|
||||
0.0f,
|
||||
m_renderTargetSize.Width,
|
||||
m_renderTargetSize.Height
|
||||
);
|
||||
|
||||
m_d3dContext->RSSetViewports(1, &viewport);
|
||||
}
|
||||
|
||||
void Direct3DBase::UpdateForRenderResolutionChange(float width, float height)
|
||||
{
|
||||
m_renderTargetSize.Width = width;
|
||||
m_renderTargetSize.Height = height;
|
||||
|
||||
ID3D11RenderTargetView* nullViews[] = {nullptr};
|
||||
m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
|
||||
m_renderTarget = nullptr;
|
||||
m_renderTargetView = nullptr;
|
||||
m_depthStencilView = nullptr;
|
||||
m_d3dContext->Flush();
|
||||
CreateWindowSizeDependentResources();
|
||||
}
|
||||
|
||||
void Direct3DBase::UpdateForWindowSizeChange(float width, float height)
|
||||
{
|
||||
m_windowBounds.Width = width;
|
||||
m_windowBounds.Height = height;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "DirectXHelper.h"
|
||||
|
||||
// Helper class that initializes DirectX APIs for 3D rendering.
|
||||
ref class Direct3DBase abstract
|
||||
{
|
||||
internal:
|
||||
Direct3DBase();
|
||||
|
||||
public:
|
||||
virtual void Initialize();
|
||||
virtual void CreateDeviceResources();
|
||||
virtual void CreateWindowSizeDependentResources();
|
||||
virtual void UpdateForRenderResolutionChange(float width, float height);
|
||||
virtual void UpdateForWindowSizeChange(float width, float height);
|
||||
virtual void Render() = 0;
|
||||
|
||||
internal:
|
||||
virtual ID3D11Texture2D* GetTexture()
|
||||
{
|
||||
return m_renderTarget.Get();
|
||||
}
|
||||
|
||||
protected private:
|
||||
// Direct3D Objects.
|
||||
Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
|
||||
Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_renderTarget;
|
||||
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
|
||||
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_depthStencilView;
|
||||
|
||||
// Cached renderer properties.
|
||||
D3D_FEATURE_LEVEL m_featureLevel;
|
||||
Windows::Foundation::Size m_renderTargetSize;
|
||||
Windows::Foundation::Rect m_windowBounds;
|
||||
};
|
@ -0,0 +1,77 @@
|
||||
#include "pch.h"
|
||||
#include "Direct3DContentProvider.h"
|
||||
|
||||
using namespace PhoneXamlDirect3DApp1Comp;
|
||||
|
||||
Direct3DContentProvider::Direct3DContentProvider(Direct3DInterop^ controller) :
|
||||
m_controller(controller)
|
||||
{
|
||||
m_controller->RequestAdditionalFrame += ref new RequestAdditionalFrameHandler([=] ()
|
||||
{
|
||||
if (m_host)
|
||||
{
|
||||
m_host->RequestAdditionalFrame();
|
||||
}
|
||||
});
|
||||
|
||||
m_controller->RecreateSynchronizedTexture += ref new RecreateSynchronizedTextureHandler([=] ()
|
||||
{
|
||||
if (m_host)
|
||||
{
|
||||
m_host->CreateSynchronizedTexture(m_controller->GetTexture(), &m_synchronizedTexture);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// IDrawingSurfaceContentProviderNative interface
|
||||
HRESULT Direct3DContentProvider::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host)
|
||||
{
|
||||
m_host = host;
|
||||
|
||||
return m_controller->Connect(host);
|
||||
}
|
||||
|
||||
void Direct3DContentProvider::Disconnect()
|
||||
{
|
||||
m_controller->Disconnect();
|
||||
m_host = nullptr;
|
||||
m_synchronizedTexture = nullptr;
|
||||
}
|
||||
|
||||
HRESULT Direct3DContentProvider::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty)
|
||||
{
|
||||
return m_controller->PrepareResources(presentTargetTime, contentDirty);
|
||||
}
|
||||
|
||||
HRESULT Direct3DContentProvider::GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (!m_synchronizedTexture)
|
||||
{
|
||||
hr = m_host->CreateSynchronizedTexture(m_controller->GetTexture(), &m_synchronizedTexture);
|
||||
}
|
||||
|
||||
// Set output parameters.
|
||||
textureSubRectangle->left = 0.0f;
|
||||
textureSubRectangle->top = 0.0f;
|
||||
textureSubRectangle->right = static_cast<FLOAT>(size->width);
|
||||
textureSubRectangle->bottom = static_cast<FLOAT>(size->height);
|
||||
|
||||
m_synchronizedTexture.CopyTo(synchronizedTexture);
|
||||
|
||||
// Draw to the texture.
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = m_synchronizedTexture->BeginDraw();
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = m_controller->GetTexture(size, synchronizedTexture, textureSubRectangle);
|
||||
}
|
||||
|
||||
m_synchronizedTexture->EndDraw();
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
#include <wrl/module.h>
|
||||
#include <Windows.Phone.Graphics.Interop.h>
|
||||
#include <DrawingSurfaceNative.h>
|
||||
|
||||
#include "Direct3DInterop.h"
|
||||
|
||||
class Direct3DContentProvider : public Microsoft::WRL::RuntimeClass<
|
||||
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::WinRtClassicComMix>,
|
||||
ABI::Windows::Phone::Graphics::Interop::IDrawingSurfaceContentProvider,
|
||||
IDrawingSurfaceContentProviderNative>
|
||||
{
|
||||
public:
|
||||
Direct3DContentProvider(PhoneXamlDirect3DApp1Comp::Direct3DInterop^ controller);
|
||||
|
||||
void ReleaseD3DResources();
|
||||
|
||||
// IDrawingSurfaceContentProviderNative
|
||||
HRESULT STDMETHODCALLTYPE Connect(_In_ IDrawingSurfaceRuntimeHostNative* host);
|
||||
void STDMETHODCALLTYPE Disconnect();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty);
|
||||
HRESULT STDMETHODCALLTYPE GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle);
|
||||
|
||||
private:
|
||||
HRESULT InitializeTexture(_In_ const DrawingSurfaceSizeF* size);
|
||||
|
||||
PhoneXamlDirect3DApp1Comp::Direct3DInterop^ m_controller;
|
||||
Microsoft::WRL::ComPtr<IDrawingSurfaceRuntimeHostNative> m_host;
|
||||
Microsoft::WRL::ComPtr<IDrawingSurfaceSynchronizedTextureNative> m_synchronizedTexture;
|
||||
};
|
@ -0,0 +1,351 @@
|
||||
#include "pch.h"
|
||||
#include "Direct3DInterop.h"
|
||||
#include "Direct3DContentProvider.h"
|
||||
#include <windows.storage.streams.h>
|
||||
#include <wrl.h>
|
||||
#include <robuffer.h>
|
||||
#include <opencv2\core\core.hpp>
|
||||
#include <opencv2\imgproc\imgproc.hpp>
|
||||
#include <opencv2\features2d\features2d.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Windows::Storage::Streams;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Windows::Phone::Graphics::Interop;
|
||||
using namespace Windows::Phone::Input::Interop;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
using namespace Windows::Phone::Media::Capture;
|
||||
|
||||
#if !defined(_M_ARM)
|
||||
#pragma message("warning: Direct3DInterop.cpp: Windows Phone camera code does not run in the emulator.")
|
||||
#pragma message("warning: Direct3DInterop.cpp: Please compile as an ARM build and run on a device.")
|
||||
#endif
|
||||
|
||||
namespace PhoneXamlDirect3DApp1Comp
|
||||
{
|
||||
// Called each time a preview frame is available
|
||||
void CameraCapturePreviewSink::OnFrameAvailable(
|
||||
DXGI_FORMAT format,
|
||||
UINT width,
|
||||
UINT height,
|
||||
BYTE* pixels
|
||||
)
|
||||
{
|
||||
m_Direct3dInterop->UpdateFrame(pixels, width, height);
|
||||
}
|
||||
|
||||
// Called each time a captured frame is available
|
||||
void CameraCaptureSampleSink::OnSampleAvailable(
|
||||
ULONGLONG hnsPresentationTime,
|
||||
ULONGLONG hnsSampleDuration,
|
||||
DWORD cbSample,
|
||||
BYTE* pSample)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
Direct3DInterop::Direct3DInterop()
|
||||
: m_algorithm(OCVFilterType::ePreview)
|
||||
, m_contentDirty(false)
|
||||
, m_backFrame(nullptr)
|
||||
, m_frontFrame(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool Direct3DInterop::SwapFrames()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if(m_backFrame != nullptr)
|
||||
{
|
||||
std::swap(m_backFrame, m_frontFrame);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Direct3DInterop::UpdateFrame(byte* buffer,int width,int height)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if(m_backFrame == nullptr)
|
||||
{
|
||||
m_backFrame = std::shared_ptr<cv::Mat> (new cv::Mat(height, width, CV_8UC4));
|
||||
m_frontFrame = std::shared_ptr<cv::Mat> (new cv::Mat(height, width, CV_8UC4));
|
||||
}
|
||||
|
||||
memcpy(m_backFrame.get()->data, buffer, 4 * height*width);
|
||||
m_contentDirty = true;
|
||||
RequestAdditionalFrame();
|
||||
}
|
||||
|
||||
void Direct3DInterop::ProcessFrame()
|
||||
{
|
||||
if (SwapFrames())
|
||||
{
|
||||
if (m_renderer)
|
||||
{
|
||||
cv::Mat* mat = m_frontFrame.get();
|
||||
|
||||
switch (m_algorithm)
|
||||
{
|
||||
case OCVFilterType::ePreview:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case OCVFilterType::eGray:
|
||||
{
|
||||
ApplyGrayFilter(mat);
|
||||
break;
|
||||
}
|
||||
|
||||
case OCVFilterType::eCanny:
|
||||
{
|
||||
ApplyCannyFilter(mat);
|
||||
break;
|
||||
}
|
||||
|
||||
case OCVFilterType::eBlur:
|
||||
{
|
||||
ApplyBlurFilter(mat);
|
||||
break;
|
||||
}
|
||||
|
||||
case OCVFilterType::eFindFeatures:
|
||||
{
|
||||
ApplyFindFeaturesFilter(mat);
|
||||
break;
|
||||
}
|
||||
|
||||
case OCVFilterType::eSepia:
|
||||
{
|
||||
ApplySepiaFilter(mat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_renderer->CreateTextureFromByte(mat->data, mat->cols, mat->rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Direct3DInterop::ApplyGrayFilter(cv::Mat* mat)
|
||||
{
|
||||
cv::Mat intermediateMat;
|
||||
cv::cvtColor(*mat, intermediateMat, CV_RGBA2GRAY);
|
||||
cv::cvtColor(intermediateMat, *mat, CV_GRAY2BGRA);
|
||||
}
|
||||
|
||||
void Direct3DInterop::ApplyCannyFilter(cv::Mat* mat)
|
||||
{
|
||||
cv::Mat intermediateMat;
|
||||
cv::Canny(*mat, intermediateMat, 80, 90);
|
||||
cv::cvtColor(intermediateMat, *mat, CV_GRAY2BGRA);
|
||||
}
|
||||
|
||||
void Direct3DInterop::ApplyBlurFilter(cv::Mat* mat)
|
||||
{
|
||||
cv::Mat intermediateMat;
|
||||
// cv::Blur(image, intermediateMat, 80, 90);
|
||||
cv::cvtColor(intermediateMat, *mat, CV_GRAY2BGRA);
|
||||
}
|
||||
|
||||
void Direct3DInterop::ApplyFindFeaturesFilter(cv::Mat* mat)
|
||||
{
|
||||
cv::Mat intermediateMat;
|
||||
cv::Ptr<cv::FastFeatureDetector> detector = cv::FastFeatureDetector::create(50);
|
||||
std::vector<cv::KeyPoint> features;
|
||||
|
||||
cv::cvtColor(*mat, intermediateMat, CV_RGBA2GRAY);
|
||||
detector->detect(intermediateMat, features);
|
||||
|
||||
for( unsigned int i = 0; i < std::min(features.size(), (size_t)50); i++ )
|
||||
{
|
||||
const cv::KeyPoint& kp = features[i];
|
||||
cv::circle(*mat, cv::Point((int)kp.pt.x, (int)kp.pt.y), 10, cv::Scalar(255,0,0,255));
|
||||
}
|
||||
}
|
||||
|
||||
void Direct3DInterop::ApplySepiaFilter(cv::Mat* mat)
|
||||
{
|
||||
const float SepiaKernelData[16] =
|
||||
{
|
||||
/* B */0.131f, 0.534f, 0.272f, 0.f,
|
||||
/* G */0.168f, 0.686f, 0.349f, 0.f,
|
||||
/* R */0.189f, 0.769f, 0.393f, 0.f,
|
||||
/* A */0.000f, 0.000f, 0.000f, 1.f
|
||||
};
|
||||
|
||||
const cv::Mat SepiaKernel(4, 4, CV_32FC1, (void*)SepiaKernelData);
|
||||
cv::transform(*mat, *mat, SepiaKernel);
|
||||
}
|
||||
|
||||
IDrawingSurfaceContentProvider^ Direct3DInterop::CreateContentProvider()
|
||||
{
|
||||
ComPtr<Direct3DContentProvider> provider = Make<Direct3DContentProvider>(this);
|
||||
return reinterpret_cast<IDrawingSurfaceContentProvider^>(provider.Detach());
|
||||
}
|
||||
|
||||
// IDrawingSurfaceManipulationHandler
|
||||
void Direct3DInterop::SetManipulationHost(DrawingSurfaceManipulationHost^ manipulationHost)
|
||||
{
|
||||
manipulationHost->PointerPressed +=
|
||||
ref new TypedEventHandler<DrawingSurfaceManipulationHost^, PointerEventArgs^>(this, &Direct3DInterop::OnPointerPressed);
|
||||
|
||||
manipulationHost->PointerMoved +=
|
||||
ref new TypedEventHandler<DrawingSurfaceManipulationHost^, PointerEventArgs^>(this, &Direct3DInterop::OnPointerMoved);
|
||||
|
||||
manipulationHost->PointerReleased +=
|
||||
ref new TypedEventHandler<DrawingSurfaceManipulationHost^, PointerEventArgs^>(this, &Direct3DInterop::OnPointerReleased);
|
||||
}
|
||||
|
||||
void Direct3DInterop::RenderResolution::set(Windows::Foundation::Size renderResolution)
|
||||
{
|
||||
if (renderResolution.Width != m_renderResolution.Width ||
|
||||
renderResolution.Height != m_renderResolution.Height)
|
||||
{
|
||||
m_renderResolution = renderResolution;
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->UpdateForRenderResolutionChange(m_renderResolution.Width, m_renderResolution.Height);
|
||||
RecreateSynchronizedTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Event Handlers
|
||||
|
||||
void Direct3DInterop::OnPointerPressed(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
// Insert your code here.
|
||||
}
|
||||
|
||||
void Direct3DInterop::OnPointerMoved(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
// Insert your code here.
|
||||
}
|
||||
|
||||
void Direct3DInterop::OnPointerReleased(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
// Insert your code here.
|
||||
}
|
||||
|
||||
void Direct3DInterop::StartCamera()
|
||||
{
|
||||
// Set the capture dimensions
|
||||
Size captureDimensions;
|
||||
captureDimensions.Width = 640;
|
||||
captureDimensions.Height = 480;
|
||||
|
||||
// Open the AudioVideoCaptureDevice for video only
|
||||
IAsyncOperation<AudioVideoCaptureDevice^> ^openOperation = AudioVideoCaptureDevice::OpenForVideoOnlyAsync(CameraSensorLocation::Back, captureDimensions);
|
||||
|
||||
openOperation->Completed = ref new AsyncOperationCompletedHandler<AudioVideoCaptureDevice^>(
|
||||
[this] (IAsyncOperation<AudioVideoCaptureDevice^> ^operation, Windows::Foundation::AsyncStatus status)
|
||||
{
|
||||
if (status == Windows::Foundation::AsyncStatus::Completed)
|
||||
{
|
||||
auto captureDevice = operation->GetResults();
|
||||
|
||||
// Save the reference to the opened video capture device
|
||||
pAudioVideoCaptureDevice = captureDevice;
|
||||
|
||||
// Retrieve the native ICameraCaptureDeviceNative interface from the managed video capture device
|
||||
ICameraCaptureDeviceNative *iCameraCaptureDeviceNative = NULL;
|
||||
HRESULT hr = reinterpret_cast<IUnknown*>(captureDevice)->QueryInterface(__uuidof(ICameraCaptureDeviceNative), (void**) &iCameraCaptureDeviceNative);
|
||||
|
||||
// Save the pointer to the native interface
|
||||
pCameraCaptureDeviceNative = iCameraCaptureDeviceNative;
|
||||
|
||||
// Initialize the preview dimensions (see the accompanying article at )
|
||||
// The aspect ratio of the capture and preview resolution must be equal,
|
||||
// 4:3 for capture => 4:3 for preview, and 16:9 for capture => 16:9 for preview.
|
||||
Size previewDimensions;
|
||||
previewDimensions.Width = 640;
|
||||
previewDimensions.Height = 480;
|
||||
|
||||
IAsyncAction^ setPreviewResolutionAction = pAudioVideoCaptureDevice->SetPreviewResolutionAsync(previewDimensions);
|
||||
setPreviewResolutionAction->Completed = ref new AsyncActionCompletedHandler(
|
||||
[this](IAsyncAction^ action, Windows::Foundation::AsyncStatus status)
|
||||
{
|
||||
HResult hr = action->ErrorCode;
|
||||
|
||||
if (status == Windows::Foundation::AsyncStatus::Completed)
|
||||
{
|
||||
// Create the sink
|
||||
MakeAndInitialize<CameraCapturePreviewSink>(&pCameraCapturePreviewSink);
|
||||
pCameraCapturePreviewSink->SetDelegate(this);
|
||||
pCameraCaptureDeviceNative->SetPreviewSink(pCameraCapturePreviewSink);
|
||||
|
||||
// Set the preview format
|
||||
pCameraCaptureDeviceNative->SetPreviewFormat(DXGI_FORMAT::DXGI_FORMAT_B8G8R8A8_UNORM);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Retrieve IAudioVideoCaptureDeviceNative native interface from managed projection.
|
||||
IAudioVideoCaptureDeviceNative *iAudioVideoCaptureDeviceNative = NULL;
|
||||
hr = reinterpret_cast<IUnknown*>(captureDevice)->QueryInterface(__uuidof(IAudioVideoCaptureDeviceNative), (void**) &iAudioVideoCaptureDeviceNative);
|
||||
|
||||
// Save the pointer to the IAudioVideoCaptureDeviceNative native interface
|
||||
pAudioVideoCaptureDeviceNative = iAudioVideoCaptureDeviceNative;
|
||||
|
||||
// Set sample encoding format to ARGB. See the documentation for further values.
|
||||
pAudioVideoCaptureDevice->VideoEncodingFormat = CameraCaptureVideoFormat::Argb;
|
||||
|
||||
// Initialize and set the CameraCaptureSampleSink class as sink for captures samples
|
||||
MakeAndInitialize<CameraCaptureSampleSink>(&pCameraCaptureSampleSink);
|
||||
pAudioVideoCaptureDeviceNative->SetVideoSampleSink(pCameraCaptureSampleSink);
|
||||
|
||||
// Start recording (only way to receive samples using the ICameraCaptureSampleSink interface
|
||||
pAudioVideoCaptureDevice->StartRecordingToSinkAsync();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
// Interface With Direct3DContentProvider
|
||||
HRESULT Direct3DInterop::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host)
|
||||
{
|
||||
m_renderer = ref new QuadRenderer();
|
||||
m_renderer->Initialize();
|
||||
m_renderer->UpdateForWindowSizeChange(WindowBounds.Width, WindowBounds.Height);
|
||||
m_renderer->UpdateForRenderResolutionChange(m_renderResolution.Width, m_renderResolution.Height);
|
||||
StartCamera();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void Direct3DInterop::Disconnect()
|
||||
{
|
||||
m_renderer = nullptr;
|
||||
}
|
||||
|
||||
HRESULT Direct3DInterop::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty)
|
||||
{
|
||||
*contentDirty = m_contentDirty;
|
||||
if(m_contentDirty)
|
||||
{
|
||||
ProcessFrame();
|
||||
}
|
||||
m_contentDirty = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Direct3DInterop::GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle)
|
||||
{
|
||||
m_renderer->Update();
|
||||
m_renderer->Render();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ID3D11Texture2D* Direct3DInterop::GetTexture()
|
||||
{
|
||||
return m_renderer->GetTexture();
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
#include "BasicTimer.h"
|
||||
#include "QuadRenderer.h"
|
||||
#include <DrawingSurfaceNative.h>
|
||||
#include <ppltasks.h>
|
||||
#include <windows.storage.streams.h>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
#include <opencv2\imgproc\types_c.h>
|
||||
|
||||
|
||||
namespace PhoneXamlDirect3DApp1Comp
|
||||
{
|
||||
|
||||
public enum class OCVFilterType
|
||||
{
|
||||
ePreview,
|
||||
eGray,
|
||||
eCanny,
|
||||
eBlur,
|
||||
eFindFeatures,
|
||||
eSepia,
|
||||
eNumOCVFilterTypes
|
||||
};
|
||||
|
||||
class CameraCapturePreviewSink;
|
||||
class CameraCaptureSampleSink;
|
||||
|
||||
public delegate void RequestAdditionalFrameHandler();
|
||||
public delegate void RecreateSynchronizedTextureHandler();
|
||||
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class Direct3DInterop sealed : public Windows::Phone::Input::Interop::IDrawingSurfaceManipulationHandler
|
||||
{
|
||||
public:
|
||||
Direct3DInterop();
|
||||
|
||||
Windows::Phone::Graphics::Interop::IDrawingSurfaceContentProvider^ CreateContentProvider();
|
||||
|
||||
// IDrawingSurfaceManipulationHandler
|
||||
virtual void SetManipulationHost(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ manipulationHost);
|
||||
|
||||
event RequestAdditionalFrameHandler^ RequestAdditionalFrame;
|
||||
event RecreateSynchronizedTextureHandler^ RecreateSynchronizedTexture;
|
||||
|
||||
property Windows::Foundation::Size WindowBounds;
|
||||
property Windows::Foundation::Size NativeResolution;
|
||||
property Windows::Foundation::Size RenderResolution
|
||||
{
|
||||
Windows::Foundation::Size get(){ return m_renderResolution; }
|
||||
void set(Windows::Foundation::Size renderResolution);
|
||||
}
|
||||
void SetAlgorithm(OCVFilterType type) { m_algorithm = type; };
|
||||
void UpdateFrame(byte* buffer, int width, int height);
|
||||
|
||||
|
||||
protected:
|
||||
// Event Handlers
|
||||
void OnPointerPressed(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
||||
void OnPointerMoved(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
||||
void OnPointerReleased(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
||||
|
||||
internal:
|
||||
HRESULT STDMETHODCALLTYPE Connect(_In_ IDrawingSurfaceRuntimeHostNative* host);
|
||||
void STDMETHODCALLTYPE Disconnect();
|
||||
HRESULT STDMETHODCALLTYPE PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty);
|
||||
HRESULT STDMETHODCALLTYPE GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle);
|
||||
ID3D11Texture2D* GetTexture();
|
||||
|
||||
private:
|
||||
void StartCamera();
|
||||
void ProcessFrame();
|
||||
bool SwapFrames();
|
||||
|
||||
QuadRenderer^ m_renderer;
|
||||
Windows::Foundation::Size m_renderResolution;
|
||||
OCVFilterType m_algorithm;
|
||||
bool m_contentDirty;
|
||||
std::shared_ptr<cv::Mat> m_backFrame;
|
||||
std::shared_ptr<cv::Mat> m_frontFrame;
|
||||
std::mutex m_mutex;
|
||||
|
||||
Windows::Phone::Media::Capture::AudioVideoCaptureDevice ^pAudioVideoCaptureDevice;
|
||||
ICameraCaptureDeviceNative* pCameraCaptureDeviceNative;
|
||||
IAudioVideoCaptureDeviceNative* pAudioVideoCaptureDeviceNative;
|
||||
CameraCapturePreviewSink* pCameraCapturePreviewSink;
|
||||
CameraCaptureSampleSink* pCameraCaptureSampleSink;
|
||||
|
||||
//void ApplyPreviewFilter(const cv::Mat& image);
|
||||
void ApplyGrayFilter(cv::Mat* mat);
|
||||
void ApplyCannyFilter(cv::Mat* mat);
|
||||
void ApplyBlurFilter(cv::Mat* mat);
|
||||
void ApplyFindFeaturesFilter(cv::Mat* mat);
|
||||
void ApplySepiaFilter(cv::Mat* mat);
|
||||
};
|
||||
|
||||
class CameraCapturePreviewSink :
|
||||
public Microsoft::WRL::RuntimeClass<
|
||||
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::ClassicCom>,
|
||||
ICameraCapturePreviewSink>
|
||||
{
|
||||
public:
|
||||
void SetDelegate(Direct3DInterop^ delegate)
|
||||
{
|
||||
m_Direct3dInterop = delegate;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(void) OnFrameAvailable(
|
||||
DXGI_FORMAT format,
|
||||
UINT width,
|
||||
UINT height,
|
||||
BYTE* pixels);
|
||||
|
||||
private:
|
||||
Direct3DInterop^ m_Direct3dInterop;
|
||||
};
|
||||
|
||||
class CameraCaptureSampleSink :
|
||||
public Microsoft::WRL::RuntimeClass<
|
||||
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::ClassicCom>,
|
||||
ICameraCaptureSampleSink>
|
||||
{
|
||||
public:
|
||||
void SetDelegate(Direct3DInterop^ delegate)
|
||||
{
|
||||
m_Direct3dInterop = delegate;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(void) OnSampleAvailable(
|
||||
ULONGLONG hnsPresentationTime,
|
||||
ULONGLONG hnsSampleDuration,
|
||||
DWORD cbSample,
|
||||
BYTE* pSample);
|
||||
|
||||
private:
|
||||
Direct3DInterop^ m_Direct3dInterop;
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <wrl/client.h>
|
||||
#include <ppl.h>
|
||||
#include <ppltasks.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
inline void ThrowIfFailed(HRESULT hr)
|
||||
{
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// Set a breakpoint on this line to catch Win32 API errors.
|
||||
throw Platform::Exception::CreateException(hr);
|
||||
}
|
||||
}
|
||||
|
||||
// Function that reads from a binary file asynchronously.
|
||||
inline Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename)
|
||||
{
|
||||
using namespace Windows::Storage;
|
||||
using namespace Concurrency;
|
||||
|
||||
auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
|
||||
|
||||
return create_task(folder->GetFileAsync(filename)).then([] (StorageFile^ file)
|
||||
{
|
||||
return file->OpenReadAsync();
|
||||
}).then([] (Streams::IRandomAccessStreamWithContentType^ stream)
|
||||
{
|
||||
unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
|
||||
auto fileBuffer = ref new Streams::Buffer(bufferSize);
|
||||
return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
|
||||
}).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
|
||||
{
|
||||
auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
|
||||
Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
|
||||
return fileData;
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|ARM">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}</ProjectGuid>
|
||||
<RootNamespace>PhoneXamlDirect3DApp1Comp</RootNamespace>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<WinMDAssembly>true</WinMDAssembly>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup>
|
||||
<!-- If OutDir was set outside of the project file, then we will append ProjectName -->
|
||||
<OutDir Condition="'$(OutDirWasSpecified)' == 'true'">$(OutDir)\$(MSBuildProjectName)\</OutDir>
|
||||
<!-- else, OutDir needs to have project specific directory in order to handle files with unique names -->
|
||||
<OutDir Condition="'$(OutDirWasSpecified)' != 'true' and '$(Platform)' == 'Win32'">$(SolutionDir)$(Configuration)\$(MSBuildProjectName)\</OutDir>
|
||||
<OutDir Condition="'$(OutDirWasSpecified)' != 'true' and '$(Platform)' != 'Win32'">$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutDir>
|
||||
<!-- After OutDir has been fixed, disable Microsoft.common.targets from fixing it again -->
|
||||
<OutDirWasSpecified>false</OutDirWasSpecified>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LibraryPath>$(ProjectDir)..\..\..\..\..\bin\WP\8.0\x86\lib\Debug;$(ProjectDir)..\..\..\..\..\bin\WP\8.0\x86\3rdparty\lib\Debug;$(WP80ToolSetPath)lib;$(WindowsSDK_LibraryPath_x86)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\modules\core\include;$(ProjectDir)..\..\..\..\..\modules\imgproc\include;$(ProjectDir)..\..\..\..\..\modules\flann\include;$(ProjectDir)..\..\..\..\..\modules\features2d\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>opencv_core300d.lib;opencv_imgproc300d.lib;opencv_features2d300d.lib;opencv_flann300d.lib;opencv_ml300d.lib;zlibd.lib;d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\..\binWP8;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\..\binWP8;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\..\binWP8;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="platform.winmd">
|
||||
<IsWinMDFile>true</IsWinMDFile>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BasicTimer.h" />
|
||||
<ClInclude Include="Direct3DInterop.h" />
|
||||
<ClInclude Include="DirectXHelper.h" />
|
||||
<ClInclude Include="Direct3DBase.h" />
|
||||
<ClInclude Include="Direct3DContentProvider.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="QuadRenderer.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Direct3DInterop.cpp" />
|
||||
<ClCompile Include="Direct3DBase.cpp" />
|
||||
<ClCompile Include="Direct3DContentProvider.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="QuadRenderer.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<FxCompile Include="SimplePixelShader.hlsl">
|
||||
<ShaderType>Pixel</ShaderType>
|
||||
<ShaderModel>4.0_level_9_3</ShaderModel>
|
||||
</FxCompile>
|
||||
<FxCompile Include="SimpleVertexShader.hlsl">
|
||||
<ShaderType>Vertex</ShaderType>
|
||||
<ShaderModel>4.0_level_9_3</ShaderModel>
|
||||
</FxCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_core300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_features2d300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_flann300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_imgproc300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_ml300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\packages\NokiaImagingSDK.1.0.272.0\build\native\NokiaImagingSDK.targets" Condition="Exists('..\..\packages\NokiaImagingSDK.1.0.272.0\build\native\NokiaImagingSDK.targets')" />
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -0,0 +1,340 @@
|
||||
#include "pch.h"
|
||||
#include "QuadRenderer.h"
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::Core;
|
||||
|
||||
QuadRenderer::QuadRenderer() :
|
||||
m_loadingComplete(false),
|
||||
m_indexCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
void QuadRenderer::CreateTextureFromByte(byte* buffer,int width,int height)
|
||||
{
|
||||
int pixelSize = 4;
|
||||
|
||||
if (m_Texture.Get() == nullptr)
|
||||
{
|
||||
CD3D11_TEXTURE2D_DESC textureDesc(
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM, // format
|
||||
static_cast<UINT>(width), // width
|
||||
static_cast<UINT>(height), // height
|
||||
1, // arraySize
|
||||
1, // mipLevels
|
||||
D3D11_BIND_SHADER_RESOURCE, // bindFlags
|
||||
D3D11_USAGE_DYNAMIC, // usage
|
||||
D3D11_CPU_ACCESS_WRITE, // cpuaccessFlags
|
||||
1, // sampleCount
|
||||
0, // sampleQuality
|
||||
0 // miscFlags
|
||||
);
|
||||
|
||||
D3D11_SUBRESOURCE_DATA data;
|
||||
data.pSysMem = buffer;
|
||||
data.SysMemPitch = pixelSize*width;
|
||||
data.SysMemSlicePitch = pixelSize*width*height;
|
||||
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateTexture2D(
|
||||
&textureDesc,
|
||||
&data,
|
||||
m_Texture.ReleaseAndGetAddressOf()
|
||||
)
|
||||
);
|
||||
|
||||
m_d3dDevice->CreateShaderResourceView(m_Texture.Get(), NULL, m_SRV.ReleaseAndGetAddressOf());
|
||||
D3D11_SAMPLER_DESC sampDesc;
|
||||
ZeroMemory(&sampDesc, sizeof(sampDesc));
|
||||
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
sampDesc.MinLOD = 0;
|
||||
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
m_d3dDevice->CreateSamplerState(&sampDesc, m_QuadsTexSamplerState.ReleaseAndGetAddressOf());
|
||||
}
|
||||
else
|
||||
{
|
||||
int nRowSpan = width * pixelSize;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
HRESULT hr = m_d3dContext->Map(m_Texture.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
BYTE* mappedData = static_cast<BYTE*>(mappedResource.pData);
|
||||
|
||||
for (int i = 0; i < height; ++i)
|
||||
{
|
||||
memcpy(mappedData + (i*mappedResource.RowPitch), buffer + (i*nRowSpan), nRowSpan);
|
||||
}
|
||||
|
||||
m_d3dContext->Unmap(m_Texture.Get(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void QuadRenderer::CreateDeviceResources()
|
||||
{
|
||||
Direct3DBase::CreateDeviceResources();
|
||||
D3D11_BLEND_DESC blendDesc;
|
||||
ZeroMemory( &blendDesc, sizeof(blendDesc) );
|
||||
|
||||
D3D11_RENDER_TARGET_BLEND_DESC rtbd;
|
||||
ZeroMemory( &rtbd, sizeof(rtbd) );
|
||||
|
||||
rtbd.BlendEnable = TRUE;
|
||||
rtbd.SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
||||
rtbd.DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||
rtbd.BlendOp = D3D11_BLEND_OP_ADD;
|
||||
rtbd.SrcBlendAlpha = D3D11_BLEND_ONE;
|
||||
rtbd.DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||
rtbd.BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
rtbd.RenderTargetWriteMask = 0x0f;
|
||||
|
||||
blendDesc.AlphaToCoverageEnable = false;
|
||||
blendDesc.RenderTarget[0] = rtbd;
|
||||
|
||||
m_d3dDevice->CreateBlendState(&blendDesc, &m_Transparency);
|
||||
|
||||
D3D11_RASTERIZER_DESC cmdesc;
|
||||
ZeroMemory(&cmdesc, sizeof(D3D11_RASTERIZER_DESC));
|
||||
|
||||
cmdesc.FillMode = D3D11_FILL_SOLID;
|
||||
cmdesc.CullMode = D3D11_CULL_BACK;
|
||||
cmdesc.DepthClipEnable = TRUE;
|
||||
|
||||
cmdesc.FrontCounterClockwise = true;
|
||||
m_d3dDevice->CreateRasterizerState(&cmdesc, &CCWcullMode);
|
||||
|
||||
cmdesc.FrontCounterClockwise = false;
|
||||
m_d3dDevice->CreateRasterizerState(&cmdesc, &CWcullMode);
|
||||
|
||||
auto loadVSTask = DX::ReadDataAsync("SimpleVertexShader.cso");
|
||||
auto loadPSTask = DX::ReadDataAsync("SimplePixelShader.cso");
|
||||
auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData)
|
||||
{
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateVertexShader(
|
||||
fileData->Data,
|
||||
fileData->Length,
|
||||
nullptr,
|
||||
&m_vertexShader
|
||||
)
|
||||
);
|
||||
|
||||
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
|
||||
{
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
};
|
||||
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateInputLayout(
|
||||
vertexDesc,
|
||||
ARRAYSIZE(vertexDesc),
|
||||
fileData->Data,
|
||||
fileData->Length,
|
||||
&m_inputLayout
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData)
|
||||
{
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreatePixelShader(
|
||||
fileData->Data,
|
||||
fileData->Length,
|
||||
nullptr,
|
||||
&m_pixelShader
|
||||
)
|
||||
);
|
||||
|
||||
CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateBuffer(
|
||||
&constantBufferDesc,
|
||||
nullptr,
|
||||
&m_constantBuffer
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
auto createCubeTask = (createPSTask && createVSTask).then([this] ()
|
||||
{
|
||||
Vertex v[] =
|
||||
{
|
||||
Vertex(-1.0f, -1.0f, 1.0f, 1.0f, 1.0f),
|
||||
Vertex(1.0f, -1.0f, 1.0f, 0.0f, 1.0f),
|
||||
Vertex(1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
|
||||
Vertex(-1.0f, 1.0f, 1.0f, 1.0f, 0.0f)
|
||||
};
|
||||
|
||||
D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
|
||||
vertexBufferData.pSysMem = v;
|
||||
vertexBufferData.SysMemPitch = 0;
|
||||
vertexBufferData.SysMemSlicePitch = 0;
|
||||
CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(v), D3D11_BIND_VERTEX_BUFFER);
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateBuffer(
|
||||
&vertexBufferDesc,
|
||||
&vertexBufferData,
|
||||
&m_vertexBuffer
|
||||
)
|
||||
);
|
||||
|
||||
DWORD indices[] =
|
||||
{
|
||||
// Front Face
|
||||
0, 2, 1,
|
||||
0, 3, 2,
|
||||
|
||||
};
|
||||
|
||||
m_indexCount = ARRAYSIZE(indices);
|
||||
|
||||
D3D11_SUBRESOURCE_DATA indexBufferData = {0};
|
||||
indexBufferData.pSysMem = indices;
|
||||
indexBufferData.SysMemPitch = 0;
|
||||
indexBufferData.SysMemSlicePitch = 0;
|
||||
CD3D11_BUFFER_DESC indexBufferDesc(sizeof(indices), D3D11_BIND_INDEX_BUFFER);
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateBuffer(
|
||||
&indexBufferDesc,
|
||||
&indexBufferData,
|
||||
&m_indexBuffer
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
createCubeTask.then([this] ()
|
||||
{
|
||||
m_loadingComplete = true;
|
||||
});
|
||||
}
|
||||
|
||||
void QuadRenderer::CreateWindowSizeDependentResources()
|
||||
{
|
||||
Direct3DBase::CreateWindowSizeDependentResources();
|
||||
|
||||
float aspectRatio = m_windowBounds.Width / m_windowBounds.Height;
|
||||
float fovAngleY = 60.0f * (XM_PI / 180.0f);
|
||||
|
||||
if (aspectRatio < 1.0f)
|
||||
{
|
||||
fovAngleY /= aspectRatio;
|
||||
}
|
||||
|
||||
XMStoreFloat4x4(
|
||||
&m_constantBufferData.projection,
|
||||
XMMatrixTranspose(
|
||||
XMMatrixPerspectiveFovRH(
|
||||
fovAngleY,
|
||||
aspectRatio,
|
||||
0.01f,
|
||||
100.0f
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void QuadRenderer::Update(float timeTotal, float timeDelta)
|
||||
{
|
||||
(void) timeDelta; // Unused parameter.
|
||||
|
||||
XMVECTOR X = XMVectorSet(0.0f, 0.0f, .3f, 0.0f);
|
||||
XMVECTOR Y = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
XMVECTOR Z = XMVectorSet(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
XMStoreFloat4x4(&m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtLH(X, Y, Z)));
|
||||
XMStoreFloat4x4(&m_constantBufferData.model, XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));
|
||||
}
|
||||
|
||||
void QuadRenderer::Render()
|
||||
{
|
||||
Render(m_renderTargetView, m_depthStencilView);
|
||||
}
|
||||
|
||||
void QuadRenderer::Render(Microsoft::WRL::ComPtr<ID3D11RenderTargetView> renderTargetView, Microsoft::WRL::ComPtr<ID3D11DepthStencilView> depthStencilView)
|
||||
{
|
||||
const float black[] = {0, 0, 0, 1.0 };
|
||||
|
||||
m_d3dContext->ClearRenderTargetView(
|
||||
renderTargetView.Get(),
|
||||
black
|
||||
);
|
||||
|
||||
m_d3dContext->ClearDepthStencilView(
|
||||
depthStencilView.Get(),
|
||||
D3D11_CLEAR_DEPTH,
|
||||
1.0f,
|
||||
0
|
||||
);
|
||||
|
||||
if (m_SRV && m_loadingComplete) // Only draw the cube once it is loaded (loading is asynchronous).
|
||||
{
|
||||
m_d3dContext->OMSetRenderTargets(
|
||||
1,
|
||||
renderTargetView.GetAddressOf(),
|
||||
depthStencilView.Get()
|
||||
);
|
||||
|
||||
m_d3dContext->UpdateSubresource(
|
||||
m_constantBuffer.Get(),
|
||||
0,
|
||||
NULL,
|
||||
&m_constantBufferData,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
UINT stride = sizeof(Vertex);
|
||||
UINT offset = 0;
|
||||
|
||||
m_d3dContext->IASetVertexBuffers(
|
||||
0,
|
||||
1,
|
||||
m_vertexBuffer.GetAddressOf(),
|
||||
&stride,
|
||||
&offset
|
||||
);
|
||||
|
||||
m_d3dContext->IASetIndexBuffer(
|
||||
m_indexBuffer.Get(),
|
||||
DXGI_FORMAT_R32_UINT,
|
||||
0
|
||||
);
|
||||
|
||||
m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
m_d3dContext->IASetInputLayout(m_inputLayout.Get());
|
||||
|
||||
m_d3dContext->VSSetShader(
|
||||
m_vertexShader.Get(),
|
||||
nullptr,
|
||||
0
|
||||
);
|
||||
|
||||
m_d3dContext->VSSetConstantBuffers(
|
||||
0,
|
||||
1,
|
||||
m_constantBuffer.GetAddressOf()
|
||||
);
|
||||
|
||||
m_d3dContext->PSSetShader(
|
||||
m_pixelShader.Get(),
|
||||
nullptr,
|
||||
0
|
||||
);
|
||||
|
||||
m_d3dContext->PSSetShaderResources(0, 1, m_SRV.GetAddressOf());
|
||||
m_d3dContext->PSSetSamplers(0, 1, m_QuadsTexSamplerState.GetAddressOf());
|
||||
m_d3dContext->OMSetBlendState(m_Transparency.Get(), nullptr, 0xffffffff);
|
||||
m_d3dContext->RSSetState(CCWcullMode.Get());
|
||||
|
||||
m_d3dContext->DrawIndexed(
|
||||
m_indexCount,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "Direct3DBase.h"
|
||||
#include <d3d11.h>
|
||||
|
||||
|
||||
struct ModelViewProjectionConstantBuffer
|
||||
{
|
||||
DirectX::XMFLOAT4X4 model;
|
||||
DirectX::XMFLOAT4X4 view;
|
||||
DirectX::XMFLOAT4X4 projection;
|
||||
};
|
||||
|
||||
struct Vertex //Overloaded Vertex Structure
|
||||
{
|
||||
Vertex(){}
|
||||
Vertex(float x, float y, float z,
|
||||
float u, float v)
|
||||
: pos(x,y,z), texCoord(u, v){}
|
||||
|
||||
DirectX::XMFLOAT3 pos;
|
||||
DirectX::XMFLOAT2 texCoord;
|
||||
};
|
||||
|
||||
// This class renders a simple quad.
|
||||
ref class QuadRenderer sealed : public Direct3DBase
|
||||
{
|
||||
public:
|
||||
QuadRenderer();
|
||||
|
||||
void Update(float timeTotal = 0.0f, float timeDelta = 0.0f);
|
||||
void CreateTextureFromByte(byte * buffer,int width,int height);
|
||||
|
||||
// Direct3DBase methods.
|
||||
virtual void CreateDeviceResources() override;
|
||||
virtual void CreateWindowSizeDependentResources() override;
|
||||
virtual void Render() override;
|
||||
|
||||
private:
|
||||
void Render(Microsoft::WRL::ComPtr<ID3D11RenderTargetView> renderTargetView, Microsoft::WRL::ComPtr<ID3D11DepthStencilView> depthStencilView);
|
||||
bool m_loadingComplete;
|
||||
uint32 m_indexCount;
|
||||
ModelViewProjectionConstantBuffer m_constantBufferData;
|
||||
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
|
||||
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_Texture;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_SRV;
|
||||
Microsoft::WRL::ComPtr<ID3D11SamplerState> m_QuadsTexSamplerState;
|
||||
Microsoft::WRL::ComPtr<ID3D11BlendState> m_Transparency;
|
||||
Microsoft::WRL::ComPtr<ID3D11RasterizerState> CCWcullMode;
|
||||
Microsoft::WRL::ComPtr<ID3D11RasterizerState> CWcullMode;
|
||||
};
|
@ -0,0 +1,25 @@
|
||||
Texture2D shaderTexture;
|
||||
SamplerState SampleType;
|
||||
|
||||
//////////////
|
||||
// TYPEDEFS //
|
||||
//////////////
|
||||
struct PixelInputType
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel Shader
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
float4 main(PixelInputType input) : SV_TARGET
|
||||
{
|
||||
float4 textureColor;
|
||||
|
||||
|
||||
// Sample the pixel color from the texture using the sampler at this texture coordinate location.
|
||||
textureColor = shaderTexture.Sample(SampleType, input.tex);
|
||||
|
||||
return textureColor;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
cbuffer ModelViewProjectionConstantBuffer : register(b0)
|
||||
{
|
||||
matrix model;
|
||||
matrix view;
|
||||
matrix projection;
|
||||
};
|
||||
|
||||
struct VertexInputType
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PixelInputType
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Vertex Shader
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
PixelInputType main(VertexInputType input)
|
||||
{
|
||||
PixelInputType output;
|
||||
|
||||
// Change the position vector to be 4 units for proper matrix calculations.
|
||||
input.position.w = 1.0f;
|
||||
|
||||
// Calculate the position of the vertex against the world, view, and projection matrices.
|
||||
output.position = mul(input.position, model);
|
||||
output.position = mul(output.position, view);
|
||||
output.position = mul(output.position, projection);
|
||||
// Store the texture coordinates for the pixel shader.
|
||||
output.tex = input.tex;
|
||||
|
||||
return output;
|
||||
}
|
@ -0,0 +1 @@
|
||||
#include "pch.h"
|
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <wrl/client.h>
|
||||
#include <d3d11_1.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <memory>
|
||||
#include <agile.h>
|
||||
#include <implements.h>
|
||||
#include <Windows.Phone.Media.Capture.h>
|
||||
#include <Windows.Phone.Media.Capture.Native.h>
|
76
samples/wp8/OcvRotatingCube/OcvRotatingCube.sln
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PhoneXamlDirect3DApp1Comp", "PhoneXamlDirect3DApp1\PhoneXamlDirect3DApp1Comp\PhoneXamlDirect3DApp1Comp.vcxproj", "{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcvRotatingCube", "PhoneXamlDirect3DApp1\PhoneXamlDirect3DApp1\OcvRotatingCube.csproj", "{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|Mixed Platforms = Release|Mixed Platforms
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Debug|x86.Build.0 = Debug|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|ARM.Build.0 = Release|ARM
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|Win32.Build.0 = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}.Release|x86.Build.0 = Release|Win32
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Win32.ActiveCfg = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Win32.Build.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|Win32.Deploy.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|x86.Build.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|ARM.Build.0 = Release|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Win32.ActiveCfg = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Win32.Build.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|Win32.Deploy.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|x86.ActiveCfg = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|x86.Build.0 = Release|x86
|
||||
{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -0,0 +1,20 @@
|
||||
<Application
|
||||
x:Class="PhoneXamlDirect3DApp1.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
|
||||
|
||||
<!--Application Resources-->
|
||||
<Application.Resources>
|
||||
<local:LocalizedStrings xmlns:local="clr-namespace:PhoneXamlDirect3DApp1" x:Key="LocalizedStrings"/>
|
||||
</Application.Resources>
|
||||
|
||||
<Application.ApplicationLifetimeObjects>
|
||||
<!--Required object that handles lifetime events for the application-->
|
||||
<shell:PhoneApplicationService
|
||||
Launching="Application_Launching" Closing="Application_Closing"
|
||||
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||
</Application.ApplicationLifetimeObjects>
|
||||
|
||||
</Application>
|
@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Resources;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using PhoneXamlDirect3DApp1.Resources;
|
||||
|
||||
namespace PhoneXamlDirect3DApp1
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides easy access to the root frame of the Phone Application.
|
||||
/// </summary>
|
||||
/// <returns>The root frame of the Phone Application.</returns>
|
||||
public static PhoneApplicationFrame RootFrame { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Application object.
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
// Global handler for uncaught exceptions.
|
||||
UnhandledException += Application_UnhandledException;
|
||||
|
||||
// Standard XAML initialization
|
||||
InitializeComponent();
|
||||
|
||||
// Phone-specific initialization
|
||||
InitializePhoneApplication();
|
||||
|
||||
// Language display initialization
|
||||
InitializeLanguage();
|
||||
|
||||
// Show graphics profiling information while debugging.
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// Display the current frame rate counters.
|
||||
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||
|
||||
// Show the areas of the app that are being redrawn in each frame.
|
||||
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||
|
||||
// Enable non-production analysis visualization mode,
|
||||
// which shows areas of a page that are handed off to GPU with a colored overlay.
|
||||
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||
|
||||
// Prevent the screen from turning off while under the debugger by disabling
|
||||
// the application's idle detection.
|
||||
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
|
||||
// and consume battery power when the user is not using the phone.
|
||||
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Code to execute when the application is launching (eg, from Start)
|
||||
// This code will not execute when the application is reactivated
|
||||
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is activated (brought to foreground)
|
||||
// This code will not execute when the application is first launched
|
||||
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is deactivated (sent to background)
|
||||
// This code will not execute when the application is closing
|
||||
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is closing (eg, user hit Back)
|
||||
// This code will not execute when the application is deactivated
|
||||
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute if a navigation fails
|
||||
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// A navigation has failed; break into the debugger
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
// Code to execute on Unhandled Exceptions
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// An unhandled exception has occurred; break into the debugger
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
#region Phone application initialization
|
||||
|
||||
// Avoid double-initialization
|
||||
private bool phoneApplicationInitialized = false;
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void InitializePhoneApplication()
|
||||
{
|
||||
if (phoneApplicationInitialized)
|
||||
return;
|
||||
|
||||
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||
// screen to remain active until the application is ready to render.
|
||||
RootFrame = new PhoneApplicationFrame();
|
||||
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||
|
||||
// Handle navigation failures
|
||||
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||
|
||||
// Handle reset requests for clearing the backstack
|
||||
RootFrame.Navigated += CheckForResetNavigation;
|
||||
|
||||
// Ensure we don't initialize again
|
||||
phoneApplicationInitialized = true;
|
||||
}
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Set the root visual to allow the application to render
|
||||
if (RootVisual != RootFrame)
|
||||
RootVisual = RootFrame;
|
||||
|
||||
// Remove this handler since it is no longer needed
|
||||
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||
}
|
||||
|
||||
private void CheckForResetNavigation(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// If the app has received a 'reset' navigation, then we need to check
|
||||
// on the next navigation to see if the page stack should be reset
|
||||
if (e.NavigationMode == NavigationMode.Reset)
|
||||
RootFrame.Navigated += ClearBackStackAfterReset;
|
||||
}
|
||||
|
||||
private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Unregister the event so it doesn't get called again
|
||||
RootFrame.Navigated -= ClearBackStackAfterReset;
|
||||
|
||||
// Only clear the stack for 'new' (forward) and 'refresh' navigations
|
||||
if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh)
|
||||
return;
|
||||
|
||||
// For UI consistency, clear the entire page stack
|
||||
while (RootFrame.RemoveBackEntry() != null)
|
||||
{
|
||||
; // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Initialize the app's font and flow direction as defined in its localized resource strings.
|
||||
//
|
||||
// To ensure that the font of your application is aligned with its supported languages and that the
|
||||
// FlowDirection for each of those languages follows its traditional direction, ResourceLanguage
|
||||
// and ResourceFlowDirection should be initialized in each resx file to match these values with that
|
||||
// file's culture. For example:
|
||||
//
|
||||
// AppResources.es-ES.resx
|
||||
// ResourceLanguage's value should be "es-ES"
|
||||
// ResourceFlowDirection's value should be "LeftToRight"
|
||||
//
|
||||
// AppResources.ar-SA.resx
|
||||
// ResourceLanguage's value should be "ar-SA"
|
||||
// ResourceFlowDirection's value should be "RightToLeft"
|
||||
//
|
||||
// For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072.
|
||||
//
|
||||
private void InitializeLanguage()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Set the font to match the display language defined by the
|
||||
// ResourceLanguage resource string for each supported language.
|
||||
//
|
||||
// Fall back to the font of the neutral language if the Display
|
||||
// language of the phone is not supported.
|
||||
//
|
||||
// If a compiler error is hit then ResourceLanguage is missing from
|
||||
// the resource file.
|
||||
RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage);
|
||||
|
||||
// Set the FlowDirection of all elements under the root frame based
|
||||
// on the ResourceFlowDirection resource string for each
|
||||
// supported language.
|
||||
//
|
||||
// If a compiler error is hit then ResourceFlowDirection is missing from
|
||||
// the resource file.
|
||||
FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection);
|
||||
RootFrame.FlowDirection = flow;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// If an exception is caught here it is most likely due to either
|
||||
// ResourceLangauge not being correctly set to a supported language
|
||||
// code or ResourceFlowDirection is set to a value other than LeftToRight
|
||||
// or RightToLeft.
|
||||
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
Debugger.Break();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 483 KiB |
After Width: | Height: | Size: 9.7 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 3.6 KiB |
@ -0,0 +1,14 @@
|
||||
using PhoneXamlDirect3DApp1.Resources;
|
||||
|
||||
namespace PhoneXamlDirect3DApp1
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to string resources.
|
||||
/// </summary>
|
||||
public class LocalizedStrings
|
||||
{
|
||||
private static AppResources _localizedResources = new AppResources();
|
||||
|
||||
public AppResources LocalizedResources { get { return _localizedResources; } }
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<phone:PhoneApplicationPage
|
||||
x:Class="PhoneXamlDirect3DApp1.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<DrawingSurface x:Name="DrawingSurface" Loaded="DrawingSurface_Loaded" />
|
||||
<StackPanel Margin="40">
|
||||
<RadioButton x:Name="Normal" Content="Normal" GroupName="Group1"
|
||||
Checked="RadioButton_Checked" IsChecked="True"/>
|
||||
<RadioButton x:Name="Gray" Content="Gray" GroupName="Group1"
|
||||
Checked="RadioButton_Checked"/>
|
||||
<RadioButton x:Name="Canny" Content="Canny" GroupName="Group1"
|
||||
Checked="RadioButton_Checked"/>
|
||||
<RadioButton x:Name="Sepia" Content="Sepia" GroupName="Group1"
|
||||
Checked="RadioButton_Checked"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</phone:PhoneApplicationPage>
|
@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using PhoneXamlDirect3DApp1Comp;
|
||||
using Microsoft.Phone.Tasks;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Threading;
|
||||
using System.Windows.Resources;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Microsoft.Xna.Framework.Media;
|
||||
|
||||
namespace PhoneXamlDirect3DApp1
|
||||
{
|
||||
public partial class MainPage : PhoneApplicationPage
|
||||
{
|
||||
private Direct3DInterop m_d3dInterop = new Direct3DInterop();
|
||||
WriteableBitmap m_bmp;
|
||||
bool m_bInitialized = false;
|
||||
|
||||
// Constructor
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Set window bounds in dips
|
||||
m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
|
||||
(float)DrawingSurface.ActualWidth,
|
||||
(float)DrawingSurface.ActualHeight
|
||||
);
|
||||
|
||||
// Set native resolution in pixels
|
||||
m_d3dInterop.NativeResolution = new Windows.Foundation.Size(
|
||||
(float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
|
||||
(float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
|
||||
);
|
||||
|
||||
// Set render resolution to the full native resolution
|
||||
m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution;
|
||||
|
||||
// Hook-up native component to DrawingSurface
|
||||
DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider());
|
||||
DrawingSurface.SetManipulationHandler(m_d3dInterop);
|
||||
|
||||
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
StreamResourceInfo resourceInfo = Application.GetResourceStream(new Uri("Assets/Lena.png", UriKind.Relative));
|
||||
BitmapImage bitmap = new BitmapImage();
|
||||
bitmap.SetSource(resourceInfo.Stream);
|
||||
m_bmp = new WriteableBitmap(bitmap);
|
||||
m_d3dInterop.CreateTexture(m_bmp.Pixels, m_bmp.PixelWidth, m_bmp.PixelHeight, OCVFilterType.ePreview);
|
||||
m_bInitialized = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void RadioButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!m_bInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RadioButton rb = sender as RadioButton;
|
||||
switch (rb.Name)
|
||||
{
|
||||
case "Normal":
|
||||
m_d3dInterop.CreateTexture(m_bmp.Pixels, m_bmp.PixelWidth, m_bmp.PixelHeight, OCVFilterType.ePreview);
|
||||
break;
|
||||
|
||||
case "Gray":
|
||||
m_d3dInterop.CreateTexture(m_bmp.Pixels, m_bmp.PixelWidth, m_bmp.PixelHeight, OCVFilterType.eGray);
|
||||
break;
|
||||
|
||||
case "Canny":
|
||||
m_d3dInterop.CreateTexture(m_bmp.Pixels, m_bmp.PixelWidth, m_bmp.PixelHeight, OCVFilterType.eCanny);
|
||||
break;
|
||||
|
||||
case "Sepia":
|
||||
m_d3dInterop.CreateTexture(m_bmp.Pixels, m_bmp.PixelWidth, m_bmp.PixelHeight, OCVFilterType.eSepia);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20506</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{CC734B3D-D8F2-4528-B223-0E7B8A4F6CC7}</ProjectGuid>
|
||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PhoneXamlDirect3DApp1</RootNamespace>
|
||||
<AssemblyName>PhoneXamlDirect3DApp1</AssemblyName>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||
<SilverlightApplication>true</SilverlightApplication>
|
||||
<SupportedCultures>
|
||||
</SupportedCultures>
|
||||
<XapOutputs>true</XapOutputs>
|
||||
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||
<XapFilename>OCVRotatingCube.xap</XapFilename>
|
||||
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||
<SilverlightAppEntry>PhoneXamlDirect3DApp1.App</SilverlightAppEntry>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\x86\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\x86\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\ARM\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\ARM\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LocalizedStrings.cs" />
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resources\AppResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>AppResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AppManifest.xml" />
|
||||
<None Include="Properties\WMAppManifest.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\AlignmentGrid.png" />
|
||||
<Content Include="Assets\ApplicationIcon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\FlipCycleTileLarge.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\FlipCycleTileMedium.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\FlipCycleTileSmall.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\IconicTileMediumLarge.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\IconicTileSmall.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Lena.png" />
|
||||
<Content Include="SplashScreenImage.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PhoneXamlDirect3DApp1Comp\PhoneXamlDirect3DApp1Comp.vcxproj">
|
||||
<Name>PhoneXamlDirect3DApp1Comp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\AppResources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ProjectExtensions />
|
||||
</Project>
|
@ -0,0 +1,6 @@
|
||||
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
>
|
||||
<Deployment.Parts>
|
||||
</Deployment.Parts>
|
||||
</Deployment>
|
@ -0,0 +1,37 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Resources;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PhoneXamlDirect3DApp1")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PhoneXamlDirect3DApp1")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8ca838f9-f7c6-4550-9b89-59e915a2cddb")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
|
||||
<DefaultLanguage xmlns="" code="en-US" />
|
||||
<App xmlns="" ProductID="{cc734b3d-d8f2-4528-b223-0e7b8a4f6cc7}" Title="OCVRotatingCube" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="Microsoft Open Technologies, Inc." Description="Sample description" Publisher="Microsoft Open Technologies, Inc." PublisherID="{4029c95e-d442-45ca-b556-33d7e3bde613}">
|
||||
<IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
|
||||
<Capabilities>
|
||||
<Capability Name="ID_CAP_SENSORS" />
|
||||
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
|
||||
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
|
||||
<Capability Name="ID_CAP_NETWORKING" />
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="PhoneXamlDirect3DApp1Token" TaskName="_default">
|
||||
<TemplateFlip>
|
||||
<SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
|
||||
<Count>0</Count>
|
||||
<BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
|
||||
<Title>OCVRotatingCube</Title>
|
||||
<BackContent>
|
||||
</BackContent>
|
||||
<BackBackgroundImageURI>
|
||||
</BackBackgroundImageURI>
|
||||
<BackTitle>
|
||||
</BackTitle>
|
||||
<DeviceLockImageURI>
|
||||
</DeviceLockImageURI>
|
||||
<HasLarge>
|
||||
</HasLarge>
|
||||
</TemplateFlip>
|
||||
</PrimaryToken>
|
||||
</Tokens>
|
||||
<ScreenResolutions>
|
||||
<ScreenResolution Name="ID_RESOLUTION_WVGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_WXGA" />
|
||||
<ScreenResolution Name="ID_RESOLUTION_HD720P" />
|
||||
</ScreenResolutions>
|
||||
</App>
|
||||
</Deployment>
|
@ -0,0 +1,105 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17626
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace PhoneXamlDirect3DApp1.Resources
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class AppResources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal AppResources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PhoneXamlDirect3DApp1.Resources.AppResources", typeof(AppResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to LeftToRight.
|
||||
/// </summary>
|
||||
public static string ResourceFlowDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to us-EN.
|
||||
/// </summary>
|
||||
public static string ResourceLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ResourceLanguage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to MY APPLICATION.
|
||||
/// </summary>
|
||||
public static string ApplicationTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ApplicationTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ResourceFlowDirection" xml:space="preserve">
|
||||
<value>LeftToRight</value>
|
||||
<comment>Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language</comment>
|
||||
</data>
|
||||
<data name="ResourceLanguage" xml:space="preserve">
|
||||
<value>en-US</value>
|
||||
<comment>Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.</comment>
|
||||
</data>
|
||||
<data name="ApplicationTitle" xml:space="preserve">
|
||||
<value>MY APPLICATION</value>
|
||||
</data>
|
||||
</root>
|
After Width: | Height: | Size: 118 KiB |
@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
#include <wrl.h>
|
||||
|
||||
// Helper class for basic timing.
|
||||
ref class BasicTimer sealed
|
||||
{
|
||||
public:
|
||||
// Initializes internal timer values.
|
||||
BasicTimer()
|
||||
{
|
||||
if (!QueryPerformanceFrequency(&m_frequency))
|
||||
{
|
||||
throw ref new Platform::FailureException();
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
// Reset the timer to initial values.
|
||||
void Reset()
|
||||
{
|
||||
Update();
|
||||
m_startTime = m_currentTime;
|
||||
m_total = 0.0f;
|
||||
m_delta = 1.0f / 60.0f;
|
||||
}
|
||||
|
||||
// Update the timer's internal values.
|
||||
void Update()
|
||||
{
|
||||
if (!QueryPerformanceCounter(&m_currentTime))
|
||||
{
|
||||
throw ref new Platform::FailureException();
|
||||
}
|
||||
|
||||
m_total = static_cast<float>(
|
||||
static_cast<double>(m_currentTime.QuadPart - m_startTime.QuadPart) /
|
||||
static_cast<double>(m_frequency.QuadPart)
|
||||
);
|
||||
|
||||
if (m_lastTime.QuadPart == m_startTime.QuadPart)
|
||||
{
|
||||
// If the timer was just reset, report a time delta equivalent to 60Hz frame time.
|
||||
m_delta = 1.0f / 60.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_delta = static_cast<float>(
|
||||
static_cast<double>(m_currentTime.QuadPart - m_lastTime.QuadPart) /
|
||||
static_cast<double>(m_frequency.QuadPart)
|
||||
);
|
||||
}
|
||||
|
||||
m_lastTime = m_currentTime;
|
||||
}
|
||||
|
||||
// Duration in seconds between the last call to Reset() and the last call to Update().
|
||||
property float Total
|
||||
{
|
||||
float get() { return m_total; }
|
||||
}
|
||||
|
||||
// Duration in seconds between the previous two calls to Update().
|
||||
property float Delta
|
||||
{
|
||||
float get() { return m_delta; }
|
||||
}
|
||||
|
||||
private:
|
||||
LARGE_INTEGER m_frequency;
|
||||
LARGE_INTEGER m_currentTime;
|
||||
LARGE_INTEGER m_startTime;
|
||||
LARGE_INTEGER m_lastTime;
|
||||
float m_total;
|
||||
float m_delta;
|
||||
};
|
@ -0,0 +1,416 @@
|
||||
#include "pch.h"
|
||||
#include "CubeRenderer.h"
|
||||
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::Core;
|
||||
|
||||
CubeRenderer::CubeRenderer() :
|
||||
m_loadingComplete(false),
|
||||
m_indexCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
void CubeRenderer::CreateTextureFromByte(byte* buffer, int width, int height)
|
||||
{
|
||||
int pixelSize = 4;
|
||||
|
||||
if (m_texture.Get() == nullptr)
|
||||
{
|
||||
CD3D11_TEXTURE2D_DESC textureDesc(
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM, // format
|
||||
static_cast<UINT>(width), // width
|
||||
static_cast<UINT>(height), // height
|
||||
1, // arraySize
|
||||
1, // mipLevels
|
||||
D3D11_BIND_SHADER_RESOURCE, // bindFlags
|
||||
D3D11_USAGE_DYNAMIC, // usage
|
||||
D3D11_CPU_ACCESS_WRITE, // cpuaccessFlags
|
||||
1, // sampleCount
|
||||
0, // sampleQuality
|
||||
0 // miscFlags
|
||||
);
|
||||
|
||||
D3D11_SUBRESOURCE_DATA data;
|
||||
data.pSysMem = buffer;
|
||||
data.SysMemPitch = pixelSize*width;
|
||||
data.SysMemSlicePitch = pixelSize*width*height;
|
||||
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateTexture2D(
|
||||
&textureDesc,
|
||||
&data,
|
||||
m_texture.ReleaseAndGetAddressOf()
|
||||
)
|
||||
);
|
||||
|
||||
m_d3dDevice->CreateShaderResourceView(m_texture.Get(), NULL, m_SRV.ReleaseAndGetAddressOf());
|
||||
D3D11_SAMPLER_DESC sampDesc;
|
||||
ZeroMemory(&sampDesc, sizeof(sampDesc));
|
||||
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
sampDesc.MinLOD = 0;
|
||||
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
m_d3dDevice->CreateSamplerState(&sampDesc, m_cubesTexSamplerState.ReleaseAndGetAddressOf());
|
||||
}
|
||||
else
|
||||
{
|
||||
int nRowSpan = width * pixelSize;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
HRESULT hr = m_d3dContext->Map(m_texture.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
BYTE* mappedData = static_cast<BYTE*>(mappedResource.pData);
|
||||
|
||||
for (int i = 0; i < height; ++i)
|
||||
{
|
||||
memcpy(mappedData + (i*mappedResource.RowPitch), buffer + (i*nRowSpan), nRowSpan);
|
||||
}
|
||||
|
||||
m_d3dContext->Unmap(m_texture.Get(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void CubeRenderer::CreateDeviceResources()
|
||||
{
|
||||
Direct3DBase::CreateDeviceResources();
|
||||
D3D11_BLEND_DESC blendDesc;
|
||||
ZeroMemory( &blendDesc, sizeof(blendDesc) );
|
||||
|
||||
D3D11_RENDER_TARGET_BLEND_DESC rtbd;
|
||||
ZeroMemory( &rtbd, sizeof(rtbd) );
|
||||
|
||||
|
||||
rtbd.BlendEnable = TRUE;
|
||||
rtbd.SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
||||
rtbd.DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||
rtbd.BlendOp = D3D11_BLEND_OP_ADD;
|
||||
rtbd.SrcBlendAlpha = D3D11_BLEND_ONE;
|
||||
rtbd.DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||
rtbd.BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
rtbd.RenderTargetWriteMask = 0x0f;
|
||||
|
||||
|
||||
|
||||
blendDesc.AlphaToCoverageEnable = false;
|
||||
blendDesc.RenderTarget[0] = rtbd;
|
||||
|
||||
m_d3dDevice->CreateBlendState(&blendDesc, &m_transparency);
|
||||
|
||||
|
||||
D3D11_RASTERIZER_DESC cmdesc;
|
||||
ZeroMemory(&cmdesc, sizeof(D3D11_RASTERIZER_DESC));
|
||||
|
||||
cmdesc.FillMode = D3D11_FILL_SOLID;
|
||||
cmdesc.CullMode = D3D11_CULL_BACK;
|
||||
cmdesc.DepthClipEnable = TRUE;
|
||||
|
||||
|
||||
cmdesc.FrontCounterClockwise = true;
|
||||
m_d3dDevice->CreateRasterizerState(&cmdesc, &m_CCWcullMode);
|
||||
|
||||
cmdesc.FrontCounterClockwise = false;
|
||||
m_d3dDevice->CreateRasterizerState(&cmdesc, &m_CWcullMode);
|
||||
|
||||
|
||||
auto loadVSTask = DX::ReadDataAsync("SimpleVertexShader.cso");
|
||||
auto loadPSTask = DX::ReadDataAsync("SimplePixelShader.cso");
|
||||
|
||||
auto createVSTask = loadVSTask.then([this](Platform::Array<byte>^ fileData) {
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateVertexShader(
|
||||
fileData->Data,
|
||||
fileData->Length,
|
||||
nullptr,
|
||||
&m_vertexShader
|
||||
)
|
||||
);
|
||||
|
||||
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
|
||||
{
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateInputLayout(
|
||||
vertexDesc,
|
||||
ARRAYSIZE(vertexDesc),
|
||||
fileData->Data,
|
||||
fileData->Length,
|
||||
&m_inputLayout
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
auto createPSTask = loadPSTask.then([this](Platform::Array<byte>^ fileData) {
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreatePixelShader(
|
||||
fileData->Data,
|
||||
fileData->Length,
|
||||
nullptr,
|
||||
&m_pixelShader
|
||||
)
|
||||
);
|
||||
|
||||
CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ModelViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateBuffer(
|
||||
&constantBufferDesc,
|
||||
nullptr,
|
||||
&m_constantBuffer
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
auto createCubeTask = (createPSTask && createVSTask).then([this] () {
|
||||
Vertex v[] =
|
||||
{
|
||||
// Front Face
|
||||
Vertex(-1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
|
||||
Vertex(-1.0f, 1.0f, -1.0f, 0.0f, 0.0f),
|
||||
Vertex( 1.0f, 1.0f, -1.0f, 1.0f, 0.0f),
|
||||
Vertex( 1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
|
||||
|
||||
// Back Face
|
||||
Vertex(-1.0f, -1.0f, 1.0f, 1.0f, 1.0f),
|
||||
Vertex( 1.0f, -1.0f, 1.0f, 0.0f, 1.0f),
|
||||
Vertex( 1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
|
||||
Vertex(-1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
|
||||
|
||||
// Top Face
|
||||
Vertex(-1.0f, 1.0f, -1.0f, 0.0f, 1.0f),
|
||||
Vertex(-1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
|
||||
Vertex( 1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
|
||||
Vertex( 1.0f, 1.0f, -1.0f, 1.0f, 1.0f),
|
||||
|
||||
// Bottom Face
|
||||
Vertex(-1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
|
||||
Vertex( 1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
|
||||
Vertex( 1.0f, -1.0f, 1.0f, 0.0f, 0.0f),
|
||||
Vertex(-1.0f, -1.0f, 1.0f, 1.0f, 0.0f),
|
||||
|
||||
// Left Face
|
||||
Vertex(-1.0f, -1.0f, 1.0f, 0.0f, 1.0f),
|
||||
Vertex(-1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
|
||||
Vertex(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f),
|
||||
Vertex(-1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
|
||||
|
||||
// Right Face
|
||||
Vertex( 1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
|
||||
Vertex( 1.0f, 1.0f, -1.0f, 0.0f, 0.0f),
|
||||
Vertex( 1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
|
||||
Vertex( 1.0f, -1.0f, 1.0f, 1.0f, 1.0f),
|
||||
};
|
||||
|
||||
|
||||
|
||||
D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
|
||||
vertexBufferData.pSysMem = v;
|
||||
vertexBufferData.SysMemPitch = 0;
|
||||
vertexBufferData.SysMemSlicePitch = 0;
|
||||
CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(v), D3D11_BIND_VERTEX_BUFFER);
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateBuffer(
|
||||
&vertexBufferDesc,
|
||||
&vertexBufferData,
|
||||
&m_vertexBuffer
|
||||
)
|
||||
);
|
||||
|
||||
DWORD indices[] = {
|
||||
// Front Face
|
||||
0, 2, 1,
|
||||
0, 3, 2,
|
||||
|
||||
// Back Face
|
||||
4, 6, 5,
|
||||
4, 7, 6,
|
||||
|
||||
// Top Face
|
||||
8, 10, 9,
|
||||
8, 11, 10,
|
||||
|
||||
// Bottom Face
|
||||
12, 14, 13,
|
||||
12, 15, 14,
|
||||
|
||||
// Left Face
|
||||
16, 18, 17,
|
||||
16, 19, 18,
|
||||
|
||||
// Right Face
|
||||
20, 22, 21,
|
||||
20, 23, 22
|
||||
};
|
||||
|
||||
m_indexCount = ARRAYSIZE(indices);
|
||||
|
||||
D3D11_SUBRESOURCE_DATA indexBufferData = {0};
|
||||
indexBufferData.pSysMem = indices;
|
||||
indexBufferData.SysMemPitch = 0;
|
||||
indexBufferData.SysMemSlicePitch = 0;
|
||||
CD3D11_BUFFER_DESC indexBufferDesc(sizeof(indices), D3D11_BIND_INDEX_BUFFER);
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateBuffer(
|
||||
&indexBufferDesc,
|
||||
&indexBufferData,
|
||||
&m_indexBuffer
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
createCubeTask.then([this] () {
|
||||
m_loadingComplete = true;
|
||||
});
|
||||
}
|
||||
|
||||
void CubeRenderer::CreateWindowSizeDependentResources()
|
||||
{
|
||||
Direct3DBase::CreateWindowSizeDependentResources();
|
||||
|
||||
float aspectRatio = m_windowBounds.Width / m_windowBounds.Height;
|
||||
float fovAngleY = 70.0f * XM_PI / 180.0f;
|
||||
if (aspectRatio < 1.0f)
|
||||
{
|
||||
fovAngleY /= aspectRatio;
|
||||
}
|
||||
|
||||
XMStoreFloat4x4(
|
||||
&m_constantBufferData.projection,
|
||||
XMMatrixTranspose(
|
||||
XMMatrixPerspectiveFovRH(
|
||||
fovAngleY,
|
||||
aspectRatio,
|
||||
0.01f,
|
||||
100.0f
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void CubeRenderer::Update(float timeTotal, float timeDelta)
|
||||
{
|
||||
(void) timeDelta; // Unused parameter.
|
||||
|
||||
XMVECTOR eye = XMVectorSet(0.0f, 0.0f, 3.f, 0.0f);
|
||||
XMVECTOR at = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
|
||||
|
||||
XMStoreFloat4x4(&m_constantBufferData.view, XMMatrixTranspose(XMMatrixLookAtRH(eye, at, up)));
|
||||
XMStoreFloat4x4(&m_constantBufferData.model, XMMatrixTranspose(XMMatrixRotationY(timeTotal * XM_PIDIV4)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CubeRenderer::Render()
|
||||
{
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
Render(m_renderTargetView, m_depthStencilView);
|
||||
}
|
||||
|
||||
void CubeRenderer::Render(Microsoft::WRL::ComPtr<ID3D11RenderTargetView> renderTargetView, Microsoft::WRL::ComPtr<ID3D11DepthStencilView> depthStencilView)
|
||||
{
|
||||
|
||||
const float black[] = {0, 0, 0, 1.0 };
|
||||
m_d3dContext->ClearRenderTargetView(
|
||||
renderTargetView.Get(),
|
||||
black
|
||||
);
|
||||
|
||||
m_d3dContext->ClearDepthStencilView(
|
||||
depthStencilView.Get(),
|
||||
D3D11_CLEAR_DEPTH,
|
||||
1.0f,
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Only draw the cube once it is loaded (loading is asynchronous).
|
||||
if (!m_SRV || !m_loadingComplete)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_d3dContext->OMSetRenderTargets(
|
||||
1,
|
||||
renderTargetView.GetAddressOf(),
|
||||
depthStencilView.Get()
|
||||
);
|
||||
|
||||
m_d3dContext->UpdateSubresource(
|
||||
m_constantBuffer.Get(),
|
||||
0,
|
||||
NULL,
|
||||
&m_constantBufferData,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
UINT stride = sizeof(Vertex);
|
||||
UINT offset = 0;
|
||||
m_d3dContext->IASetVertexBuffers(
|
||||
0,
|
||||
1,
|
||||
m_vertexBuffer.GetAddressOf(),
|
||||
&stride,
|
||||
&offset
|
||||
);
|
||||
|
||||
m_d3dContext->IASetIndexBuffer(
|
||||
m_indexBuffer.Get(),
|
||||
DXGI_FORMAT_R32_UINT,
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
||||
m_d3dContext->IASetInputLayout(m_inputLayout.Get());
|
||||
|
||||
m_d3dContext->VSSetShader(
|
||||
m_vertexShader.Get(),
|
||||
nullptr,
|
||||
0
|
||||
);
|
||||
|
||||
m_d3dContext->VSSetConstantBuffers(
|
||||
0,
|
||||
1,
|
||||
m_constantBuffer.GetAddressOf()
|
||||
);
|
||||
|
||||
m_d3dContext->PSSetShader(
|
||||
m_pixelShader.Get(),
|
||||
nullptr,
|
||||
0
|
||||
);
|
||||
|
||||
m_d3dContext->PSSetShaderResources( 0, 1, m_SRV.GetAddressOf());
|
||||
m_d3dContext->PSSetSamplers( 0, 1, m_cubesTexSamplerState.GetAddressOf());
|
||||
|
||||
//float blendFactor[] = {0.75f, 0.75f, 0.75f, 1.0f};
|
||||
m_d3dContext->OMSetBlendState(m_transparency.Get(), nullptr, 0xffffffff);
|
||||
|
||||
m_d3dContext->RSSetState(m_CCWcullMode.Get());
|
||||
m_d3dContext->DrawIndexed(
|
||||
m_indexCount,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
m_d3dContext->RSSetState(m_CWcullMode.Get());
|
||||
m_d3dContext->DrawIndexed(
|
||||
m_indexCount,
|
||||
0,
|
||||
0
|
||||
);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include "Direct3DBase.h"
|
||||
#include <d3d11.h>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
struct ModelViewProjectionConstantBuffer
|
||||
{
|
||||
DirectX::XMFLOAT4X4 model;
|
||||
DirectX::XMFLOAT4X4 view;
|
||||
DirectX::XMFLOAT4X4 projection;
|
||||
};
|
||||
|
||||
struct Vertex //Overloaded Vertex Structure
|
||||
{
|
||||
Vertex(){}
|
||||
Vertex(float x, float y, float z,
|
||||
float u, float v)
|
||||
: pos(x,y,z), texCoord(u, v){}
|
||||
|
||||
DirectX::XMFLOAT3 pos;
|
||||
DirectX::XMFLOAT2 texCoord;
|
||||
};
|
||||
|
||||
// This class renders a simple spinning cube.
|
||||
ref class CubeRenderer sealed : public Direct3DBase
|
||||
{
|
||||
public:
|
||||
CubeRenderer();
|
||||
|
||||
// Direct3DBase methods.
|
||||
virtual void CreateDeviceResources() override;
|
||||
virtual void CreateWindowSizeDependentResources() override;
|
||||
virtual void Render() override;
|
||||
|
||||
// Method for updating time-dependent objects.
|
||||
void Update(float timeTotal, float timeDelta);
|
||||
|
||||
void CreateTextureFromByte(byte * buffer,int width,int height);
|
||||
private:
|
||||
void Render(Microsoft::WRL::ComPtr<ID3D11RenderTargetView> renderTargetView, Microsoft::WRL::ComPtr<ID3D11DepthStencilView> depthStencilView);
|
||||
bool m_loadingComplete;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
|
||||
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_texture;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_SRV;
|
||||
Microsoft::WRL::ComPtr<ID3D11SamplerState> m_cubesTexSamplerState;
|
||||
uint32 m_indexCount;
|
||||
ModelViewProjectionConstantBuffer m_constantBufferData;
|
||||
std::mutex m_mutex;
|
||||
Microsoft::WRL::ComPtr<ID3D11BlendState> m_transparency;
|
||||
Microsoft::WRL::ComPtr<ID3D11RasterizerState> m_CCWcullMode;
|
||||
Microsoft::WRL::ComPtr<ID3D11RasterizerState> m_CWcullMode;
|
||||
|
||||
};
|
@ -0,0 +1,162 @@
|
||||
#include "pch.h"
|
||||
#include "Direct3DBase.h"
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::Graphics::Display;
|
||||
|
||||
// Constructor.
|
||||
Direct3DBase::Direct3DBase()
|
||||
{
|
||||
}
|
||||
|
||||
// Initialize the Direct3D resources required to run.
|
||||
void Direct3DBase::Initialize()
|
||||
{
|
||||
CreateDeviceResources();
|
||||
}
|
||||
|
||||
// These are the resources that depend on the device.
|
||||
void Direct3DBase::CreateDeviceResources()
|
||||
{
|
||||
// This flag adds support for surfaces with a different color channel ordering
|
||||
// than the API default. It is required for compatibility with Direct2D.
|
||||
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
|
||||
|
||||
#if defined(_DEBUG)
|
||||
// If the project is in a debug build, enable debugging via SDK Layers with this flag.
|
||||
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
#endif
|
||||
|
||||
// This array defines the set of DirectX hardware feature levels this app will support.
|
||||
// Note the ordering should be preserved.
|
||||
// Don't forget to declare your application's minimum required feature level in its
|
||||
// description. All applications are assumed to support 9.1 unless otherwise stated.
|
||||
D3D_FEATURE_LEVEL featureLevels[] =
|
||||
{
|
||||
D3D_FEATURE_LEVEL_11_1,
|
||||
D3D_FEATURE_LEVEL_11_0,
|
||||
D3D_FEATURE_LEVEL_10_1,
|
||||
D3D_FEATURE_LEVEL_10_0,
|
||||
D3D_FEATURE_LEVEL_9_3
|
||||
};
|
||||
|
||||
// Create the Direct3D 11 API device object and a corresponding context.
|
||||
ComPtr<ID3D11Device> device;
|
||||
ComPtr<ID3D11DeviceContext> context;
|
||||
DX::ThrowIfFailed(
|
||||
D3D11CreateDevice(
|
||||
nullptr, // Specify nullptr to use the default adapter.
|
||||
D3D_DRIVER_TYPE_HARDWARE,
|
||||
nullptr,
|
||||
creationFlags, // Set set debug and Direct2D compatibility flags.
|
||||
featureLevels, // List of feature levels this app can support.
|
||||
ARRAYSIZE(featureLevels),
|
||||
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION.
|
||||
&device, // Returns the Direct3D device created.
|
||||
&m_featureLevel, // Returns feature level of device created.
|
||||
&context // Returns the device immediate context.
|
||||
)
|
||||
);
|
||||
|
||||
// Get the Direct3D 11.1 API device and context interfaces.
|
||||
DX::ThrowIfFailed(
|
||||
device.As(&m_d3dDevice)
|
||||
);
|
||||
|
||||
DX::ThrowIfFailed(
|
||||
context.As(&m_d3dContext)
|
||||
);
|
||||
}
|
||||
|
||||
// Allocate all memory resources that depend on the window size.
|
||||
void Direct3DBase::CreateWindowSizeDependentResources()
|
||||
{
|
||||
// Create a descriptor for the render target buffer.
|
||||
CD3D11_TEXTURE2D_DESC renderTargetDesc(
|
||||
DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
static_cast<UINT>(m_renderTargetSize.Width),
|
||||
static_cast<UINT>(m_renderTargetSize.Height),
|
||||
1,
|
||||
1,
|
||||
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE
|
||||
);
|
||||
renderTargetDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | D3D11_RESOURCE_MISC_SHARED_NTHANDLE;
|
||||
|
||||
// Allocate a 2-D surface as the render target buffer.
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateTexture2D(
|
||||
&renderTargetDesc,
|
||||
nullptr,
|
||||
&m_renderTarget
|
||||
)
|
||||
);
|
||||
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateRenderTargetView(
|
||||
m_renderTarget.Get(),
|
||||
nullptr,
|
||||
&m_renderTargetView
|
||||
)
|
||||
);
|
||||
|
||||
// Create a depth stencil view.
|
||||
CD3D11_TEXTURE2D_DESC depthStencilDesc(
|
||||
DXGI_FORMAT_D24_UNORM_S8_UINT,
|
||||
static_cast<UINT>(m_renderTargetSize.Width),
|
||||
static_cast<UINT>(m_renderTargetSize.Height),
|
||||
1,
|
||||
1,
|
||||
D3D11_BIND_DEPTH_STENCIL
|
||||
);
|
||||
|
||||
ComPtr<ID3D11Texture2D> depthStencil;
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateTexture2D(
|
||||
&depthStencilDesc,
|
||||
nullptr,
|
||||
&depthStencil
|
||||
)
|
||||
);
|
||||
|
||||
CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D);
|
||||
DX::ThrowIfFailed(
|
||||
m_d3dDevice->CreateDepthStencilView(
|
||||
depthStencil.Get(),
|
||||
&depthStencilViewDesc,
|
||||
&m_depthStencilView
|
||||
)
|
||||
);
|
||||
|
||||
// Set the rendering viewport to target the entire window.
|
||||
CD3D11_VIEWPORT viewport(
|
||||
0.0f,
|
||||
0.0f,
|
||||
m_renderTargetSize.Width,
|
||||
m_renderTargetSize.Height
|
||||
);
|
||||
|
||||
m_d3dContext->RSSetViewports(1, &viewport);
|
||||
}
|
||||
|
||||
void Direct3DBase::UpdateForRenderResolutionChange(float width, float height)
|
||||
{
|
||||
m_renderTargetSize.Width = width;
|
||||
m_renderTargetSize.Height = height;
|
||||
|
||||
ID3D11RenderTargetView* nullViews[] = {nullptr};
|
||||
m_d3dContext->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
|
||||
m_renderTarget = nullptr;
|
||||
m_renderTargetView = nullptr;
|
||||
m_depthStencilView = nullptr;
|
||||
m_d3dContext->Flush();
|
||||
CreateWindowSizeDependentResources();
|
||||
}
|
||||
|
||||
void Direct3DBase::UpdateForWindowSizeChange(float width, float height)
|
||||
{
|
||||
m_windowBounds.Width = width;
|
||||
m_windowBounds.Height = height;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "DirectXHelper.h"
|
||||
|
||||
// Helper class that initializes DirectX APIs for 3D rendering.
|
||||
ref class Direct3DBase abstract
|
||||
{
|
||||
internal:
|
||||
Direct3DBase();
|
||||
|
||||
public:
|
||||
virtual void Initialize();
|
||||
virtual void CreateDeviceResources();
|
||||
virtual void CreateWindowSizeDependentResources();
|
||||
virtual void UpdateForRenderResolutionChange(float width, float height);
|
||||
virtual void UpdateForWindowSizeChange(float width, float height);
|
||||
virtual void Render() = 0;
|
||||
|
||||
internal:
|
||||
virtual ID3D11Texture2D* GetTexture()
|
||||
{
|
||||
return m_renderTarget.Get();
|
||||
}
|
||||
|
||||
protected private:
|
||||
// Direct3D Objects.
|
||||
Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
|
||||
Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> m_renderTarget;
|
||||
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
|
||||
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_depthStencilView;
|
||||
|
||||
// Cached renderer properties.
|
||||
D3D_FEATURE_LEVEL m_featureLevel;
|
||||
Windows::Foundation::Size m_renderTargetSize;
|
||||
Windows::Foundation::Rect m_windowBounds;
|
||||
};
|
@ -0,0 +1,77 @@
|
||||
#include "pch.h"
|
||||
#include "Direct3DContentProvider.h"
|
||||
|
||||
using namespace PhoneXamlDirect3DApp1Comp;
|
||||
|
||||
Direct3DContentProvider::Direct3DContentProvider(Direct3DInterop^ controller) :
|
||||
m_controller(controller)
|
||||
{
|
||||
m_controller->RequestAdditionalFrame += ref new RequestAdditionalFrameHandler([=] ()
|
||||
{
|
||||
if (m_host)
|
||||
{
|
||||
m_host->RequestAdditionalFrame();
|
||||
}
|
||||
});
|
||||
|
||||
m_controller->RecreateSynchronizedTexture += ref new RecreateSynchronizedTextureHandler([=] ()
|
||||
{
|
||||
if (m_host)
|
||||
{
|
||||
m_host->CreateSynchronizedTexture(m_controller->GetTexture(), &m_synchronizedTexture);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// IDrawingSurfaceContentProviderNative interface
|
||||
HRESULT Direct3DContentProvider::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host)
|
||||
{
|
||||
m_host = host;
|
||||
|
||||
return m_controller->Connect(host);
|
||||
}
|
||||
|
||||
void Direct3DContentProvider::Disconnect()
|
||||
{
|
||||
m_controller->Disconnect();
|
||||
m_host = nullptr;
|
||||
m_synchronizedTexture = nullptr;
|
||||
}
|
||||
|
||||
HRESULT Direct3DContentProvider::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty)
|
||||
{
|
||||
return m_controller->PrepareResources(presentTargetTime, contentDirty);
|
||||
}
|
||||
|
||||
HRESULT Direct3DContentProvider::GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (!m_synchronizedTexture)
|
||||
{
|
||||
hr = m_host->CreateSynchronizedTexture(m_controller->GetTexture(), &m_synchronizedTexture);
|
||||
}
|
||||
|
||||
// Set output parameters.
|
||||
textureSubRectangle->left = 0.0f;
|
||||
textureSubRectangle->top = 0.0f;
|
||||
textureSubRectangle->right = static_cast<FLOAT>(size->width);
|
||||
textureSubRectangle->bottom = static_cast<FLOAT>(size->height);
|
||||
|
||||
m_synchronizedTexture.CopyTo(synchronizedTexture);
|
||||
|
||||
// Draw to the texture.
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = m_synchronizedTexture->BeginDraw();
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = m_controller->GetTexture(size, synchronizedTexture, textureSubRectangle);
|
||||
}
|
||||
|
||||
m_synchronizedTexture->EndDraw();
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
#include <wrl/module.h>
|
||||
#include <Windows.Phone.Graphics.Interop.h>
|
||||
#include <DrawingSurfaceNative.h>
|
||||
|
||||
#include "Direct3DInterop.h"
|
||||
|
||||
class Direct3DContentProvider : public Microsoft::WRL::RuntimeClass<
|
||||
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::WinRtClassicComMix>,
|
||||
ABI::Windows::Phone::Graphics::Interop::IDrawingSurfaceContentProvider,
|
||||
IDrawingSurfaceContentProviderNative>
|
||||
{
|
||||
public:
|
||||
Direct3DContentProvider(PhoneXamlDirect3DApp1Comp::Direct3DInterop^ controller);
|
||||
|
||||
void ReleaseD3DResources();
|
||||
|
||||
// IDrawingSurfaceContentProviderNative
|
||||
HRESULT STDMETHODCALLTYPE Connect(_In_ IDrawingSurfaceRuntimeHostNative* host);
|
||||
void STDMETHODCALLTYPE Disconnect();
|
||||
|
||||
HRESULT STDMETHODCALLTYPE PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty);
|
||||
HRESULT STDMETHODCALLTYPE GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle);
|
||||
|
||||
private:
|
||||
HRESULT InitializeTexture(_In_ const DrawingSurfaceSizeF* size);
|
||||
|
||||
PhoneXamlDirect3DApp1Comp::Direct3DInterop^ m_controller;
|
||||
Microsoft::WRL::ComPtr<IDrawingSurfaceRuntimeHostNative> m_host;
|
||||
Microsoft::WRL::ComPtr<IDrawingSurfaceSynchronizedTextureNative> m_synchronizedTexture;
|
||||
};
|
@ -0,0 +1,186 @@
|
||||
#include "pch.h"
|
||||
#include "Direct3DInterop.h"
|
||||
#include "Direct3DContentProvider.h"
|
||||
#include <windows.storage.streams.h>
|
||||
#include <wrl.h>
|
||||
#include <robuffer.h>
|
||||
#include <opencv2\imgproc\types_c.h>
|
||||
|
||||
using namespace Windows::Storage::Streams;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Windows::Phone::Graphics::Interop;
|
||||
using namespace Windows::Phone::Input::Interop;
|
||||
|
||||
namespace PhoneXamlDirect3DApp1Comp
|
||||
{
|
||||
void Direct3DInterop::ApplyGrayFilter(const cv::Mat& image)
|
||||
{
|
||||
cv::Mat intermediateMat;
|
||||
cv::cvtColor(image, intermediateMat, CV_RGBA2GRAY);
|
||||
cv::cvtColor(intermediateMat, image, CV_GRAY2BGRA);
|
||||
}
|
||||
|
||||
void Direct3DInterop::ApplyCannyFilter(const cv::Mat& image)
|
||||
{
|
||||
cv::Mat intermediateMat;
|
||||
cv::Canny(image, intermediateMat, 80, 90);
|
||||
cv::cvtColor(intermediateMat, image, CV_GRAY2BGRA);
|
||||
}
|
||||
|
||||
void Direct3DInterop::ApplySepiaFilter(const cv::Mat& image)
|
||||
{
|
||||
const float SepiaKernelData[16] =
|
||||
{
|
||||
/* B */0.131f, 0.534f, 0.272f, 0.f,
|
||||
/* G */0.168f, 0.686f, 0.349f, 0.f,
|
||||
/* R */0.189f, 0.769f, 0.393f, 0.f,
|
||||
/* A */0.000f, 0.000f, 0.000f, 1.f
|
||||
};
|
||||
|
||||
const cv::Mat SepiaKernel(4, 4, CV_32FC1, (void*)SepiaKernelData);
|
||||
cv::transform(image, image, SepiaKernel);
|
||||
}
|
||||
|
||||
Direct3DInterop::Direct3DInterop() :
|
||||
m_timer(ref new BasicTimer())
|
||||
{
|
||||
}
|
||||
|
||||
IDrawingSurfaceContentProvider^ Direct3DInterop::CreateContentProvider()
|
||||
{
|
||||
ComPtr<Direct3DContentProvider> provider = Make<Direct3DContentProvider>(this);
|
||||
return reinterpret_cast<IDrawingSurfaceContentProvider^>(provider.Detach());
|
||||
}
|
||||
|
||||
// IDrawingSurfaceManipulationHandler
|
||||
void Direct3DInterop::SetManipulationHost(DrawingSurfaceManipulationHost^ manipulationHost)
|
||||
{
|
||||
manipulationHost->PointerPressed +=
|
||||
ref new TypedEventHandler<DrawingSurfaceManipulationHost^, PointerEventArgs^>(this, &Direct3DInterop::OnPointerPressed);
|
||||
|
||||
manipulationHost->PointerMoved +=
|
||||
ref new TypedEventHandler<DrawingSurfaceManipulationHost^, PointerEventArgs^>(this, &Direct3DInterop::OnPointerMoved);
|
||||
|
||||
manipulationHost->PointerReleased +=
|
||||
ref new TypedEventHandler<DrawingSurfaceManipulationHost^, PointerEventArgs^>(this, &Direct3DInterop::OnPointerReleased);
|
||||
}
|
||||
|
||||
void Direct3DInterop::RenderResolution::set(Windows::Foundation::Size renderResolution)
|
||||
{
|
||||
if (renderResolution.Width != m_renderResolution.Width ||
|
||||
renderResolution.Height != m_renderResolution.Height)
|
||||
{
|
||||
m_renderResolution = renderResolution;
|
||||
|
||||
if (m_renderer)
|
||||
{
|
||||
m_renderer->UpdateForRenderResolutionChange(m_renderResolution.Width, m_renderResolution.Height);
|
||||
RecreateSynchronizedTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Event Handlers
|
||||
|
||||
void Direct3DInterop::OnPointerPressed(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
// Insert your code here.
|
||||
}
|
||||
|
||||
void Direct3DInterop::OnPointerMoved(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
// Insert your code here.
|
||||
}
|
||||
|
||||
void Direct3DInterop::OnPointerReleased(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
// Insert your code here.
|
||||
}
|
||||
|
||||
// Interface With Direct3DContentProvider
|
||||
HRESULT Direct3DInterop::Connect(_In_ IDrawingSurfaceRuntimeHostNative* host)
|
||||
{
|
||||
m_renderer = ref new CubeRenderer();
|
||||
m_renderer->Initialize();
|
||||
m_renderer->UpdateForWindowSizeChange(WindowBounds.Width, WindowBounds.Height);
|
||||
m_renderer->UpdateForRenderResolutionChange(m_renderResolution.Width, m_renderResolution.Height);
|
||||
|
||||
// Restart timer after renderer has finished initializing.
|
||||
m_timer->Reset();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void Direct3DInterop::Disconnect()
|
||||
{
|
||||
m_renderer = nullptr;
|
||||
}
|
||||
|
||||
HRESULT Direct3DInterop::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty)
|
||||
{
|
||||
*contentDirty = true;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Direct3DInterop::GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle)
|
||||
{
|
||||
m_timer->Update();
|
||||
m_renderer->Update(m_timer->Total, m_timer->Delta);
|
||||
m_renderer->Render();
|
||||
|
||||
RequestAdditionalFrame();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
ID3D11Texture2D* Direct3DInterop::GetTexture()
|
||||
{
|
||||
return m_renderer->GetTexture();
|
||||
}
|
||||
|
||||
void Direct3DInterop::CreateTexture(const Platform::Array<int>^ buffer,int width,int height, OCVFilterType filter)
|
||||
{
|
||||
if (m_renderer)
|
||||
{
|
||||
cv::Mat Lena = cv::Mat(height, width, CV_8UC4);
|
||||
memcpy(Lena.data, buffer->Data, 4 * height*width);
|
||||
|
||||
switch (filter)
|
||||
{
|
||||
case OCVFilterType::ePreview:
|
||||
break;
|
||||
|
||||
case OCVFilterType::eGray:
|
||||
ApplyGrayFilter(Lena);
|
||||
break;
|
||||
|
||||
case OCVFilterType::eCanny:
|
||||
ApplyCannyFilter(Lena);
|
||||
break;
|
||||
|
||||
case OCVFilterType::eSepia:
|
||||
ApplySepiaFilter(Lena);
|
||||
break;
|
||||
}
|
||||
|
||||
m_renderer->CreateTextureFromByte(Lena.data, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
byte* GetPointerToPixelData( Windows::Storage::Streams::IBuffer ^ pixelBuffer)
|
||||
{
|
||||
// Query the IBufferByteAccess interface.
|
||||
ComPtr<IBufferByteAccess> bufferByteAccess;
|
||||
reinterpret_cast<IInspectable*>( pixelBuffer)->QueryInterface(IID_PPV_ARGS(&bufferByteAccess));
|
||||
|
||||
// Retrieve the buffer data.
|
||||
byte* pixels = nullptr;
|
||||
bufferByteAccess->Buffer(&pixels);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
#include "BasicTimer.h"
|
||||
#include "CubeRenderer.h"
|
||||
#include <DrawingSurfaceNative.h>
|
||||
#include <ppltasks.h>
|
||||
#include <windows.storage.streams.h>
|
||||
#include <opencv2\core\core.hpp>
|
||||
#include <opencv2\imgproc\imgproc.hpp>
|
||||
#include <opencv2\features2d\features2d.hpp>
|
||||
|
||||
namespace PhoneXamlDirect3DApp1Comp
|
||||
{
|
||||
|
||||
public enum class OCVFilterType
|
||||
{
|
||||
ePreview,
|
||||
eGray,
|
||||
eCanny,
|
||||
eSepia,
|
||||
eNumOCVFilterTypes
|
||||
};
|
||||
|
||||
public delegate void RequestAdditionalFrameHandler();
|
||||
public delegate void RecreateSynchronizedTextureHandler();
|
||||
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class Direct3DInterop sealed : public Windows::Phone::Input::Interop::IDrawingSurfaceManipulationHandler
|
||||
{
|
||||
public:
|
||||
Direct3DInterop();
|
||||
|
||||
Windows::Phone::Graphics::Interop::IDrawingSurfaceContentProvider^ CreateContentProvider();
|
||||
|
||||
// IDrawingSurfaceManipulationHandler
|
||||
virtual void SetManipulationHost(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ manipulationHost);
|
||||
|
||||
event RequestAdditionalFrameHandler^ RequestAdditionalFrame;
|
||||
event RecreateSynchronizedTextureHandler^ RecreateSynchronizedTexture;
|
||||
|
||||
property Windows::Foundation::Size WindowBounds;
|
||||
property Windows::Foundation::Size NativeResolution;
|
||||
property Windows::Foundation::Size RenderResolution
|
||||
{
|
||||
Windows::Foundation::Size get(){ return m_renderResolution; }
|
||||
void set(Windows::Foundation::Size renderResolution);
|
||||
}
|
||||
void CreateTexture(const Platform::Array<int>^ buffer, int with, int height, OCVFilterType filter);
|
||||
|
||||
|
||||
protected:
|
||||
// Event Handlers
|
||||
void OnPointerPressed(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
||||
void OnPointerMoved(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
||||
void OnPointerReleased(Windows::Phone::Input::Interop::DrawingSurfaceManipulationHost^ sender, Windows::UI::Core::PointerEventArgs^ args);
|
||||
|
||||
internal:
|
||||
HRESULT STDMETHODCALLTYPE Connect(_In_ IDrawingSurfaceRuntimeHostNative* host);
|
||||
void STDMETHODCALLTYPE Disconnect();
|
||||
HRESULT STDMETHODCALLTYPE PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Out_ BOOL* contentDirty);
|
||||
HRESULT STDMETHODCALLTYPE GetTexture(_In_ const DrawingSurfaceSizeF* size, _Out_ IDrawingSurfaceSynchronizedTextureNative** synchronizedTexture, _Out_ DrawingSurfaceRectF* textureSubRectangle);
|
||||
ID3D11Texture2D* GetTexture();
|
||||
|
||||
private:
|
||||
CubeRenderer^ m_renderer;
|
||||
BasicTimer^ m_timer;
|
||||
Windows::Foundation::Size m_renderResolution;
|
||||
|
||||
void ApplyGrayFilter(const cv::Mat& image);
|
||||
void ApplyCannyFilter(const cv::Mat& image);
|
||||
void ApplySepiaFilter(const cv::Mat& image);
|
||||
|
||||
void UpdateImage(const cv::Mat& image);
|
||||
|
||||
cv::Mat Lena;
|
||||
unsigned int frameWidth, frameHeight;
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <wrl/client.h>
|
||||
#include <ppl.h>
|
||||
#include <ppltasks.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
inline void ThrowIfFailed(HRESULT hr)
|
||||
{
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// Set a breakpoint on this line to catch Win32 API errors.
|
||||
throw Platform::Exception::CreateException(hr);
|
||||
}
|
||||
}
|
||||
|
||||
// Function that reads from a binary file asynchronously.
|
||||
inline Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename)
|
||||
{
|
||||
using namespace Windows::Storage;
|
||||
using namespace Concurrency;
|
||||
|
||||
auto folder = Windows::ApplicationModel::Package::Current->InstalledLocation;
|
||||
|
||||
return create_task(folder->GetFileAsync(filename)).then([] (StorageFile^ file)
|
||||
{
|
||||
return file->OpenReadAsync();
|
||||
}).then([] (Streams::IRandomAccessStreamWithContentType^ stream)
|
||||
{
|
||||
unsigned int bufferSize = static_cast<unsigned int>(stream->Size);
|
||||
auto fileBuffer = ref new Streams::Buffer(bufferSize);
|
||||
return stream->ReadAsync(fileBuffer, bufferSize, Streams::InputStreamOptions::None);
|
||||
}).then([] (Streams::IBuffer^ fileBuffer) -> Platform::Array<byte>^
|
||||
{
|
||||
auto fileData = ref new Platform::Array<byte>(fileBuffer->Length);
|
||||
Streams::DataReader::FromBuffer(fileBuffer)->ReadBytes(fileData);
|
||||
return fileData;
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|ARM">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{C0F94AFA-466F-4FC4-B5C1-6CD955F3FF88}</ProjectGuid>
|
||||
<RootNamespace>PhoneXamlDirect3DApp1Comp</RootNamespace>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<WinMDAssembly>true</WinMDAssembly>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup>
|
||||
<!-- If OutDir was set outside of the project file, then we will append ProjectName -->
|
||||
<OutDir Condition="'$(OutDirWasSpecified)' == 'true'">$(OutDir)\$(MSBuildProjectName)\</OutDir>
|
||||
<!-- else, OutDir needs to have project specific directory in order to handle files with unique names -->
|
||||
<OutDir Condition="'$(OutDirWasSpecified)' != 'true' and '$(Platform)' == 'Win32'">$(SolutionDir)$(Configuration)\$(MSBuildProjectName)\</OutDir>
|
||||
<OutDir Condition="'$(OutDirWasSpecified)' != 'true' and '$(Platform)' != 'Win32'">$(SolutionDir)$(Platform)\$(Configuration)\$(MSBuildProjectName)\</OutDir>
|
||||
<!-- After OutDir has been fixed, disable Microsoft.common.targets from fixing it again -->
|
||||
<OutDirWasSpecified>false</OutDirWasSpecified>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LibraryPath>$(ProjectDir)..\..\..\..\..\bin\WP\8.0\x86\lib\Debug;$(ProjectDir)..\..\..\..\..\bin\WP\8.0\x86\3rdparty\lib\Debug;$(WP80ToolSetPath)lib;$(WindowsSDK_LibraryPath_x86)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\modules\features2d\include;$(ProjectDir)..\..\..\..\..\modules\flann\include;$(ProjectDir)..\..\..\..\..\modules\imgproc\include;$(ProjectDir)..\..\..\..\..\modules\core\include;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>opencv_core300d.lib;opencv_imgproc300d.lib;opencv_features2d300d.lib;opencv_flann300d.lib;opencv_ml300d.lib;zlibd.lib;d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\..\binWP8;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\..\binWP8;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\..\binWP8;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<AdditionalDependencies>d3d11.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="platform.winmd">
|
||||
<IsWinMDFile>true</IsWinMDFile>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BasicTimer.h" />
|
||||
<ClInclude Include="Direct3DInterop.h" />
|
||||
<ClInclude Include="CubeRenderer.h" />
|
||||
<ClInclude Include="DirectXHelper.h" />
|
||||
<ClInclude Include="Direct3DBase.h" />
|
||||
<ClInclude Include="Direct3DContentProvider.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Direct3DInterop.cpp" />
|
||||
<ClCompile Include="CubeRenderer.cpp" />
|
||||
<ClCompile Include="Direct3DBase.cpp" />
|
||||
<ClCompile Include="Direct3DContentProvider.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<FxCompile Include="SimplePixelShader.hlsl">
|
||||
<ShaderType>Pixel</ShaderType>
|
||||
<ShaderModel>4.0_level_9_3</ShaderModel>
|
||||
</FxCompile>
|
||||
<FxCompile Include="SimpleVertexShader.hlsl">
|
||||
<ShaderType>Vertex</ShaderType>
|
||||
<ShaderModel>4.0_level_9_3</ShaderModel>
|
||||
</FxCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_core300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_features2d300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_flann300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_imgproc300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_ml300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\..\packages\NokiaImagingSDK.1.0.272.0\build\native\NokiaImagingSDK.targets" Condition="Exists('..\..\packages\NokiaImagingSDK.1.0.272.0\build\native\NokiaImagingSDK.targets')" />
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -0,0 +1,25 @@
|
||||
Texture2D shaderTexture;
|
||||
SamplerState SampleType;
|
||||
|
||||
//////////////
|
||||
// TYPEDEFS //
|
||||
//////////////
|
||||
struct PixelInputType
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Pixel Shader
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
float4 main(PixelInputType input) : SV_TARGET
|
||||
{
|
||||
float4 textureColor;
|
||||
|
||||
|
||||
// Sample the pixel color from the texture using the sampler at this texture coordinate location.
|
||||
textureColor = shaderTexture.Sample(SampleType, input.tex);
|
||||
|
||||
return textureColor;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
cbuffer ModelViewProjectionConstantBuffer : register(b0)
|
||||
{
|
||||
matrix model;
|
||||
matrix view;
|
||||
matrix projection;
|
||||
};
|
||||
|
||||
struct VertexInputType
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PixelInputType
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Vertex Shader
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
PixelInputType main(VertexInputType input)
|
||||
{
|
||||
PixelInputType output;
|
||||
|
||||
// Change the position vector to be 4 units for proper matrix calculations.
|
||||
input.position.w = 1.0f;
|
||||
|
||||
// Calculate the position of the vertex against the world, view, and projection matrices.
|
||||
output.position = mul(input.position, model);
|
||||
output.position = mul(output.position, view);
|
||||
output.position = mul(output.position, projection);
|
||||
// Store the texture coordinates for the pixel shader.
|
||||
output.tex = input.tex;
|
||||
|
||||
return output;
|
||||
}
|
@ -0,0 +1 @@
|
||||
#include "pch.h"
|
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <wrl/client.h>
|
||||
#include <d3d11_1.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <memory>
|
||||
#include <agile.h>
|
69
samples/wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
// OpenCVComponent.cpp
|
||||
#include "pch.h"
|
||||
#include "OpenCVComponent.h"
|
||||
|
||||
#include <opencv2\imgproc\types_c.h>
|
||||
#include <opencv2\core\core.hpp>
|
||||
#include <opencv2\imgproc\imgproc.hpp>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace OpenCVComponent;
|
||||
using namespace Platform;
|
||||
using namespace concurrency;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
|
||||
void CopyIVectorToMatrix(IVector<int>^ input, cv::Mat& mat, int size);
|
||||
void CopyMatrixToVector(const cv::Mat& mat, std::vector<int>& vector, int size);
|
||||
|
||||
OpenCVLib::OpenCVLib()
|
||||
{
|
||||
}
|
||||
|
||||
IAsyncOperation<IVectorView<int>^>^ OpenCVLib::ProcessAsync(IVector<int>^ input, int width, int height)
|
||||
{
|
||||
int size = input->Size;
|
||||
cv::Mat mat(width, height, CV_8UC4);
|
||||
CopyIVectorToMatrix(input, mat, size);
|
||||
|
||||
return create_async([=]() -> IVectorView<int>^
|
||||
{
|
||||
// convert to grayscale
|
||||
cv::Mat intermediateMat;
|
||||
cv::cvtColor(mat, intermediateMat, CV_RGB2GRAY);
|
||||
|
||||
// convert to BGRA
|
||||
cv::cvtColor(intermediateMat, mat, CV_GRAY2BGRA);
|
||||
|
||||
std::vector<int> output;
|
||||
CopyMatrixToVector(mat, output, size);
|
||||
|
||||
// Return the outputs as a VectorView<float>
|
||||
return ref new Platform::Collections::VectorView<int>(output);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void CopyIVectorToMatrix(IVector<int>^ input, cv::Mat& mat, int size)
|
||||
{
|
||||
unsigned char* data = mat.data;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
int value = input->GetAt(i);
|
||||
memcpy(data, (void*) &value, 4);
|
||||
data += 4;
|
||||
}
|
||||
}
|
||||
|
||||
void CopyMatrixToVector(const cv::Mat& mat, std::vector<int>& vector, int size)
|
||||
{
|
||||
int* data = (int*) mat.data;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
vector.push_back(data[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
14
samples/wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <ppltasks.h>
|
||||
#include <collection.h>
|
||||
|
||||
namespace OpenCVComponent
|
||||
{
|
||||
public ref class OpenCVLib sealed
|
||||
{
|
||||
public:
|
||||
OpenCVLib();
|
||||
Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<int>^>^ ProcessAsync(Windows::Foundation::Collections::IVector<int>^ input, int width, int height);
|
||||
};
|
||||
}
|
156
samples/wp8/OpenCVXaml/OpenCVComponent/OpenCVComponent.vcxproj
Normal file
@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|ARM">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{eadff7b8-e6c3-4f34-9b33-014b3035c595}</ProjectGuid>
|
||||
<RootNamespace>OpenCVComponent</RootNamespace>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<WinMDAssembly>true</WinMDAssembly>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<PlatformToolset>v110_wp80</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<GenerateManifest>false</GenerateManifest>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LibraryPath>$(ProjectDir)..\..\..\..\bin\WP\8.0\x86\lib\Debug;$(ProjectDir)..\..\..\..\bin\WP\8.0\x86\3rdparty\lib\Debug;$(WP80ToolSetPath)lib;$(WindowsSDK_LibraryPath_x86)</LibraryPath>
|
||||
<IgnoreImportLibrary>false</IgnoreImportLibrary>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\modules\imgproc\include;$(ProjectDir)..\..\..\..\modules\core\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
<AdditionalDependencies>opencv_core300d.lib;opencv_imgproc300d.lib;zlibd.lib;WindowsPhoneCore.lib;RuntimeObject.lib;PhoneAppModelHost.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\binWP8;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\binWP8;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<AdditionalIncludeDirectories>..\..\..\..\binWP8;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
<IgnoreSpecificDefaultLibraries>ole32.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="platform.winmd">
|
||||
<IsWinMDFile>true</IsWinMDFile>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="OpenCVComponent.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="OpenCVComponent.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader>Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_core300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
<None Include="..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_imgproc300d.dll">
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Resources">
|
||||
<UniqueIdentifier>5fd0e509-b6ae-4f29-bd2a-4d2cc10f3aa0</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="OpenCVComponent.cpp" />
|
||||
<ClCompile Include="pch.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="OpenCVComponent.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_core300d.dll" />
|
||||
<None Include="..\..\..\..\bin\WP\8.0\x86\bin\Debug\opencv_imgproc300d.dll" />
|
||||
</ItemGroup>
|
||||
</Project>
|
6
samples/wp8/OpenCVXaml/OpenCVComponent/pch.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
//
|
||||
// pch.cpp
|
||||
// Include the standard header and generate the precompiled header.
|
||||
//
|
||||
|
||||
#include "pch.h"
|
6
samples/wp8/OpenCVXaml/OpenCVComponent/pch.h
Normal file
@ -0,0 +1,6 @@
|
||||
//
|
||||
// pch.h
|
||||
// Header for standard system include files.
|
||||
//
|
||||
|
||||
#pragma once
|
76
samples/wp8/OpenCVXaml/OpenCVXaml.sln
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCVXaml", "OpenCVXaml\OpenCVXaml.csproj", "{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenCVComponent", "OpenCVComponent\OpenCVComponent.vcxproj", "{EADFF7B8-E6C3-4F34-9B33-014B3035C595}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|Mixed Platforms = Release|Mixed Platforms
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Win32.ActiveCfg = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Win32.Build.0 = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|Win32.Deploy.0 = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|x86.Build.0 = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|ARM.Build.0 = Release|ARM
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Mixed Platforms.Deploy.0 = Release|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Win32.ActiveCfg = Release|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Win32.Build.0 = Release|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|Win32.Deploy.0 = Release|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|x86.ActiveCfg = Release|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|x86.Build.0 = Release|x86
|
||||
{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}.Release|x86.Deploy.0 = Release|x86
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Debug|x86.Build.0 = Debug|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|Any CPU.ActiveCfg = Release|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|ARM.Build.0 = Release|ARM
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|Win32.Build.0 = Release|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|x86.ActiveCfg = Release|Win32
|
||||
{EADFF7B8-E6C3-4F34-9B33-014B3035C595}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
20
samples/wp8/OpenCVXaml/OpenCVXaml/App.xaml
Normal file
@ -0,0 +1,20 @@
|
||||
<Application
|
||||
x:Class="OpenCVXaml.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
|
||||
|
||||
<!--Application Resources-->
|
||||
<Application.Resources>
|
||||
<local:LocalizedStrings xmlns:local="clr-namespace:OpenCVXaml" x:Key="LocalizedStrings"/>
|
||||
</Application.Resources>
|
||||
|
||||
<Application.ApplicationLifetimeObjects>
|
||||
<!--Required object that handles lifetime events for the application-->
|
||||
<shell:PhoneApplicationService
|
||||
Launching="Application_Launching" Closing="Application_Closing"
|
||||
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||
</Application.ApplicationLifetimeObjects>
|
||||
|
||||
</Application>
|
223
samples/wp8/OpenCVXaml/OpenCVXaml/App.xaml.cs
Normal file
@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Resources;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using OpenCVXaml.Resources;
|
||||
|
||||
namespace OpenCVXaml
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides easy access to the root frame of the Phone Application.
|
||||
/// </summary>
|
||||
/// <returns>The root frame of the Phone Application.</returns>
|
||||
public static PhoneApplicationFrame RootFrame { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for the Application object.
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
// Global handler for uncaught exceptions.
|
||||
UnhandledException += Application_UnhandledException;
|
||||
|
||||
// Standard XAML initialization
|
||||
InitializeComponent();
|
||||
|
||||
// Phone-specific initialization
|
||||
InitializePhoneApplication();
|
||||
|
||||
// Language display initialization
|
||||
InitializeLanguage();
|
||||
|
||||
// Show graphics profiling information while debugging.
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// Display the current frame rate counters.
|
||||
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||
|
||||
// Show the areas of the app that are being redrawn in each frame.
|
||||
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||
|
||||
// Enable non-production analysis visualization mode,
|
||||
// which shows areas of a page that are handed off to GPU with a colored overlay.
|
||||
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||
|
||||
// Prevent the screen from turning off while under the debugger by disabling
|
||||
// the application's idle detection.
|
||||
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
|
||||
// and consume battery power when the user is not using the phone.
|
||||
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Code to execute when the application is launching (eg, from Start)
|
||||
// This code will not execute when the application is reactivated
|
||||
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is activated (brought to foreground)
|
||||
// This code will not execute when the application is first launched
|
||||
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is deactivated (sent to background)
|
||||
// This code will not execute when the application is closing
|
||||
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute when the application is closing (eg, user hit Back)
|
||||
// This code will not execute when the application is deactivated
|
||||
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
// Code to execute if a navigation fails
|
||||
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// A navigation has failed; break into the debugger
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
// Code to execute on Unhandled Exceptions
|
||||
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||
{
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
// An unhandled exception has occurred; break into the debugger
|
||||
Debugger.Break();
|
||||
}
|
||||
}
|
||||
|
||||
#region Phone application initialization
|
||||
|
||||
// Avoid double-initialization
|
||||
private bool phoneApplicationInitialized = false;
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void InitializePhoneApplication()
|
||||
{
|
||||
if (phoneApplicationInitialized)
|
||||
return;
|
||||
|
||||
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||
// screen to remain active until the application is ready to render.
|
||||
RootFrame = new PhoneApplicationFrame();
|
||||
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||
|
||||
// Handle navigation failures
|
||||
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||
|
||||
// Handle reset requests for clearing the backstack
|
||||
RootFrame.Navigated += CheckForResetNavigation;
|
||||
|
||||
// Ensure we don't initialize again
|
||||
phoneApplicationInitialized = true;
|
||||
}
|
||||
|
||||
// Do not add any additional code to this method
|
||||
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Set the root visual to allow the application to render
|
||||
if (RootVisual != RootFrame)
|
||||
RootVisual = RootFrame;
|
||||
|
||||
// Remove this handler since it is no longer needed
|
||||
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||
}
|
||||
|
||||
private void CheckForResetNavigation(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// If the app has received a 'reset' navigation, then we need to check
|
||||
// on the next navigation to see if the page stack should be reset
|
||||
if (e.NavigationMode == NavigationMode.Reset)
|
||||
RootFrame.Navigated += ClearBackStackAfterReset;
|
||||
}
|
||||
|
||||
private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
|
||||
{
|
||||
// Unregister the event so it doesn't get called again
|
||||
RootFrame.Navigated -= ClearBackStackAfterReset;
|
||||
|
||||
// Only clear the stack for 'new' (forward) and 'refresh' navigations
|
||||
if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh)
|
||||
return;
|
||||
|
||||
// For UI consistency, clear the entire page stack
|
||||
while (RootFrame.RemoveBackEntry() != null)
|
||||
{
|
||||
; // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// Initialize the app's font and flow direction as defined in its localized resource strings.
|
||||
//
|
||||
// To ensure that the font of your application is aligned with its supported languages and that the
|
||||
// FlowDirection for each of those languages follows its traditional direction, ResourceLanguage
|
||||
// and ResourceFlowDirection should be initialized in each resx file to match these values with that
|
||||
// file's culture. For example:
|
||||
//
|
||||
// AppResources.es-ES.resx
|
||||
// ResourceLanguage's value should be "es-ES"
|
||||
// ResourceFlowDirection's value should be "LeftToRight"
|
||||
//
|
||||
// AppResources.ar-SA.resx
|
||||
// ResourceLanguage's value should be "ar-SA"
|
||||
// ResourceFlowDirection's value should be "RightToLeft"
|
||||
//
|
||||
// For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072.
|
||||
//
|
||||
private void InitializeLanguage()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Set the font to match the display language defined by the
|
||||
// ResourceLanguage resource string for each supported language.
|
||||
//
|
||||
// Fall back to the font of the neutral language if the Display
|
||||
// language of the phone is not supported.
|
||||
//
|
||||
// If a compiler error is hit then ResourceLanguage is missing from
|
||||
// the resource file.
|
||||
RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage);
|
||||
|
||||
// Set the FlowDirection of all elements under the root frame based
|
||||
// on the ResourceFlowDirection resource string for each
|
||||
// supported language.
|
||||
//
|
||||
// If a compiler error is hit then ResourceFlowDirection is missing from
|
||||
// the resource file.
|
||||
FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection);
|
||||
RootFrame.FlowDirection = flow;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// If an exception is caught here it is most likely due to either
|
||||
// ResourceLangauge not being correctly set to a supported language
|
||||
// code or ResourceFlowDirection is set to a value other than LeftToRight
|
||||
// or RightToLeft.
|
||||
|
||||
if (Debugger.IsAttached)
|
||||
{
|
||||
Debugger.Break();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
samples/wp8/OpenCVXaml/OpenCVXaml/Assets/AlignmentGrid.png
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
samples/wp8/OpenCVXaml/OpenCVXaml/Assets/ApplicationIcon.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
samples/wp8/OpenCVXaml/OpenCVXaml/Assets/Lena.png
Normal file
After Width: | Height: | Size: 483 KiB |
After Width: | Height: | Size: 9.7 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 3.6 KiB |
14
samples/wp8/OpenCVXaml/OpenCVXaml/LocalizedStrings.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using OpenCVXaml.Resources;
|
||||
|
||||
namespace OpenCVXaml
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to string resources.
|
||||
/// </summary>
|
||||
public class LocalizedStrings
|
||||
{
|
||||
private static AppResources _localizedResources = new AppResources();
|
||||
|
||||
public AppResources LocalizedResources { get { return _localizedResources; } }
|
||||
}
|
||||
}
|
64
samples/wp8/OpenCVXaml/OpenCVXaml/MainPage.xaml
Normal file
@ -0,0 +1,64 @@
|
||||
<phone:PhoneApplicationPage
|
||||
x:Class="OpenCVXaml.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- LOCALIZATION NOTE:
|
||||
To localize the displayed strings copy their values to appropriately named
|
||||
keys in the app's neutral language resource file (AppResources.resx) then
|
||||
replace the hard-coded text value between the attributes' quotation marks
|
||||
with the binding clause whose path points to that string name.
|
||||
|
||||
For example:
|
||||
|
||||
Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"
|
||||
|
||||
This binding points to the template's string resource named "ApplicationTitle".
|
||||
|
||||
Adding supported languages in the Project Properties tab will create a
|
||||
new resx file per language that can carry the translated values of your
|
||||
UI strings. The binding in these examples will cause the value of the
|
||||
attributes to be drawn from the .resx file that matches the
|
||||
CurrentUICulture of the app at run time.
|
||||
-->
|
||||
|
||||
<!--TitlePanel contains the name of the application and page title-->
|
||||
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
|
||||
<TextBlock Text="OpenCV" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!--ContentPanel - place additional content here-->
|
||||
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||
<StackPanel>
|
||||
<Image Source="Assets\\Lena.png" Name="Preview"></Image>
|
||||
<Button Content="Process" Name="ProcessButton" Click="Button_Click"></Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!--Uncomment to see an alignment grid to help ensure your controls are
|
||||
aligned on common boundaries. The image has a top margin of -32px to
|
||||
account for the System Tray. Set this to 0 (or remove the margin altogether)
|
||||
if the System Tray is hidden.
|
||||
|
||||
Before shipping remove this XAML and the image itself.-->
|
||||
<!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
|
||||
</Grid>
|
||||
|
||||
</phone:PhoneApplicationPage>
|
70
samples/wp8/OpenCVXaml/OpenCVXaml/MainPage.xaml.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using OpenCVXaml.Resources;
|
||||
using System.Windows.Media.Imaging;
|
||||
using OpenCVComponent;
|
||||
|
||||
namespace OpenCVXaml
|
||||
{
|
||||
public partial class MainPage : PhoneApplicationPage
|
||||
{
|
||||
private OpenCVLib m_opencv = new OpenCVLib();
|
||||
|
||||
// Constructor
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Sample code to localize the ApplicationBar
|
||||
//BuildLocalizedApplicationBar();
|
||||
}
|
||||
|
||||
private async void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Preview.Source != null)
|
||||
{
|
||||
ProcessButton.IsEnabled = false;
|
||||
|
||||
// Get WriteableBitmap. ImageToModify is defined in MainPage.xaml
|
||||
WriteableBitmap bitmap = new WriteableBitmap(Preview.Source as BitmapSource);
|
||||
|
||||
// call OpenCVLib to convert pixels to grayscale. This is an asynchronous call.
|
||||
var pixels = await m_opencv.ProcessAsync(bitmap.Pixels, bitmap.PixelWidth, bitmap.PixelHeight);
|
||||
|
||||
// copy the pixels into the WriteableBitmap
|
||||
for (int x = 0; x < bitmap.Pixels.Length; x++)
|
||||
{
|
||||
bitmap.Pixels[x] = pixels[x];
|
||||
}
|
||||
|
||||
// Set Image object, defined in XAML, to the modified bitmap.
|
||||
Preview.Source = bitmap;
|
||||
|
||||
ProcessButton.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sample code for building a localized ApplicationBar
|
||||
//private void BuildLocalizedApplicationBar()
|
||||
//{
|
||||
// // Set the page's ApplicationBar to a new instance of ApplicationBar.
|
||||
// ApplicationBar = new ApplicationBar();
|
||||
|
||||
// // Create a new button and set the text value to the localized string from AppResources.
|
||||
// ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
|
||||
// appBarButton.Text = AppResources.AppBarButtonText;
|
||||
// ApplicationBar.Buttons.Add(appBarButton);
|
||||
|
||||
// // Create a new menu item with the localized string from AppResources.
|
||||
// ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
|
||||
// ApplicationBar.MenuItems.Add(appBarMenuItem);
|
||||
//}
|
||||
}
|
||||
}
|
167
samples/wp8/OpenCVXaml/OpenCVXaml/OpenCVXaml.csproj
Normal file
@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20506</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{AF139C56-D9C7-4AFE-8972-E5B30AABA1BC}</ProjectGuid>
|
||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenCVXaml</RootNamespace>
|
||||
<AssemblyName>OpenCVXaml</AssemblyName>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||
<SilverlightApplication>true</SilverlightApplication>
|
||||
<SupportedCultures>
|
||||
</SupportedCultures>
|
||||
<XapOutputs>true</XapOutputs>
|
||||
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||
<XapFilename>OpenCVXaml_$(Configuration)_$(Platform).xap</XapFilename>
|
||||
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||
<SilverlightAppEntry>OpenCVXaml.App</SilverlightAppEntry>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\x86\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\x86\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>Bin\ARM\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>Bin\ARM\Release</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LocalizedStrings.cs" />
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resources\AppResources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>AppResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Properties\AppManifest.xml" />
|
||||
<None Include="Properties\WMAppManifest.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\AlignmentGrid.png" />
|
||||
<Content Include="Assets\ApplicationIcon.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Lena.png" />
|
||||
<Content Include="Assets\Tiles\FlipCycleTileLarge.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\FlipCycleTileMedium.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\FlipCycleTileSmall.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\IconicTileMediumLarge.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Assets\Tiles\IconicTileSmall.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\AppResources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>AppResources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenCVComponent\OpenCVComponent.vcxproj">
|
||||
<Project>{eadff7b8-e6c3-4f34-9b33-014b3035c595}</Project>
|
||||
<Name>OpenCVComponent</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<ProjectExtensions />
|
||||
</Project>
|
@ -0,0 +1,6 @@
|
||||
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
>
|
||||
<Deployment.Parts>
|
||||
</Deployment.Parts>
|
||||
</Deployment>
|
37
samples/wp8/OpenCVXaml/OpenCVXaml/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Resources;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OpenCVXaml")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("OpenCVXaml")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0ceefb1d-fe54-4732-bca5-865e13ecdbf0")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
|
||||
<DefaultLanguage xmlns="" code="en-US"/>
|
||||
<App xmlns="" ProductID="{af139c56-d9c7-4afe-8972-e5b30aaba1bc}" Title="OpenCVXaml" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="OpenCVXaml author" Description="Sample description" Publisher="OpenCVXaml" PublisherID="{8dd284a7-c759-40d0-9076-a1ced47c6a9a}">
|
||||
<IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
|
||||
<Capabilities>
|
||||
<Capability Name="ID_CAP_NETWORKING"/>
|
||||
<Capability Name="ID_CAP_MEDIALIB_AUDIO"/>
|
||||
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK"/>
|
||||
<Capability Name="ID_CAP_SENSORS"/>
|
||||
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
|
||||
</Capabilities>
|
||||
<Tasks>
|
||||
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="OpenCVXamlToken" TaskName="_default">
|
||||
<TemplateFlip>
|
||||
<SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
|
||||
<Count>0</Count>
|
||||
<BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
|
||||
<Title>OpenCVXaml</Title>
|
||||
<BackContent></BackContent>
|
||||
<BackBackgroundImageURI></BackBackgroundImageURI>
|
||||
<BackTitle></BackTitle>
|
||||
<DeviceLockImageURI></DeviceLockImageURI>
|
||||
<HasLarge></HasLarge>
|
||||
</TemplateFlip>
|
||||
</PrimaryToken>
|
||||
</Tokens>
|
||||
<ScreenResolutions>
|
||||
<ScreenResolution Name="ID_RESOLUTION_WVGA"/>
|
||||
<ScreenResolution Name="ID_RESOLUTION_WXGA"/>
|
||||
<ScreenResolution Name="ID_RESOLUTION_HD720P"/>
|
||||
</ScreenResolutions>
|
||||
</App>
|
||||
</Deployment>
|
127
samples/wp8/OpenCVXaml/OpenCVXaml/Resources/AppResources.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17626
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace OpenCVXaml.Resources
|
||||
{
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class AppResources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal AppResources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OpenCVXaml.Resources.AppResources", typeof(AppResources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to LeftToRight.
|
||||
/// </summary>
|
||||
public static string ResourceFlowDirection
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to us-EN.
|
||||
/// </summary>
|
||||
public static string ResourceLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ResourceLanguage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to MY APPLICATION.
|
||||
/// </summary>
|
||||
public static string ApplicationTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("ApplicationTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to button.
|
||||
/// </summary>
|
||||
public static string AppBarButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("AppBarButtonText", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to menu item.
|
||||
/// </summary>
|
||||
public static string AppBarMenuItemText
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceManager.GetString("AppBarMenuItemText", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
137
samples/wp8/OpenCVXaml/OpenCVXaml/Resources/AppResources.resx
Normal file
@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ResourceFlowDirection" xml:space="preserve">
|
||||
<value>LeftToRight</value>
|
||||
<comment>Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language</comment>
|
||||
</data>
|
||||
<data name="ResourceLanguage" xml:space="preserve">
|
||||
<value>en-US</value>
|
||||
<comment>Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.</comment>
|
||||
</data>
|
||||
<data name="ApplicationTitle" xml:space="preserve">
|
||||
<value>MY APPLICATION</value>
|
||||
</data>
|
||||
<data name="AppBarButtonText" xml:space="preserve">
|
||||
<value>add</value>
|
||||
</data>
|
||||
<data name="AppBarMenuItemText" xml:space="preserve">
|
||||
<value>Menu Item</value>
|
||||
</data>
|
||||
</root>
|
6
samples/wp8/readme.txt
Normal file
@ -0,0 +1,6 @@
|
||||
Building OpenCV Windows Phone Samples
|
||||
=====================================
|
||||
|
||||
Samples are created to run against x86 architecture OpenCV binaries.
|
||||
|
||||
Please follow the instructions in "platforms/winrt/readme.txt" to generate and build OpenCV for Windows Phone 8.0/8.1
|