mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-22 20:21:20 +00:00
7c37bad4ac
commit57ebeb79e2
Author: Simon <simonbrown77@googlemail.com> Date: Thu Feb 16 22:07:38 2023 +0000 Fixed issue with FrameSetup being called in the wrong place this seemed to limit the correctly submitted frames to 60 fps! commit16299b3f8a
Author: Simon <simonbrown77@googlemail.com> Date: Tue Feb 14 20:51:03 2023 +0000 Get floor height offset correct for each game commitfa74cf0559
Author: Simon <simonbrown77@googlemail.com> Date: Tue Feb 14 20:37:29 2023 +0000 Clean exit on Pico & Quest and gold tier patron credit screen commitdeb2c35988
Author: Simon <simonbrown77@googlemail.com> Date: Mon Feb 13 22:22:29 2023 +0000 Number of small changed - Hide crosshair if it isn't needed - Don't draw black bar when drawing FPS counter - added roll in to the weapon sprite - If drawing full screen mode always use orthographic projection commitf1a165add7
Author: Simon <simonbrown77@googlemail.com> Date: Mon Feb 13 21:44:42 2023 +0000 FInal changes to get MV rendering correctly commit936f079db8
Merge:06a99dbaf
f8c1f49e6
Author: Simon <simonbrown77@googlemail.com> Date: Mon Feb 13 11:29:23 2023 +0000 Merge branch 'multiview' into direct-eye-buffers commit06a99dbafb
Author: Simon <simonbrown77@googlemail.com> Date: Mon Feb 13 11:26:44 2023 +0000 Implementation using no additional frame buffers commitf8c1f49e6f
Author: Simon <simonbrown77@googlemail.com> Date: Sun Feb 12 11:19:27 2023 +0000 Failed attempt at multiview
167 lines
5.4 KiB
C++
167 lines
5.4 KiB
C++
/*
|
|
** gamehud.cpp
|
|
**
|
|
** Management of HUD elements
|
|
**
|
|
**---------------------------------------------------------------------------
|
|
** Copyright 2019-2021 Christoph Oelckers
|
|
** 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 <memory>
|
|
#include <assert.h>
|
|
#include "gamehud.h"
|
|
#include "textures.h"
|
|
#include "palette.h"
|
|
#include "gamecontrol.h"
|
|
#include "v_2ddrawer.h"
|
|
#include "v_video.h"
|
|
#include "build.h"
|
|
#include "v_draw.h"
|
|
#include "v_font.h"
|
|
#include "gamestruct.h"
|
|
#include "gamefuncs.h"
|
|
#include "gamestate.h"
|
|
#include "version.h"
|
|
#include "texinfo.h"
|
|
|
|
#include "buildtiles.h"
|
|
|
|
F2DDrawer twodpsp;
|
|
|
|
|
|
void hud_drawsprite(double sx, double sy, double sz, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha)
|
|
{
|
|
sz *= 1. / 65536.;
|
|
alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.;
|
|
int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum);
|
|
|
|
auto tex = tileGetTexture(picnum, true);
|
|
|
|
DrawTexture(&twodpsp, tex, sx, sy,
|
|
DTA_ScaleX, sz, DTA_ScaleY, sz,
|
|
DTA_Color, shadeToLight(dashade),
|
|
DTA_TranslationIndex, palid,
|
|
DTA_ViewportX, viewport3d.Left(), DTA_ViewportY, viewport3d.Top(),
|
|
DTA_ViewportWidth, viewport3d.Width(), DTA_ViewportHeight, viewport3d.Height(),
|
|
DTA_FullscreenScale, (dastat & RS_STRETCH)? FSMode_ScaleToScreen: FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
|
|
DTA_CenterOffsetRel, (dastat & (RS_TOPLEFT | RS_CENTER))? 0:2,
|
|
DTA_TopLeft, !!(dastat & RS_TOPLEFT),
|
|
DTA_CenterOffset, !!(dastat & RS_CENTER),
|
|
DTA_FlipX, !!(dastat & RS_XFLIPHUD),
|
|
DTA_FlipY, !!(dastat & RS_YFLIPHUD),
|
|
DTA_Pin, (dastat & RS_ALIGN_R) ? 1 : (dastat & RS_ALIGN_L) ? -1 : 0,
|
|
DTA_Rotate, a,
|
|
DTA_FlipOffsets, !(dastat & (/*RS_TOPLEFT |*/ RS_CENTER)),
|
|
DTA_Alpha, alpha,
|
|
TAG_DONE);
|
|
}
|
|
|
|
|
|
//==========================================================================
|
|
//
|
|
// DFrameBuffer :: DrawRateStuff
|
|
//
|
|
// Draws the fps counter, dot ticker, and palette debug.
|
|
//
|
|
//==========================================================================
|
|
EXTERN_CVAR(Bool, vid_fps)
|
|
|
|
|
|
static FString statFPS()
|
|
{
|
|
static int32_t frameCount;
|
|
static double lastFrameTime;
|
|
static double cumulativeFrameDelay;
|
|
static double lastFPS;
|
|
|
|
FString output;
|
|
|
|
double frameTime = I_msTimeF();
|
|
double frameDelay = frameTime - lastFrameTime;
|
|
cumulativeFrameDelay += frameDelay;
|
|
|
|
frameCount++;
|
|
if (frameDelay >= 0)
|
|
{
|
|
output.AppendFormat("%5.1f fps", lastFPS);
|
|
if (frameDelay < 10) output.AppendFormat(" ");
|
|
output.AppendFormat(" (%.1f ms)\n", frameDelay);
|
|
|
|
if (cumulativeFrameDelay >= 1000.0)
|
|
{
|
|
lastFPS = 1000. * frameCount / cumulativeFrameDelay;
|
|
frameCount = 0;
|
|
cumulativeFrameDelay = 0.0;
|
|
}
|
|
}
|
|
lastFrameTime = frameTime;
|
|
return output;
|
|
}
|
|
|
|
void DrawRateStuff()
|
|
{
|
|
// Draws frame time and cumulative fps
|
|
if (vid_fps)
|
|
{
|
|
FString fpsbuff = statFPS();
|
|
|
|
int textScale = active_con_scale(twod_blend);
|
|
int rate_x = (screen->GetWidth() / 2) / textScale - (NewConsoleFont->StringWidth(&fpsbuff[0]) / 2);
|
|
//twod->AddColorOnlyQuad(rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, MAKEARGB(255, 0, 0, 0));
|
|
DrawText(twod_blend, NewConsoleFont, CR_WHITE, rate_x, screen->GetHeight() / 2, (char*)&fpsbuff[0],
|
|
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
|
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
|
DTA_KeepRatio, true, TAG_DONE);
|
|
|
|
}
|
|
}
|
|
|
|
void DrawVersionString ()
|
|
{
|
|
static uint64_t first = screen->FrameTime;
|
|
|
|
//Only show version string for 5 seconds
|
|
if ((screen->FrameTime - first) > 15000)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (gamestate == GS_STARTUP ||
|
|
gamestate == GS_DEMOSCREEN) {
|
|
char buff[60];
|
|
|
|
int textScale = active_con_scale(twod) * 3;
|
|
|
|
mysnprintf(buff, countof(buff), "Team Beef Presents - %s (Raze ver. %s)", RAZEXR_VERSIONSTR, VERSIONSTR);
|
|
DrawText(twod, ConFont, CR_WHITE, 0, 0, (char *) &buff[0],
|
|
DTA_VirtualWidth, screen->GetWidth() / textScale,
|
|
DTA_VirtualHeight, screen->GetHeight() / textScale,
|
|
DTA_KeepRatio, true, TAG_DONE);
|
|
}
|
|
}
|