- moved around more stuff from the FRenderer interface.

This commit is contained in:
Christoph Oelckers 2018-04-03 22:50:47 +02:00
parent 91813ec43d
commit fcc33f0a09
11 changed files with 133 additions and 129 deletions

View file

@ -680,7 +680,7 @@ void D_Display ()
cycles.Clock();
r_UseVanillaTransparency = UseVanillaTransparency(); // [SP] Cache UseVanillaTransparency() call
r_renderercaps = Renderer->GetCaps(); // [SP] Get the current capabilities of the renderer
r_renderercaps = screen->GetCaps(); // [SP] Get the current capabilities of the renderer
if (players[consoleplayer].camera == NULL)
{
@ -808,8 +808,9 @@ void D_Display ()
Renderer->RenderView(&players[consoleplayer]);
screen->Begin2D(viewactive);
Renderer->DrawRemainingPlayerSprites();
screen->DrawBlendingRect();
// todo: These need to go into RenderView.
//Renderer->DrawRemainingPlayerSprites();
//screen->DrawBlendingRect();
if (automapactive)
{
AM_Drawer (hud_althud? viewheight : StatusBar->GetTopOfStatusbar());

View file

@ -1003,10 +1003,6 @@ struct FGLInterface : public FRenderer
void RenderView(player_t *player) override;
void WriteSavePic (player_t *player, FileWriter *file, int width, int height) override;
void RenderTextureView (FCanvasTexture *self, AActor *viewpoint, double fov) override;
void PreprocessLevel() override;
void SetClearColor(int color) override;
uint32_t GetCaps() override;
};
//==========================================================================
@ -1021,20 +1017,6 @@ void FGLInterface::Precache(uint8_t *texhitlist, TMap<PClassActor*, bool> &actor
gl_PrecacheTexture(texhitlist, actorhitlist);
}
//===========================================================================
//
//
//
//===========================================================================
void FGLInterface::SetClearColor(int color)
{
PalEntry pe = GPalette.BaseColors[color];
GLRenderer->mSceneClearColor[0] = pe.r / 255.f;
GLRenderer->mSceneClearColor[1] = pe.g / 255.f;
GLRenderer->mSceneClearColor[2] = pe.b / 255.f;
}
//===========================================================================
//
// Render the view to a savegame picture
@ -1110,44 +1092,6 @@ void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, do
camtexcount++;
}
//===========================================================================
//
//
//
//===========================================================================
void FGLInterface::PreprocessLevel()
{
if (GLRenderer != NULL)
{
GLRenderer->SetupLevel();
}
}
uint32_t FGLInterface::GetCaps()
{
// describe our basic feature set
ActorRenderFeatureFlags FlagSet = RFF_FLATSPRITES | RFF_MODELS | RFF_SLOPE3DFLOORS |
RFF_TILTPITCH | RFF_ROLLSPRITES | RFF_POLYGONAL;
if (r_drawvoxels)
FlagSet |= RFF_VOXELS;
if (gl_legacy_mode)
{
// legacy mode always has truecolor because palette tonemap is not available
FlagSet |= RFF_TRUECOLOR;
}
else if (!(FGLRenderBuffers::IsEnabled()))
{
// truecolor is always available when renderbuffers are unavailable because palette tonemap is not possible
FlagSet |= RFF_TRUECOLOR | RFF_MATSHADER | RFF_BRIGHTMAP;
}
else
{
if (gl_tonemap != 5) // not running palette tonemap shader
FlagSet |= RFF_TRUECOLOR;
FlagSet |= RFF_MATSHADER | RFF_POSTSHADER | RFF_BRIGHTMAP;
}
return (uint32_t)FlagSet;
}
//===========================================================================
//
//

View file

@ -40,6 +40,7 @@
#include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderbuffers.h"
#include "gl/renderer/gl_renderstate.h"
#include "gl/renderer/gl_lightdata.h"
#include "gl/textures/gl_hwtexture.h"
@ -189,6 +190,43 @@ void OpenGLFrameBuffer::Update()
GLRenderer->SetOutputViewport(nullptr);
}
//===========================================================================
//
//
//
//===========================================================================
EXTERN_CVAR(Bool, r_drawvoxels)
EXTERN_CVAR(Int, gl_tonemap)
extern int currentrenderer;
uint32_t OpenGLFrameBuffer::GetCaps()
{
if (currentrenderer == 0) return Super::GetCaps();
// describe our basic feature set
ActorRenderFeatureFlags FlagSet = RFF_FLATSPRITES | RFF_MODELS | RFF_SLOPE3DFLOORS |
RFF_TILTPITCH | RFF_ROLLSPRITES | RFF_POLYGONAL;
if (r_drawvoxels)
FlagSet |= RFF_VOXELS;
if (gl.legacyMode)
{
// legacy mode always has truecolor because palette tonemap is not available
FlagSet |= RFF_TRUECOLOR;
}
else if (!(FGLRenderBuffers::IsEnabled()))
{
// truecolor is always available when renderbuffers are unavailable because palette tonemap is not possible
FlagSet |= RFF_TRUECOLOR | RFF_MATSHADER | RFF_BRIGHTMAP;
}
else
{
if (gl_tonemap != 5) // not running palette tonemap shader
FlagSet |= RFF_TRUECOLOR;
FlagSet |= RFF_MATSHADER | RFF_POSTSHADER | RFF_BRIGHTMAP;
}
return (uint32_t)FlagSet;
}
//==========================================================================
//
@ -329,6 +367,29 @@ void OpenGLFrameBuffer::GetFlash(PalEntry &rgb, int &amount)
amount = Flash.a;
}
void OpenGLFrameBuffer::InitForLevel()
{
if (GLRenderer != NULL)
{
GLRenderer->SetupLevel();
}
}
//===========================================================================
//
//
//
//===========================================================================
void OpenGLFrameBuffer::SetClearColor(int color)
{
PalEntry pe = GPalette.BaseColors[color];
GLRenderer->mSceneClearColor[0] = pe.r / 255.f;
GLRenderer->mSceneClearColor[1] = pe.g / 255.f;
GLRenderer->mSceneClearColor[2] = pe.b / 255.f;
}
//==========================================================================
//
//

View file

@ -39,13 +39,16 @@ public:
bool SetContrast(float contrast);
void DoSetGamma();
void UpdatePalette();
void GetFlashedPalette (PalEntry pal[256]);
PalEntry *GetPalette ();
bool SetFlash(PalEntry rgb, int amount);
void GetFlash(PalEntry &rgb, int &amount);
bool Begin2D(bool copy3d);
void GameRestart();
void UpdatePalette() override;
void GetFlashedPalette (PalEntry pal[256]) override;
PalEntry *GetPalette () override;
bool SetFlash(PalEntry rgb, int amount) override;
void GetFlash(PalEntry &rgb, int &amount) override;
bool Begin2D(bool copy3d) override;
void GameRestart() override;
void InitForLevel() override;
void SetClearColor(int color) override;
uint32_t GetCaps() override;
// Retrieves a buffer containing image data for a screenshot.
// Hint: Pitch can be negative for upside-down images, in which case buffer

View file

@ -4128,9 +4128,9 @@ void P_SetupLevel (const char *lumpname, int position)
}
// This must be done BEFORE the PolyObj Spawn!!!
InitRenderInfo();
Renderer->PreprocessLevel();
SWRenderer->PreprocessLevel();
InitRenderInfo(); // create hardware independent renderer resources for the level.
screen->InitForLevel(); // create hardware dependent level resources (e.g. the vertex buffer)
SWRenderer->SetColormap(); //The SW renderer needs to do some special setup for the level's default colormap.
InitPortalGroups();
times[16].Clock();

View file

@ -26,15 +26,18 @@ struct FRenderer
// renders view to a savegame picture
virtual void WriteSavePic (player_t *player, FileWriter *file, int width, int height) = 0;
// render to a camera texture
virtual void RenderTextureView(FCanvasTexture *tex, AActor *viewpoint, double fov) = 0;
// draws player sprites with hardware acceleration (only useful for software rendering)
virtual void DrawRemainingPlayerSprites() {}
virtual void OnModeSet () {}
virtual void SetClearColor(int color) = 0;
virtual void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, double fov) = 0;
virtual void PreprocessLevel() {}
// set up the colormap for a newly loaded level.
virtual void SetColormap() {}
virtual uint32_t GetCaps() { return 0; }
virtual void OnModeSet () {}
virtual void SetClearColor(int color) {};
};

View file

@ -994,7 +994,8 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
{
color = pr_hom();
}
Renderer->SetClearColor(color);
screen->SetClearColor(color);
SWRenderer->SetClearColor(color);
}
}

View file

@ -90,10 +90,11 @@ FRenderer *CreateSWRenderer()
return new FSoftwareRenderer;
}
EXTERN_CVAR(Bool, swtruecolor)
void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache)
{
bool isbgra = screen->IsBgra();
bool isbgra = swtruecolor;
if (tex != NULL)
{
@ -329,7 +330,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
r_viewwindow = cameraViewwindow;
}
void FSoftwareRenderer::PreprocessLevel()
void FSoftwareRenderer::SetColormap()
{
// This just sets the default colormap for the spftware renderer.
NormalLight.Maps = realcolormaps.Maps;
@ -341,23 +342,3 @@ void FSoftwareRenderer::PreprocessLevel()
}
}
uint32_t FSoftwareRenderer::GetCaps()
{
ActorRenderFeatureFlags FlagSet = 0;
if (r_polyrenderer)
FlagSet |= RFF_POLYGONAL | RFF_TILTPITCH | RFF_SLOPE3DFLOORS;
else
{
FlagSet |= RFF_UNCLIPPEDTEX;
if (r_drawvoxels)
FlagSet |= RFF_VOXELS;
}
if (screen && screen->IsBgra())
FlagSet |= RFF_TRUECOLOR;
else
FlagSet |= RFF_COLORMAP;
return (uint32_t)FlagSet;
}

View file

@ -24,9 +24,7 @@ struct FSoftwareRenderer : public FRenderer
void SetClearColor(int color) override;
void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, double fov) override;
void PreprocessLevel() override;
uint32_t GetCaps() override;
void SetColormap() override;
private:
void PrecacheTexture(FTexture *tex, int cache);

View file

@ -868,20 +868,6 @@ bool DFrameBuffer::Begin2D (bool copy3d)
return false;
}
//==========================================================================
//
// DFrameBuffer :: DrawBlendingRect
//
// In hardware 2D modes, the blending rect needs to be drawn separately
// from transferring the 3D scene to video memory, because the weapon
// sprite is drawn on top of that.
//
//==========================================================================
void DFrameBuffer::DrawBlendingRect()
{
}
//==========================================================================
//
// DFrameBuffer :: WipeStartScreen
@ -945,6 +931,37 @@ void DFrameBuffer::GameRestart()
{
}
//==========================================================================
//
// DFrameBuffer :: GetCaps
//
//==========================================================================
EXTERN_CVAR(Bool, r_polyrenderer)
EXTERN_CVAR(Bool, r_drawvoxels)
uint32_t DFrameBuffer::GetCaps()
{
ActorRenderFeatureFlags FlagSet = 0;
if (r_polyrenderer)
FlagSet |= RFF_POLYGONAL | RFF_TILTPITCH | RFF_SLOPE3DFLOORS;
else
{
FlagSet |= RFF_UNCLIPPEDTEX;
if (r_drawvoxels)
FlagSet |= RFF_VOXELS;
}
if (swtruecolor)
FlagSet |= RFF_TRUECOLOR;
else
FlagSet |= RFF_COLORMAP;
return (uint32_t)FlagSet;
}
CCMD(clean)
{
Printf ("CleanXfac: %d\nCleanYfac: %d\n", CleanXfac, CleanYfac);
@ -1018,7 +1035,9 @@ void V_UpdateModeSize (int width, int height)
DisplayHeight = height;
R_OldBlend = ~0;
Renderer->OnModeSet();
// the software renderer also needs to be notified
SWRenderer->OnModeSet();
}
void V_OutputResized (int width, int height)

View file

@ -290,7 +290,6 @@ public:
inline int GetWidth() const { return Width; }
inline int GetHeight() const { return Height; }
inline bool IsBgra() const { return Bgra; }
virtual DCanvas *GetCanvas() { return nullptr; }
@ -343,10 +342,7 @@ public:
virtual bool LockCanvas() { return true; }
virtual void UnlockCanvas() {}
// Begin 2D drawing operations. This is like Update, but it doesn't end
// the scene, and it doesn't present the image yet. If you are going to
// be covering the entire screen with 2D elements, then pass false to
// avoid copying the software buffer to the screen.
// Begin 2D drawing operations.
// Returns true if hardware-accelerated 2D has been entered, false if not.
virtual bool Begin2D(bool copy3d);
void End2D() { isIn2D = false; }
@ -356,14 +352,11 @@ public:
// DrawTexture calls after Begin2D use native textures.
// Draws the blending rectangle over the viewwindow if in hardware-
// accelerated 2D mode.
virtual void DrawBlendingRect();
// Precaches or unloads a texture
// Report a game restart
virtual void GameRestart();
virtual void InitForLevel() {}
virtual void SetClearColor(int color) {}
virtual uint32_t GetCaps();
// Screen wiping
virtual bool WipeStartScreen(int type);