From 0bf1c60c9de2cc3ac2ae82ad0d2fa22861856047 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Mon, 27 Feb 2017 02:26:42 +0300 Subject: [PATCH] ios changes --- .../Salmon Engine.xcodeproj/project.pbxproj | 4 +-- include/GUIManager/ButtonWidget.h | 18 ++++++------ include/GUIManager/GUIManager.h | 28 +++++++++---------- .../Render/SalmonRender/SalmonRenderGLES20.h | 9 +++++- include/Render/SalmonRender/SalmonRenderIos.h | 7 +++-- include/SmartValueManager/SmartValueManager.h | 4 +-- include/Utils/BindableVar.h | 6 ++-- include/Utils/IosApi/IosWrapper.h | 5 +++- include/Utils/Network/Network.h | 23 ++++++++------- include/Utils/Network/SignalSender.h | 6 ++-- include/Utils/ThreadUtils.h | 4 +-- include/Utils/Utils.h | 5 ++-- src/FrameManager/FrameManager.cpp | 8 ++++-- src/GUIManager/GUIManager.cpp | 20 ++++++------- src/Render/SalmonRender/SalmonRenderIos.cpp | 14 +++++++++- src/TextureManager/SalmonTexture.cpp | 2 +- src/Utils/IosApi/IosApi.mm | 18 ++++++++++-- src/Utils/Network/Network.cpp | 4 +-- 18 files changed, 116 insertions(+), 69 deletions(-) diff --git a/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj b/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj index 1244b9c..e8d986e 100644 --- a/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj +++ b/iOS/Salmon Engine/Salmon Engine.xcodeproj/project.pbxproj @@ -1676,7 +1676,7 @@ REZ_SEARCH_PATHS = ""; SKIP_INSTALL = NO; TARGETED_DEVICE_FAMILY = "1,2"; - VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64"; + VALID_ARCHS = "arm64 armv7 armv7s"; }; name = Debug; }; @@ -1717,7 +1717,7 @@ REZ_SEARCH_PATHS = ""; SKIP_INSTALL = NO; TARGETED_DEVICE_FAMILY = "1,2"; - VALID_ARCHS = "arm64 armv7 armv7s i386 x86_64"; + VALID_ARCHS = "arm64 armv7 armv7s"; }; name = Release; }; diff --git a/include/GUIManager/ButtonWidget.h b/include/GUIManager/ButtonWidget.h index 9afa4ed..47a3760 100644 --- a/include/GUIManager/ButtonWidget.h +++ b/include/GUIManager/ButtonWidget.h @@ -106,7 +106,7 @@ struct TSquareStatic : public TInstancingWidgetAncestor struct TDynamicText : public TInstancingWidgetAncestor { protected: - boost::signals::connection SmartValueConnection; + boost::signals2::connection SmartValueConnection; TTextParams LastTextParams; @@ -194,16 +194,16 @@ protected: void RefreshTextTriangleList(); - boost::signals::connection InputConnection; + boost::signals2::connection InputConnection; - boost::signals::connection SetTextSlotConnection; + boost::signals2::connection SetTextSlotConnection; public: ~TEdit(); TRenderPairList::iterator TextIterator; - boost::signal OnTextChanged; + boost::signals2::signal OnTextChanged; virtual bool CheckClick(vec2 mousePos); @@ -230,7 +230,7 @@ class TCheckBox : public TInstancingWidgetAncestor protected: bool IsChecked; //To be set immediately on tap up - boost::signals::connection SetCheckedSlotConnection; + boost::signals2::connection SetCheckedSlotConnection; void RefreshVisibility(); public: std::vector StaticTextureIteratorArr; @@ -252,7 +252,7 @@ public: //Logic: void SetChecked(bool isChecked); - boost::signal OnSetChecked; + boost::signals2::signal OnSetChecked; static TCheckBox* CreateCheckBox(vec2 posFrom, vec2 posTo); static TCheckBox* CreateCheckBoxWithFiller(vec2 posFrom, vec2 posTo, boost::function checkBoxFillerFunc); @@ -274,7 +274,7 @@ class TRadioButton : public TInstancingWidgetAncestor protected: bool IsChecked; //To be set immediately on tap up - boost::signals::connection SetCheckedSlotConnection; + boost::signals2::connection SetCheckedSlotConnection; void RefreshVisibility(); public: std::vector StaticTextureIteratorArr; @@ -296,7 +296,7 @@ public: //Logic: void SetChecked(bool isChecked); - boost::signal OnSetChecked; + boost::signals2::signal OnSetChecked; static TRadioButton* CreateRadioButton(vec2 posFrom, vec2 posTo); static TRadioButton* CreateRadioButtonWithFiller(vec2 posFrom, vec2 posTo, boost::function radioButtonFillerFunc); @@ -402,4 +402,4 @@ public: } //namespace SE -#endif \ No newline at end of file +#endif diff --git a/include/GUIManager/GUIManager.h b/include/GUIManager/GUIManager.h index 0e2c5a9..87577f9 100644 --- a/include/GUIManager/GUIManager.h +++ b/include/GUIManager/GUIManager.h @@ -32,7 +32,7 @@ struct TWidgetStruct std::shared_ptr Widget; - std::map>> SignalMap; + std::map>> SignalMap; TWidgetStruct(const std::string& name, const std::string& groupName, std::shared_ptr widget, int order = 0) : Name(name) @@ -41,10 +41,10 @@ struct TWidgetStruct , IsMouseDown(false) , Widget(widget) { - SignalMap[CONST_HOLD_SIGNAL_NAME] = std::shared_ptr>(new boost::signal()); - SignalMap[CONST_CLICK_SIGNAL_NAME] = std::shared_ptr>(new boost::signal()); - SignalMap[CONST_TAPDOWN_SIGNAL_NAME] = std::shared_ptr>(new boost::signal()); - SignalMap[CONST_DRAG_SIGNAL_NAME] = std::shared_ptr>(new boost::signal()); + SignalMap[CONST_HOLD_SIGNAL_NAME] = std::shared_ptr>(new boost::signals2::signal()); + SignalMap[CONST_CLICK_SIGNAL_NAME] = std::shared_ptr>(new boost::signals2::signal()); + SignalMap[CONST_TAPDOWN_SIGNAL_NAME] = std::shared_ptr>(new boost::signals2::signal()); + SignalMap[CONST_DRAG_SIGNAL_NAME] = std::shared_ptr>(new boost::signals2::signal()); } TWidgetStruct(const TWidgetStruct& widgetStruct) @@ -142,10 +142,10 @@ protected: public: bool KeyboardIsOnScreen; - boost::signal KeyPressedSignal; - boost::signal SetTextSignal; - boost::signal OnKeyboardShowSignal; - boost::signal OnKeyboardHideSignal; + boost::signals2::signal KeyPressedSignal; + boost::signals2::signal SetTextSignal; + boost::signals2::signal OnKeyboardShowSignal; + boost::signals2::signal OnKeyboardHideSignal; TGUIManager(); @@ -185,10 +185,10 @@ public: void PrintWidgetList(); - std::shared_ptr> GetOnClickSignal(const std::string& widgetName); - std::shared_ptr> GetOnHoldSignal(const std::string& widgetName); - std::shared_ptr> GetSignal(const std::string& signalName, const std::string& widgetName); - std::shared_ptr> GetOnTapDownSignal(const std::string& widgetName); + std::shared_ptr> GetOnClickSignal(const std::string& widgetName); + std::shared_ptr> GetOnHoldSignal(const std::string& widgetName); + std::shared_ptr> GetSignal(const std::string& signalName, const std::string& widgetName); + std::shared_ptr> GetOnTapDownSignal(const std::string& widgetName); //TFunctionBinderInterface implementation: void SQ_MoveWidget(const SQChar *widgetName, float x, float y); @@ -199,4 +199,4 @@ public: } //namespace SE -#endif \ No newline at end of file +#endif diff --git a/include/Render/SalmonRender/SalmonRenderGLES20.h b/include/Render/SalmonRender/SalmonRenderGLES20.h index a662185..3f382eb 100644 --- a/include/Render/SalmonRender/SalmonRenderGLES20.h +++ b/include/Render/SalmonRender/SalmonRenderGLES20.h @@ -9,6 +9,13 @@ #include #endif +#ifdef TARGET_IOS +//#include +#include +#include +#include +#endif + namespace SE { @@ -26,4 +33,4 @@ public: } //namespace SE -#endif \ No newline at end of file +#endif diff --git a/include/Render/SalmonRender/SalmonRenderIos.h b/include/Render/SalmonRender/SalmonRenderIos.h index 038c4d7..503f9e5 100644 --- a/include/Render/SalmonRender/SalmonRenderIos.h +++ b/include/Render/SalmonRender/SalmonRenderIos.h @@ -9,12 +9,15 @@ namespace SE class TSalmonRendererIos : public TSalmonRendererGLES20 { protected: + + GLint defaultFBO; public: - + virtual void InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + virtual void SwitchToScreen(); }; } //namespace SE -#endif \ No newline at end of file +#endif diff --git a/include/SmartValueManager/SmartValueManager.h b/include/SmartValueManager/SmartValueManager.h index feac70b..a0161ed 100644 --- a/include/SmartValueManager/SmartValueManager.h +++ b/include/SmartValueManager/SmartValueManager.h @@ -40,7 +40,7 @@ public: } template - boost::signal& GetSignal(const std::string& dictName, const std::string& valueName) + boost::signals2::signal& GetSignal(const std::string& dictName, const std::string& valueName) { return boost::get>>(GetSmartValue(dictName, valueName))->OnVarChanged; } @@ -52,4 +52,4 @@ public: } //namespace SE -#endif \ No newline at end of file +#endif diff --git a/include/Utils/BindableVar.h b/include/Utils/BindableVar.h index c7c6213..5f93b61 100644 --- a/include/Utils/BindableVar.h +++ b/include/Utils/BindableVar.h @@ -1,12 +1,14 @@ #ifndef BINDABLE_VAR_H_INCLUDED #define BINDABLE_VAR_H_INCLUDED -#include "boost/signal.hpp" +#include "boost/signals2.hpp" #include "boost/variant.hpp" + namespace SE { + //Must be stored in shared_ptr: template @@ -17,7 +19,7 @@ protected: public: - boost::signal OnVarChanged; + boost::signals2::signal OnVarChanged; TBindableVar() { diff --git a/include/Utils/IosApi/IosWrapper.h b/include/Utils/IosApi/IosWrapper.h index 0e26d97..ec76fb5 100644 --- a/include/Utils/IosApi/IosWrapper.h +++ b/include/Utils/IosApi/IosWrapper.h @@ -21,5 +21,8 @@ void AppOnScroll(int shiftx, int shifty, int touchNumber); void AppOnScale(float scale); void AppOnTapUpAfterMove(int posx, int posy, int touchNumber); + + void SetBindDrawableFunc(void(*funcPtr)()); -} \ No newline at end of file + +} diff --git a/include/Utils/Network/Network.h b/include/Utils/Network/Network.h index ba0d62e..28341a8 100644 --- a/include/Utils/Network/Network.h +++ b/include/Utils/Network/Network.h @@ -10,12 +10,11 @@ #include "boost/asio.hpp" #include "boost/date_time/posix_time/posix_time.hpp" -#include "boost/signal.hpp" +#include "boost/signals2.hpp" #include "boost/variant.hpp" #include "include/Utils/Network/SignalSender.h" - namespace SE { @@ -28,7 +27,7 @@ void SendPropertyTree(boost::asio::io_service& ioService, boost::asio::ip::tcp:: class TDataReadSignalMap { protected: - std::map>> SignalMap; + std::map>> SignalMap; public: void AddSlot(const std::string& nodeName, boost::function f); @@ -69,7 +68,7 @@ public: void HandleReadData(const boost::system::error_code& error); - boost::signal ErrorSignal; + boost::signals2::signal ErrorSignal; }; @@ -100,9 +99,9 @@ public: void HandleGetData(boost::property_tree::ptree pTree); - boost::signal AuthorizedSignal; - boost::signal SaveLoginPasswordSignal; - boost::signal ErrorSignal; + boost::signals2::signal AuthorizedSignal; + boost::signals2::signal SaveLoginPasswordSignal; + boost::signals2::signal ErrorSignal; }; typedef boost::variant> TAuthorizationVariant; @@ -127,10 +126,10 @@ protected: bool Opened; public: - boost::signal OnAddressNotResolvedSignal; - boost::signal OnConnectedSignal; - boost::signal OnAutorizedSignal; - boost::signal OnDisconnectedSignal; + boost::signals2::signal OnAddressNotResolvedSignal; + boost::signals2::signal OnConnectedSignal; + boost::signals2::signal OnAutorizedSignal; + boost::signals2::signal OnDisconnectedSignal; boost::shared_ptr ClientDataReader; @@ -158,4 +157,4 @@ public: } //namespace SE -#endif \ No newline at end of file +#endif diff --git a/include/Utils/Network/SignalSender.h b/include/Utils/Network/SignalSender.h index 7008912..b3d04bc 100644 --- a/include/Utils/Network/SignalSender.h +++ b/include/Utils/Network/SignalSender.h @@ -6,12 +6,14 @@ #include "boost/shared_ptr.hpp" #include "boost/array.hpp" #include "boost/enable_shared_from_this.hpp" -#include "boost/signal.hpp" +#include "boost/signals2.hpp" #include "boost/thread.hpp" #include "boost/date_time/posix_time/posix_time.hpp" #include "boost/property_tree/ptree.hpp" #include "boost/property_tree/xml_parser.hpp" + + namespace SE { //Xperimental -- need to optimize this @@ -25,7 +27,7 @@ struct TSignalSender std::string Data; - boost::signal ErrorSignal; + boost::signals2::signal ErrorSignal; TSignalSender(boost::asio::ip::tcp::socket& socket, int length, std::string data) : Socket(socket) diff --git a/include/Utils/ThreadUtils.h b/include/Utils/ThreadUtils.h index 69900d0..8f67589 100644 --- a/include/Utils/ThreadUtils.h +++ b/include/Utils/ThreadUtils.h @@ -2,7 +2,7 @@ #define THREAD_UTILS_H_INCLUDED #include "boost/asio.hpp" -#include "boost/signal.hpp" +#include "boost/signals2.hpp" #include "boost/thread.hpp" @@ -46,4 +46,4 @@ namespace SE } //namespace SE -#endif \ No newline at end of file +#endif diff --git a/include/Utils/Utils.h b/include/Utils/Utils.h index b6ad9d8..127e4c7 100644 --- a/include/Utils/Utils.h +++ b/include/Utils/Utils.h @@ -14,7 +14,8 @@ This code combines additional routines (such as console/log, exceptions, math ut #include "boost/asio.hpp" #include "boost/date_time/posix_time/posix_time.hpp" -#include "boost/signal.hpp" +#include "boost/signals2.hpp" + #include "include/Utils/Console/Console.h" @@ -42,4 +43,4 @@ This code combines additional routines (such as console/log, exceptions, math ut #endif -#endif \ No newline at end of file +#endif diff --git a/src/FrameManager/FrameManager.cpp b/src/FrameManager/FrameManager.cpp index 4da0f7d..049284f 100644 --- a/src/FrameManager/FrameManager.cpp +++ b/src/FrameManager/FrameManager.cpp @@ -59,7 +59,8 @@ cardinal TFrameManager::AddFrameRenderBuffer(const std::string& frameName,cardin cardinal frameBuffer; cardinal depthRenderBuffer; cardinal status; - + + glGenFramebuffers(1,&frameBuffer); glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer); @@ -77,6 +78,9 @@ cardinal TFrameManager::AddFrameRenderBuffer(const std::string& frameName,cardin #ifdef TARGET_IOS glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); #endif + + glBindRenderbuffer(GL_RENDERBUFFER, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer); @@ -354,4 +358,4 @@ TTextureData TFrameManager::ReadFromBufferToTexData(const std::string& frameName } -} //namespace SE \ No newline at end of file +} //namespace SE diff --git a/src/GUIManager/GUIManager.cpp b/src/GUIManager/GUIManager.cpp index a3d5b34..e55cf93 100644 --- a/src/GUIManager/GUIManager.cpp +++ b/src/GUIManager/GUIManager.cpp @@ -124,7 +124,7 @@ void TGUIManager::Update(cardinal dt) { boost::lock_guard guard(WidgetListMutex); - std::vector>> signalMap; + std::vector>> signalMap; for (TWidgetArr::iterator i = WidgetArr.begin(); i != WidgetArr.end(); ++i) { @@ -298,7 +298,7 @@ void TGUIManager::OnMouseDown(vec2 pos, int touchNumber) LastTapPos[touchNumber] = pos; TotalShift[touchNumber] = vec2(0,0); - std::vector>> signalMap; + std::vector>> signalMap; for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { @@ -336,7 +336,7 @@ void TGUIManager::OnMouseUp(vec2 pos, int touchNumber) TWidgetArr::reverse_iterator i; - std::vector>> signalMap; + std::vector>> signalMap; for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { @@ -374,7 +374,7 @@ void TGUIManager::OnMouseUp(vec2 pos, int touchNumber) TWidgetArr::reverse_iterator i; - std::vector>> signalMap; + std::vector>> signalMap; for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { @@ -434,7 +434,7 @@ void TGUIManager::OnMove(vec2 shift, int touchNumber) //LastTapPos += shift; - std::vector>> signalMap; + std::vector>> signalMap; for (i = WidgetArr.rbegin(); i != WidgetArr.rend(); ++i) { @@ -535,7 +535,7 @@ void TGUIManager::PrintWidgetList() } -std::shared_ptr> TGUIManager::GetOnClickSignal(const std::string& widgetName) +std::shared_ptr> TGUIManager::GetOnClickSignal(const std::string& widgetName) { TWidgetArr::iterator i = FindWidgetInArr(widgetName); @@ -544,7 +544,7 @@ std::shared_ptr> TGUIManager::GetOnClickSigna } -std::shared_ptr> TGUIManager::GetOnHoldSignal(const std::string& widgetName) +std::shared_ptr> TGUIManager::GetOnHoldSignal(const std::string& widgetName) { TWidgetArr::iterator i = FindWidgetInArr(widgetName); @@ -553,7 +553,7 @@ std::shared_ptr> TGUIManager::GetOnHoldSignal } -std::shared_ptr> TGUIManager::GetOnTapDownSignal(const std::string& widgetName) +std::shared_ptr> TGUIManager::GetOnTapDownSignal(const std::string& widgetName) { TWidgetArr::iterator i = FindWidgetInArr(widgetName); @@ -562,7 +562,7 @@ std::shared_ptr> TGUIManager::GetOnTapDownSig } -std::shared_ptr> TGUIManager::GetSignal(const std::string& signalName, const std::string& widgetName) +std::shared_ptr> TGUIManager::GetSignal(const std::string& signalName, const std::string& widgetName) { TWidgetArr::iterator i = FindWidgetInArr(widgetName); @@ -594,4 +594,4 @@ void TGUIManager::BindFunctions() &TGUIManager::SQ_MoveWidget); } -} //namespace SE \ No newline at end of file +} //namespace SE diff --git a/src/Render/SalmonRender/SalmonRenderIos.cpp b/src/Render/SalmonRender/SalmonRenderIos.cpp index 8425ec3..142fcf5 100644 --- a/src/Render/SalmonRender/SalmonRenderIos.cpp +++ b/src/Render/SalmonRender/SalmonRenderIos.cpp @@ -3,16 +3,28 @@ #include "include/Utils/Utils.h" #include "include/Engine.h" + namespace SE { + void TSalmonRendererIos::InitOpenGL(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) + { + TSalmonRendererGLES20::InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); + + + //glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &this->defaultFBO); + + + } void TSalmonRendererIos::SwitchToScreen() { AssertIfInMainThread(); IosSwitchToScreen(); + //glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } -} //namespace SE \ No newline at end of file +} //namespace SE diff --git a/src/TextureManager/SalmonTexture.cpp b/src/TextureManager/SalmonTexture.cpp index e4fe9db..47ce13a 100755 --- a/src/TextureManager/SalmonTexture.cpp +++ b/src/TextureManager/SalmonTexture.cpp @@ -856,4 +856,4 @@ void TTextureListClass::SaveTexDataToPlainBmpToUserData(const std::string& fileN } -} //namespace SE \ No newline at end of file +} //namespace SE diff --git a/src/Utils/IosApi/IosApi.mm b/src/Utils/IosApi/IosApi.mm index 03a7e7e..d7ea5c1 100644 --- a/src/Utils/IosApi/IosApi.mm +++ b/src/Utils/IosApi/IosApi.mm @@ -12,11 +12,14 @@ #include "include/Utils/Utils.h" -GLKView* defaultView = 0; //Need to be set up by App! +//GLKView* defaultView = 0; //Need to be set up by App! UITextField* extKeyboardTextView = 0; +void(*bindDrawableFuncPtr)() = nullptr; + + namespace SE { @@ -60,7 +63,11 @@ std::string IosGetFilePathUserData(const std::string& filename) void IosSwitchToScreen() { - [defaultView bindDrawable]; + if (bindDrawableFuncPtr != nullptr) + { + (*bindDrawableFuncPtr)(); + } + //[defaultView bindDrawable]; } void ShowKeyboard(std::string text) @@ -114,6 +121,13 @@ bool IsIphone5() return NO; } + + void SetBindDrawableFunc(void(*funcPtr)()) + { + bindDrawableFuncPtr = funcPtr; + } + + } //namespace SE diff --git a/src/Utils/Network/Network.cpp b/src/Utils/Network/Network.cpp index c325208..9439e4a 100644 --- a/src/Utils/Network/Network.cpp +++ b/src/Utils/Network/Network.cpp @@ -28,7 +28,7 @@ void TDataReadSignalMap::AddSlot(const std::string& nodeName, boost::function>(new boost::signal); + SignalMap[nodeName] = std::shared_ptr>(new boost::signals2::signal); SignalMap[nodeName]->connect(f); } else @@ -335,4 +335,4 @@ void TClientSocket::SendPropertyTree(boost::property_tree::ptree pTree) SE::SendPropertyTree(IoService, Socket, pTree); } -} //namspace SE \ No newline at end of file +} //namspace SE