From 8ee4340db342c748e69ddd187a85a270923440d6 Mon Sep 17 00:00:00 2001 From: huangshiwu Date: Thu, 7 Aug 2014 18:38:11 +0800 Subject: [PATCH] fix winrt complie error --- cocos/2d/cocos2d_winrt.vcxproj | 10 ++- cocos/2d/cocos2d_winrt.vcxproj.filters | 33 +++---- cocos/platform/CCFileUtils.cpp | 16 ++-- cocos/platform/winrt/CCApplication.cpp | 2 +- .../winrt/{CCGLView.cpp => CCGLViewImpl.cpp} | 86 +++++++++---------- .../winrt/{CCGLView.h => CCGLViewImpl.h} | 22 ++--- cocos/platform/winrt/InputEvent.cpp | 2 +- .../platform/wp8-xaml/cpp/Cocos2dRenderer.cpp | 2 +- extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp | 2 +- 9 files changed, 90 insertions(+), 85 deletions(-) rename cocos/platform/winrt/{CCGLView.cpp => CCGLViewImpl.cpp} (85%) rename cocos/platform/winrt/{CCGLView.h => CCGLViewImpl.h} (93%) diff --git a/cocos/2d/cocos2d_winrt.vcxproj b/cocos/2d/cocos2d_winrt.vcxproj index 54bec1007c..3ad2b3a2f5 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj +++ b/cocos/2d/cocos2d_winrt.vcxproj @@ -357,6 +357,7 @@ + @@ -388,7 +389,7 @@ - + @@ -397,7 +398,7 @@ - + @@ -552,6 +553,7 @@ + @@ -595,7 +597,7 @@ - + @@ -603,7 +605,7 @@ - + diff --git a/cocos/2d/cocos2d_winrt.vcxproj.filters b/cocos/2d/cocos2d_winrt.vcxproj.filters index e90211419a..1fc613a19b 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj.filters +++ b/cocos/2d/cocos2d_winrt.vcxproj.filters @@ -71,9 +71,6 @@ platform\winrt - - platform\winrt - platform\winrt @@ -98,9 +95,6 @@ platform - - platform - platform @@ -410,9 +404,6 @@ base - - base - base @@ -581,6 +572,15 @@ physics + + platform + + + platform\winrt + + + base + @@ -600,9 +600,6 @@ platform\winrt - - platform\winrt - platform\winrt @@ -645,9 +642,6 @@ platform - - platform - platform @@ -1185,6 +1179,15 @@ physics + + platform + + + platform\winrt + + + base + diff --git a/cocos/platform/CCFileUtils.cpp b/cocos/platform/CCFileUtils.cpp index 985bbbbee8..e4df663e09 100644 --- a/cocos/platform/CCFileUtils.cpp +++ b/cocos/platform/CCFileUtils.cpp @@ -945,14 +945,14 @@ bool FileUtils::isAbsolutePath(const std::string& path) const bool FileUtils::isDirectoryExistInternal(const std::string& dirPath) const { -#if !((CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) struct stat st; if (stat(dirPath.c_str(), &st) == 0) { return S_ISDIR(st.st_mode); } return false; -#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) WIN32_FILE_ATTRIBUTE_DATA wfad; if (GetFileAttributesExA(dirPath.c_str(), GetFileExInfoStandard, &wfad)) { @@ -1037,7 +1037,7 @@ bool FileUtils::createDirectory(const std::string& path) } } -#if !((CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) DIR *dir = NULL; // Create path recursively @@ -1055,7 +1055,7 @@ bool FileUtils::createDirectory(const std::string& path) } } return true; -#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) WIN32_FILE_ATTRIBUTE_DATA wfad; if (!(GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &wfad))) { @@ -1098,7 +1098,7 @@ bool FileUtils::removeDirectory(const std::string& path) } // Remove downloaded files -#if !((CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) std::string command = "rm -r "; // Path may include space. command += "\"" + path + "\""; @@ -1106,7 +1106,7 @@ bool FileUtils::removeDirectory(const std::string& path) return true; else return false; -#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) if (RemoveDirectoryA(path.c_str())) { return true; @@ -1126,7 +1126,7 @@ bool FileUtils::removeDirectory(const std::string& path) bool FileUtils::removeFile(const std::string &path) { // Remove downloaded file -#if !((CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)) +#if (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) std::string command = "rm -f "; // Path may include space. command += "\"" + path + "\""; @@ -1134,7 +1134,7 @@ bool FileUtils::removeFile(const std::string &path) return true; else return false; -#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) if (DeleteFileA(path.c_str())) { return true; diff --git a/cocos/platform/winrt/CCApplication.cpp b/cocos/platform/winrt/CCApplication.cpp index be99ecf394..084ae68061 100644 --- a/cocos/platform/winrt/CCApplication.cpp +++ b/cocos/platform/winrt/CCApplication.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCApplication.h" #if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT -#include "platform/winrt/CCGLView.h" +#include "platform/winrt/CCGLViewImpl.h" #else #include "platform/wp8/CCGLViewImpl.h" #endif diff --git a/cocos/platform/winrt/CCGLView.cpp b/cocos/platform/winrt/CCGLViewImpl.cpp similarity index 85% rename from cocos/platform/winrt/CCGLView.cpp rename to cocos/platform/winrt/CCGLViewImpl.cpp index 7fb7e1b9fd..9bf0241ab6 100644 --- a/cocos/platform/winrt/CCGLView.cpp +++ b/cocos/platform/winrt/CCGLViewImpl.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include "base/CCPlatformConfig.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) -#include "CCGLView.h" +#include "CCGLViewImpl.h" #include "base/ccMacros.h" #include "base/CCDirector.h" #include "base/CCTouch.h" @@ -54,7 +54,7 @@ using namespace Windows::UI::ViewManagement; NS_CC_BEGIN -static GLView* s_pEglView = NULL; +static GLViewImpl* s_pEglView = NULL; ////////////////////////////////////////////////////////////////////////// // impliment GLView @@ -165,7 +165,7 @@ void WinRTWindow::OnSuspending() void WinRTWindow::ResizeWindow() { - GLView::sharedOpenGLView()->UpdateForWindowSizeChange(); + GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(); } cocos2d::Vec2 WinRTWindow::GetCCPoint(PointerEventArgs^ args) { @@ -174,7 +174,7 @@ cocos2d::Vec2 WinRTWindow::GetCCPoint(PointerEventArgs^ args) { float y = getScaledDPIValue(p->Position.Y); Vec2 pt(x, y); - float zoomFactor = GLView::sharedOpenGLView()->getFrameZoomFactor(); + float zoomFactor = GLViewImpl::sharedOpenGLView()->getFrameZoomFactor(); if(zoomFactor > 0.0f) { pt.x /= zoomFactor; @@ -185,12 +185,12 @@ cocos2d::Vec2 WinRTWindow::GetCCPoint(PointerEventArgs^ args) { void WinRTWindow::ShowKeyboard(InputPane^ inputPane, InputPaneVisibilityEventArgs^ args) { - GLView::sharedOpenGLView()->ShowKeyboard(args->OccludedRect); + GLViewImpl::sharedOpenGLView()->ShowKeyboard(args->OccludedRect); } void WinRTWindow::HideKeyboard(InputPane^ inputPane, InputPaneVisibilityEventArgs^ args) { - GLView::sharedOpenGLView()->HideKeyboard(args->OccludedRect); + GLViewImpl::sharedOpenGLView()->HideKeyboard(args->OccludedRect); } void WinRTWindow::setIMEKeyboardState(bool bOpen) @@ -268,14 +268,14 @@ void WinRTWindow::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ ar float direction = (float)args->CurrentPoint->Properties->MouseWheelDelta; int id = 0; Vec2 p(0.0f,0.0f); - GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &p.x, &p.y); + GLViewImpl::sharedOpenGLView()->handleTouchesBegin(1, &id, &p.x, &p.y); p.y += direction; - GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y); - GLView::sharedOpenGLView()->handleTouchesEnd(1, &id, &p.x, &p.y); + GLViewImpl::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y); + GLViewImpl::sharedOpenGLView()->handleTouchesEnd(1, &id, &p.x, &p.y); } // user pressed the Back Key on the phone -void GLView::OnBackKeyPress() +void GLViewImpl::OnBackKeyPress() { #if 0 if (m_delegate) @@ -287,7 +287,7 @@ void GLView::OnBackKeyPress() } -void GLView::OnPointerPressed(PointerEventArgs^ args) +void GLViewImpl::OnPointerPressed(PointerEventArgs^ args) { #if 0 int id = args->CurrentPoint->PointerId; @@ -296,7 +296,7 @@ void GLView::OnPointerPressed(PointerEventArgs^ args) #endif } -void GLView::OnPointerMoved(PointerEventArgs^ args) +void GLViewImpl::OnPointerMoved(PointerEventArgs^ args) { #if 0 auto currentPoint = args->CurrentPoint; @@ -318,7 +318,7 @@ void GLView::OnPointerMoved(PointerEventArgs^ args) #endif } -void GLView::OnPointerReleased(PointerEventArgs^ args) +void GLViewImpl::OnPointerReleased(PointerEventArgs^ args) { #if 0 int id = args->CurrentPoint->PointerId; @@ -334,7 +334,7 @@ void WinRTWindow::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) { int id = args->CurrentPoint->PointerId; Vec2 pt = GetCCPoint(args); - GLView::sharedOpenGLView()->handleTouchesBegin(1, &id, &pt.x, &pt.y); + GLViewImpl::sharedOpenGLView()->handleTouchesBegin(1, &id, &pt.x, &pt.y); } void WinRTWindow::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args) @@ -346,7 +346,7 @@ void WinRTWindow::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args) { int id = args->CurrentPoint->PointerId; Vec2 p = GetCCPoint(args); - GLView::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y); + GLViewImpl::sharedOpenGLView()->handleTouchesMove(1, &id, &p.x, &p.y); } m_lastPoint = currentPoint->Position; m_lastPointValid = true; @@ -361,38 +361,38 @@ void WinRTWindow::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args) { int id = args->CurrentPoint->PointerId; Vec2 pt = GetCCPoint(args); - GLView::sharedOpenGLView()->handleTouchesEnd(1, &id, &pt.x, &pt.y); + GLViewImpl::sharedOpenGLView()->handleTouchesEnd(1, &id, &pt.x, &pt.y); } void WinRTWindow::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args) { ResizeWindow(); - GLView::sharedOpenGLView()->UpdateForWindowSizeChange(); + GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(); } void WinRTWindow::OnLogicalDpiChanged(Object^ sender) { - GLView::sharedOpenGLView()->UpdateForWindowSizeChange(); + GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(); } void WinRTWindow::OnOrientationChanged(Object^ sender) { ResizeWindow(); - GLView::sharedOpenGLView()->UpdateForWindowSizeChange(); + GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(); } void WinRTWindow::OnDisplayContentsInvalidated(Object^ sender) { - GLView::sharedOpenGLView()->UpdateForWindowSizeChange(); + GLViewImpl::sharedOpenGLView()->UpdateForWindowSizeChange(); } void WinRTWindow::OnRendering(Object^ sender, Object^ args) { - GLView::sharedOpenGLView()->OnRendering(); + GLViewImpl::sharedOpenGLView()->OnRendering(); } -GLView::GLView() +GLViewImpl::GLViewImpl() : m_window(nullptr) , m_fFrameZoomFactor(1.0f) , m_bSupportTouch(false) @@ -405,7 +405,7 @@ GLView::GLView() _viewName = "Cocos2dxWinRT"; } -GLView::~GLView() +GLViewImpl::~GLViewImpl() { CC_ASSERT(this == s_pEglView); s_pEglView = NULL; @@ -413,7 +413,7 @@ GLView::~GLView() // TODO: cleanup } -bool GLView::Create(CoreWindow^ window, SwapChainBackgroundPanel^ panel) +bool GLViewImpl::Create(CoreWindow^ window, SwapChainBackgroundPanel^ panel) { bool bRet = false; m_window = window; @@ -426,25 +426,25 @@ bool GLView::Create(CoreWindow^ window, SwapChainBackgroundPanel^ panel) return bRet; } -bool GLView::isOpenGLReady() +bool GLViewImpl::isOpenGLReady() { // TODO: need to revisit this return (m_window.Get() != nullptr); } -void GLView::end() +void GLViewImpl::end() { // TODO: need to implement } -void GLView::swapBuffers() +void GLViewImpl::swapBuffers() { m_winRTWindow->swapBuffers(); } -void GLView::setIMEKeyboardState(bool bOpen) +void GLViewImpl::setIMEKeyboardState(bool bOpen) { if(m_winRTWindow) { @@ -453,12 +453,12 @@ void GLView::setIMEKeyboardState(bool bOpen) } -void GLView::resize(int width, int height) +void GLViewImpl::resize(int width, int height) { } -void GLView::setFrameZoomFactor(float fZoomFactor) +void GLViewImpl::setFrameZoomFactor(float fZoomFactor) { m_fFrameZoomFactor = fZoomFactor; resize((int) (_screenSize.width * fZoomFactor), (int) (_screenSize.height * fZoomFactor)); @@ -467,23 +467,23 @@ void GLView::setFrameZoomFactor(float fZoomFactor) } -float GLView::getFrameZoomFactor() +float GLViewImpl::getFrameZoomFactor() { return m_fFrameZoomFactor; } -void GLView::setFrameSize(float width, float height) +void GLViewImpl::setFrameSize(float width, float height) { // not implemented in WinRT. Window is always full screen // GLViewProtocol::setFrameSize(width, height); } -void GLView::centerWindow() +void GLViewImpl::centerWindow() { // not implemented in WinRT. Window is always full screen } -void GLView::OnSuspending() +void GLViewImpl::OnSuspending() { if (m_winRTWindow) { @@ -491,12 +491,12 @@ void GLView::OnSuspending() } } -GLView* GLView::sharedOpenGLView() +GLViewImpl* GLViewImpl::sharedOpenGLView() { return s_pEglView; } -int GLView::Run() +int GLViewImpl::Run() { m_running = true; @@ -504,7 +504,7 @@ int GLView::Run() }; -void GLView::OnRendering() +void GLViewImpl::OnRendering() { if(m_running && m_initialized) { @@ -512,7 +512,7 @@ void GLView::OnRendering() } } -void GLView::HideKeyboard(Windows::Foundation::Rect r) +void GLViewImpl::HideKeyboard(Windows::Foundation::Rect r) { return; // not implemented #if 0 @@ -532,7 +532,7 @@ void GLView::HideKeyboard(Windows::Foundation::Rect r) #endif } -void GLView::ShowKeyboard(Windows::Foundation::Rect r) +void GLViewImpl::ShowKeyboard(Windows::Foundation::Rect r) { return; // not implemented #if 0 @@ -554,7 +554,7 @@ void GLView::ShowKeyboard(Windows::Foundation::Rect r) } -void GLView::UpdateForWindowSizeChange() +void GLViewImpl::UpdateForWindowSizeChange() { float width = ConvertDipsToPixels(m_window->Bounds.Width); float height = ConvertDipsToPixels(m_window->Bounds.Height); @@ -562,18 +562,18 @@ void GLView::UpdateForWindowSizeChange() if(!m_initialized) { m_initialized = true; - GLViewProtocol::setFrameSize(width, height); + GLView::setFrameSize(width, height); } else { setFrameSize(width, height); Size designSize = getDesignResolutionSize(); - GLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::SHOW_ALL); + GLViewImpl::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::SHOW_ALL); Director::sharedDirector()->setProjection(Director::sharedDirector()->getProjection()); } } -void GLView::QueueEvent(std::shared_ptr& event) +void GLViewImpl::QueueEvent(std::shared_ptr& event) { std::lock_guard guard(mMutex); mInputEvents.push(event); diff --git a/cocos/platform/winrt/CCGLView.h b/cocos/platform/winrt/CCGLViewImpl.h similarity index 93% rename from cocos/platform/winrt/CCGLView.h rename to cocos/platform/winrt/CCGLViewImpl.h index 96b403a3c1..a678936133 100644 --- a/cocos/platform/winrt/CCGLView.h +++ b/cocos/platform/winrt/CCGLViewImpl.h @@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __CC_EGLVIEW_WINRT_H__ -#define __CC_EGLVIEW_WINRT_H__ +#ifndef __CC_EGLVIEWIMPL_WINRT_H__ +#define __CC_EGLVIEWIMPL_WINRT_H__ #include "base/CCPlatformConfig.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) @@ -33,7 +33,7 @@ THE SOFTWARE. #include "CCGL.h" #include "platform/CCCommon.h" #include "InputEvent.h" -#include "platform/CCGLViewProtocol.h" +#include "platform/CCGLView.h" #include #include @@ -46,7 +46,7 @@ THE SOFTWARE. NS_CC_BEGIN class CCEGL; -class GLView; +class GLViewImpl; ref class WinRTWindow sealed { @@ -93,14 +93,14 @@ private: ESContext m_esContext; - friend GLView; + friend GLViewImpl; }; -class CC_DLL GLView : public Ref, public GLViewProtocol +class CC_DLL GLViewImpl : public GLView { public: - GLView(); - virtual ~GLView(); + GLViewImpl(); + virtual ~GLViewImpl(); /* override functions */ virtual bool isOpenGLReady(); @@ -114,7 +114,7 @@ public: void UpdateForWindowSizeChange(); void OnRendering(); void OnSuspending(); - void GLView::QueueEvent(std::shared_ptr& event); + void GLViewImpl::QueueEvent(std::shared_ptr& event); void OnPointerPressed(Windows::UI::Core::PointerEventArgs^ args); void OnPointerMoved(Windows::UI::Core::PointerEventArgs^ args); @@ -148,7 +148,7 @@ public: /** @brief get the shared main open gl window */ - static GLView* sharedOpenGLView(); + static GLViewImpl* sharedOpenGLView(); protected: @@ -169,4 +169,4 @@ NS_CC_END #endif // (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) -#endif // end of __CC_EGLVIEW_WINRT_H__ +#endif // end of __CC_EGLVIEWIMPL_WINRT_H__ diff --git a/cocos/platform/winrt/InputEvent.cpp b/cocos/platform/winrt/InputEvent.cpp index e28e9c5d78..62f0629afd 100644 --- a/cocos/platform/winrt/InputEvent.cpp +++ b/cocos/platform/winrt/InputEvent.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "InputEvent.h" -#include "CCGLView.h" +#include "CCGLViewImpl.h" #include "base/CCEventAcceleration.h" NS_CC_BEGIN diff --git a/cocos/platform/wp8-xaml/cpp/Cocos2dRenderer.cpp b/cocos/platform/wp8-xaml/cpp/Cocos2dRenderer.cpp index d70ac5c2fb..7231d15208 100644 --- a/cocos/platform/wp8-xaml/cpp/Cocos2dRenderer.cpp +++ b/cocos/platform/wp8-xaml/cpp/Cocos2dRenderer.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include "Cocos2dRenderer.h" #include "cocos2d.h" #include "CCApplication.h" -#include "CCGLView.h" +#include "CCGLViewImpl.h" #include "AppDelegate.h" #include diff --git a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp b/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp index 7e45fbf0b6..245149d164 100644 --- a/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp +++ b/extensions/GUI/CCEditBox/CCEditBoxImplWp8.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. #include "CCEditBoxImplWp8.h" #include "CCEditBox.h" -#include "CCGLView.h" +#include "CCGLViewImpl.h" #include "base/CCScriptSupport.h" #include "base/ccUTF8.h"