This commit is contained in:
Christoph Oelckers 2017-11-25 11:37:46 +01:00
commit 430ed532ef
8 changed files with 17 additions and 127 deletions

View file

@ -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 )

View file

@ -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());
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();
}

View file

@ -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) *

View file

@ -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) *

View file

@ -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();
}

View file

@ -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 <assert.h>
#include <sys/sysctl.h>
#include <sys/time.h>
#include <pthread.h>
#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()
{
}

View file

@ -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();
}

View file

@ -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 <assert.h>
#include <signal.h>
#include <sys/time.h>
#include <SDL.h>
#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);
}