mirror of https://github.com/axmolengine/axmol.git
update windows 8.1 univeral app cpp-template files
This commit is contained in:
parent
ac8755868d
commit
102726784e
|
@ -114,27 +114,29 @@ void Cocos2dRenderer::DeviceLost()
|
||||||
|
|
||||||
void Cocos2dRenderer::Draw(GLsizei width, GLsizei height, float dpi, DisplayOrientations orientation)
|
void Cocos2dRenderer::Draw(GLsizei width, GLsizei height, float dpi, DisplayOrientations orientation)
|
||||||
{
|
{
|
||||||
|
auto glView = GLViewImpl::sharedOpenGLView();
|
||||||
|
|
||||||
if (orientation != m_orientation)
|
if (orientation != m_orientation)
|
||||||
{
|
{
|
||||||
m_orientation = orientation;
|
m_orientation = orientation;
|
||||||
GLViewImpl::sharedOpenGLView()->UpdateOrientation(orientation);
|
glView->UpdateOrientation(orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width != m_width || height != m_height)
|
if (width != m_width || height != m_height)
|
||||||
{
|
{
|
||||||
m_width = width;
|
m_width = width;
|
||||||
m_height = height;
|
m_height = height;
|
||||||
GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(static_cast<float>(width), static_cast<float>(height));
|
glView->UpdateForWindowSizeChange(static_cast<float>(width), static_cast<float>(height));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dpi != m_dpi)
|
if (dpi != m_dpi)
|
||||||
{
|
{
|
||||||
m_dpi = dpi;
|
m_dpi = dpi;
|
||||||
GLViewImpl::sharedOpenGLView()->SetDPI(m_dpi);
|
glView->SetDPI(m_dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLViewImpl::sharedOpenGLView()->ProcessEvents();
|
glView->ProcessEvents();
|
||||||
GLViewImpl::sharedOpenGLView()->Render();
|
glView->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cocos2dRenderer::QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args)
|
void Cocos2dRenderer::QueuePointerEvent(cocos2d::PointerEventType type, Windows::UI::Core::PointerEventArgs^ args)
|
||||||
|
|
|
@ -63,6 +63,11 @@ void OpenGLES::Initialize()
|
||||||
// EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices.
|
// EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices.
|
||||||
// Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it.
|
// Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it.
|
||||||
EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
|
EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
|
||||||
|
|
||||||
|
// EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call
|
||||||
|
// the IDXGIDevice3::Trim method on behalf of the application when it gets suspended.
|
||||||
|
// Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement.
|
||||||
|
EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,6 +79,7 @@ void OpenGLES::Initialize()
|
||||||
EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
|
EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9,
|
||||||
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3,
|
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3,
|
||||||
EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
|
EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
|
||||||
|
EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,6 +90,7 @@ void OpenGLES::Initialize()
|
||||||
EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
|
EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
|
||||||
EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE,
|
EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_DEVICE_TYPE_WARP_ANGLE,
|
||||||
EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
|
EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,
|
||||||
|
EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,10 @@ public:
|
||||||
void MakeCurrent(const EGLSurface surface);
|
void MakeCurrent(const EGLSurface surface);
|
||||||
EGLBoolean SwapBuffers(const EGLSurface surface);
|
EGLBoolean SwapBuffers(const EGLSurface surface);
|
||||||
void Reset();
|
void Reset();
|
||||||
|
void Cleanup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void Cleanup();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EGLDisplay mEglDisplay;
|
EGLDisplay mEglDisplay;
|
||||||
|
|
|
@ -261,7 +261,13 @@ void OpenGLESPage::TerminateApp()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
critical_section::scoped_lock lock(mRenderSurfaceCriticalSection);
|
critical_section::scoped_lock lock(mRenderSurfaceCriticalSection);
|
||||||
DestroyRenderSurface();
|
|
||||||
|
if (mOpenGLES)
|
||||||
|
{
|
||||||
|
mOpenGLES->DestroySurface(mRenderSurface);
|
||||||
|
mOpenGLES->Cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Windows::UI::Xaml::Application::Current->Exit();
|
Windows::UI::Xaml::Application::Current->Exit();
|
||||||
}
|
}
|
||||||
|
@ -311,10 +317,21 @@ void OpenGLESPage::StartRenderLoop()
|
||||||
GetSwapChainPanelSize(&panelWidth, &panelHeight);
|
GetSwapChainPanelSize(&panelWidth, &panelHeight);
|
||||||
m_renderer.get()->Draw(panelWidth, panelHeight, m_dpi, m_orientation);
|
m_renderer.get()->Draw(panelWidth, panelHeight, m_dpi, m_orientation);
|
||||||
|
|
||||||
// The call to eglSwapBuffers might not be successful (i.e. due to Device Lost)
|
// run on main UI thread
|
||||||
// If the call fails, then we must reinitialize EGL and the GL resources.
|
if (m_renderer->AppShouldExit())
|
||||||
if (mOpenGLES->SwapBuffers(mRenderSurface) != GL_TRUE)
|
|
||||||
{
|
{
|
||||||
|
swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]()
|
||||||
|
{
|
||||||
|
TerminateApp();
|
||||||
|
}));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (mOpenGLES->SwapBuffers(mRenderSurface) != GL_TRUE)
|
||||||
|
{
|
||||||
|
// The call to eglSwapBuffers might not be successful (i.e. due to Device Lost)
|
||||||
|
// If the call fails, then we must reinitialize EGL and the GL resources.
|
||||||
|
|
||||||
m_deviceLost = true;
|
m_deviceLost = true;
|
||||||
|
|
||||||
if (m_renderer)
|
if (m_renderer)
|
||||||
|
@ -330,17 +347,6 @@ void OpenGLESPage::StartRenderLoop()
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// run on main UI thread
|
|
||||||
if (m_renderer->AppShouldExit())
|
|
||||||
{
|
|
||||||
swapChainPanel->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]()
|
|
||||||
{
|
|
||||||
TerminateApp();
|
|
||||||
}));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_renderer)
|
if (m_renderer)
|
||||||
|
|
Loading…
Reference in New Issue