mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- removed Windows types from several files which don't need them.
- split out the software renderer's video classes into their own file because they got included by all OpenGL sources.
This commit is contained in:
parent
8bd9c5a983
commit
03e1cbcfc0
17 changed files with 479 additions and 466 deletions
|
@ -78,7 +78,7 @@ struct dmd_chunk_t
|
|||
#pragma pack(1)
|
||||
struct dmd_packedVertex_t
|
||||
{
|
||||
byte vertex[3];
|
||||
uint8_t vertex[3];
|
||||
unsigned short normal; // Yaw and pitch.
|
||||
};
|
||||
|
||||
|
@ -202,7 +202,7 @@ void FDMDModel::LoadGeometry()
|
|||
for(c = 0; c < 3; c++)
|
||||
{
|
||||
framev->vertices[k].xyz[axis[c]] =
|
||||
(pVtx->vertex[c] * FLOAT(pfr->scale[c]) + FLOAT(pfr->translate[c]));
|
||||
(pVtx->vertex[c] * float(pfr->scale[c]) + float(pfr->translate[c]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -415,8 +415,8 @@ struct md2_header_t
|
|||
|
||||
struct md2_triangleVertex_t
|
||||
{
|
||||
byte vertex[3];
|
||||
byte lightNormalIndex;
|
||||
uint8_t vertex[3];
|
||||
uint8_t lightNormalIndex;
|
||||
};
|
||||
|
||||
struct md2_packedFrame_t
|
||||
|
@ -437,7 +437,7 @@ bool FMD2Model::Load(const char * path, int lumpnum, const char * buffer, int le
|
|||
{
|
||||
md2_header_t * md2header = (md2_header_t *)buffer;
|
||||
ModelFrame *frame;
|
||||
byte *md2_frames;
|
||||
uint8_t *md2_frames;
|
||||
int i;
|
||||
|
||||
// Convert it to DMD.
|
||||
|
@ -481,7 +481,7 @@ bool FMD2Model::Load(const char * path, int lumpnum, const char * buffer, int le
|
|||
}
|
||||
|
||||
// The frames need to be unpacked.
|
||||
md2_frames = (byte*)buffer + info.offsetFrames;
|
||||
md2_frames = (uint8_t*)buffer + info.offsetFrames;
|
||||
frames = new ModelFrame[info.numFrames];
|
||||
|
||||
for (i = 0, frame = frames; i < info.numFrames; i++, frame++)
|
||||
|
@ -504,14 +504,14 @@ bool FMD2Model::Load(const char * path, int lumpnum, const char * buffer, int le
|
|||
void FMD2Model::LoadGeometry()
|
||||
{
|
||||
static int axis[3] = { VX, VY, VZ };
|
||||
byte *md2_frames;
|
||||
uint8_t *md2_frames;
|
||||
FMemLump lumpdata = Wads.ReadLump(mLumpNum);
|
||||
const char *buffer = (const char *)lumpdata.GetMem();
|
||||
|
||||
texCoords = new FTexCoord[info.numTexCoords];
|
||||
memcpy(texCoords, (byte*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord));
|
||||
memcpy(texCoords, (uint8_t*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord));
|
||||
|
||||
md2_frames = (byte*)buffer + info.offsetFrames;
|
||||
md2_frames = (uint8_t*)buffer + info.offsetFrames;
|
||||
framevtx = new ModelFrameVertexData[info.numFrames];
|
||||
ModelFrameVertexData *framev;
|
||||
int i, k, c;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4305)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -601,7 +601,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
|
|||
extsector_t::xfloor &x = sector->e->XFloor;
|
||||
dynlightindex = -1;
|
||||
|
||||
byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum];
|
||||
uint8_t &srf = gl_drawinfo->sectorrenderflags[sector->sectornum];
|
||||
|
||||
//
|
||||
//
|
||||
|
|
|
@ -992,7 +992,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i
|
|||
CopyToBackbuffer(&bounds, false);
|
||||
glFlush();
|
||||
|
||||
byte * scr = (byte *)M_Malloc(width * height * 3);
|
||||
uint8_t * scr = (uint8_t *)M_Malloc(width * height * 3);
|
||||
glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr);
|
||||
M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width*3);
|
||||
M_Free(scr);
|
||||
|
|
|
@ -894,7 +894,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
|||
rendersector->GetCeilingLight() : rendersector->GetFloorLight());
|
||||
foglevel = (BYTE)clamp<short>(rendersector->lightlevel, 0, 255);
|
||||
|
||||
lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingpos);
|
||||
lightlevel = gl_CheckSpriteGlow(rendersector, lightlevel, thingpos);
|
||||
|
||||
ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff;
|
||||
ThingColor.a = 255;
|
||||
|
|
|
@ -271,15 +271,7 @@ void FGLDebug::DebugCallback(GLenum source, GLenum type, GLuint id, GLenum sever
|
|||
return;
|
||||
|
||||
PrintMessage(source, type, id, severity, length, message);
|
||||
|
||||
if (severity != GL_DEBUG_SEVERITY_NOTIFICATION)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
DebugBreak();
|
||||
#else
|
||||
raise(SIGTRAP);
|
||||
#endif
|
||||
}
|
||||
assert(severity == GL_DEBUG_SEVERITY_NOTIFICATION);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -47,18 +47,6 @@
|
|||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/renderer/gl_2ddrawer.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
struct POINT {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
};
|
||||
struct RECT {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
};
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
@ -414,10 +402,19 @@ int OpenGLFrameBuffer::Wiper_Melt::MakeVBO(int ticks, OpenGLFrameBuffer *fb, boo
|
|||
}
|
||||
if (ticks == 0)
|
||||
{
|
||||
struct {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
} dpt;
|
||||
struct {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
} rect;
|
||||
|
||||
// Only draw for the final tick.
|
||||
// No need for optimization. Wipes won't ever be drawn with anything else.
|
||||
RECT rect;
|
||||
POINT dpt;
|
||||
|
||||
dpt.x = i * fb->Width / WIDTH;
|
||||
dpt.y = MAX(0, y[i] * fb->Height / HEIGHT);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <intrin.h>
|
||||
|
@ -76,7 +76,7 @@ double gl_MillisecPerCycle = 1e-5; // 100 MHz
|
|||
|
||||
void gl_CalculateCPUSpeed ()
|
||||
{
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
LARGE_INTEGER freq;
|
||||
|
||||
QueryPerformanceFrequency (&freq);
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#include "f_wipe.h"
|
||||
#include "sbar.h"
|
||||
#include "win32iface.h"
|
||||
#include "win32swiface.h"
|
||||
#include "doomstat.h"
|
||||
#include "v_palette.h"
|
||||
#include "w_wad.h"
|
||||
|
@ -1208,10 +1209,7 @@ void D3DFB::Flip()
|
|||
}
|
||||
}
|
||||
// Limiting the frame rate is as simple as waiting for the timer to signal this event.
|
||||
if (FPSLimitEvent != NULL)
|
||||
{
|
||||
WaitForSingleObject(FPSLimitEvent, 1000);
|
||||
}
|
||||
I_FPSLimit();
|
||||
D3DDevice->Present(NULL, NULL, NULL, NULL);
|
||||
InScene = false;
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "doomtype.h"
|
||||
#include "f_wipe.h"
|
||||
#include "win32iface.h"
|
||||
#include "win32swiface.h"
|
||||
#include "templates.h"
|
||||
#include "m_random.h"
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "doomerrors.h"
|
||||
|
||||
#include "win32iface.h"
|
||||
#include "win32swiface.h"
|
||||
#include "v_palette.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
@ -1197,10 +1198,7 @@ void DDrawFB::Update ()
|
|||
LockCount = 0;
|
||||
UpdatePending = false;
|
||||
|
||||
if (FPSLimitEvent != NULL)
|
||||
{
|
||||
WaitForSingleObject(FPSLimitEvent, 1000);
|
||||
}
|
||||
I_FPSLimit();
|
||||
if (!Windowed && AppActive && !SessionState /*&& !UseBlitter && !MustBuffer*/)
|
||||
{
|
||||
HRESULT hr = PrimarySurf->Flip (NULL, FlipFlags);
|
||||
|
|
|
@ -63,6 +63,7 @@ void I_SaveWindowedPos ();
|
|||
void I_RestoreWindowedPos ();
|
||||
|
||||
void I_SetFPSLimit(int limit);
|
||||
void I_FPSLimit();
|
||||
|
||||
|
||||
extern IVideo *Video;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "m_argv.h"
|
||||
#include "rawinput.h"
|
||||
|
||||
#define SAFE_RELEASE(x) { if (x != NULL) { x->Release(); x = NULL; } }
|
||||
|
||||
// WBEMIDL BITS -- because w32api doesn't have this, either -----------------
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
|
|
@ -1126,10 +1126,7 @@ void Win32GLFrameBuffer::SetVSync (bool vsync)
|
|||
void Win32GLFrameBuffer::SwapBuffers()
|
||||
{
|
||||
// Limiting the frame rate is as simple as waiting for the timer to signal this event.
|
||||
if (FPSLimitEvent != NULL)
|
||||
{
|
||||
WaitForSingleObject(FPSLimitEvent, 1000);
|
||||
}
|
||||
I_FPSLimit();
|
||||
::SwapBuffers(static_cast<Win32GLVideo *>(Video)->m_hDC);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,6 @@
|
|||
|
||||
EXTERN_CVAR (Bool, vid_vsync)
|
||||
|
||||
extern HANDLE FPSLimitEvent;
|
||||
|
||||
class D3DTex;
|
||||
class D3DPal;
|
||||
struct FSoftwareRenderer;
|
||||
|
@ -79,6 +77,7 @@ class Win32Video : public IVideo
|
|||
void BlankForGDI ();
|
||||
|
||||
void DumpAdapters ();
|
||||
void AddMode(int x, int y, int bits, int baseHeight, int doubling);
|
||||
|
||||
private:
|
||||
struct ModeInfo
|
||||
|
@ -102,13 +101,11 @@ class Win32Video : public IVideo
|
|||
int m_IteratorBits;
|
||||
bool m_IteratorFS;
|
||||
bool m_IsFullscreen;
|
||||
UINT m_Adapter;
|
||||
unsigned int m_Adapter;
|
||||
|
||||
void AddMode (int x, int y, int bits, int baseHeight, int doubling);
|
||||
void FreeModes ();
|
||||
|
||||
static HRESULT WINAPI EnumDDModesCB (LPDDSURFACEDESC desc, void *modes);
|
||||
void AddD3DModes (UINT adapter, D3DFORMAT format);
|
||||
void AddD3DModes (unsigned adapter);
|
||||
void AddLowResModes ();
|
||||
void AddLetterboxModes ();
|
||||
void ScaleModes (int doubling);
|
||||
|
@ -126,7 +123,7 @@ public:
|
|||
bool IsFullscreen () { return !Windowed; }
|
||||
virtual void Blank () = 0;
|
||||
virtual bool PaintToWindow () = 0;
|
||||
virtual HRESULT GetHR () = 0;
|
||||
virtual long/*HRESULT*/ GetHR () = 0; // HRESULT is a long in Windows but this header should not be polluted with windows.h just for this single definition
|
||||
virtual void ScaleCoordsFromWindow(int16_t &x, int16_t &y);
|
||||
|
||||
protected:
|
||||
|
@ -141,398 +138,5 @@ protected:
|
|||
BaseWinFB() {}
|
||||
};
|
||||
|
||||
class DDrawFB : public BaseWinFB
|
||||
{
|
||||
DECLARE_CLASS(DDrawFB, BaseWinFB)
|
||||
public:
|
||||
DDrawFB (int width, int height, bool fullscreen);
|
||||
~DDrawFB ();
|
||||
|
||||
bool IsValid ();
|
||||
bool Lock (bool buffer);
|
||||
void Unlock ();
|
||||
void ForceBuffering (bool force);
|
||||
void Update ();
|
||||
PalEntry *GetPalette ();
|
||||
void GetFlashedPalette (PalEntry pal[256]);
|
||||
void UpdatePalette ();
|
||||
bool SetGamma (float gamma);
|
||||
bool SetFlash (PalEntry rgb, int amount);
|
||||
void GetFlash (PalEntry &rgb, int &amount);
|
||||
int GetPageCount ();
|
||||
int QueryNewPalette ();
|
||||
void PaletteChanged ();
|
||||
void SetVSync (bool vsync);
|
||||
void NewRefreshRate();
|
||||
HRESULT GetHR ();
|
||||
bool Is8BitMode();
|
||||
virtual int GetTrueHeight() { return TrueHeight; }
|
||||
|
||||
void Blank ();
|
||||
bool PaintToWindow ();
|
||||
|
||||
private:
|
||||
enum LockSurfRes { NoGood, Good, GoodWasLost };
|
||||
|
||||
bool CreateResources ();
|
||||
void ReleaseResources ();
|
||||
bool CreateSurfacesAttached ();
|
||||
bool CreateSurfacesComplex ();
|
||||
bool CreateBlitterSource ();
|
||||
LockSurfRes LockSurf (LPRECT lockrect, LPDIRECTDRAWSURFACE surf);
|
||||
void RebuildColorTable ();
|
||||
void MaybeCreatePalette ();
|
||||
bool AddBackBuf (LPDIRECTDRAWSURFACE *surface, int num);
|
||||
HRESULT AttemptRestore ();
|
||||
|
||||
HRESULT LastHR;
|
||||
BYTE GammaTable[3][256];
|
||||
PalEntry SourcePalette[256];
|
||||
PALETTEENTRY PalEntries[256];
|
||||
DWORD FlipFlags;
|
||||
|
||||
LPDIRECTDRAWPALETTE Palette;
|
||||
LPDIRECTDRAWSURFACE PrimarySurf;
|
||||
LPDIRECTDRAWSURFACE BackSurf;
|
||||
LPDIRECTDRAWSURFACE BackSurf2;
|
||||
LPDIRECTDRAWSURFACE BlitSurf;
|
||||
LPDIRECTDRAWSURFACE LockingSurf;
|
||||
LPDIRECTDRAWCLIPPER Clipper;
|
||||
HPALETTE GDIPalette;
|
||||
DWORD ClipSize;
|
||||
PalEntry Flash;
|
||||
int FlashAmount;
|
||||
int BufferCount;
|
||||
int BufferPitch;
|
||||
int TrueHeight;
|
||||
int PixelDoubling;
|
||||
float Gamma;
|
||||
|
||||
bool NeedGammaUpdate;
|
||||
bool NeedPalUpdate;
|
||||
bool NeedResRecreate;
|
||||
bool PaletteChangeExpected;
|
||||
bool MustBuffer; // The screen is not 8-bit, or there is no backbuffer
|
||||
bool BufferingNow; // Most recent Lock was buffered
|
||||
bool WasBuffering; // Second most recent Lock was buffered
|
||||
bool Write8bit;
|
||||
bool UpdatePending; // On final unlock, call Update()
|
||||
bool UseBlitter; // Use blitter to copy from sys mem to video mem
|
||||
bool UsePfx;
|
||||
|
||||
DDrawFB() {}
|
||||
};
|
||||
|
||||
class D3DFB : public BaseWinFB
|
||||
{
|
||||
DECLARE_CLASS(D3DFB, BaseWinFB)
|
||||
public:
|
||||
D3DFB (UINT adapter, int width, int height, bool fullscreen);
|
||||
~D3DFB ();
|
||||
|
||||
bool IsValid ();
|
||||
bool Lock (bool buffered);
|
||||
void Unlock ();
|
||||
void Update ();
|
||||
void Flip ();
|
||||
PalEntry *GetPalette ();
|
||||
void GetFlashedPalette (PalEntry palette[256]);
|
||||
void UpdatePalette ();
|
||||
bool SetGamma (float gamma);
|
||||
bool SetFlash (PalEntry rgb, int amount);
|
||||
void GetFlash (PalEntry &rgb, int &amount);
|
||||
int GetPageCount ();
|
||||
bool IsFullscreen ();
|
||||
void PaletteChanged ();
|
||||
int QueryNewPalette ();
|
||||
void Blank ();
|
||||
bool PaintToWindow ();
|
||||
void SetVSync (bool vsync);
|
||||
void NewRefreshRate();
|
||||
void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type);
|
||||
void ReleaseScreenshotBuffer();
|
||||
void SetBlendingRect (int x1, int y1, int x2, int y2);
|
||||
bool Begin2D (bool copy3d);
|
||||
void DrawBlendingRect ();
|
||||
FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping);
|
||||
FNativePalette *CreatePalette (FRemapTable *remap);
|
||||
void DrawTextureParms (FTexture *img, DrawParms &parms);
|
||||
void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color);
|
||||
void Dim (PalEntry color, float amount, int x1, int y1, int w, int h);
|
||||
void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin);
|
||||
void DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor);
|
||||
void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor);
|
||||
void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
|
||||
double originx, double originy, double scalex, double scaley,
|
||||
DAngle rotation, FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip) override;
|
||||
bool WipeStartScreen(int type);
|
||||
void WipeEndScreen();
|
||||
bool WipeDo(int ticks);
|
||||
void WipeCleanup();
|
||||
HRESULT GetHR ();
|
||||
bool Is8BitMode() { return false; }
|
||||
virtual int GetTrueHeight() { return TrueHeight; }
|
||||
|
||||
private:
|
||||
friend class D3DTex;
|
||||
friend class D3DPal;
|
||||
|
||||
struct PackedTexture;
|
||||
struct Atlas;
|
||||
|
||||
struct FBVERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw;
|
||||
D3DCOLOR color0, color1;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
#define D3DFVF_FBVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1)
|
||||
|
||||
struct BufferedTris
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
BYTE Flags;
|
||||
BYTE ShaderNum:4;
|
||||
BYTE BlendOp:4;
|
||||
BYTE SrcBlend, DestBlend;
|
||||
};
|
||||
DWORD Group1;
|
||||
};
|
||||
BYTE Desat;
|
||||
D3DPal *Palette;
|
||||
IDirect3DTexture9 *Texture;
|
||||
int NumVerts; // Number of _unique_ vertices used by this set.
|
||||
int NumTris; // Number of triangles used by this set.
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PSCONST_Desaturation = 1,
|
||||
PSCONST_PaletteMod = 2,
|
||||
PSCONST_Weights = 6,
|
||||
PSCONST_Gamma = 7,
|
||||
};
|
||||
enum
|
||||
{
|
||||
SHADER_NormalColor,
|
||||
SHADER_NormalColorPal,
|
||||
SHADER_NormalColorInv,
|
||||
SHADER_NormalColorPalInv,
|
||||
|
||||
SHADER_RedToAlpha,
|
||||
SHADER_RedToAlphaInv,
|
||||
|
||||
SHADER_VertexColor,
|
||||
|
||||
SHADER_SpecialColormap,
|
||||
SHADER_SpecialColormapPal,
|
||||
|
||||
SHADER_InGameColormap,
|
||||
SHADER_InGameColormapDesat,
|
||||
SHADER_InGameColormapInv,
|
||||
SHADER_InGameColormapInvDesat,
|
||||
SHADER_InGameColormapPal,
|
||||
SHADER_InGameColormapPalDesat,
|
||||
SHADER_InGameColormapPalInv,
|
||||
SHADER_InGameColormapPalInvDesat,
|
||||
|
||||
SHADER_BurnWipe,
|
||||
SHADER_GammaCorrection,
|
||||
|
||||
NUM_SHADERS
|
||||
};
|
||||
static const char *const ShaderNames[NUM_SHADERS];
|
||||
|
||||
void SetInitialState();
|
||||
bool CreateResources();
|
||||
void ReleaseResources();
|
||||
bool LoadShaders();
|
||||
void CreateBlockSurfaces();
|
||||
bool CreateFBTexture();
|
||||
bool CreatePaletteTexture();
|
||||
bool CreateGammaTexture();
|
||||
bool CreateVertexes();
|
||||
void DoOffByOneCheck();
|
||||
void UploadPalette();
|
||||
void UpdateGammaTexture(float igamma);
|
||||
void FillPresentParameters (D3DPRESENT_PARAMETERS *pp, bool fullscreen, bool vsync);
|
||||
void CalcFullscreenCoords (FBVERTEX verts[4], bool viewarea_only, bool can_double, D3DCOLOR color0, D3DCOLOR color1) const;
|
||||
bool Reset();
|
||||
IDirect3DTexture9 *GetCurrentScreen(D3DPOOL pool=D3DPOOL_SYSTEMMEM);
|
||||
void ReleaseDefaultPoolItems();
|
||||
void KillNativePals();
|
||||
void KillNativeTexs();
|
||||
PackedTexture *AllocPackedTexture(int width, int height, bool wrapping, D3DFORMAT format);
|
||||
void DrawPackedTextures(int packnum);
|
||||
void DrawLetterbox();
|
||||
void Draw3DPart(bool copy3d);
|
||||
bool SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1, BufferedTris &quad);
|
||||
static D3DBLEND GetStyleAlpha(int type);
|
||||
static void SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1);
|
||||
void DoWindowedGamma();
|
||||
void AddColorOnlyQuad(int left, int top, int width, int height, D3DCOLOR color);
|
||||
void AddColorOnlyRect(int left, int top, int width, int height, D3DCOLOR color);
|
||||
void CheckQuadBatch(int numtris=2, int numverts=4);
|
||||
void BeginQuadBatch();
|
||||
void EndQuadBatch();
|
||||
void BeginLineBatch();
|
||||
void EndLineBatch();
|
||||
void EndBatch();
|
||||
void CopyNextFrontBuffer();
|
||||
|
||||
D3DCAPS9 DeviceCaps;
|
||||
|
||||
// State
|
||||
void EnableAlphaTest(BOOL enabled);
|
||||
void SetAlphaBlend(D3DBLENDOP op, D3DBLEND srcblend=D3DBLEND(0), D3DBLEND destblend=D3DBLEND(0));
|
||||
void SetConstant(int cnum, float r, float g, float b, float a);
|
||||
void SetPixelShader(IDirect3DPixelShader9 *shader);
|
||||
void SetTexture(int tnum, IDirect3DTexture9 *texture);
|
||||
void SetPaletteTexture(IDirect3DTexture9 *texture, int count, D3DCOLOR border_color);
|
||||
void SetPalTexBilinearConstants(Atlas *texture);
|
||||
|
||||
BOOL AlphaTestEnabled;
|
||||
BOOL AlphaBlendEnabled;
|
||||
D3DBLENDOP AlphaBlendOp;
|
||||
D3DBLEND AlphaSrcBlend;
|
||||
D3DBLEND AlphaDestBlend;
|
||||
float Constant[3][4];
|
||||
D3DCOLOR CurBorderColor;
|
||||
IDirect3DPixelShader9 *CurPixelShader;
|
||||
IDirect3DTexture9 *Texture[5];
|
||||
|
||||
PalEntry SourcePalette[256];
|
||||
D3DCOLOR BorderColor;
|
||||
D3DCOLOR FlashColor0, FlashColor1;
|
||||
PalEntry FlashColor;
|
||||
int FlashAmount;
|
||||
int TrueHeight;
|
||||
int PixelDoubling;
|
||||
int SkipAt;
|
||||
int LBOffsetI;
|
||||
int RenderTextureToggle;
|
||||
int CurrRenderTexture;
|
||||
float LBOffset;
|
||||
float Gamma;
|
||||
bool UpdatePending;
|
||||
bool NeedPalUpdate;
|
||||
bool NeedGammaUpdate;
|
||||
int FBWidth, FBHeight;
|
||||
bool VSync;
|
||||
RECT BlendingRect;
|
||||
int In2D;
|
||||
bool InScene;
|
||||
bool SM14;
|
||||
bool GatheringWipeScreen;
|
||||
bool AALines;
|
||||
BYTE BlockNum;
|
||||
D3DPal *Palettes;
|
||||
D3DTex *Textures;
|
||||
Atlas *Atlases;
|
||||
HRESULT LastHR;
|
||||
|
||||
UINT Adapter;
|
||||
IDirect3DDevice9 *D3DDevice;
|
||||
IDirect3DTexture9 *FBTexture;
|
||||
IDirect3DTexture9 *TempRenderTexture, *RenderTexture[2];
|
||||
IDirect3DTexture9 *PaletteTexture;
|
||||
IDirect3DTexture9 *GammaTexture;
|
||||
IDirect3DTexture9 *ScreenshotTexture;
|
||||
IDirect3DSurface9 *ScreenshotSurface;
|
||||
IDirect3DSurface9 *FrontCopySurface;
|
||||
|
||||
IDirect3DVertexBuffer9 *VertexBuffer;
|
||||
FBVERTEX *VertexData;
|
||||
IDirect3DIndexBuffer9 *IndexBuffer;
|
||||
uint16_t *IndexData;
|
||||
BufferedTris *QuadExtra;
|
||||
int VertexPos;
|
||||
int IndexPos;
|
||||
int QuadBatchPos;
|
||||
enum { BATCH_None, BATCH_Quads, BATCH_Lines } BatchType;
|
||||
|
||||
IDirect3DPixelShader9 *Shaders[NUM_SHADERS];
|
||||
IDirect3DPixelShader9 *GammaShader;
|
||||
|
||||
IDirect3DSurface9 *BlockSurface[2];
|
||||
IDirect3DSurface9 *OldRenderTarget;
|
||||
IDirect3DTexture9 *InitialWipeScreen, *FinalWipeScreen;
|
||||
|
||||
D3DFB() {}
|
||||
|
||||
class Wiper
|
||||
{
|
||||
public:
|
||||
virtual ~Wiper();
|
||||
virtual bool Run(int ticks, D3DFB *fb) = 0;
|
||||
|
||||
void DrawScreen(D3DFB *fb, IDirect3DTexture9 *tex,
|
||||
D3DBLENDOP blendop=D3DBLENDOP(0), D3DCOLOR color0=0, D3DCOLOR color1=0xFFFFFFF);
|
||||
};
|
||||
|
||||
class Wiper_Melt; friend class Wiper_Melt;
|
||||
class Wiper_Burn; friend class Wiper_Burn;
|
||||
class Wiper_Crossfade; friend class Wiper_Crossfade;
|
||||
|
||||
Wiper *ScreenWipe;
|
||||
};
|
||||
|
||||
// Flags for a buffered quad
|
||||
enum
|
||||
{
|
||||
BQF_GamePalette = 1,
|
||||
BQF_CustomPalette = 7,
|
||||
BQF_Paletted = 7,
|
||||
BQF_Bilinear = 8,
|
||||
BQF_WrapUV = 16,
|
||||
BQF_InvertSource = 32,
|
||||
BQF_DisableAlphaTest= 64,
|
||||
BQF_Desaturated = 128,
|
||||
};
|
||||
|
||||
// Shaders for a buffered quad
|
||||
enum
|
||||
{
|
||||
BQS_PalTex,
|
||||
BQS_Plain,
|
||||
BQS_RedToAlpha,
|
||||
BQS_ColorOnly,
|
||||
BQS_SpecialColormap,
|
||||
BQS_InGameColormap,
|
||||
};
|
||||
|
||||
#if 0
|
||||
#define STARTLOG do { if (!dbg) dbg = fopen ("e:/vid.log", "w"); } while(0)
|
||||
#define STOPLOG do { if (dbg) { fclose (dbg); dbg=NULL; } } while(0)
|
||||
#define LOG(x) do { if (dbg) { fprintf (dbg, x); fflush (dbg); } } while(0)
|
||||
#define LOG1(x,y) do { if (dbg) { fprintf (dbg, x, y); fflush (dbg); } } while(0)
|
||||
#define LOG2(x,y,z) do { if (dbg) { fprintf (dbg, x, y, z); fflush (dbg); } } while(0)
|
||||
#define LOG3(x,y,z,zz) do { if (dbg) { fprintf (dbg, x, y, z, zz); fflush (dbg); } } while(0)
|
||||
#define LOG4(x,y,z,a,b) do { if (dbg) { fprintf (dbg, x, y, z, a, b); fflush (dbg); } } while(0)
|
||||
#define LOG5(x,y,z,a,b,c) do { if (dbg) { fprintf (dbg, x, y, z, a, b, c); fflush (dbg); } } while(0)
|
||||
extern FILE *dbg;
|
||||
#define VID_FILE_DEBUG 1
|
||||
#elif _DEBUG && 0
|
||||
#define STARTLOG
|
||||
#define STOPLOG
|
||||
#define LOG(x) { OutputDebugString(x); }
|
||||
#define LOG1(x,y) { char poo[1024]; mysnprintf(poo, countof(poo), x, y); OutputDebugString(poo); }
|
||||
#define LOG2(x,y,z) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z); OutputDebugString(poo); }
|
||||
#define LOG3(x,y,z,zz) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, zz); OutputDebugString(poo); }
|
||||
#define LOG4(x,y,z,a,b) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, a, b); OutputDebugString(poo); }
|
||||
#define LOG5(x,y,z,a,b,c) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, a, b, c); OutputDebugString(poo); }
|
||||
#else
|
||||
#define STARTLOG
|
||||
#define STOPLOG
|
||||
#define LOG(x)
|
||||
#define LOG1(x,y)
|
||||
#define LOG2(x,y,z)
|
||||
#define LOG3(x,y,z,zz)
|
||||
#define LOG4(x,y,z,a,b)
|
||||
#define LOG5(x,y,z,a,b,c)
|
||||
#endif
|
||||
|
||||
#endif // __WIN32IFACE_H
|
||||
|
|
411
src/win32/win32swiface.h
Normal file
411
src/win32/win32swiface.h
Normal file
|
@ -0,0 +1,411 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef DIRECTDRAW_VERSION
|
||||
#define DIRECTDRAW_VERSION 0x0300
|
||||
#endif
|
||||
#ifndef DIRECT3D_VERSION
|
||||
#define DIRECT3D_VERSION 0x0900
|
||||
#endif
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <ddraw.h>
|
||||
#include <d3d9.h>
|
||||
|
||||
#define SAFE_RELEASE(x) { if (x != NULL) { x->Release(); x = NULL; } }
|
||||
|
||||
extern HANDLE FPSLimitEvent;
|
||||
|
||||
class DDrawFB : public BaseWinFB
|
||||
{
|
||||
DECLARE_CLASS(DDrawFB, BaseWinFB)
|
||||
public:
|
||||
DDrawFB (int width, int height, bool fullscreen);
|
||||
~DDrawFB ();
|
||||
|
||||
bool IsValid ();
|
||||
bool Lock (bool buffer);
|
||||
void Unlock ();
|
||||
void ForceBuffering (bool force);
|
||||
void Update ();
|
||||
PalEntry *GetPalette ();
|
||||
void GetFlashedPalette (PalEntry pal[256]);
|
||||
void UpdatePalette ();
|
||||
bool SetGamma (float gamma);
|
||||
bool SetFlash (PalEntry rgb, int amount);
|
||||
void GetFlash (PalEntry &rgb, int &amount);
|
||||
int GetPageCount ();
|
||||
int QueryNewPalette ();
|
||||
void PaletteChanged ();
|
||||
void SetVSync (bool vsync);
|
||||
void NewRefreshRate();
|
||||
HRESULT GetHR ();
|
||||
bool Is8BitMode();
|
||||
virtual int GetTrueHeight() { return TrueHeight; }
|
||||
|
||||
void Blank ();
|
||||
bool PaintToWindow ();
|
||||
|
||||
private:
|
||||
enum LockSurfRes { NoGood, Good, GoodWasLost };
|
||||
|
||||
bool CreateResources ();
|
||||
void ReleaseResources ();
|
||||
bool CreateSurfacesAttached ();
|
||||
bool CreateSurfacesComplex ();
|
||||
bool CreateBlitterSource ();
|
||||
LockSurfRes LockSurf (LPRECT lockrect, LPDIRECTDRAWSURFACE surf);
|
||||
void RebuildColorTable ();
|
||||
void MaybeCreatePalette ();
|
||||
bool AddBackBuf (LPDIRECTDRAWSURFACE *surface, int num);
|
||||
HRESULT AttemptRestore ();
|
||||
|
||||
HRESULT LastHR;
|
||||
BYTE GammaTable[3][256];
|
||||
PalEntry SourcePalette[256];
|
||||
PALETTEENTRY PalEntries[256];
|
||||
DWORD FlipFlags;
|
||||
|
||||
LPDIRECTDRAWPALETTE Palette;
|
||||
LPDIRECTDRAWSURFACE PrimarySurf;
|
||||
LPDIRECTDRAWSURFACE BackSurf;
|
||||
LPDIRECTDRAWSURFACE BackSurf2;
|
||||
LPDIRECTDRAWSURFACE BlitSurf;
|
||||
LPDIRECTDRAWSURFACE LockingSurf;
|
||||
LPDIRECTDRAWCLIPPER Clipper;
|
||||
HPALETTE GDIPalette;
|
||||
DWORD ClipSize;
|
||||
PalEntry Flash;
|
||||
int FlashAmount;
|
||||
int BufferCount;
|
||||
int BufferPitch;
|
||||
int TrueHeight;
|
||||
int PixelDoubling;
|
||||
float Gamma;
|
||||
|
||||
bool NeedGammaUpdate;
|
||||
bool NeedPalUpdate;
|
||||
bool NeedResRecreate;
|
||||
bool PaletteChangeExpected;
|
||||
bool MustBuffer; // The screen is not 8-bit, or there is no backbuffer
|
||||
bool BufferingNow; // Most recent Lock was buffered
|
||||
bool WasBuffering; // Second most recent Lock was buffered
|
||||
bool Write8bit;
|
||||
bool UpdatePending; // On final unlock, call Update()
|
||||
bool UseBlitter; // Use blitter to copy from sys mem to video mem
|
||||
bool UsePfx;
|
||||
|
||||
DDrawFB() {}
|
||||
};
|
||||
|
||||
class D3DFB : public BaseWinFB
|
||||
{
|
||||
DECLARE_CLASS(D3DFB, BaseWinFB)
|
||||
public:
|
||||
D3DFB (UINT adapter, int width, int height, bool fullscreen);
|
||||
~D3DFB ();
|
||||
|
||||
bool IsValid ();
|
||||
bool Lock (bool buffered);
|
||||
void Unlock ();
|
||||
void Update ();
|
||||
void Flip ();
|
||||
PalEntry *GetPalette ();
|
||||
void GetFlashedPalette (PalEntry palette[256]);
|
||||
void UpdatePalette ();
|
||||
bool SetGamma (float gamma);
|
||||
bool SetFlash (PalEntry rgb, int amount);
|
||||
void GetFlash (PalEntry &rgb, int &amount);
|
||||
int GetPageCount ();
|
||||
bool IsFullscreen ();
|
||||
void PaletteChanged ();
|
||||
int QueryNewPalette ();
|
||||
void Blank ();
|
||||
bool PaintToWindow ();
|
||||
void SetVSync (bool vsync);
|
||||
void NewRefreshRate();
|
||||
void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type);
|
||||
void ReleaseScreenshotBuffer();
|
||||
void SetBlendingRect (int x1, int y1, int x2, int y2);
|
||||
bool Begin2D (bool copy3d);
|
||||
void DrawBlendingRect ();
|
||||
FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping);
|
||||
FNativePalette *CreatePalette (FRemapTable *remap);
|
||||
void DrawTextureParms (FTexture *img, DrawParms &parms);
|
||||
void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color);
|
||||
void Dim (PalEntry color, float amount, int x1, int y1, int w, int h);
|
||||
void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin);
|
||||
void DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor);
|
||||
void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor);
|
||||
void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
|
||||
double originx, double originy, double scalex, double scaley,
|
||||
DAngle rotation, FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip) override;
|
||||
bool WipeStartScreen(int type);
|
||||
void WipeEndScreen();
|
||||
bool WipeDo(int ticks);
|
||||
void WipeCleanup();
|
||||
HRESULT GetHR ();
|
||||
bool Is8BitMode() { return false; }
|
||||
virtual int GetTrueHeight() { return TrueHeight; }
|
||||
|
||||
private:
|
||||
friend class D3DTex;
|
||||
friend class D3DPal;
|
||||
|
||||
struct PackedTexture;
|
||||
struct Atlas;
|
||||
|
||||
struct FBVERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw;
|
||||
D3DCOLOR color0, color1;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
#define D3DFVF_FBVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1)
|
||||
|
||||
struct BufferedTris
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
BYTE Flags;
|
||||
BYTE ShaderNum:4;
|
||||
BYTE BlendOp:4;
|
||||
BYTE SrcBlend, DestBlend;
|
||||
};
|
||||
DWORD Group1;
|
||||
};
|
||||
BYTE Desat;
|
||||
D3DPal *Palette;
|
||||
IDirect3DTexture9 *Texture;
|
||||
int NumVerts; // Number of _unique_ vertices used by this set.
|
||||
int NumTris; // Number of triangles used by this set.
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PSCONST_Desaturation = 1,
|
||||
PSCONST_PaletteMod = 2,
|
||||
PSCONST_Weights = 6,
|
||||
PSCONST_Gamma = 7,
|
||||
};
|
||||
enum
|
||||
{
|
||||
SHADER_NormalColor,
|
||||
SHADER_NormalColorPal,
|
||||
SHADER_NormalColorInv,
|
||||
SHADER_NormalColorPalInv,
|
||||
|
||||
SHADER_RedToAlpha,
|
||||
SHADER_RedToAlphaInv,
|
||||
|
||||
SHADER_VertexColor,
|
||||
|
||||
SHADER_SpecialColormap,
|
||||
SHADER_SpecialColormapPal,
|
||||
|
||||
SHADER_InGameColormap,
|
||||
SHADER_InGameColormapDesat,
|
||||
SHADER_InGameColormapInv,
|
||||
SHADER_InGameColormapInvDesat,
|
||||
SHADER_InGameColormapPal,
|
||||
SHADER_InGameColormapPalDesat,
|
||||
SHADER_InGameColormapPalInv,
|
||||
SHADER_InGameColormapPalInvDesat,
|
||||
|
||||
SHADER_BurnWipe,
|
||||
SHADER_GammaCorrection,
|
||||
|
||||
NUM_SHADERS
|
||||
};
|
||||
static const char *const ShaderNames[NUM_SHADERS];
|
||||
|
||||
void SetInitialState();
|
||||
bool CreateResources();
|
||||
void ReleaseResources();
|
||||
bool LoadShaders();
|
||||
void CreateBlockSurfaces();
|
||||
bool CreateFBTexture();
|
||||
bool CreatePaletteTexture();
|
||||
bool CreateGammaTexture();
|
||||
bool CreateVertexes();
|
||||
void DoOffByOneCheck();
|
||||
void UploadPalette();
|
||||
void UpdateGammaTexture(float igamma);
|
||||
void FillPresentParameters (D3DPRESENT_PARAMETERS *pp, bool fullscreen, bool vsync);
|
||||
void CalcFullscreenCoords (FBVERTEX verts[4], bool viewarea_only, bool can_double, D3DCOLOR color0, D3DCOLOR color1) const;
|
||||
bool Reset();
|
||||
IDirect3DTexture9 *GetCurrentScreen(D3DPOOL pool=D3DPOOL_SYSTEMMEM);
|
||||
void ReleaseDefaultPoolItems();
|
||||
void KillNativePals();
|
||||
void KillNativeTexs();
|
||||
PackedTexture *AllocPackedTexture(int width, int height, bool wrapping, D3DFORMAT format);
|
||||
void DrawPackedTextures(int packnum);
|
||||
void DrawLetterbox();
|
||||
void Draw3DPart(bool copy3d);
|
||||
bool SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1, BufferedTris &quad);
|
||||
static D3DBLEND GetStyleAlpha(int type);
|
||||
static void SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1);
|
||||
void DoWindowedGamma();
|
||||
void AddColorOnlyQuad(int left, int top, int width, int height, D3DCOLOR color);
|
||||
void AddColorOnlyRect(int left, int top, int width, int height, D3DCOLOR color);
|
||||
void CheckQuadBatch(int numtris=2, int numverts=4);
|
||||
void BeginQuadBatch();
|
||||
void EndQuadBatch();
|
||||
void BeginLineBatch();
|
||||
void EndLineBatch();
|
||||
void EndBatch();
|
||||
void CopyNextFrontBuffer();
|
||||
|
||||
D3DCAPS9 DeviceCaps;
|
||||
|
||||
// State
|
||||
void EnableAlphaTest(BOOL enabled);
|
||||
void SetAlphaBlend(D3DBLENDOP op, D3DBLEND srcblend=D3DBLEND(0), D3DBLEND destblend=D3DBLEND(0));
|
||||
void SetConstant(int cnum, float r, float g, float b, float a);
|
||||
void SetPixelShader(IDirect3DPixelShader9 *shader);
|
||||
void SetTexture(int tnum, IDirect3DTexture9 *texture);
|
||||
void SetPaletteTexture(IDirect3DTexture9 *texture, int count, D3DCOLOR border_color);
|
||||
void SetPalTexBilinearConstants(Atlas *texture);
|
||||
|
||||
BOOL AlphaTestEnabled;
|
||||
BOOL AlphaBlendEnabled;
|
||||
D3DBLENDOP AlphaBlendOp;
|
||||
D3DBLEND AlphaSrcBlend;
|
||||
D3DBLEND AlphaDestBlend;
|
||||
float Constant[3][4];
|
||||
D3DCOLOR CurBorderColor;
|
||||
IDirect3DPixelShader9 *CurPixelShader;
|
||||
IDirect3DTexture9 *Texture[5];
|
||||
|
||||
PalEntry SourcePalette[256];
|
||||
D3DCOLOR BorderColor;
|
||||
D3DCOLOR FlashColor0, FlashColor1;
|
||||
PalEntry FlashColor;
|
||||
int FlashAmount;
|
||||
int TrueHeight;
|
||||
int PixelDoubling;
|
||||
int SkipAt;
|
||||
int LBOffsetI;
|
||||
int RenderTextureToggle;
|
||||
int CurrRenderTexture;
|
||||
float LBOffset;
|
||||
float Gamma;
|
||||
bool UpdatePending;
|
||||
bool NeedPalUpdate;
|
||||
bool NeedGammaUpdate;
|
||||
int FBWidth, FBHeight;
|
||||
bool VSync;
|
||||
RECT BlendingRect;
|
||||
int In2D;
|
||||
bool InScene;
|
||||
bool SM14;
|
||||
bool GatheringWipeScreen;
|
||||
bool AALines;
|
||||
BYTE BlockNum;
|
||||
D3DPal *Palettes;
|
||||
D3DTex *Textures;
|
||||
Atlas *Atlases;
|
||||
HRESULT LastHR;
|
||||
|
||||
UINT Adapter;
|
||||
IDirect3DDevice9 *D3DDevice;
|
||||
IDirect3DTexture9 *FBTexture;
|
||||
IDirect3DTexture9 *TempRenderTexture, *RenderTexture[2];
|
||||
IDirect3DTexture9 *PaletteTexture;
|
||||
IDirect3DTexture9 *GammaTexture;
|
||||
IDirect3DTexture9 *ScreenshotTexture;
|
||||
IDirect3DSurface9 *ScreenshotSurface;
|
||||
IDirect3DSurface9 *FrontCopySurface;
|
||||
|
||||
IDirect3DVertexBuffer9 *VertexBuffer;
|
||||
FBVERTEX *VertexData;
|
||||
IDirect3DIndexBuffer9 *IndexBuffer;
|
||||
uint16_t *IndexData;
|
||||
BufferedTris *QuadExtra;
|
||||
int VertexPos;
|
||||
int IndexPos;
|
||||
int QuadBatchPos;
|
||||
enum { BATCH_None, BATCH_Quads, BATCH_Lines } BatchType;
|
||||
|
||||
IDirect3DPixelShader9 *Shaders[NUM_SHADERS];
|
||||
IDirect3DPixelShader9 *GammaShader;
|
||||
|
||||
IDirect3DSurface9 *BlockSurface[2];
|
||||
IDirect3DSurface9 *OldRenderTarget;
|
||||
IDirect3DTexture9 *InitialWipeScreen, *FinalWipeScreen;
|
||||
|
||||
D3DFB() {}
|
||||
|
||||
class Wiper
|
||||
{
|
||||
public:
|
||||
virtual ~Wiper();
|
||||
virtual bool Run(int ticks, D3DFB *fb) = 0;
|
||||
|
||||
void DrawScreen(D3DFB *fb, IDirect3DTexture9 *tex,
|
||||
D3DBLENDOP blendop=D3DBLENDOP(0), D3DCOLOR color0=0, D3DCOLOR color1=0xFFFFFFF);
|
||||
};
|
||||
|
||||
class Wiper_Melt; friend class Wiper_Melt;
|
||||
class Wiper_Burn; friend class Wiper_Burn;
|
||||
class Wiper_Crossfade; friend class Wiper_Crossfade;
|
||||
|
||||
Wiper *ScreenWipe;
|
||||
};
|
||||
|
||||
// Flags for a buffered quad
|
||||
enum
|
||||
{
|
||||
BQF_GamePalette = 1,
|
||||
BQF_CustomPalette = 7,
|
||||
BQF_Paletted = 7,
|
||||
BQF_Bilinear = 8,
|
||||
BQF_WrapUV = 16,
|
||||
BQF_InvertSource = 32,
|
||||
BQF_DisableAlphaTest= 64,
|
||||
BQF_Desaturated = 128,
|
||||
};
|
||||
|
||||
// Shaders for a buffered quad
|
||||
enum
|
||||
{
|
||||
BQS_PalTex,
|
||||
BQS_Plain,
|
||||
BQS_RedToAlpha,
|
||||
BQS_ColorOnly,
|
||||
BQS_SpecialColormap,
|
||||
BQS_InGameColormap,
|
||||
};
|
||||
|
||||
#if 0
|
||||
#define STARTLOG do { if (!dbg) dbg = fopen ("e:/vid.log", "w"); } while(0)
|
||||
#define STOPLOG do { if (dbg) { fclose (dbg); dbg=NULL; } } while(0)
|
||||
#define LOG(x) do { if (dbg) { fprintf (dbg, x); fflush (dbg); } } while(0)
|
||||
#define LOG1(x,y) do { if (dbg) { fprintf (dbg, x, y); fflush (dbg); } } while(0)
|
||||
#define LOG2(x,y,z) do { if (dbg) { fprintf (dbg, x, y, z); fflush (dbg); } } while(0)
|
||||
#define LOG3(x,y,z,zz) do { if (dbg) { fprintf (dbg, x, y, z, zz); fflush (dbg); } } while(0)
|
||||
#define LOG4(x,y,z,a,b) do { if (dbg) { fprintf (dbg, x, y, z, a, b); fflush (dbg); } } while(0)
|
||||
#define LOG5(x,y,z,a,b,c) do { if (dbg) { fprintf (dbg, x, y, z, a, b, c); fflush (dbg); } } while(0)
|
||||
extern FILE *dbg;
|
||||
#define VID_FILE_DEBUG 1
|
||||
#elif _DEBUG && 0
|
||||
#define STARTLOG
|
||||
#define STOPLOG
|
||||
#define LOG(x) { OutputDebugString(x); }
|
||||
#define LOG1(x,y) { char poo[1024]; mysnprintf(poo, countof(poo), x, y); OutputDebugString(poo); }
|
||||
#define LOG2(x,y,z) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z); OutputDebugString(poo); }
|
||||
#define LOG3(x,y,z,zz) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, zz); OutputDebugString(poo); }
|
||||
#define LOG4(x,y,z,a,b) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, a, b); OutputDebugString(poo); }
|
||||
#define LOG5(x,y,z,a,b,c) { char poo[1024]; mysnprintf(poo, countof(poo), x, y, z, a, b, c); OutputDebugString(poo); }
|
||||
#else
|
||||
#define STARTLOG
|
||||
#define STOPLOG
|
||||
#define LOG(x)
|
||||
#define LOG1(x,y)
|
||||
#define LOG2(x,y,z)
|
||||
#define LOG3(x,y,z,zz)
|
||||
#define LOG4(x,y,z,a,b)
|
||||
#define LOG5(x,y,z,a,b,c)
|
||||
#endif
|
|
@ -73,6 +73,7 @@
|
|||
#include "version.h"
|
||||
|
||||
#include "win32iface.h"
|
||||
#include "win32swiface.h"
|
||||
|
||||
#include "optwin32.h"
|
||||
|
||||
|
@ -223,8 +224,8 @@ bool Win32Video::InitD3D9 ()
|
|||
|
||||
// Enumerate available display modes.
|
||||
FreeModes ();
|
||||
AddD3DModes (m_Adapter, D3DFMT_X8R8G8B8);
|
||||
AddD3DModes (m_Adapter, D3DFMT_R5G6B5);
|
||||
AddD3DModes (m_Adapter);
|
||||
AddD3DModes (m_Adapter);
|
||||
if (Args->CheckParm ("-2"))
|
||||
{ // Force all modes to be pixel-doubled.
|
||||
ScaleModes (1);
|
||||
|
@ -253,6 +254,12 @@ closelib:
|
|||
return false;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI EnumDDModesCB(LPDDSURFACEDESC desc, void *data)
|
||||
{
|
||||
((Win32Video *)data)->AddMode(desc->dwWidth, desc->dwHeight, 8, desc->dwHeight, 0);
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
void Win32Video::InitDDraw ()
|
||||
{
|
||||
DIRECTDRAWCREATEFUNC directdraw_create;
|
||||
|
@ -436,23 +443,20 @@ void Win32Video::DumpAdapters()
|
|||
|
||||
// Mode enumeration --------------------------------------------------------
|
||||
|
||||
HRESULT WINAPI Win32Video::EnumDDModesCB (LPDDSURFACEDESC desc, void *data)
|
||||
void Win32Video::AddD3DModes (unsigned adapter)
|
||||
{
|
||||
((Win32Video *)data)->AddMode (desc->dwWidth, desc->dwHeight, 8, desc->dwHeight, 0);
|
||||
return DDENUMRET_OK;
|
||||
}
|
||||
|
||||
void Win32Video::AddD3DModes (UINT adapter, D3DFORMAT format)
|
||||
{
|
||||
UINT modecount, i;
|
||||
D3DDISPLAYMODE mode;
|
||||
|
||||
modecount = D3D->GetAdapterModeCount (adapter, format);
|
||||
for (i = 0; i < modecount; ++i)
|
||||
for (D3DFORMAT format : { D3DFMT_X8R8G8B8, D3DFMT_R5G6B5})
|
||||
{
|
||||
if (D3D_OK == D3D->EnumAdapterModes (adapter, format, i, &mode))
|
||||
UINT modecount, i;
|
||||
D3DDISPLAYMODE mode;
|
||||
|
||||
modecount = D3D->GetAdapterModeCount(adapter, format);
|
||||
for (i = 0; i < modecount; ++i)
|
||||
{
|
||||
AddMode (mode.Width, mode.Height, 8, mode.Height, 0);
|
||||
if (D3D_OK == D3D->EnumAdapterModes(adapter, format, i, &mode))
|
||||
{
|
||||
AddMode(mode.Width, mode.Height, 8, mode.Height, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -841,3 +845,11 @@ static void StopFPSLimit()
|
|||
{
|
||||
I_SetFPSLimit(0);
|
||||
}
|
||||
|
||||
void I_FPSLimit()
|
||||
{
|
||||
if (FPSLimitEvent != NULL)
|
||||
{
|
||||
WaitForSingleObject(FPSLimitEvent, 1000);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue