-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathshuihu.cpp
149 lines (121 loc) · 4.51 KB
/
shuihu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include <wrl/client.h>
#include <d3d11_1.h>
#include <DirectXMath.h>
#include <memory>
#include <agile.h>
#include <ppltasks.h>
#include "shuihu.h"
#include "CCApplication.h"
using namespace Windows::ApplicationModel;
using namespace Windows::ApplicationModel::Core;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::UI::Core;
using namespace Windows::System;
using namespace Windows::Foundation;
using namespace Windows::Graphics::Display;
using namespace Windows::Phone::UI::Input;
using namespace Windows::Graphics::Display;
using namespace concurrency;
USING_NS_CC;
shuihu::shuihu()
{
}
void shuihu::Initialize(CoreApplicationView^ applicationView)
{
applicationView->Activated +=
ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &shuihu::OnActivated);
CoreApplication::Suspending +=
ref new EventHandler<SuspendingEventArgs^>(this, &shuihu::OnSuspending);
CoreApplication::Resuming +=
ref new EventHandler<Platform::Object^>(this, &shuihu::OnResuming);
}
void shuihu::SetWindow(CoreWindow^ window)
{
// Specify the orientation of your application here
// The choices are DisplayOrientations::Portrait or DisplayOrientations::Landscape or DisplayOrientations::LandscapeFlipped
DisplayProperties::AutoRotationPreferences = DisplayOrientations::Landscape;
window->VisibilityChanged +=
ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &shuihu::OnVisibilityChanged);
window->Closed +=
ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &shuihu::OnWindowClosed);
window->PointerPressed +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &shuihu::OnPointerPressed);
window->PointerMoved +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &shuihu::OnPointerMoved);
window->PointerReleased +=
ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &shuihu::OnPointerReleased);
CCEGLView* eglView = new CCEGLView();
eglView->Create(window);
eglView->setViewName("shuihu");
}
void shuihu::Load(Platform::String^ entryPoint)
{
}
void shuihu::Run()
{
CCApplication::sharedApplication()->run();
}
void shuihu::Uninitialize()
{
}
void shuihu::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnVisibilityChanged(sender, args);
}
void shuihu::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnWindowClosed(sender, args);
}
void shuihu::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnPointerPressed(sender, args);
}
void shuihu::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnPointerMoved(sender, args);
}
void shuihu::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
{
CCEGLView::sharedOpenGLView()->OnPointerReleased(sender, args);
}
void shuihu::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
{
HardwareButtons::BackPressed += ref new EventHandler<BackPressedEventArgs^>(this, &shuihu::OnBackButtonPressed);
CoreWindow::GetForCurrentThread()->Activate();
}
void shuihu::OnBackButtonPressed(Object^ sender, BackPressedEventArgs^ args)
{
// Leave args->Handled set to false and the app will quit when user presses the back button on the phone
}
void shuihu::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
{
// Save app state asynchronously after requesting a deferral. Holding a deferral
// indicates that the application is busy performing suspending operations. Be
// aware that a deferral may not be held indefinitely. After about five seconds,
// the app will be forced to exit.
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
//m_renderer->ReleaseResourcesForSuspending();
create_task([this, deferral]()
{
// Insert your code here.
deferral->Complete();
});
}
void shuihu::OnResuming(Platform::Object^ sender, Platform::Object^ args)
{
// Restore any data or state that was unloaded on suspend. By default, data
// and state are persisted when resuming from suspend. Note that this event
// does not occur if the app was previously terminated.
// m_renderer->CreateWindowSizeDependentResources();
}
IFrameworkView^ Direct3DApplicationSource::CreateView()
{
return ref new shuihu();
}
[Platform::MTAThread]
int main(Platform::Array<Platform::String^>^)
{
auto direct3DApplicationSource = ref new Direct3DApplicationSource();
CoreApplication::Run(direct3DApplicationSource);
return 0;
}