- made video base code game independent

This commit is contained in:
Christoph Oelckers 2020-04-28 17:22:17 +02:00
parent 2196b4fb04
commit ddef3f7b98
56 changed files with 251 additions and 241 deletions

View file

@ -48,6 +48,7 @@
#include "g_game.h"
#include "v_video.h"
#include "d_main.h"
#include "v_draw.h"
#include "m_cheat.h"
#include "c_dispatch.h"

View file

@ -39,7 +39,8 @@
#include "v_draw.h"
#include "fcolormap.h"
F2DDrawer* twod;
static F2DDrawer drawer;
F2DDrawer* twod = &drawer;
EXTERN_CVAR(Float, transsouls)

View file

@ -198,7 +198,7 @@ public:
int GetWidth() const { return Width; }
int GetHeight() const { return Height; }
void SetSize(int w, int h) { Width = w; Height = h; }
void Begin() { isIn2D = true; }
void Begin(int w, int h) { isIn2D = true; Width = w; Height = h; }
void End() { isIn2D = false; }
bool HasBegun2D() { return isIn2D; }

View file

@ -1222,7 +1222,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Screen, DrawThickLine, DrawThickLine)
//==========================================================================
//
// DCanvas :: Clear
// ClearRect
//
// Set an area to a specified color.
//
@ -1281,7 +1281,7 @@ DEFINE_ACTION_FUNCTION(_Screen, Clear)
//==========================================================================
//
// DCanvas :: Dim
// DoDim
//
// Applies a colored overlay to an area of the screen.
//

View file

@ -219,7 +219,6 @@ void DoDim(F2DDrawer* drawer, PalEntry color, float amount, int x1, int y1, int
void Dim(F2DDrawer* drawer, PalEntry color, float damount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr);
void FillBorder(F2DDrawer *drawer, FGameTexture* img); // Fills the border around a 4:3 part of the screen on non-4:3 displays
void DrawFrame(F2DDrawer* drawer, int left, int top, int width, int height);
void DrawBorder(F2DDrawer* drawer, FTextureID, int x1, int y1, int x2, int y2);
void DrawFrame(F2DDrawer* twod, PalEntry color, int left, int top, int width, int height, int thickness);

View file

@ -1,6 +1,7 @@
#pragma once
#include "zstring.h"
#include "intrect.h"
struct SystemCallbacks
{
@ -13,6 +14,8 @@ struct SystemCallbacks
void (*PlayStartupSound)(const char* name);
bool (*IsSpecialUI)();
bool (*DisableTextureFilter)();
void (*OnScreenSizeChanged)();
IntRect(*GetSceneRect)();
};
extern SystemCallbacks *sysCallbacks;

View file

@ -38,7 +38,6 @@
#include "palentry.h"
#include "name.h"
class DCanvas;
class FGameTexture;
struct FRemapTable;

View file

@ -31,13 +31,13 @@
#include "sc_man.h"
#include "m_crc32.h"
#include "printf.h"
#include "models.h"
#include "model_ue1.h"
#include "model_obj.h"
#include "model_md2.h"
#include "model_md3.h"
#include "model_kvx.h"
#include "i_time.h"
#include "voxels.h"
#include "texturemanager.h"
#include "modelrenderer.h"

View file

@ -2,6 +2,7 @@
#include <stdint.h>
#include "textureid.h"
#include "i_modelvertexbuffer.h"
class FModelRenderer;
class FGameTexture;

View file

@ -1,5 +1,7 @@
#include "models.h"
#include "renderstyle.h"
#include "matrix.h"
#include "model.h"
class FModelRenderer
{

View file

@ -30,6 +30,7 @@
#include "model_md2.h"
#include "texturemanager.h"
#include "modelrenderer.h"
#include "printf.h"
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data

View file

@ -23,6 +23,8 @@
#include "model_obj.h"
#include "texturemanager.h"
#include "modelrenderer.h"
#include "printf.h"
#include "textureid.h"
/**
* Load an OBJ model

View file

@ -33,6 +33,10 @@
#include "image.h"
#include "texturemanager.h"
#include "modelrenderer.h"
#include "voxels.h"
#include "texturemanager.h"
#include "palettecontainer.h"
#include "textures.h"
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data

View file

@ -43,7 +43,6 @@
#include "v_video.h"
#include "sc_man.h"
#include "voxels.h"
#include "info.h"
#include "printf.h"
void VOX_AddVoxel(int sprnum, int frame, FVoxelDef *def);

View file

@ -1,8 +1,7 @@
#ifndef __RES_VOXEL_H
#define __RES_VOXEL_H
#include "doomdef.h"
#include <stdint.h>
// [RH] Voxels from Build
#define MAXVOXMIPS 5

View file

@ -35,6 +35,7 @@
#include "v_video.h"
#include "templates.h"
#include "hw_vrmodes.h"
#include "v_draw.h"
extern bool vid_hdr_active;
@ -123,7 +124,7 @@ void FGLRenderer::Flush()
if (eyeCount - eye_ix > 1)
mBuffers->NextEye(eyeCount);
}
screen->Clear2D();
twod->Clear();
FGLPostProcessState savedState;
FGLDebug::PushGroup("PresentEyes");
@ -143,7 +144,7 @@ void FGLRenderer::Flush()
void FGLRenderer::CopyToBackbuffer(const IntRect *bounds, bool applyGamma)
{
screen->Draw2D(); // draw all pending 2D stuff before copying the buffer
screen->Clear2D();
twod->Clear();
GLPPRenderState renderstate(mBuffers);
hw_postprocess.customShaders.Run(&renderstate, "screen");

View file

@ -26,13 +26,10 @@
*/
#include "templates.h"
#include "doomstat.h"
#include "r_data/colormaps.h"
#include "gl_system.h"
#include "gl_interface.h"
#include "hw_cvars.h"
#include "flatvertices.h"
#include "hwrenderer/scene/hw_skydome.h"
#include "gl_shader.h"
#include "gl/renderer/gl_renderer.h"
#include "hw_lightbuffer.h"

View file

@ -40,12 +40,11 @@
#include "v_draw.h"
#include "i_interface.h"
#include "printf.h"
#include "version.h"
#define NUMSCALEMODES countof(vScaleTable)
extern bool setsizeneeded;
EXTERN_CVAR(Int, vid_aspect)
CUSTOM_CVAR(Int, vid_scale_customwidth, VID_MIN_WIDTH, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (self < VID_MIN_WIDTH)

View file

@ -50,6 +50,12 @@ private:
int texnum;
};
class FNullTextureID : public FTextureID
{
public:
FNullTextureID() : FTextureID(0) {}
};
// This is for the script interface which needs to do casts from int to texture.
class FSetTextureID : public FTextureID
{

View file

@ -124,12 +124,6 @@ class FMultipatchTextureBuilder;
extern int r_spriteadjustSW, r_spriteadjustHW;
class FNullTextureID : public FTextureID
{
public:
FNullTextureID() : FTextureID(0) {}
};
enum FTextureFormat : uint32_t
{
TEX_Pal,

View file

@ -68,6 +68,7 @@
#include "i_music.h"
#include "s_music.h"
#include "texturemanager.h"
#include "v_draw.h"
extern FILE *Logfile;
extern bool insave;

View file

@ -67,6 +67,7 @@
#include "s_music.h"
#include "i_time.h"
#include "texturemanager.h"
#include "v_draw.h"
#include "gi.h"
@ -1000,7 +1001,7 @@ void C_AdjustBottom ()
void C_NewModeAdjust ()
{
C_InitConsole (twod->GetWidth(), twod->GetHeight(), true);
C_InitConsole (screen->GetWidth(), screen->GetHeight(), true);
C_FlushDisplay ();
C_AdjustBottom ();
}

View file

@ -44,6 +44,7 @@
#include "vm.h"
#include "c_buttons.h"
#include "d_buttons.h"
#include "v_draw.h"
enum
{

View file

@ -89,6 +89,7 @@
#include "d_netinf.h"
#include "m_cheat.h"
#include "m_joy.h"
#include "v_draw.h"
#include "po_man.h"
#include "p_local.h"
#include "autosegs.h"
@ -113,6 +114,7 @@
#include "scriptutil.h"
#include "v_palette.h"
#include "texturemanager.h"
#include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/scene/hw_drawinfo.h"
#ifdef __unix__
@ -216,6 +218,27 @@ CUSTOM_CVAR(Float, i_timescale, 1.0f, CVAR_NOINITCALL)
// PUBLIC DATA DEFINITIONS -------------------------------------------------
CUSTOM_CVAR(Int, vid_rendermode, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
if (self < 0 || self > 4)
{
self = 4;
}
else if (self == 2 || self == 3)
{
self = self - 2; // softpoly to software
}
if (usergame)
{
// [SP] Update pitch limits to the netgame/gamesim.
players[consoleplayer].SendPitchLimits();
}
screen->SetTextureFilterMode();
// No further checks needed. All this changes now is which scene drawer the render backend calls.
}
CUSTOM_CVAR (Int, fraglimit, 0, CVAR_SERVERINFO)
{
// Check for the fraglimit being hit because the fraglimit is being
@ -937,6 +960,7 @@ static void End2DAndUpdate()
{
DrawRateStuff();
twod->End();
CheckBench();
screen->Update();
}
@ -1070,7 +1094,7 @@ void D_Display ()
viewsec = RenderView(&players[consoleplayer]);
}, true);
screen->Begin2D();
twod->Begin(screen->GetWidth(), screen->GetHeight());
if (!hud_toggled)
{
V_DrawBlend(viewsec);
@ -1117,11 +1141,10 @@ void D_Display ()
}
else
{
screen->Begin2D();
twod->Begin(screen->GetWidth(), screen->GetHeight());
switch (gamestate)
{
case GS_FULLCONSOLE:
screen->Begin2D();
C_DrawConsole ();
M_Drawer ();
End2DAndUpdate ();
@ -1207,7 +1230,7 @@ void D_Display ()
GSnd->SetSfxPaused(true, 1);
I_FreezeTime(true);
screen->End2D();
twod->End();
auto wipend = MakeGameTexture(screen->WipeEndScreen(), nullptr, ETextureType::SWCanvas);
auto wiper = Wiper::Create(wipe_type);
wiper->SetTextures(wipe, wipend);
@ -1224,7 +1247,7 @@ void D_Display ()
diff = (nowtime - wipestart) * 40 / 1000; // Using 35 here feels too slow.
} while (diff < 1);
wipestart = nowtime;
screen->Begin2D();
twod->Begin(screen->GetWidth(), screen->GetHeight());
done = wiper->Run(1);
C_DrawConsole (); // console and
M_Drawer (); // menu are drawn even on top of wipes
@ -2798,6 +2821,40 @@ static bool System_DisableTextureFilter()
return !V_IsHardwareRenderer();
}
static void System_OnScreenSizeChanged()
{
if (StatusBar != NULL)
{
StatusBar->CallScreenSizeChanged();
}
// Reload crosshair if transitioned to a different size
ST_LoadCrosshair(true);
if (primaryLevel && primaryLevel->automap)
primaryLevel->automap->NewResolution();
}
IntRect System_GetSceneRect()
{
IntRect mSceneViewport;
// Special handling so the view with a visible status bar displays properly
int height, width;
if (screenblocks >= 10)
{
height = screen->GetHeight();
width = screen->GetWidth();
}
else
{
height = (screenblocks * screen->GetHeight() / 10) & ~7;
width = (screenblocks * screen->GetWidth() / 10);
}
mSceneViewport.left = viewwindowx;
mSceneViewport.top = screen->GetHeight() - (height + viewwindowy - ((height - viewheight) / 2));
mSceneViewport.width = viewwidth;
mSceneViewport.height = height;
return mSceneViewport;
}
//==========================================================================
//
// DoomSpecificInfo
@ -3004,6 +3061,8 @@ static int D_DoomMain_Internal (void)
System_PlayStartupSound,
System_IsSpecialUI,
System_DisableTextureFilter,
System_OnScreenSizeChanged,
System_GetSceneRect,
};
sysCallbacks = &syscb;

View file

@ -71,6 +71,7 @@
EXTERN_CVAR (Int, disableautosave)
EXTERN_CVAR (Int, autosavecount)
EXTERN_CVAR(Bool, cl_capfps)
//#define SIMULATEERRORS (RAND_MAX/3)
#define SIMULATEERRORS 0
@ -146,8 +147,6 @@ static int oldentertics;
extern bool advancedemo;
CVAR (Bool, cl_capfps, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, net_ticbalance, false, CVAR_SERVERINFO | CVAR_NOSAVE)
CUSTOM_CVAR(Int, net_extratic, 0, CVAR_SERVERINFO | CVAR_NOSAVE)
{

View file

@ -42,6 +42,7 @@
#include "serialize_obj.h"
#include "doomstat.h"
#include "vm.h"
#include "v_draw.h"
EXTERN_CVAR(Int, con_scaletext)

View file

@ -51,6 +51,7 @@
#include "utf8.h"
#include "texturemanager.h"
#include "v_palette.h"
#include "v_draw.h"
#define ARTIFLASH_OFFSET (statusBar->invBarOffset+6)
enum

View file

@ -48,6 +48,7 @@
#include "cmdlib.h"
#include "g_levellocals.h"
#include "vm.h"
#include "v_draw.h"
#include <time.h>

View file

@ -62,6 +62,7 @@
#include "utf8.h"
#include "texturemanager.h"
#include "v_palette.h"
#include "v_draw.h"
#include "../version.h"
@ -141,6 +142,57 @@ CUSTOM_CVAR(Int, am_showmaplabel, 2, CVAR_ARCHIVE)
CVAR (Bool, idmypos, false, 0);
//==========================================================================
//
// V_DrawFrame
//
// Draw a frame around the specified area using the view border
// frame graphics. The border is drawn outside the area, not in it.
//
//==========================================================================
void V_DrawFrame(F2DDrawer* drawer, int left, int top, int width, int height)
{
FGameTexture* p;
const gameborder_t* border = &gameinfo.Border;
// Sanity check for incomplete gameinfo
if (border == NULL)
return;
int offset = border->offset;
int right = left + width;
int bottom = top + height;
// Draw top and bottom sides.
p = TexMan.GetGameTextureByName(border->t);
drawer->AddFlatFill(left, top - (int)p->GetDisplayHeight(), right, top, p, true);
p = TexMan.GetGameTextureByName(border->b);
drawer->AddFlatFill(left, bottom, right, bottom + (int)p->GetDisplayHeight(), p, true);
// Draw left and right sides.
p = TexMan.GetGameTextureByName(border->l);
drawer->AddFlatFill(left - (int)p->GetDisplayWidth(), top, left, bottom, p, true);
p = TexMan.GetGameTextureByName(border->r);
drawer->AddFlatFill(right, top, right + (int)p->GetDisplayWidth(), bottom, p, true);
// Draw beveled corners.
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tl), left - offset, top - offset, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tr), left + width, top - offset, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->bl), left - offset, top + height, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->br), left + width, top + height, TAG_DONE);
}
DEFINE_ACTION_FUNCTION(_Screen, DrawFrame)
{
PARAM_PROLOGUE;
PARAM_INT(x);
PARAM_INT(y);
PARAM_INT(w);
PARAM_INT(h);
if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
V_DrawFrame(twod, x, y, w, h);
return 0;
}
//---------------------------------------------------------------------------
//
// Load crosshair definitions
@ -964,7 +1016,7 @@ void DBaseStatusBar::RefreshViewBorder ()
DrawBorder(twod, tex, viewwindowx + viewwidth, viewwindowy, Width, viewheight + viewwindowy);
DrawBorder(twod, tex, 0, viewwindowy + viewheight, Width, StatusBar->GetTopOfStatusbar());
DrawFrame(twod, viewwindowx, viewwindowy, viewwidth, viewheight);
V_DrawFrame(twod, viewwindowx, viewwindowy, viewwidth, viewheight);
}
}

View file

@ -569,6 +569,12 @@ void FGameConfigFile::DoGlobalSetup ()
UCVarValue v = var->GetGenericRep(CVAR_Float);
vid_gamma = v.Float;
}
var = FindCVar("fullscreen", NULL);
if (var != NULL)
{
UCVarValue v = var->GetGenericRep(CVAR_Bool);
vid_fullscreen = v.Float;
}
}
}

View file

@ -52,6 +52,7 @@
#include "g_game.h"
#include "sbar.h"
#include "texturemanager.h"
#include "v_draw.h"
// MACROS ------------------------------------------------------------------

View file

@ -53,6 +53,7 @@
#include "templates.h"
#include "s_music.h"
#include "texturemanager.h"
#include "v_draw.h"
FIntermissionDescriptorList IntermissionDescriptors;
@ -941,7 +942,7 @@ void DIntermissionController::OnDestroy ()
void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, uint8_t state)
{
ScaleOverrider s(&screen->m2DDrawer);
ScaleOverrider s(twod);
if (DIntermissionController::CurrentIntermission != NULL)
{
DIntermissionController::CurrentIntermission->Destroy();
@ -987,7 +988,7 @@ void F_StartIntermission(FName seq, uint8_t state)
bool F_Responder (event_t* ev)
{
ScaleOverrider s(&screen->m2DDrawer);
ScaleOverrider s(twod);
if (DIntermissionController::CurrentIntermission != NULL)
{
return DIntermissionController::CurrentIntermission->Responder(ev);
@ -1003,7 +1004,7 @@ bool F_Responder (event_t* ev)
void F_Ticker ()
{
ScaleOverrider s(&screen->m2DDrawer);
ScaleOverrider s(twod);
if (DIntermissionController::CurrentIntermission != NULL)
{
DIntermissionController::CurrentIntermission->Ticker();
@ -1018,7 +1019,7 @@ void F_Ticker ()
void F_Drawer ()
{
ScaleOverrider s(&screen->m2DDrawer);
ScaleOverrider s(twod);
if (DIntermissionController::CurrentIntermission != NULL)
{
DIntermissionController::CurrentIntermission->Drawer();
@ -1034,7 +1035,6 @@ void F_Drawer ()
void F_EndFinale ()
{
ScaleOverrider s(&screen->m2DDrawer);
if (DIntermissionController::CurrentIntermission != NULL)
{
DIntermissionController::CurrentIntermission->Destroy();
@ -1050,7 +1050,7 @@ void F_EndFinale ()
void F_AdvanceIntermission()
{
ScaleOverrider s(&screen->m2DDrawer);
ScaleOverrider s(twod);
if (DIntermissionController::CurrentIntermission != NULL)
{
DIntermissionController::CurrentIntermission->mAdvance = true;

View file

@ -45,6 +45,7 @@
#include "i_system.h"
#include "v_video.h"
#include "findfile.h"
#include "v_draw.h"
// Save name length limit for old binary formats.
#define OLDSAVESTRINGSIZE 24

View file

@ -56,6 +56,7 @@
#include "c_buttons.h"
#include "types.h"
#include "texturemanager.h"
#include "v_draw.h"
int DMenu::InMenu;
static ScaleOverrider *CurrentScaleOverrider;
@ -381,7 +382,7 @@ void M_StartControlPanel (bool makeSound, bool scaleoverride)
}
BackbuttonTime = 0;
BackbuttonAlpha = 0;
if (scaleoverride && !CurrentScaleOverrider) CurrentScaleOverrider = new ScaleOverrider(&screen->m2DDrawer);
if (scaleoverride && !CurrentScaleOverrider) CurrentScaleOverrider = new ScaleOverrider(twod);
else if (!scaleoverride && CurrentScaleOverrider)
{
delete CurrentScaleOverrider;

View file

@ -57,6 +57,7 @@
#include "vm.h"
#include "v_video.h"
#include "actorinlines.h"
#include "v_draw.h"
static FRandom pr_randomspeech("RandomSpeech");

View file

@ -29,6 +29,7 @@
#include "templates.h"
#include "bitmap.h"
#include "hw_material.h"
#include "v_draw.h"
class FBurnTexture : public FTexture
{

View file

@ -48,6 +48,7 @@
#include "r_utility.h"
#include "hw_cvars.h"
#include "d_main.h"
#include "v_draw.h"
CVAR(Float, underwater_fade_scalar, 1.0f, CVAR_ARCHIVE) // [Nash] user-settable underwater blend intensity
CVAR( Float, blood_fade_scalar, 1.0f, CVAR_ARCHIVE ) // [SP] Pulled from Skulltag - changed default from 0.5 to 1.0

View file

@ -57,6 +57,7 @@
#include "gl_buffers.h"
#include "swrenderer/r_swscene.h"
#include "gl_postprocessstate.h"
#include "v_draw.h"
#include "flatvertices.h"
#include "hw_cvars.h"
@ -522,7 +523,7 @@ void OpenGLFrameBuffer::Draw2D()
if (GLRenderer != nullptr)
{
GLRenderer->mBuffers->BindCurrentFB();
::Draw2D(&m2DDrawer, gl_RenderState);
::Draw2D(twod, gl_RenderState);
}
}

View file

@ -43,6 +43,7 @@
#include "hw_lightbuffer.h"
#include "hw_vrmodes.h"
#include "hw_clipper.h"
#include "v_draw.h"
EXTERN_CVAR(Float, r_visibility)
CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE)

View file

@ -36,6 +36,7 @@
#include "hw_cvars.h"
#include "hw_renderstate.h"
#include "r_videoscale.h"
#include "v_draw.h"
//===========================================================================

View file

@ -28,6 +28,7 @@
#include "g_game.h"
#include "v_text.h"
#include "i_video.h"
#include "v_draw.h"
#include "hwrenderer/utility/hw_clock.h"
#include "hw_vrmodes.h"
@ -171,7 +172,7 @@ void PolyFrameBuffer::Update()
Flush3D.Clock();
Draw2D();
Clear2D();
twod->Clear();
Flush3D.Unclock();
@ -375,7 +376,7 @@ FTexture *PolyFrameBuffer::WipeStartScreen()
FTexture *PolyFrameBuffer::WipeEndScreen()
{
Draw2D();
Clear2D();
twod->Clear();
auto tex = new FWrapperTexture(mScreenViewport.width, mScreenViewport.height, 1);
auto systex = static_cast<PolyHardwareTexture*>(tex->GetSystemTexture());
@ -430,7 +431,7 @@ void PolyFrameBuffer::BeginFrame()
void PolyFrameBuffer::Draw2D()
{
::Draw2D(&m2DDrawer, *mRenderState);
::Draw2D(twod, *mRenderState);
}
unsigned int PolyFrameBuffer::GetLightBufferBlockSize() const

View file

@ -64,6 +64,7 @@
#include "actorinlines.h"
#include "g_game.h"
#include "i_system.h"
#include "v_draw.h"
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
@ -140,7 +141,6 @@ int LocalViewPitch;
bool LocalKeyboardTurner;
int setblocks;
bool setsizeneeded;
unsigned int R_OldBlend = ~0;
int validcount = 1; // increment every time a check is made
@ -368,7 +368,7 @@ CUSTOM_CVAR (Int, screenblocks, 10, CVAR_ARCHIVE)
//==========================================================================
FRenderer *CreateSWRenderer();
FRenderer* SWRenderer;
//==========================================================================
//
@ -1031,30 +1031,6 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
}
//==========================================================================
//
// CVAR transsouls
//
// How translucent things drawn with STYLE_SoulTrans are. Normally, only
// Lost Souls have this render style.
// Values less than 0.25 will automatically be set to
// 0.25 to ensure some degree of visibility. Likewise, values above 1.0 will
// be set to 1.0, because anything higher doesn't make sense.
//
//==========================================================================
CUSTOM_CVAR(Float, transsouls, 0.75f, CVAR_ARCHIVE)
{
if (self < 0.25f)
{
self = 0.25f;
}
else if (self > 1.f)
{
self = 1.f;
}
}
CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE | CVAR_SERVERINFO)
{
if (self>90.f) self = 90.f;

View file

@ -37,6 +37,7 @@
#include "engineerrors.h"
#include "texturemanager.h"
#include "d_main.h"
#include "v_draw.h"
// [RH] Base blending values (for e.g. underwater)
int BaseBlendR, BaseBlendG, BaseBlendB;
@ -122,11 +123,11 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
DrawTexture(twod, fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
screen->Draw2D();
screen->Clear2D();
twod->Clear();
screen->PostProcessScene(true, CM_DEFAULT, [&]() {
SWRenderer->DrawRemainingPlayerSprites();
screen->Draw2D();
screen->Clear2D();
twod->Clear();
});
}
else
@ -143,7 +144,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
SWRenderer->DrawRemainingPlayerSprites();
screen->Draw2D();
screen->Clear2D();
twod->Clear();
}
return r_viewpoint.sector;

View file

@ -36,6 +36,7 @@
#include "c_dispatch.h"
#include "cmdlib.h"
#include "d_net.h"
#include "v_draw.h"
#include "g_level.h"
#include "r_utility.h"
#include "d_player.h"

View file

@ -23,7 +23,7 @@
#include <float.h>
#include "templates.h"
#include "v_draw.h"
#include "filesystem.h"
#include "doomdef.h"
#include "doomstat.h"

View file

@ -66,6 +66,7 @@
#include "swrenderer/r_memory.h"
#include "swrenderer/r_renderthread.h"
#include "g_levellocals.h"
#include "v_draw.h"
EXTERN_CVAR(Bool, r_drawplayersprites)
EXTERN_CVAR(Bool, r_deathcamera)

View file

@ -43,6 +43,7 @@
#include "swrenderer/plane/r_flatplane.h"
#include "swrenderer/drawers/r_draw_pal.h"
#include "swrenderer/drawers/r_draw_rgba.h"
#include "v_draw.h"
CVAR(String, r_viewsize, "", CVAR_NOSET)

View file

@ -35,23 +35,21 @@
#include <stdio.h>
#include "x86.h"
#include "actor.h"
#include "v_video.h"
#include "c_dispatch.h"
#include "sbar.h"
#include "hardware.h"
#include "r_utility.h"
#include "swrenderer/r_renderer.h"
#include "vm.h"
#include "r_videoscale.h"
#include "i_time.h"
#include "hwrenderer/scene/hw_portal.h"
#include "hwrenderer/utility/hw_clock.h"
#include "v_font.h"
#include "v_draw.h"
#include "i_time.h"
#include "v_2ddrawer.h"
#include "vm.h"
#include "i_interface.h"
#include "flatvertices.h"
#include "swrenderer/r_swscene.h"
#include "version.h"
#include "hw_material.h"
#include <chrono>
#include <thread>
@ -60,7 +58,7 @@
CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE);
EXTERN_CVAR(Int, vid_maxfps)
EXTERN_CVAR(Bool, cl_capfps)
CVAR(Bool, cl_capfps, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
EXTERN_CVAR(Int, screenblocks)
//==========================================================================
@ -75,21 +73,16 @@ EXTERN_CVAR(Int, screenblocks)
DFrameBuffer::DFrameBuffer (int width, int height)
{
SetSize(width, height);
mPortalState = new FPortalSceneState;
twod = &m2DDrawer;
}
DFrameBuffer::~DFrameBuffer()
{
if (twod == &m2DDrawer) twod = nullptr;
delete mPortalState;
}
void DFrameBuffer::SetSize(int width, int height)
{
Width = ViewportScaledWidth(width, height);
Height = ViewportScaledHeight(width, height);
m2DDrawer.SetSize(width, height);
}
//==========================================================================
@ -100,8 +93,6 @@ void DFrameBuffer::SetSize(int width, int height)
void DFrameBuffer::Update()
{
CheckBench();
int initialWidth = GetClientWidth();
int initialHeight = GetClientHeight();
int clientWidth = ViewportScaledWidth(initialWidth, initialHeight);
@ -182,19 +173,6 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds)
return;
}
// Special handling so the view with a visible status bar displays properly
int height, width;
if (screenblocks >= 10)
{
height = GetHeight();
width = GetWidth();
}
else
{
height = (screenblocks*GetHeight() / 10) & ~7;
width = (screenblocks*GetWidth() / 10);
}
// Back buffer letterbox for the final output
int clientWidth = GetClientWidth();
int clientHeight = GetClientHeight();
@ -222,10 +200,8 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds)
mScreenViewport.height = screenHeight;
// Viewport for the 3D scene
mSceneViewport.left = viewwindowx;
mSceneViewport.top = screenHeight - (height + viewwindowy - ((height - viewheight) / 2));
mSceneViewport.width = viewwidth;
mSceneViewport.height = height;
if (sysCallbacks && sysCallbacks->GetSceneRect) mSceneViewport = sysCallbacks->GetSceneRect();
else mSceneViewport = mScreenViewport;
// Scale viewports to fit letterbox
bool notScaled = ((mScreenViewport.width == ViewportScaledWidth(mScreenViewport.width, mScreenViewport.height)) &&

View file

@ -39,13 +39,8 @@
#include "c_cvars.h"
#include "x86.h"
#include "i_video.h"
#include "r_state.h"
#include "am_map.h"
#include "doomstat.h"
#include "c_console.h"
#include "hu_stuff.h"
#include "m_argv.h"
@ -54,23 +49,19 @@
#include "sc_man.h"
#include "filesystem.h"
#include "c_dispatch.h"
#include "cmdlib.h"
#include "sbar.h"
#include "hardware.h"
#include "m_png.h"
#include "r_utility.h"
#include "swrenderer/r_renderer.h"
#include "menu/menu.h"
#include "vm.h"
#include "r_videoscale.h"
#include "i_time.h"
#include "version.h"
#include "g_levellocals.h"
#include "am_map.h"
#include "texturemanager.h"
#include "v_palette.h"
#include "i_interface.h"
#include "v_draw.h"
#include "templates.h"
EXTERN_CVAR(Int, menu_resolution_custom_width)
EXTERN_CVAR(Int, menu_resolution_custom_height)
@ -83,37 +74,16 @@ CVAR(Bool, win_maximized, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITC
CUSTOM_CVAR(Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
if (vid_maxfps < TICRATE && vid_maxfps != 0)
if (self < GameTicRate && self != 0)
{
vid_maxfps = TICRATE;
self = GameTicRate;
}
else if (vid_maxfps > 1000)
{
vid_maxfps = 1000;
self = 1000;
}
}
CUSTOM_CVAR(Int, vid_rendermode, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
if (self < 0 || self > 4)
{
self = 4;
}
else if (self == 2 || self == 3)
{
self = self - 2; // softpoly to software
}
if (usergame)
{
// [SP] Update pitch limits to the netgame/gamesim.
players[consoleplayer].SendPitchLimits();
}
screen->SetTextureFilterMode();
// No further checks needed. All this changes now is which scene drawer the render backend calls.
}
CUSTOM_CVAR(Int, vid_preferbackend, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
// [SP] This may seem pointless - but I don't want to implement live switching just
@ -146,10 +116,8 @@ CUSTOM_CVAR(Int, uiscale, 0, CVAR_ARCHIVE | CVAR_NOINITCALL)
self = 0;
return;
}
if (StatusBar != NULL)
{
StatusBar->CallScreenSizeChanged();
}
if (sysCallbacks && sysCallbacks->OnScreenSizeChanged)
sysCallbacks->OnScreenSizeChanged();
setsizeneeded = true;
}
@ -159,8 +127,6 @@ EXTERN_CVAR(Bool, r_blendmethod)
int active_con_scale();
FRenderer *SWRenderer;
#define DBGBREAK assert(0)
class DDummyFrameBuffer : public DFrameBuffer
@ -201,7 +167,8 @@ CUSTOM_CVAR (Bool, vid_vsync, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
}
// [RH] Set true when vid_setmode command has been executed
bool setmodeneeded = false;
bool setmodeneeded = false;
bool setsizeneeded = false;
//==========================================================================
//
@ -317,23 +284,15 @@ void V_UpdateModeSize (int width, int height)
DisplayWidth = width;
DisplayHeight = height;
R_OldBlend = ~0;
}
void V_OutputResized (int width, int height)
{
V_UpdateModeSize(width, height);
setsizeneeded = true;
if (StatusBar != NULL)
{
StatusBar->CallScreenSizeChanged();
}
C_NewModeAdjust();
// Reload crosshair if transitioned to a different size
ST_LoadCrosshair(true);
if (primaryLevel && primaryLevel->automap)
primaryLevel->automap->NewResolution();
if (sysCallbacks && sysCallbacks->OnScreenSizeChanged)
sysCallbacks->OnScreenSizeChanged();
}
bool IVideo::SetResolution ()
@ -430,10 +389,8 @@ void V_Init2()
CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
{
setsizeneeded = true;
if (StatusBar != NULL)
{
StatusBar->CallScreenSizeChanged();
}
if (sysCallbacks && sysCallbacks->OnScreenSizeChanged)
sysCallbacks->OnScreenSizeChanged();
}
DEFINE_ACTION_FUNCTION(_Screen, GetAspectRatio)
@ -460,7 +417,7 @@ void IVideo::DumpAdapters ()
Printf("Multi-monitor support unavailable.\n");
}
CUSTOM_CVAR_NAMED(Bool, vid_fullscreen, fullscreen, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
CUSTOM_CVAR(Bool, vid_fullscreen, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
setmodeneeded = true;
}
@ -496,7 +453,6 @@ DEFINE_GLOBAL(CleanXfac_1)
DEFINE_GLOBAL(CleanYfac_1)
DEFINE_GLOBAL(CleanWidth_1)
DEFINE_GLOBAL(CleanHeight_1)
DEFINE_GLOBAL(generic_ui)
IHardwareTexture* CreateHardwareTexture()
{
@ -505,51 +461,25 @@ IHardwareTexture* CreateHardwareTexture()
//==========================================================================
//
// V_DrawFrame
// CVAR transsouls
//
// Draw a frame around the specified area using the view border
// frame graphics. The border is drawn outside the area, not in it.
// How translucent things drawn with STYLE_SoulTrans are. Normally, only
// Lost Souls have this render style.
// Values less than 0.25 will automatically be set to
// 0.25 to ensure some degree of visibility. Likewise, values above 1.0 will
// be set to 1.0, because anything higher doesn't make sense.
//
//==========================================================================
void DrawFrame(F2DDrawer* drawer, int left, int top, int width, int height)
CUSTOM_CVAR(Float, transsouls, 0.75f, CVAR_ARCHIVE)
{
FGameTexture* p;
const gameborder_t* border = &gameinfo.Border;
// Sanity check for incomplete gameinfo
if (border == NULL)
return;
int offset = border->offset;
int right = left + width;
int bottom = top + height;
// Draw top and bottom sides.
p = TexMan.GetGameTextureByName(border->t);
drawer->AddFlatFill(left, top - (int)p->GetDisplayHeight(), right, top, p, true);
p = TexMan.GetGameTextureByName(border->b);
drawer->AddFlatFill(left, bottom, right, bottom + (int)p->GetDisplayHeight(), p, true);
// Draw left and right sides.
p = TexMan.GetGameTextureByName(border->l);
drawer->AddFlatFill(left - (int)p->GetDisplayWidth(), top, left, bottom, p, true);
p = TexMan.GetGameTextureByName(border->r);
drawer->AddFlatFill(right, top, right + (int)p->GetDisplayWidth(), bottom, p, true);
// Draw beveled corners.
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tl), left - offset, top - offset, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tr), left + width, top - offset, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->bl), left - offset, top + height, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->br), left + width, top + height, TAG_DONE);
if (self < 0.25f)
{
self = 0.25f;
}
else if (self > 1.f)
{
self = 1.f;
}
}
DEFINE_ACTION_FUNCTION(_Screen, DrawFrame)
{
PARAM_PROLOGUE;
PARAM_INT(x);
PARAM_INT(y);
PARAM_INT(w);
PARAM_INT(h);
if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
DrawFrame(twod, x, y, w, h);
return 0;
}

View file

@ -35,8 +35,8 @@
#define __V_VIDEO_H__
#include <functional>
#include "basics.h"
#include "vectors.h"
#include "m_png.h"
#include "renderstyle.h"
#include "c_cvars.h"
@ -44,10 +44,7 @@
#include "intrect.h"
#include "hw_shadowmap.h"
static const int VID_MIN_WIDTH = 320;
static const int VID_MIN_HEIGHT = 200;
class player_t;
struct sector_t;
struct FPortalSceneState;
class FSkyVertexBuffer;
@ -128,9 +125,6 @@ class FTexture;
class DFrameBuffer
{
public:
F2DDrawer m2DDrawer;
private:
int Width = 0;
int Height = 0;
@ -144,7 +138,6 @@ public:
unsigned int uniformblockalignment = 256; // Hardware dependent uniform buffer alignment.
unsigned int maxuniformblock = 65536;
const char *vendorstring; // We have to account for some issues with particular vendors.
FPortalSceneState *mPortalState; // global portal state.
FSkyVertexBuffer *mSkyData = nullptr; // the sky vertex buffer
FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data
HWViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data.
@ -224,14 +217,6 @@ public:
virtual IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) { return nullptr; }
bool BuffersArePersistent() { return !!(hwcaps & RFL_BUFFER_STORAGE); }
// Begin/End 2D drawing operations.
void Begin2D()
{
m2DDrawer.Begin();
m2DDrawer.SetSize(Width, Height);
}
void End2D() { m2DDrawer.End(); }
// This is overridable in case Vulkan does it differently.
virtual bool RenderTextureIsFlipped() const
{
@ -255,7 +240,6 @@ public:
virtual void RenderTextureView(FCanvasTexture* tex, std::function<void(IntRect&)> renderFunc) {}
virtual void SetActiveRenderTarget() {}
// Screen wiping
virtual FTexture *WipeStartScreen();
virtual FTexture *WipeEndScreen();
@ -265,7 +249,6 @@ public:
void ScaleCoordsFromWindow(int16_t &x, int16_t &y);
virtual void Draw2D() {}
void Clear2D() { m2DDrawer.Clear(); }
virtual void SetViewportRects(IntRect *bounds);
int ScreenToWindowX(int x);
@ -310,14 +293,8 @@ void V_Init2 ();
void V_Shutdown ();
class FScanner;
struct FScriptPosition;
inline bool IsRatioWidescreen(int ratio) { return (ratio & 3) != 0; }
#include "v_draw.h"
extern bool setsizeneeded, setmodeneeded;
#endif // __V_VIDEO_H__

View file

@ -31,6 +31,7 @@
#include "g_game.h"
#include "v_text.h"
#include "version.h"
#include "v_draw.h"
#include "hwrenderer/utility/hw_clock.h"
#include "hw_vrmodes.h"
@ -192,7 +193,7 @@ void VulkanFrameBuffer::Update()
GetPostprocess()->SetActiveRenderTarget();
Draw2D();
Clear2D();
twod->Clear();
mRenderState->EndRenderPass();
mRenderState->EndFrame();
@ -480,7 +481,7 @@ FTexture *VulkanFrameBuffer::WipeEndScreen()
{
GetPostprocess()->SetActiveRenderTarget();
Draw2D();
Clear2D();
twod->Clear();
auto tex = new FWrapperTexture(mScreenViewport.width, mScreenViewport.height, 1);
auto systex = static_cast<VkHardwareTexture*>(tex->GetSystemTexture());
@ -643,7 +644,7 @@ void VulkanFrameBuffer::UpdateGpuStats()
void VulkanFrameBuffer::Draw2D()
{
::Draw2D(&m2DDrawer, *mRenderState);
::Draw2D(twod, *mRenderState);
}
VulkanCommandBuffer *VulkanFrameBuffer::GetTransferCommands()

View file

@ -58,6 +58,7 @@
#include "c_dispatch.h"
#include "s_music.h"
#include "texturemanager.h"
#include "v_draw.h"
DVector2 AM_GetPosition();
int Net_GetLatency(int *ld, int *ad);
@ -3498,3 +3499,4 @@ DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, name);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, baseorder);
DEFINE_FIELD_X(MusPlayingInfo, MusPlayingInfo, loop);
DEFINE_GLOBAL(generic_ui)

View file

@ -65,6 +65,7 @@
#include "vm.h"
#include "g_game.h"
#include "s_music.h"
#include "v_draw.h"
// PUBLIC DATA DEFINITIONS -------------------------------------------------

View file

@ -112,6 +112,8 @@ const char *GetVersionString();
const int SAVEPICWIDTH = 216;
const int SAVEPICHEIGHT = 162;
const int VID_MIN_WIDTH = 320;
const int VID_MIN_HEIGHT = 200;
#endif //__VERSION_H__

View file

@ -55,6 +55,7 @@
#include "g_levellocals.h"
#include "vm.h"
#include "texturemanager.h"
#include "v_draw.h"
CVAR(Bool, wi_percents, true, CVAR_ARCHIVE)
CVAR(Bool, wi_showtotaltime, true, CVAR_ARCHIVE)
@ -701,7 +702,7 @@ void WI_Ticker()
{
if (WI_Screen)
{
ScaleOverrider s(&screen->m2DDrawer);
ScaleOverrider s(twod);
IFVIRTUALPTRNAME(WI_Screen, "StatusScreen", Ticker)
{
VMValue self = WI_Screen;
@ -721,7 +722,7 @@ void WI_Drawer()
{
if (WI_Screen)
{
ScaleOverrider s(&screen->m2DDrawer);
ScaleOverrider s(twod);
IFVIRTUALPTRNAME(WI_Screen, "StatusScreen", Drawer)
{
FillBorder(twod, nullptr);
@ -765,7 +766,7 @@ void WI_Start(wbstartstruct_t *wbstartstruct)
}
WI_Screen = cls->CreateNew();
ScaleOverrider s(&screen->m2DDrawer);
ScaleOverrider s(twod);
IFVIRTUALPTRNAME(WI_Screen, "StatusScreen", Start)
{
VMValue val[2] = { WI_Screen, wbstartstruct };

View file

@ -2216,7 +2216,7 @@ OptionMenu VideoModeMenu protected
Option "$VIDMNU_PREFERBACKEND", "vid_preferbackend", "PreferBackend"
StaticText " "
Option "$VIDMNU_RENDERMODE", "vid_rendermode", "RenderMode"
Option "$VIDMNU_FULLSCREEN", "fullscreen", "YesNo"
Option "$VIDMNU_FULLSCREEN", "vid_fullscreen", "YesNo"
IfOption(Mac)
{