diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc6545ea3..c88d50b15 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -507,7 +507,6 @@ set( PLAT_SDL_SOURCES posix/sdl/i_joystick.cpp posix/sdl/i_main.cpp posix/sdl/i_system.cpp - posix/sdl/i_timer.cpp posix/sdl/sdlvideo.cpp posix/sdl/sdlglvideo.cpp posix/sdl/st_start.cpp ) @@ -525,7 +524,6 @@ set( PLAT_COCOA_SOURCES posix/cocoa/i_main.mm posix/cocoa/i_main_except.cpp posix/cocoa/i_system.mm - posix/cocoa/i_timer.cpp posix/cocoa/i_video.mm posix/cocoa/st_console.mm posix/cocoa/st_start.mm ) diff --git a/src/i_time.cpp b/src/i_time.cpp index 516ecfad1..bea027243 100644 --- a/src/i_time.cpp +++ b/src/i_time.cpp @@ -130,11 +130,22 @@ int I_WaitForTic(int prevtic) int time; while ((time = I_GetTime()) <= prevtic) { + // Windows-specific note: // The minimum amount of time a thread can sleep is controlled by timeBeginPeriod. // We set this to 1 ms in DoMain. - uint64_t sleepTime = NSToMS(FirstFrameStartTime + TicToNS(prevtic + 1) - I_nsTime()); - if (sleepTime > 2) - std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime - 2)); + + const uint64_t next = FirstFrameStartTime + TicToNS(prevtic + 1); + const uint64_t now = I_nsTime(); + + if (next > now) + { + const uint64_t sleepTime = NSToMS(next - now); + + if (sleepTime > 2) + { + std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime - 2)); + } + } I_SetFrameTime(); } diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index 1b00412d1..7517083c5 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -209,6 +209,7 @@ void PolyRenderer::SetupPerspectiveMatrix() float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(Viewpoint.FieldOfView.Radians() / 2) / fovratio)).Degrees); WorldToView = + TriMatrix::rotate((float)Viewpoint.Angles.Roll.Radians(), 0.0f, 0.0f, 1.0f) * TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) * diff --git a/src/polyrenderer/scene/poly_portal.cpp b/src/polyrenderer/scene/poly_portal.cpp index 8abfb66f5..cbf4ccc9c 100644 --- a/src/polyrenderer/scene/poly_portal.cpp +++ b/src/polyrenderer/scene/poly_portal.cpp @@ -59,6 +59,7 @@ void PolyDrawSectorPortal::Render(int portalDepth) float fovratio = (viewwindow.WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(viewpoint.FieldOfView.Radians() / 2) / fovratio)).Degrees); TriMatrix worldToView = + TriMatrix::rotate((float)viewpoint.Angles.Roll.Radians(), 0.0f, 0.0f, 1.0f) * TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) * @@ -169,6 +170,7 @@ void PolyDrawLinePortal::Render(int portalDepth) float fovratio = (viewwindow.WidescreenRatio >= 1.3f) ? 1.333333f : ratio; float fovy = (float)(2 * DAngle::ToDegrees(atan(tan(viewpoint.FieldOfView.Radians() / 2) / fovratio)).Degrees); TriMatrix worldToView = + TriMatrix::rotate((float)viewpoint.Angles.Roll.Radians(), 0.0f, 0.0f, 1.0f) * TriMatrix::rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) * TriMatrix::rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) * TriMatrix::scale(1.0f, level.info->pixelstretch, 1.0f) * diff --git a/src/posix/cocoa/i_system.mm b/src/posix/cocoa/i_system.mm index cc9dc613a..bb1ea2e1b 100644 --- a/src/posix/cocoa/i_system.mm +++ b/src/posix/cocoa/i_system.mm @@ -84,9 +84,6 @@ void SetLanguageIDs() } -void I_InitTimer(); -void I_ShutdownTimer(); - double PerfToSec, PerfToMillisec; static void CalculateCPUSpeed() @@ -114,7 +111,6 @@ void I_Init(void) atterm(I_ShutdownSound); I_InitSound(); - I_InitTimer(); } static int has_exited; @@ -129,8 +125,6 @@ void I_Quit() } C_DeinitConsole(); - - I_ShutdownTimer(); } diff --git a/src/posix/cocoa/i_timer.cpp b/src/posix/cocoa/i_timer.cpp deleted file mode 100644 index 503fa64ec..000000000 --- a/src/posix/cocoa/i_timer.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - ** i_timer.cpp - ** - **--------------------------------------------------------------------------- - ** Copyright 2012-2015 Alexey Lysiuk - ** All rights reserved. - ** - ** Redistribution and use in source and binary forms, with or without - ** modification, are permitted provided that the following conditions - ** are met: - ** - ** 1. Redistributions of source code must retain the above copyright - ** notice, this list of conditions and the following disclaimer. - ** 2. Redistributions in binary form must reproduce the above copyright - ** notice, this list of conditions and the following disclaimer in the - ** documentation and/or other materials provided with the distribution. - ** 3. The name of the author may not be used to endorse or promote products - ** derived from this software without specific prior written permission. - ** - ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - **--------------------------------------------------------------------------- - ** - */ - -#include -#include -#include -#include - -#include "doomdef.h" -#include "i_system.h" -#include "templates.h" - -// To do: this file is obviously not needed anymore. It needs to be removed. - -void I_InitTimer() -{ -} - -void I_ShutdownTimer() -{ -} diff --git a/src/posix/sdl/i_system.cpp b/src/posix/sdl/i_system.cpp index 903563da0..7bf23af11 100644 --- a/src/posix/sdl/i_system.cpp +++ b/src/posix/sdl/i_system.cpp @@ -119,9 +119,6 @@ void SetLanguageIDs () LanguageIDs[3] = LanguageIDs[2] = LanguageIDs[1] = LanguageIDs[0] = lang; } -void I_InitTimer (); -void I_ShutdownTimer (); - // // I_Init // @@ -132,7 +129,6 @@ void I_Init (void) atterm (I_ShutdownSound); I_InitSound (); - I_InitTimer (); } // @@ -148,8 +144,6 @@ void I_Quit (void) G_CheckDemoStatus(); C_DeinitConsole(); - - I_ShutdownTimer(); } diff --git a/src/posix/sdl/i_timer.cpp b/src/posix/sdl/i_timer.cpp deleted file mode 100644 index dab7c30ac..000000000 --- a/src/posix/sdl/i_timer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -** i_timer.cpp -** -**--------------------------------------------------------------------------- -** Copyright 2005-2016 Randy Heit -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -// Moved from sdl/i_system.cpp - -#include -#include -#include - -#include - -#include "m_fixed.h" -#include "hardware.h" -#include "i_system.h" -#include "templates.h" - -void I_InitTimer () -{ - if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0) - I_FatalError("Could not initialize SDL timers:\n%s\n", SDL_GetError()); - - // Maybe this file isn't needed at all anymore. - // Someone with Linux should test if the timer subsystem is used elsewhere.. -} - -void I_ShutdownTimer () -{ - SDL_QuitSubSystem(SDL_INIT_TIMER); -}