diff --git a/Android_Salmon_Engine.mk b/Android_Salmon_Engine.mk index f75bcb3..9db4a19 100644 --- a/Android_Salmon_Engine.mk +++ b/Android_Salmon_Engine.mk @@ -342,7 +342,6 @@ LOCAL_SRC_FILES += src/Render/SalmonRender/SalmonRenderAndroid.cpp LOCAL_SRC_FILES += src/Render/SalmonRender/Cameras.cpp LOCAL_SRC_FILES += src/Animation/SalmonAnimation.cpp -LOCAL_SRC_FILES += src/ApplicationInterface.cpp LOCAL_SRC_FILES += src/SalmonEngineAndroid.cpp LOCAL_SRC_FILES += src/SalmonEngineInterface.cpp LOCAL_LDLIBS := -lGLESv2 diff --git a/Salmon Engine/Salmon Engine.vcxproj b/Salmon Engine/Salmon Engine.vcxproj index f2a0f21..d7ea6ed 100644 --- a/Salmon Engine/Salmon Engine.vcxproj +++ b/Salmon Engine/Salmon Engine.vcxproj @@ -16,7 +16,6 @@ - @@ -63,7 +62,6 @@ - diff --git a/include/ApplicationInterface.h b/include/ApplicationInterface.h deleted file mode 100644 index d14a39a..0000000 --- a/include/ApplicationInterface.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef APPLICATION_INTERFACE_H_INCLUDED -#define APPLICATION_INTERFACE_H_INCLUDED - -#include "include/Utils/Utils.h" - -namespace SE -{ - -class TApplicationInterface -{ -protected: - bool IsConsoleOut; -public: - - - TApplicationInterface(); - - virtual ~TApplicationInterface(); - - virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); - - virtual void InnerInit() { } - //To do on init - - virtual void OuterDeinit(); - - virtual void InnerDeinit() { } - //To do on deinit - - virtual void OuterDraw() { } - - virtual void InnerDraw() { } - //What to draw - - virtual void OuterUpdate(cardinal timer) { } - - virtual void InnerUpdate(cardinal timer) { } -}; - -} //namespace SE - - -#endif \ No newline at end of file diff --git a/include/SalmonEngineInterface.h b/include/SalmonEngineInterface.h index cb29bea..fd49bac 100644 --- a/include/SalmonEngineInterface.h +++ b/include/SalmonEngineInterface.h @@ -5,9 +5,6 @@ This code combines all headers for Salmon engine into one header file */ - -#include "include/ApplicationInterface.h" - #include "include/Render/SalmonRender/SalmonRenderInterface.h" #ifdef TARGET_ANDROID @@ -103,12 +100,22 @@ struct TMouseState -class TApplicationAncestor : public TApplicationInterface +class TApplicationAncestor { protected: - + bool IsConsoleOut; public: + TApplicationAncestor(); + + virtual ~TApplicationAncestor(); + + virtual void OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight); + + + virtual void OuterDeinit(); + + virtual void OuterDraw(); //What to draw @@ -125,7 +132,18 @@ public: virtual void OuterOnTapUpAfterMove(vec2 p); virtual void OuterOnMove(vec2 shift); + + + virtual void InnerInit() { } + + virtual void InnerDeinit() { } + + virtual void InnerDraw() { } + virtual void InnerUpdate(cardinal timer) { } + + + virtual void InnerOnTapDown(vec2 p) { } virtual void InnerOnTapUp(vec2 p) { } @@ -134,6 +152,8 @@ public: virtual void InnerOnMove(vec2 shift) { } + + virtual void OnMouseMove(TMouseState& mouseState) { } //Windows only virtual void OnMouseWheel(short int delta) { } diff --git a/include/SalmonEngineWindows.h b/include/SalmonEngineWindows.h index 592d667..6fb8032 100644 --- a/include/SalmonEngineWindows.h +++ b/include/SalmonEngineWindows.h @@ -44,6 +44,27 @@ bool CreateEngine(int width, int height, int x = 0, int y = 0, std::string windo void MainLoop(TApplication* app); void DestroyEngine(); + +//APPTYPE must be inherited from TApplication +template +void OuterMainLoop(int width, int height) +{ + + if (CreateEngine(width, height)) + { + TApplication* app = new APPTYPE; + + app->OuterInit(width, height, static_cast(width), static_cast(height)); + + MainLoop(app); + + app->OuterDeinit(); + + DestroyEngine(); + } +} + + } //namespace SE //This file includes templates that call any of three singletones: Console, ResourceManager or Renderer diff --git a/src/ApplicationInterface.cpp b/src/ApplicationInterface.cpp deleted file mode 100644 index 78c6dbb..0000000 --- a/src/ApplicationInterface.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "include/Engine.h" - - -namespace SE -{ - -TApplicationInterface::TApplicationInterface() - : IsConsoleOut(false) -{ -} - -TApplicationInterface::~TApplicationInterface() -{ -} - -void TApplicationInterface::OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) -{ - ResourceManager->MainThreadId = boost::this_thread::get_id(); - - ResourceManager->ScriptManager.BindBasicFunctions(); - - Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); - - InnerInit(); - - CheckGlError(); - - srand(static_cast(time(0))); -} - -void TApplicationInterface::OuterDeinit() -{ - CheckGlError("OuterDeinit"); - InnerDeinit(); -} - - -} //namespace SE \ No newline at end of file diff --git a/src/SalmonEngineAndroid.cpp b/src/SalmonEngineAndroid.cpp index 6c1fd9d..2abaaac 100644 --- a/src/SalmonEngineAndroid.cpp +++ b/src/SalmonEngineAndroid.cpp @@ -8,7 +8,6 @@ namespace SE void CreateEngine() { - DestroyEngine(); Console = new TJavaConsole; diff --git a/src/SalmonEngineInterface.cpp b/src/SalmonEngineInterface.cpp index a2f9496..42017e8 100644 --- a/src/SalmonEngineInterface.cpp +++ b/src/SalmonEngineInterface.cpp @@ -60,6 +60,41 @@ TResourceManager::~TResourceManager() } +//================================================== +//============ TApplicationAncestor ================ +//================================================== + +TApplicationAncestor::TApplicationAncestor() + : IsConsoleOut(false) +{ +} + +TApplicationAncestor::~TApplicationAncestor() +{ +} + +void TApplicationAncestor::OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) +{ + ResourceManager->MainThreadId = boost::this_thread::get_id(); + + ResourceManager->ScriptManager.BindBasicFunctions(); + + Renderer->InitOpenGL(screenWidth, screenHeight, matrixWidth, matrixHeight); + + InnerInit(); + + CheckGlError(); + + srand(static_cast(time(0))); +} + + +void TApplicationAncestor::OuterDeinit() +{ + CheckGlError("OuterDeinit"); + InnerDeinit(); +} + void TApplicationAncestor::OuterDraw() {