Added IsBgra() to DCanvas

Changed SWRender output format to be decided by IsBgra()
This commit is contained in:
Magnus Norddahl 2016-05-31 09:36:18 +02:00
parent 045bad1b52
commit 05220a7133
24 changed files with 139 additions and 96 deletions

View File

@ -33,8 +33,6 @@
// SCREEN WIPE PACKAGE
//
EXTERN_CVAR(Bool, r_swtruecolor)
static int CurrentWipeType;
static short *wipe_scr_start;
@ -385,7 +383,7 @@ static bool (*wipes[])(int) =
// Returns true if the wipe should be performed.
bool wipe_StartScreen (int type)
{
if (r_swtruecolor)
if (screen->IsBgra())
return false;
CurrentWipeType = clamp(type, 0, wipe_NUMWIPES - 1);
@ -401,7 +399,7 @@ bool wipe_StartScreen (int type)
void wipe_EndScreen (void)
{
if (r_swtruecolor)
if (screen->IsBgra())
return;
if (CurrentWipeType)
@ -420,7 +418,7 @@ bool wipe_ScreenWipe (int ticks)
{
bool rc;
if (r_swtruecolor)
if (screen->IsBgra())
return true;
if (CurrentWipeType == wipe_None)
@ -436,7 +434,7 @@ bool wipe_ScreenWipe (int ticks)
// Final things for the wipe
void wipe_Cleanup()
{
if (r_swtruecolor)
if (screen->IsBgra())
return;
if (wipe_scr_start != NULL)

View File

@ -96,6 +96,8 @@ EXTERN_CVAR(Bool, ticker )
EXTERN_CVAR(Bool, vid_vsync)
EXTERN_CVAR(Bool, vid_hidpi)
CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE)
CUSTOM_CVAR(Bool, fullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
extern int NewWidth, NewHeight, NewBits, DisplayBits;
@ -199,7 +201,7 @@ public:
virtual EDisplayType GetDisplayType() { return DISPLAY_Both; }
virtual void SetWindowedScale(float scale);
virtual DFrameBuffer* CreateFrameBuffer(int width, int height, bool fs, DFrameBuffer* old);
virtual DFrameBuffer* CreateFrameBuffer(int width, int height, bool bgra, bool fs, DFrameBuffer* old);
virtual void StartModeIterator(int bits, bool fullscreen);
virtual bool NextMode(int* width, int* height, bool* letterbox);
@ -518,7 +520,7 @@ bool CocoaVideo::NextMode(int* const width, int* const height, bool* const lette
return false;
}
DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, const bool fullscreen, DFrameBuffer* const old)
DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, const bool bgra, const bool fullscreen, DFrameBuffer* const old)
{
PalEntry flashColor = 0;
int flashAmount = 0;
@ -762,7 +764,7 @@ CocoaVideo* CocoaVideo::GetInstance()
CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool fullscreen)
: DFrameBuffer(width, height)
: DFrameBuffer(width, height, false)
, m_needPaletteUpdate(false)
, m_gamma(0.0f)
, m_needGammaUpdate(false)
@ -1064,7 +1066,7 @@ void I_CreateRenderer()
DFrameBuffer* I_SetMode(int &width, int &height, DFrameBuffer* old)
{
return Video->CreateFrameBuffer(width, height, fullscreen, old);
return Video->CreateFrameBuffer(width, height, swtruecolor, fullscreen, old);
}
bool I_CheckResolution(const int width, const int height, const int bits)

View File

@ -74,7 +74,7 @@ class IVideo
virtual EDisplayType GetDisplayType () = 0;
virtual void SetWindowedScale (float scale) = 0;
virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old) = 0;
virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old) = 0;
virtual void StartModeIterator (int bits, bool fs) = 0;
virtual bool NextMode (int *width, int *height, bool *letterbox) = 0;

View File

@ -51,6 +51,7 @@
EXTERN_CVAR (Bool, ticker)
EXTERN_CVAR (Bool, fullscreen)
EXTERN_CVAR (Bool, swtruecolor)
EXTERN_CVAR (Float, vid_winscale)
IVideo *Video;
@ -128,7 +129,7 @@ DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old)
fs = fullscreen;
break;
}
DFrameBuffer *res = Video->CreateFrameBuffer (width, height, fs, old);
DFrameBuffer *res = Video->CreateFrameBuffer (width, height, swtruecolor, fs, old);
/* Right now, CreateFrameBuffer cannot return NULL
if (res == NULL)
@ -280,6 +281,8 @@ CUSTOM_CVAR (Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
}
}
CVAR (Bool, swtruecolor, false, CVAR_ARCHIVE)
extern int NewWidth, NewHeight, NewBits, DisplayBits;
CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)

View File

@ -257,7 +257,7 @@ bool SDLVideo::NextMode (int *width, int *height, bool *letterbox)
return false;
}
DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old)
DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool bgra, bool fullscreen, DFrameBuffer *old)
{
static int retry = 0;
static int owidth, oheight;
@ -335,7 +335,7 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer (int width, int height, bool fullscree
}
++retry;
fb = static_cast<SDLFB *>(CreateFrameBuffer (width, height, fullscreen, NULL));
fb = static_cast<SDLFB *>(CreateFrameBuffer (width, height, bgra, fullscreen, NULL));
}
retry = 0;
@ -351,7 +351,7 @@ void SDLVideo::SetWindowedScale (float scale)
// FrameBuffer implementation -----------------------------------------------
SDLFB::SDLFB (int width, int height, bool fullscreen, SDL_Window *oldwin)
: DFrameBuffer (width, height)
: DFrameBuffer (width, height, false)
{
int i;

View File

@ -10,7 +10,7 @@ class SDLVideo : public IVideo
EDisplayType GetDisplayType () { return DISPLAY_Both; }
void SetWindowedScale (float scale);
DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old);
DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old);
void StartModeIterator (int bits, bool fs);
bool NextMode (int *width, int *height, bool *letterbox);

View File

@ -179,7 +179,6 @@ FDynamicColormap ShadeFakeColormap[16];
BYTE identitymap[256];
EXTERN_CVAR (Int, r_columnmethod)
EXTERN_CVAR (Bool, r_swtruecolor)
void R_InitShadeMaps()
{
@ -4129,6 +4128,14 @@ const BYTE *R_GetColumn (FTexture *tex, int col)
// [RH] Initialize the column drawer pointers
void R_InitColumnDrawers ()
{
// Save a copy when switching to true color mode as the assembly palette drawers might change them
static bool pointers_saved = false;
static DWORD(*dovline1_saved)();
static DWORD(*doprevline1_saved)();
static DWORD(*domvline1_saved)();
static void(*dovline4_saved)();
static void(*domvline4_saved)();
if (r_swtruecolor)
{
R_DrawColumnHoriz = R_DrawColumnHorizP_RGBA_C;
@ -4201,6 +4208,16 @@ void R_InitColumnDrawers ()
rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_RGBA_c;
rt_initcols = rt_initcols_rgba;
if (!pointers_saved)
{
pointers_saved = true;
dovline1_saved = dovline1;
doprevline1_saved = doprevline1;
domvline1_saved = domvline1;
dovline4_saved = dovline4;
domvline4_saved = domvline4;
}
dovline1 = vlinec1_RGBA;
doprevline1 = vlinec1_RGBA;
dovline4 = vlinec4_RGBA;
@ -4304,7 +4321,27 @@ void R_InitColumnDrawers ()
rt_tlatesubclamp4cols = rt_tlatesubclamp4cols_c;
rt_tlaterevsubclamp4cols = rt_tlaterevsubclamp4cols_c;
rt_initcols = rt_initcols_pal;
if (pointers_saved)
{
pointers_saved = false;
dovline1 = dovline1_saved;
doprevline1 = doprevline1_saved;
domvline1 = domvline1_saved;
dovline4 = dovline4_saved;
domvline4 = domvline4_saved;
}
}
colfunc = basecolfunc = R_DrawColumn;
fuzzcolfunc = R_DrawFuzzColumn;
transcolfunc = R_DrawTranslatedColumn;
spanfunc = R_DrawSpan;
// [RH] Horizontal column drawers
hcolfunc_pre = R_DrawColumnHoriz;
hcolfunc_post1 = rt_map1col;
hcolfunc_post4 = rt_map4cols;
}
// [RH] Choose column drawers in a single place

View File

@ -47,8 +47,6 @@
#include "r_things.h"
#include "v_video.h"
EXTERN_CVAR(Bool, r_swtruecolor)
// I should have commented this stuff better.
//
// dc_temp is the buffer R_DrawColumnHoriz writes into.

View File

@ -103,7 +103,8 @@ bool r_dontmaplines;
CVAR (String, r_viewsize, "", CVAR_NOSET)
CVAR (Bool, r_shadercolormaps, true, CVAR_ARCHIVE)
CVAR (Bool, r_swtruecolor, false, CVAR_ARCHIVE)
bool r_swtruecolor;
double r_BaseVisibility;
double r_WallVisibility;
@ -398,16 +399,6 @@ void R_InitRenderer()
R_InitPlanes ();
R_InitShadeMaps();
R_InitColumnDrawers ();
colfunc = basecolfunc = R_DrawColumn;
fuzzcolfunc = R_DrawFuzzColumn;
transcolfunc = R_DrawTranslatedColumn;
spanfunc = R_DrawSpan;
// [RH] Horizontal column drawers
hcolfunc_pre = R_DrawColumnHoriz;
hcolfunc_post1 = rt_map1col;
hcolfunc_post4 = rt_map4cols;
}
//==========================================================================
@ -962,6 +953,13 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas,
int x, int y, int width, int height, bool dontmaplines)
{
const bool savedviewactive = viewactive;
const bool savedoutputformat = r_swtruecolor;
if (r_swtruecolor != canvas->IsBgra())
{
r_swtruecolor = canvas->IsBgra();
R_InitColumnDrawers();
}
viewwidth = width;
RenderTarget = canvas;
@ -980,7 +978,15 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas,
screen->Lock (true);
R_SetupBuffer ();
screen->Unlock ();
viewactive = savedviewactive;
r_swtruecolor = savedoutputformat;
if (r_swtruecolor != canvas->IsBgra())
{
r_swtruecolor = canvas->IsBgra();
R_InitColumnDrawers();
}
}
//==========================================================================

View File

@ -106,6 +106,8 @@ inline uint32_t shade_pal_index(uint32_t index, uint32_t light)
return 0xff000000 | (red << 16) | (green << 8) | blue;
}
extern bool r_swtruecolor;
extern double GlobVis;
void R_SetVisibility(double visibility);

View File

@ -61,8 +61,6 @@ CVAR(Bool, r_np2, true, 0)
//CVAR (Int, ty, 8, 0)
//CVAR (Int, tx, 8, 0)
EXTERN_CVAR(Bool, r_swtruecolor)
#define HEIGHTBITS 12
#define HEIGHTSHIFT (FRACBITS-HEIGHTBITS)

View File

@ -155,6 +155,12 @@ void FSoftwareRenderer::Precache(BYTE *texhitlist, TMap<PClassActor*, bool> &act
void FSoftwareRenderer::RenderView(player_t *player)
{
if (r_swtruecolor != screen->IsBgra())
{
r_swtruecolor = screen->IsBgra();
R_InitColumnDrawers();
}
R_RenderActorView (player->mo);
// [RH] Let cameras draw onto textures that were visible this frame.
FCanvasTextureInfo::UpdateAll ();
@ -182,8 +188,7 @@ void FSoftwareRenderer::RemapVoxels()
void FSoftwareRenderer::WriteSavePic (player_t *player, FILE *file, int width, int height)
{
#ifdef PALETTEOUTPUT
DCanvas *pic = new DSimpleCanvas (width, height);
DCanvas *pic = new DSimpleCanvas (width, height, false);
PalEntry palette[256];
// Take a snapshot of the player's view
@ -196,7 +201,6 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FILE *file, int width, i
pic->Destroy();
pic->ObjectFlags |= OF_YesReallyDelete;
delete pic;
#endif
}
//===========================================================================
@ -313,7 +317,6 @@ void FSoftwareRenderer::CopyStackedViewParameters()
void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov)
{
#ifdef PALETTEOUTPUT
BYTE *Pixels = const_cast<BYTE*>(tex->GetPixels());
DSimpleCanvas *Canvas = tex->GetCanvas();
@ -337,7 +340,6 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
tex->SetUpdated();
fixedcolormap = savecolormap;
realfixedcolormap = savecm;
#endif
}
//==========================================================================

View File

@ -98,7 +98,6 @@ EXTERN_CVAR (Bool, st_scale)
EXTERN_CVAR(Bool, r_shadercolormaps)
EXTERN_CVAR(Int, r_drawfuzz)
EXTERN_CVAR(Bool, r_deathcamera);
EXTERN_CVAR(Bool, r_swtruecolor)
//
// Sprite rotation 0 is facing the viewer,

View File

@ -103,7 +103,7 @@ const BYTE *FCanvasTexture::GetPixels ()
void FCanvasTexture::MakeTexture ()
{
Canvas = new DSimpleCanvas (Width, Height);
Canvas = new DSimpleCanvas (Width, Height, false);
Canvas->Lock ();
GC::AddSoftRoot(Canvas);

View File

@ -77,8 +77,6 @@ extern "C" short spanend[MAXHEIGHT];
CVAR (Bool, hud_scale, false, CVAR_ARCHIVE);
EXTERN_CVAR(Bool, r_swtruecolor)
// For routines that take RGB colors, cache the previous lookup in case there
// are several repetitions with the same color.
static int LastPal = -1;
@ -1019,7 +1017,7 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level)
oldyyshifted = yy * GetPitch();
}
if (r_swtruecolor)
if (IsBgra())
{
uint32_t *spot = (uint32_t*)GetBuffer() + oldyyshifted + xx;
@ -1091,7 +1089,7 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real
{
swapvalues (x0, x1);
}
if (r_swtruecolor)
if (IsBgra())
{
uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0;
for (int i = 0; i <= deltaX; i++)
@ -1104,7 +1102,7 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real
}
else if (deltaX == 0)
{ // vertical line
if (r_swtruecolor)
if (IsBgra())
{
uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0;
int pitch = GetPitch();
@ -1127,7 +1125,7 @@ void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 real
}
else if (deltaX == deltaY)
{ // diagonal line.
if (r_swtruecolor)
if (IsBgra())
{
uint32_t *spot = (uint32_t*)GetBuffer() + y0*GetPitch() + x0;
int advance = GetPitch() + xDir;
@ -1295,7 +1293,7 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin
palcolor = PalFromRGB(color);
}
if (r_swtruecolor)
if (IsBgra())
{
uint32_t *dest = (uint32_t*)Buffer + top * Pitch + left;
x = right - left;
@ -1502,7 +1500,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
//
void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src) const
{
if (r_swtruecolor)
if (IsBgra())
return;
int srcpitch = _width;
@ -1531,7 +1529,7 @@ void DCanvas::DrawBlock (int x, int y, int _width, int _height, const BYTE *src)
//
void DCanvas::GetBlock (int x, int y, int _width, int _height, BYTE *dest) const
{
if (r_swtruecolor)
if (IsBgra())
return;
const BYTE *src;

View File

@ -65,8 +65,6 @@
#include "menu/menu.h"
#include "r_data/voxels.h"
EXTERN_CVAR(Bool, r_swtruecolor)
FRenderer *Renderer;
IMPLEMENT_ABSTRACT_CLASS (DCanvas)
@ -83,7 +81,7 @@ class DDummyFrameBuffer : public DFrameBuffer
DECLARE_CLASS (DDummyFrameBuffer, DFrameBuffer);
public:
DDummyFrameBuffer (int width, int height)
: DFrameBuffer (0, 0)
: DFrameBuffer (0, 0, false)
{
Width = width;
Height = height;
@ -208,13 +206,14 @@ DCanvas *DCanvas::CanvasChain = NULL;
//
//==========================================================================
DCanvas::DCanvas (int _width, int _height)
DCanvas::DCanvas (int _width, int _height, bool _bgra)
{
// Init member vars
Buffer = NULL;
LockCount = 0;
Width = _width;
Height = _height;
Bgra = _bgra;
// Add to list of active canvases
Next = CanvasChain;
@ -366,7 +365,7 @@ void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
gap = Pitch - w;
if (r_swtruecolor)
if (IsBgra())
{
uint32_t *spot = (uint32_t*)Buffer + x1 + y1*Pitch;
@ -448,7 +447,7 @@ void DCanvas::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &colo
Lock(true);
buffer = GetBuffer();
pitch = GetPitch();
color_type = r_swtruecolor ? SS_BGRA : SS_PAL;
color_type = IsBgra() ? SS_BGRA : SS_PAL;
}
//==========================================================================
@ -761,8 +760,8 @@ void DCanvas::CalcGamma (float gamma, BYTE gammalookup[256])
//
//==========================================================================
DSimpleCanvas::DSimpleCanvas (int width, int height)
: DCanvas (width, height)
DSimpleCanvas::DSimpleCanvas (int width, int height, bool bgra)
: DCanvas (width, height, bgra)
{
// Making the pitch a power of 2 is very bad for performance
// Try to maximize the number of cache lines that can be filled
@ -799,8 +798,9 @@ DSimpleCanvas::DSimpleCanvas (int width, int height)
Pitch = width + MAX(0, CPU.DataL1LineSize - 8);
}
}
MemBuffer = new BYTE[Pitch * height * 4];
memset (MemBuffer, 0, Pitch * height * 4);
int bytes_per_pixel = bgra ? 4 : 1;
MemBuffer = new BYTE[Pitch * height * bytes_per_pixel];
memset (MemBuffer, 0, Pitch * height * bytes_per_pixel);
}
//==========================================================================
@ -869,8 +869,8 @@ void DSimpleCanvas::Unlock ()
//
//==========================================================================
DFrameBuffer::DFrameBuffer (int width, int height)
: DSimpleCanvas (width, height)
DFrameBuffer::DFrameBuffer (int width, int height, bool bgra)
: DSimpleCanvas (width, height, bgra)
{
LastMS = LastSec = FrameCount = LastCount = LastTic = 0;
Accel2D = false;
@ -927,7 +927,7 @@ void DFrameBuffer::DrawRateStuff ()
// Buffer can be NULL if we're doing hardware accelerated 2D
if (buffer != NULL)
{
if (r_swtruecolor)
if (IsBgra())
{
uint32_t *buffer32 = (uint32_t*)buffer;
buffer32 += (GetHeight() - 1) * GetPitch();

View File

@ -185,7 +185,7 @@ class DCanvas : public DObject
{
DECLARE_ABSTRACT_CLASS (DCanvas, DObject)
public:
DCanvas (int width, int height);
DCanvas (int width, int height, bool bgra);
virtual ~DCanvas ();
// Member variable access
@ -193,6 +193,7 @@ public:
inline int GetWidth () const { return Width; }
inline int GetHeight () const { return Height; }
inline int GetPitch () const { return Pitch; }
inline bool IsBgra() const { return Bgra; }
virtual bool IsValid ();
@ -267,6 +268,7 @@ protected:
int Height;
int Pitch;
int LockCount;
bool Bgra;
bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const;
void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete;
@ -289,7 +291,7 @@ class DSimpleCanvas : public DCanvas
{
DECLARE_CLASS (DSimpleCanvas, DCanvas)
public:
DSimpleCanvas (int width, int height);
DSimpleCanvas (int width, int height, bool bgra);
~DSimpleCanvas ();
bool IsValid ();
@ -327,7 +329,7 @@ class DFrameBuffer : public DSimpleCanvas
{
DECLARE_ABSTRACT_CLASS (DFrameBuffer, DSimpleCanvas)
public:
DFrameBuffer (int width, int height);
DFrameBuffer (int width, int height, bool bgra);
// Force the surface to use buffered output if true is passed.
virtual bool Lock (bool buffered) = 0;

View File

@ -187,7 +187,6 @@ EXTERN_CVAR (Float, Gamma)
EXTERN_CVAR (Bool, vid_vsync)
EXTERN_CVAR (Float, transsouls)
EXTERN_CVAR (Int, vid_refreshrate)
EXTERN_CVAR (Bool, r_swtruecolor)
extern IDirect3D9 *D3D;
@ -243,8 +242,8 @@ CVAR(Bool, vid_hwaalines, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
//
//==========================================================================
D3DFB::D3DFB (UINT adapter, int width, int height, bool fullscreen)
: BaseWinFB (width, height)
D3DFB::D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen)
: BaseWinFB (width, height, bgra)
{
D3DPRESENT_PARAMETERS d3dpp;
@ -766,7 +765,7 @@ void D3DFB::KillNativeTexs()
bool D3DFB::CreateFBTexture ()
{
FBFormat = r_swtruecolor ? D3DFMT_A8R8G8B8 : D3DFMT_L8;
FBFormat = IsBgra() ? D3DFMT_A8R8G8B8 : D3DFMT_L8;
if (FAILED(D3DDevice->CreateTexture(Width, Height, 1, D3DUSAGE_DYNAMIC, FBFormat, D3DPOOL_DEFAULT, &FBTexture, NULL)))
{
@ -1307,7 +1306,7 @@ void D3DFB::Draw3DPart(bool copy3d)
SUCCEEDED(FBTexture->LockRect (0, &lockrect, NULL, D3DLOCK_DISCARD))) ||
SUCCEEDED(FBTexture->LockRect (0, &lockrect, &texrect, 0)))
{
if (r_swtruecolor && FBFormat == D3DFMT_A8R8G8B8)
if (IsBgra() && FBFormat == D3DFMT_A8R8G8B8)
{
if (lockrect.Pitch == Pitch * sizeof(uint32_t) && Pitch == Width)
{
@ -1325,7 +1324,7 @@ void D3DFB::Draw3DPart(bool copy3d)
}
}
}
else if (!r_swtruecolor && FBFormat == D3DFMT_L8)
else if (!IsBgra() && FBFormat == D3DFMT_L8)
{
if (lockrect.Pitch == Pitch && Pitch == Width)
{
@ -1377,7 +1376,7 @@ void D3DFB::Draw3DPart(bool copy3d)
memset(Constant, 0, sizeof(Constant));
SetAlphaBlend(D3DBLENDOP(0));
EnableAlphaTest(FALSE);
if (r_swtruecolor)
if (IsBgra())
SetPixelShader(Shaders[SHADER_NormalColor]);
else
SetPixelShader(Shaders[SHADER_NormalColorPal]);
@ -1398,7 +1397,7 @@ void D3DFB::Draw3DPart(bool copy3d)
realfixedcolormap->ColorizeStart[1]/2, realfixedcolormap->ColorizeStart[2]/2, 0);
color1 = D3DCOLOR_COLORVALUE(realfixedcolormap->ColorizeEnd[0]/2,
realfixedcolormap->ColorizeEnd[1]/2, realfixedcolormap->ColorizeEnd[2]/2, 1);
if (r_swtruecolor)
if (IsBgra())
SetPixelShader(Shaders[SHADER_SpecialColormap]);
else
SetPixelShader(Shaders[SHADER_SpecialColormapPal]);
@ -1412,7 +1411,7 @@ void D3DFB::Draw3DPart(bool copy3d)
CalcFullscreenCoords(verts, Accel2D, false, color0, color1);
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX));
}
if (r_swtruecolor)
if (IsBgra())
SetPixelShader(Shaders[SHADER_NormalColor]);
else
SetPixelShader(Shaders[SHADER_NormalColorPal]);

View File

@ -60,9 +60,7 @@
// TYPES -------------------------------------------------------------------
#ifdef USE_OBSOLETE_DDRAW
IMPLEMENT_CLASS(DDrawFB)
#endif
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
@ -120,10 +118,8 @@ cycle_t BlitCycles;
// CODE --------------------------------------------------------------------
#ifdef USE_OBSOLETE_DDRAW
DDrawFB::DDrawFB (int width, int height, bool fullscreen)
: BaseWinFB (width, height)
: BaseWinFB (width, height, false)
{
int i;
@ -1330,7 +1326,6 @@ void DDrawFB::Blank ()
PrimarySurf->Blt (NULL, NULL, NULL, DDBLT_COLORFILL, &blitFX);
}
}
#endif
ADD_STAT (blit)
{

View File

@ -51,6 +51,7 @@
EXTERN_CVAR (Bool, ticker)
EXTERN_CVAR (Bool, fullscreen)
EXTERN_CVAR (Bool, swtruecolor)
EXTERN_CVAR (Float, vid_winscale)
CVAR(Int, win_x, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -146,7 +147,7 @@ DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old)
}
break;
}
DFrameBuffer *res = Video->CreateFrameBuffer (width, height, fs, old);
DFrameBuffer *res = Video->CreateFrameBuffer (width, height, swtruecolor, fs, old);
/* Right now, CreateFrameBuffer cannot return NULL
if (res == NULL)
@ -310,6 +311,8 @@ void I_RestoreWindowedPos ()
MoveWindow (Window, winx, winy, winw, winh, TRUE);
}
CVAR (Bool, swtruecolor, false, CVAR_ARCHIVE)
extern int NewWidth, NewHeight, NewBits, DisplayBits;
CUSTOM_CVAR (Bool, fullscreen, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)

View File

@ -45,7 +45,7 @@ class IVideo
virtual EDisplayType GetDisplayType () = 0;
virtual void SetWindowedScale (float scale) = 0;
virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old) = 0;
virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old) = 0;
virtual void StartModeIterator (int bits, bool fs) = 0;
virtual bool NextMode (int *width, int *height, bool *letterbox) = 0;

View File

@ -70,7 +70,7 @@ class Win32Video : public IVideo
EDisplayType GetDisplayType () { return DISPLAY_Both; }
void SetWindowedScale (float scale);
DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old);
DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old);
void StartModeIterator (int bits, bool fs);
bool NextMode (int *width, int *height, bool *letterbox);
@ -121,7 +121,7 @@ class BaseWinFB : public DFrameBuffer
{
DECLARE_ABSTRACT_CLASS(BaseWinFB, DFrameBuffer)
public:
BaseWinFB (int width, int height) : DFrameBuffer (width, height), Windowed (true) {}
BaseWinFB (int width, int height, bool bgra) : DFrameBuffer (width, height, bgra), Windowed (true) {}
bool IsFullscreen () { return !Windowed; }
virtual void Blank () = 0;
@ -142,7 +142,6 @@ protected:
BaseWinFB() {}
};
#ifdef USE_OBSOLETE_DDRAW
class DDrawFB : public BaseWinFB
{
DECLARE_CLASS(DDrawFB, BaseWinFB)
@ -224,13 +223,12 @@ private:
DDrawFB() {}
};
#endif
class D3DFB : public BaseWinFB
{
DECLARE_CLASS(D3DFB, BaseWinFB)
public:
D3DFB (UINT adapter, int width, int height, bool fullscreen);
D3DFB (UINT adapter, int width, int height, bool bgra, bool fullscreen);
~D3DFB ();
bool IsValid ();

View File

@ -222,6 +222,13 @@ bool Win32Video::InitD3D9 ()
// Enumerate available display modes.
FreeModes ();
#ifndef PALETTEOUTPUT // To do: remove this again (AddD3DModes fails when there are too many modes available for videomenu to display)
AddMode(320, 200, 8, 200, 0);
AddMode(320, 240, 8, 240, 0);
AddMode(640, 480, 8, 480, 0);
AddMode(800, 600, 8, 600, 0);
AddMode(1024, 768, 8, 768, 0);
AddMode(1920, 1080, 8, 1440, 0); // 1080p
AddMode(1920*2, 1080*2, 8, 1440, 0); // 4k
AddMode(2560, 1440, 8, 1440, 0); // 27" classic
@ -636,7 +643,7 @@ bool Win32Video::NextMode (int *width, int *height, bool *letterbox)
return false;
}
DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old)
DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool bgra, bool fullscreen, DFrameBuffer *old)
{
static int retry = 0;
static int owidth, oheight;
@ -652,7 +659,8 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr
BaseWinFB *fb = static_cast<BaseWinFB *> (old);
if (fb->Width == width &&
fb->Height == height &&
fb->Windowed == !fullscreen)
fb->Windowed == !fullscreen &&
fb->Bgra == bgra)
{
return old;
}
@ -667,13 +675,9 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr
flashAmount = 0;
}
#ifndef USE_OBSOLETE_DDRAW
fb = new D3DFB(m_Adapter, width, height, fullscreen);
LOG1("New fb created @ %p\n", fb);
#else
if (D3D != NULL)
{
fb = new D3DFB (m_Adapter, width, height, fullscreen);
fb = new D3DFB (m_Adapter, width, height, bgra, fullscreen);
}
else
{
@ -738,10 +742,9 @@ DFrameBuffer *Win32Video::CreateFrameBuffer (int width, int height, bool fullscr
}
++retry;
fb = static_cast<DDrawFB *>(CreateFrameBuffer (width, height, fullscreen, NULL));
fb = static_cast<DDrawFB *>(CreateFrameBuffer (width, height, bgra, fullscreen, NULL));
}
retry = 0;
#endif
fb->SetFlash (flashColor, flashAmount);
return fb;

View File

@ -661,7 +661,7 @@ OptionMenu "VideoOptions"
Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff"
Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn"
Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods"
Option "$DSPLYMNU_TRUECOLOR", "r_swtruecolor", "OnOff"
Option "$DSPLYMNU_TRUECOLOR", "swtruecolor", "OnOff"
StaticText " "
Option "$DSPLYMNU_WIPETYPE", "wipetype", "Wipes"