- video base code unified.

# Conflicts:
#	source/core/rendering/v_video.cpp
This commit is contained in:
Christoph Oelckers 2020-04-28 22:55:37 +02:00
parent edb2cb31ee
commit 1e2a3da5fd
14 changed files with 158 additions and 106 deletions

View file

@ -135,7 +135,7 @@ void scrInit(void)
void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits) void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits)
{ {
V_Init2(); videoInit();
videoClearViewableArea(0); videoClearViewableArea(0);
videoNextPage(); videoNextPage();
scrSetPalette(curPalette); scrSetPalette(curPalette);

View file

@ -852,6 +852,7 @@ static FORCE_INLINE int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t da
} }
void renderDrawMasks(void); void renderDrawMasks(void);
void videoInit();
void videoClearViewableArea(int32_t dacol); void videoClearViewableArea(int32_t dacol);
void videoClearScreen(int32_t dacol); void videoClearScreen(int32_t dacol);
void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang); void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang);
@ -1297,7 +1298,6 @@ extern void(*PolymostProcessVoxels_Callback)(void);
class F2DDrawer; class F2DDrawer;
extern F2DDrawer twodgen;
extern F2DDrawer twodpsp; extern F2DDrawer twodpsp;
extern F2DDrawer* twod; extern F2DDrawer* twod;

View file

@ -4074,6 +4074,8 @@ void videoNextPage(void)
beforedrawrooms = 1; beforedrawrooms = 1;
numframes++; numframes++;
twod->SetSize(screen->GetWidth(), screen->GetHeight());
twodpsp.SetSize(screen->GetWidth(), screen->GetHeight());
} }
// //
@ -5342,6 +5344,16 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
void videoInit()
{
V_Init2();
videoSetGameMode(vid_fullscreen, SCREENWIDTH, SCREENHEIGHT, 32, 1);
Polymost_Startup();
GLInterface.Init(SCREENHEIGHT);
GLInterface.InitGLState(4, 4/*glmultisample*/);
screen->SetTextureFilterMode();
}
// //
// clearview // clearview

View file

@ -192,6 +192,19 @@ static bool System_DisableTextureFilter()
return hw_useindexedcolortextures; return hw_useindexedcolortextures;
} }
static IntRect System_GetSceneRect()
{
// Special handling so the view with a visible status bar displays properly
int height = windowxy2.y - windowxy1.y + 1, width = windowxy2.x - windowxy1.x + 1;
IntRect mSceneViewport;
mSceneViewport.left = windowxy1.x;
mSceneViewport.top = windowxy1.y;
mSceneViewport.width = width;
mSceneViewport.height = height;
return mSceneViewport;
}
//========================================================================== //==========================================================================
// //
// DoomSpecificInfo // DoomSpecificInfo
@ -481,6 +494,8 @@ int GameMain()
nullptr, nullptr,
nullptr, nullptr,
System_DisableTextureFilter, System_DisableTextureFilter,
nullptr,
System_GetSceneRect,
}; };
sysCallbacks = &syscb; sysCallbacks = &syscb;

View file

@ -42,6 +42,7 @@
#include "m_png.h" #include "m_png.h"
#include "version.h" #include "version.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "model.h"
//#include "hwrenderer/utility/hw_clock.h" //#include "hwrenderer/utility/hw_clock.h"
#include "gl_load/gl_interface.h" #include "gl_load/gl_interface.h"
@ -113,7 +114,7 @@ void FGLRenderer::Initialize(int width, int height)
FGLRenderer::~FGLRenderer() FGLRenderer::~FGLRenderer()
{ {
//FlushModels(); FlushModels();
TexMan.FlushAll(); TexMan.FlushAll();
if (mShaderManager != nullptr) delete mShaderManager; if (mShaderManager != nullptr) delete mShaderManager;
if (mSamplerManager != nullptr) delete mSamplerManager; if (mSamplerManager != nullptr) delete mSamplerManager;

View file

@ -431,40 +431,3 @@ void OpenGLFrameBuffer::PostProcessScene(bool swscene, int fixedcm, const std::f
} }
void videoShowFrame(int32_t w)
{
static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
if (gl_ssao)
{
glDrawBuffers(1, buffers);
OpenGLRenderer::GLRenderer->AmbientOccludeScene(GLInterface.GetProjectionM5());
glViewport(screen->mSceneViewport.left, screen->mSceneViewport.top, screen->mSceneViewport.width, screen->mSceneViewport.height);
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(true);
glDrawBuffers(3, buffers);
// To do: the translucent part of the scene should be drawn here
glDrawBuffers(1, buffers);
}
OpenGLRenderer::GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture
screen->PostProcessScene(false, 0, []() {
GLInterface.Draw2D(&twodpsp); // draws the weapon sprites
});
screen->Update();
// After finishing the frame, reset everything for the next frame. This needs to be done better.
screen->BeginFrame();
if (gl_ssao)
{
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(true);
glDrawBuffers(3, buffers);
}
else
{
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false);
}
twodpsp.Clear();
twod->Clear();
GLInterface.ResetFrame();
}

View file

@ -45,16 +45,11 @@
#include "v_draw.h" #include "v_draw.h"
#include "i_time.h" #include "i_time.h"
#include "v_2ddrawer.h" #include "v_2ddrawer.h"
#include "build.h"
#include "vm.h" #include "vm.h"
#include "../glbackend/glbackend.h" #include "i_interface.h"
#include "hw_material.h" #include "flatvertices.h"
/*
#include "hwrenderer/scene/hw_portal.h"
#include "hwrenderer/utility/hw_clock.h"
*/
#include "hwrenderer/data/flatvertices.h"
#include "version.h" #include "version.h"
#include "hw_material.h"
#include <chrono> #include <chrono>
#include <thread> #include <thread>
@ -63,7 +58,7 @@
CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE); CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE);
EXTERN_CVAR(Int, vid_maxfps) EXTERN_CVAR(Int, vid_maxfps)
EXTERN_CVAR(Bool, cl_capfps) CVAR(Bool, cl_capfps, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
EXTERN_CVAR(Int, screenblocks) EXTERN_CVAR(Int, screenblocks)
//========================================================================== //==========================================================================
@ -77,6 +72,7 @@ EXTERN_CVAR(Int, screenblocks)
DFrameBuffer::DFrameBuffer (int width, int height) DFrameBuffer::DFrameBuffer (int width, int height)
{ {
twod = &m2DDrawer;
SetSize(width, height); SetSize(width, height);
} }
@ -88,8 +84,6 @@ void DFrameBuffer::SetSize(int width, int height)
{ {
Width = ViewportScaledWidth(width, height); Width = ViewportScaledWidth(width, height);
Height = ViewportScaledHeight(width, height); Height = ViewportScaledHeight(width, height);
twodgen.SetSize(Width, Height);
twodpsp.SetSize(Width, Height);
} }
//========================================================================== //==========================================================================
@ -100,8 +94,6 @@ void DFrameBuffer::SetSize(int width, int height)
void DFrameBuffer::Update() void DFrameBuffer::Update()
{ {
//CheckBench();
int initialWidth = GetClientWidth(); int initialWidth = GetClientWidth();
int initialHeight = GetClientHeight(); int initialHeight = GetClientHeight();
int clientWidth = ViewportScaledWidth(initialWidth, initialHeight); int clientWidth = ViewportScaledWidth(initialWidth, initialHeight);
@ -182,9 +174,6 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds)
return; return;
} }
// Special handling so the view with a visible status bar displays properly
int height = windowxy2.y - windowxy1.y + 1, width = windowxy2.x - windowxy1.x + 1;
// Back buffer letterbox for the final output // Back buffer letterbox for the final output
int clientWidth = GetClientWidth(); int clientWidth = GetClientWidth();
int clientHeight = GetClientHeight(); int clientHeight = GetClientHeight();
@ -212,10 +201,8 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds)
mScreenViewport.height = screenHeight; mScreenViewport.height = screenHeight;
// Viewport for the 3D scene // Viewport for the 3D scene
mSceneViewport.left = windowxy1.x; if (sysCallbacks && sysCallbacks->GetSceneRect) mSceneViewport = sysCallbacks->GetSceneRect();
mSceneViewport.top = windowxy1.y; else mSceneViewport = mScreenViewport;
mSceneViewport.width = width;
mSceneViewport.height = height;
// Scale viewports to fit letterbox // Scale viewports to fit letterbox
bool notScaled = ((mScreenViewport.width == ViewportScaledWidth(mScreenViewport.width, mScreenViewport.height)) && bool notScaled = ((mScreenViewport.width == ViewportScaledWidth(mScreenViewport.width, mScreenViewport.height)) &&
@ -261,7 +248,6 @@ void DFrameBuffer::ScaleCoordsFromWindow(int16_t &x, int16_t &y)
void DFrameBuffer::FPSLimit() void DFrameBuffer::FPSLimit()
{ {
#if 0 // This doesn't work with Build games.
using namespace std::chrono; using namespace std::chrono;
using namespace std::this_thread; using namespace std::this_thread;
@ -292,7 +278,6 @@ void DFrameBuffer::FPSLimit()
sleep_for(microseconds(timeToWait - 2'000)); sleep_for(microseconds(timeToWait - 2'000));
} }
} }
#endif
} }
FMaterial* DFrameBuffer::CreateMaterial(FGameTexture* tex, int scaleflags) FMaterial* DFrameBuffer::CreateMaterial(FGameTexture* tex, int scaleflags)

View file

@ -48,21 +48,24 @@
#include "v_text.h" #include "v_text.h"
#include "sc_man.h" #include "sc_man.h"
#include "filesystem.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "hardware.h" #include "hardware.h"
#include "m_png.h" #include "m_png.h"
#include "menu/menu.h" #include "menu/menu.h"
#include "vm.h"
#include "r_videoscale.h" #include "r_videoscale.h"
#include "i_time.h" #include "i_time.h"
#include "version.h" #include "version.h"
#include "filesystem.h" #include "texturemanager.h"
#include "build.h" #include "i_interface.h"
#include "glbackend/glbackend.h" #include "v_draw.h"
#include "templates.h"
#include "palette.h"
EXTERN_CVAR(Int, menu_resolution_custom_width) EXTERN_CVAR(Int, menu_resolution_custom_width)
EXTERN_CVAR(Int, menu_resolution_custom_height) EXTERN_CVAR(Int, menu_resolution_custom_height)
CVAR(Int, vid_aspect, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Int, win_x, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, win_x, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, win_y, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, win_y, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -70,38 +73,17 @@ CVAR(Int, win_w, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, win_h, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) CVAR(Int, win_h, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, win_maximized, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) CVAR(Bool, win_maximized, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
#if 0
CUSTOM_CVAR(Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) 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) else if (vid_maxfps > 1000)
{ {
vid_maxfps = 1000; self = 1000;
} }
} }
#endif
CUSTOM_CVAR(Int, vid_rendermode, 4, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
if (self < 0 || self > 4)
{
self = 4;
}
#if 0
if (usergame)
{
// [SP] Update pitch limits to the netgame/gamesim.
players[consoleplayer].SendPitchLimits();
}
#endif
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) CUSTOM_CVAR(Int, vid_preferbackend, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{ {
@ -128,6 +110,19 @@ CUSTOM_CVAR(Int, vid_preferbackend, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_N
CVAR(Int, vid_renderer, 1, 0) // for some stupid mods which threw caution out of the window... CVAR(Int, vid_renderer, 1, 0) // for some stupid mods which threw caution out of the window...
CUSTOM_CVAR(Int, uiscale, 0, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
if (self < 0)
{
self = 0;
return;
}
if (sysCallbacks && sysCallbacks->OnScreenSizeChanged)
sysCallbacks->OnScreenSizeChanged();
setsizeneeded = true;
}
EXTERN_CVAR(Bool, r_blendmethod) EXTERN_CVAR(Bool, r_blendmethod)
@ -297,6 +292,8 @@ void V_OutputResized (int width, int height)
V_UpdateModeSize(width, height); V_UpdateModeSize(width, height);
setsizeneeded = true; setsizeneeded = true;
C_NewModeAdjust(); C_NewModeAdjust();
if (sysCallbacks && sysCallbacks->OnScreenSizeChanged)
sysCallbacks->OnScreenSizeChanged();
} }
bool IVideo::SetResolution () bool IVideo::SetResolution ()
@ -362,7 +359,6 @@ void V_InitScreen()
void V_Init2() void V_Init2()
{ {
lookups.postLoadLookups(); lookups.postLoadLookups();
twod = &twodgen;
float gamma = static_cast<DDummyFrameBuffer *>(screen)->Gamma; float gamma = static_cast<DDummyFrameBuffer *>(screen)->Gamma;
@ -390,14 +386,14 @@ void V_Init2()
screen->SetVSync(vid_vsync); screen->SetVSync(vid_vsync);
FBaseCVar::ResetColors (); FBaseCVar::ResetColors ();
C_NewModeAdjust(); C_NewModeAdjust();
videoSetGameMode(vid_fullscreen, SCREENWIDTH, SCREENHEIGHT, 32, 1); setsizeneeded = true;
}
Polymost_Startup(); CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
GLInterface.Init(SCREENHEIGHT); {
GLInterface.InitGLState(4, 4/*glmultisample*/); setsizeneeded = true;
screen->SetTextureFilterMode(); if (sysCallbacks && sysCallbacks->OnScreenSizeChanged)
sysCallbacks->OnScreenSizeChanged();
//setsizeneeded = true;
} }
@ -438,6 +434,47 @@ CCMD(vid_listadapters)
} }
bool vid_hdr_active = false; bool vid_hdr_active = false;
F2DDrawer twodpsp, twodgen;
CVAR(Float, transsouls, 1, 0) DEFINE_GLOBAL(SmallFont)
CVAR(Int, uiscale, 0, CVAR_ARCHIVE) DEFINE_GLOBAL(SmallFont2)
DEFINE_GLOBAL(BigFont)
DEFINE_GLOBAL(ConFont)
DEFINE_GLOBAL(NewConsoleFont)
DEFINE_GLOBAL(NewSmallFont)
DEFINE_GLOBAL(AlternativeSmallFont)
DEFINE_GLOBAL(OriginalSmallFont)
DEFINE_GLOBAL(OriginalBigFont)
DEFINE_GLOBAL(IntermissionFont)
DEFINE_GLOBAL(CleanXfac)
DEFINE_GLOBAL(CleanYfac)
DEFINE_GLOBAL(CleanWidth)
DEFINE_GLOBAL(CleanHeight)
DEFINE_GLOBAL(CleanXfac_1)
DEFINE_GLOBAL(CleanYfac_1)
DEFINE_GLOBAL(CleanWidth_1)
DEFINE_GLOBAL(CleanHeight_1)
//==========================================================================
//
// 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;
}
}

View file

@ -127,7 +127,7 @@ class DFrameBuffer
{ {
protected: protected:
//F2DDrawer m2DDrawer; F2DDrawer m2DDrawer;
private: private:
int Width = 0; int Width = 0;
int Height = 0; int Height = 0;

View file

@ -5779,7 +5779,7 @@ int GameInterface::app_main()
if (g_networkMode != NET_DEDICATED_SERVER) if (g_networkMode != NET_DEDICATED_SERVER)
{ {
V_Init2(); videoInit();
videoSetPalette(0, myplayer.palette, 0); videoSetPalette(0, myplayer.palette, 0);
} }

View file

@ -219,7 +219,7 @@ void InstallEngine()
} }
uploadCinemaPalettes(); uploadCinemaPalettes();
LoadPaletteLookups(); LoadPaletteLookups();
V_Init2(); videoInit();
enginecompatibility_mode = ENGINECOMPATIBILITY_19950829; enginecompatibility_mode = ENGINECOMPATIBILITY_19950829;
} }

View file

@ -54,6 +54,8 @@
#include "v_draw.h" #include "v_draw.h"
#include "v_font.h" #include "v_font.h"
F2DDrawer twodpsp;
float shadediv[MAXPALOOKUPS]; float shadediv[MAXPALOOKUPS];
static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA }; static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA };
@ -633,3 +635,40 @@ void DrawRateStuff()
} }
} }
void videoShowFrame(int32_t w)
{
static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
if (gl_ssao)
{
glDrawBuffers(1, buffers);
OpenGLRenderer::GLRenderer->AmbientOccludeScene(GLInterface.GetProjectionM5());
glViewport(screen->mSceneViewport.left, screen->mSceneViewport.top, screen->mSceneViewport.width, screen->mSceneViewport.height);
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(true);
glDrawBuffers(3, buffers);
// To do: the translucent part of the scene should be drawn here
glDrawBuffers(1, buffers);
}
OpenGLRenderer::GLRenderer->mBuffers->BlitSceneToTexture(); // Copy the resulting scene to the current post process texture
screen->PostProcessScene(false, 0, []() {
GLInterface.Draw2D(&twodpsp); // draws the weapon sprites
});
screen->Update();
// After finishing the frame, reset everything for the next frame. This needs to be done better.
screen->BeginFrame();
if (gl_ssao)
{
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(true);
glDrawBuffers(3, buffers);
}
else
{
OpenGLRenderer::GLRenderer->mBuffers->BindSceneFB(false);
}
twodpsp.Clear();
twod->Clear();
GLInterface.ResetFrame();
}

View file

@ -7171,7 +7171,7 @@ int GameInterface::app_main()
g_clipMapFiles.Reset(); g_clipMapFiles.Reset();
#endif #endif
V_Init2(); videoInit();
videoSetPalette(0, g_player[myconnectindex].ps->palette, 0); videoSetPalette(0, g_player[myconnectindex].ps->palette, 0);
// check if the minifont will support lowercase letters (3136-3161) // check if the minifont will support lowercase letters (3136-3161)

View file

@ -816,7 +816,7 @@ bool InitGame()
enginePostInit(); enginePostInit();
V_Init2(); videoInit();
DemoModeMenuInit = TRUE; DemoModeMenuInit = TRUE;
// precache as much stuff as you can // precache as much stuff as you can