diff --git a/CMakeLists.txt b/CMakeLists.txt index 8daeca534..88bfd4606 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -948,25 +948,14 @@ source_group("modules\\thread\\sdl" FILES ${LOVE_SRC_MODULE_THREAD_SDL}) # love.timer # -set(LOVE_SRC_MODULE_TIMER_ROOT +set(LOVE_SRC_MODULE_TIMER src/modules/timer/Timer.cpp src/modules/timer/Timer.h src/modules/timer/wrap_Timer.cpp src/modules/timer/wrap_Timer.h ) -set(LOVE_SRC_MODULE_TIMER_SDL - src/modules/timer/sdl/Timer.cpp - src/modules/timer/sdl/Timer.h -) - -set(LOVE_SRC_MODULE_TIMER - ${LOVE_SRC_MODULE_TIMER_ROOT} - ${LOVE_SRC_MODULE_TIMER_SDL} -) - -source_group("modules\\timer" FILES ${LOVE_SRC_MODULE_TIMER_ROOT}) -source_group("modules\\timer\\sdl" FILES ${LOVE_SRC_MODULE_TIMER_SDL}) +source_group("modules\\timer" FILES ${LOVE_SRC_MODULE_TIMER}) # # love.touch diff --git a/platform/xcode/liblove.xcodeproj/project.pbxproj b/platform/xcode/liblove.xcodeproj/project.pbxproj index e585b3107..e992d8f40 100644 --- a/platform/xcode/liblove.xcodeproj/project.pbxproj +++ b/platform/xcode/liblove.xcodeproj/project.pbxproj @@ -820,9 +820,6 @@ FA0B7ED11A95902C000E1D17 /* wrap_ThreadModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7CB51A95902C000E1D17 /* wrap_ThreadModule.cpp */; }; FA0B7ED21A95902C000E1D17 /* wrap_ThreadModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7CB51A95902C000E1D17 /* wrap_ThreadModule.cpp */; }; FA0B7ED31A95902C000E1D17 /* wrap_ThreadModule.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7CB61A95902C000E1D17 /* wrap_ThreadModule.h */; }; - FA0B7ED41A95902D000E1D17 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7CB91A95902C000E1D17 /* Timer.cpp */; }; - FA0B7ED51A95902D000E1D17 /* Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7CB91A95902C000E1D17 /* Timer.cpp */; }; - FA0B7ED61A95902D000E1D17 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7CBA1A95902C000E1D17 /* Timer.h */; }; FA0B7ED71A95902D000E1D17 /* Timer.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7CBB1A95902C000E1D17 /* Timer.h */; }; FA0B7ED81A95902D000E1D17 /* wrap_Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7CBC1A95902C000E1D17 /* wrap_Timer.cpp */; }; FA0B7ED91A95902D000E1D17 /* wrap_Timer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7CBC1A95902C000E1D17 /* wrap_Timer.cpp */; }; @@ -1585,8 +1582,6 @@ FA0B7CB41A95902C000E1D17 /* wrap_LuaThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_LuaThread.h; sourceTree = ""; }; FA0B7CB51A95902C000E1D17 /* wrap_ThreadModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_ThreadModule.cpp; sourceTree = ""; }; FA0B7CB61A95902C000E1D17 /* wrap_ThreadModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_ThreadModule.h; sourceTree = ""; }; - FA0B7CB91A95902C000E1D17 /* Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Timer.cpp; sourceTree = ""; }; - FA0B7CBA1A95902C000E1D17 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = ""; }; FA0B7CBB1A95902C000E1D17 /* Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timer.h; sourceTree = ""; }; FA0B7CBC1A95902C000E1D17 /* wrap_Timer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Timer.cpp; sourceTree = ""; }; FA0B7CBD1A95902C000E1D17 /* wrap_Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Timer.h; sourceTree = ""; }; @@ -2882,7 +2877,6 @@ FA0B7CB71A95902C000E1D17 /* timer */ = { isa = PBXGroup; children = ( - FA0B7CB81A95902C000E1D17 /* sdl */, FA4B66C81ABBCF1900558F15 /* Timer.cpp */, FA0B7CBB1A95902C000E1D17 /* Timer.h */, FA0B7CBC1A95902C000E1D17 /* wrap_Timer.cpp */, @@ -2891,15 +2885,6 @@ path = timer; sourceTree = ""; }; - FA0B7CB81A95902C000E1D17 /* sdl */ = { - isa = PBXGroup; - children = ( - FA0B7CB91A95902C000E1D17 /* Timer.cpp */, - FA0B7CBA1A95902C000E1D17 /* Timer.h */, - ); - path = sdl; - sourceTree = ""; - }; FA0B7CBE1A95902C000E1D17 /* touch */ = { isa = PBXGroup; children = ( @@ -3175,7 +3160,6 @@ FA0B7EBA1A95902C000E1D17 /* Channel.h in Headers */, FA0B7D3E1A95902C000E1D17 /* Image.h in Headers */, FA0B7ECA1A95902C000E1D17 /* threads.h in Headers */, - FA0B7ED61A95902D000E1D17 /* Timer.h in Headers */, FA0B7DB01A95902C000E1D17 /* wrap_CompressedImageData.h in Headers */, FA0B7AC11A958EA3000E1D17 /* callbacks.h in Headers */, FA0B7D8F1A95902C000E1D17 /* ddsHandler.h in Headers */, @@ -3859,7 +3843,6 @@ FA0B7E1F1A95902C000E1D17 /* Physics.cpp in Sources */, FA0B7E821A95902C000E1D17 /* Shape.cpp in Sources */, FA0B7ACE1A958EA3000E1D17 /* packet.c in Sources */, - FA0B7ED51A95902D000E1D17 /* Timer.cpp in Sources */, FA19C4C61B4B0BD50059B0B3 /* wrap_Video.cpp in Sources */, FA27B3B41B498151008A9DCE /* wrap_Video.cpp in Sources */, FA1E88801DF363D400E808AA /* Filter.cpp in Sources */, @@ -4170,7 +4153,6 @@ FA0B7E811A95902C000E1D17 /* Shape.cpp in Sources */, FA4F2BA81DE1E36400CA37D7 /* wrap_RecordingDevice.cpp in Sources */, FA0B7B251A958EA3000E1D17 /* lutf8lib.c in Sources */, - FA0B7ED41A95902D000E1D17 /* Timer.cpp in Sources */, FA19C4C51B4B0BD50059B0B3 /* wrap_Video.cpp in Sources */, FA27B3B31B498151008A9DCE /* wrap_Video.cpp in Sources */, FA0B7A611A958EA3000E1D17 /* b2ContactManager.cpp in Sources */, diff --git a/src/common/config.h b/src/common/config.h index 2e184b460..893aae338 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -147,7 +147,6 @@ # define LOVE_ENABLE_THREAD # define LOVE_ENABLE_THREAD_SDL # define LOVE_ENABLE_TIMER -# define LOVE_ENABLE_TIMER_SDL # define LOVE_ENABLE_TOUCH # define LOVE_ENABLE_TOUCH_SDL # define LOVE_ENABLE_UTF8 diff --git a/src/common/delay.cpp b/src/common/delay.cpp index 9208f843d..bb04d50df 100644 --- a/src/common/delay.cpp +++ b/src/common/delay.cpp @@ -27,6 +27,8 @@ namespace love void sleep(unsigned int ms) { + // We don't need to initialize the SDL timer subsystem for SDL_Delay to + // function - and doing so causes SDL to create a worker thread. SDL_Delay(ms); } diff --git a/src/modules/timer/Timer.h b/src/modules/timer/Timer.h index 760b9d8c1..478b037c8 100644 --- a/src/modules/timer/Timer.h +++ b/src/modules/timer/Timer.h @@ -37,38 +37,39 @@ public: virtual ~Timer() {} // Implements Module. - virtual ModuleType getModuleType() const { return M_TIMER; } + ModuleType getModuleType() const override { return M_TIMER; } + const char *getName() const override { return "love.timer"; } /** * Measures the time between this call and the previous call, * and updates internal values accordinly. **/ - virtual void step(); + void step(); /** * Tries to sleep for the specified amount of time. The precision is * usually 1ms. * @param seconds The number of seconds to sleep for. **/ - virtual void sleep(double seconds) const; + void sleep(double seconds) const; /** * Gets the time between the last two frames, assuming step is called * each frame. **/ - virtual double getDelta() const; + double getDelta() const; /** * Gets the average FPS over the last second. Beucase the value is only updated * once per second, it does not look erratic when displayed on screen. * @return The "current" FPS. **/ - virtual int getFPS() const; + int getFPS() const; /** * Gets the average delta time (seconds per frame) over the last second. **/ - virtual double getAverageDelta() const; + double getAverageDelta() const; /** * Gets the amount of time passed since an unspecified time. Useful for diff --git a/src/modules/timer/sdl/Timer.cpp b/src/modules/timer/sdl/Timer.cpp deleted file mode 100644 index 7a6f9ff37..000000000 --- a/src/modules/timer/sdl/Timer.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2006-2016 LOVE Development Team - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - **/ - -// LOVE -#include "Timer.h" - -namespace love -{ -namespace timer -{ -namespace sdl -{ - -Timer::Timer() -{ - // We don't need to initialize the SDL timer subsystem for SDL_Delay to - // function - and doing so causes SDL to create a worker thread. -} - -Timer::~Timer() -{ -} - -const char *Timer::getName() const -{ - return "love.timer.sdl"; -} - -} // sdl -} // timer -} // love diff --git a/src/modules/timer/sdl/Timer.h b/src/modules/timer/sdl/Timer.h deleted file mode 100644 index cd5e2ea10..000000000 --- a/src/modules/timer/sdl/Timer.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2006-2016 LOVE Development Team - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - **/ - -#ifndef LOVE_TIMER_SDL_TIMER_H -#define LOVE_TIMER_SDL_TIMER_H - -// LOVE -#include "timer/Timer.h" - -namespace love -{ -namespace timer -{ -namespace sdl -{ - -class Timer : public love::timer::Timer -{ -public: - - Timer(); - virtual ~Timer(); - const char *getName() const override; - -}; // Timer - -} // sdl -} // timer -} // love - -#endif // LOVE_TIMER_SDL_TIMER_H