forked from Mirrors/openclonk
OpenGL/D3D: Remove some remains from the DirectDraw days
Mostly error messages, debug output and function names, but still.stable-5.2
parent
8da93e68dd
commit
d7de58b7ad
|
@ -155,7 +155,6 @@ class CStdD3D : public CStdDDraw
|
|||
BOOL FindDisplayMode(unsigned int iXRes, unsigned int iYRes, D3DFORMAT format, unsigned int iMonitor);
|
||||
virtual bool CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
|
||||
bool SetOutputAdapter(unsigned int iMonitor);
|
||||
BOOL CreateDirectDraw();
|
||||
inline bool HasShaders() const { return !!pShaders[0]; }
|
||||
|
||||
|
||||
|
|
|
@ -367,7 +367,6 @@ class CStdDDraw
|
|||
bool CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes);
|
||||
virtual bool CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor) = 0;
|
||||
bool Error(const char *szMsg);
|
||||
virtual BOOL CreateDirectDraw() = 0;
|
||||
void DebugLog(const char *szMsg)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
|
|
@ -145,7 +145,6 @@ class CStdGL : public CStdDDraw
|
|||
|
||||
protected:
|
||||
bool CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
|
||||
BOOL CreateDirectDraw();
|
||||
|
||||
bool CheckGLError(const char *szAtOp);
|
||||
#ifdef USE_X11
|
||||
|
|
|
@ -26,7 +26,6 @@ class CStdNoGfx : public CStdDDraw
|
|||
public:
|
||||
CStdNoGfx();
|
||||
virtual ~CStdNoGfx();
|
||||
virtual BOOL CreateDirectDraw();
|
||||
public:
|
||||
virtual bool PageFlip(RECT *pSrcRt=NULL, RECT *pDstRt=NULL, CStdWindow * pWindow = NULL) { return true; }
|
||||
virtual bool BeginScene() { return true; }
|
||||
|
|
|
@ -81,12 +81,6 @@ void CStdD3D::Clear()
|
|||
|
||||
/* Direct3D initialization */
|
||||
|
||||
BOOL CStdD3D::CreateDirectDraw()
|
||||
{
|
||||
if ((lpD3D=Direct3DCreate9(D3D_SDK_VERSION))==NULL) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool CStdD3D::PageFlip(RECT *pSrcRt, RECT *pDstRt, CStdWindow * pWindow)
|
||||
{
|
||||
// call from gfx thread only!
|
||||
|
@ -485,20 +479,20 @@ BOOL CStdD3D::FindDisplayMode(unsigned int iXRes, unsigned int iYRes, D3DFORMAT
|
|||
|
||||
bool CStdD3D::SetOutputAdapter(unsigned int iMonitor)
|
||||
{
|
||||
// set var
|
||||
//pApp->Monitor = iMonitor;
|
||||
// get associated monitor rect
|
||||
HMONITOR hMon = lpD3D->GetAdapterMonitor(iMonitor);
|
||||
if (!hMon) return false;
|
||||
if (!hMon) return Error("GetAdapterMonitor error");
|
||||
MONITORINFO nfo; ZeroMemory(&nfo, sizeof(nfo));
|
||||
nfo.cbSize = sizeof(MONITORINFO);
|
||||
if (!GetMonitorInfo(hMon, &nfo)) return false;
|
||||
//pApp->MonitorRect = nfo.rcMonitor;
|
||||
if (!GetMonitorInfo(hMon, &nfo)) return Error("GetMonitorInfo error");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CStdD3D::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor)
|
||||
{
|
||||
DebugLog("Init DX");
|
||||
DebugLog(" Create Direct3D9...");
|
||||
if ((lpD3D=Direct3DCreate9(D3D_SDK_VERSION))==NULL) return Error(" Direct3DCreate9 failure.");
|
||||
// set monitor info (Monitor-var and target rect)
|
||||
DebugLog(" SetOutput adapter...");
|
||||
if (!SetOutputAdapter(iMonitor))
|
||||
|
@ -514,6 +508,7 @@ bool CStdD3D::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigne
|
|||
|
||||
HRESULT hr;
|
||||
HWND hWindow = pApp->pWindow->hWindow;
|
||||
DebugLog(" Create Device...");
|
||||
if (Fullscreen)
|
||||
{
|
||||
// fullscreen mode
|
||||
|
@ -582,15 +577,15 @@ bool CStdD3D::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigne
|
|||
}
|
||||
switch (hr)
|
||||
{
|
||||
case D3DERR_INVALIDCALL: return Error(" CreateDevice: D3DERR_INVALIDCALL");
|
||||
case D3DERR_NOTAVAILABLE: return Error(" CreateDevice: D3DERR_NOTAVAILABLE");
|
||||
case D3DERR_OUTOFVIDEOMEMORY: return Error(" CreateDevice: D3DERR_OUTOFVIDEOMEMORY");
|
||||
case D3DERR_DRIVERINTERNALERROR: return Error(" CreateDevice: D3DERR_DRIVERINTERNALERROR");
|
||||
case D3DERR_INVALIDCALL: return Error("CreateDevice: D3DERR_INVALIDCALL");
|
||||
case D3DERR_NOTAVAILABLE: return Error("CreateDevice: D3DERR_NOTAVAILABLE");
|
||||
case D3DERR_OUTOFVIDEOMEMORY: return Error("CreateDevice: D3DERR_OUTOFVIDEOMEMORY");
|
||||
case D3DERR_DRIVERINTERNALERROR: return Error("CreateDevice: D3DERR_DRIVERINTERNALERROR");
|
||||
case D3D_OK: break;
|
||||
default: return Error(" CreateDevice: unknown error");
|
||||
default: return Error("CreateDevice: unknown error");
|
||||
}
|
||||
// device successfully created?
|
||||
if (!lpDevice) return FALSE;
|
||||
if (!lpDevice) return Error("CreateDevice: unreported error");
|
||||
// store color depth
|
||||
byByteCnt=iColorDepth/8;
|
||||
PrimarySrfcFormat=d3dpp.BackBufferFormat;
|
||||
|
@ -611,7 +606,7 @@ bool CStdD3D::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigne
|
|||
return FALSE;
|
||||
}
|
||||
// update monitor rect by new screen size
|
||||
if (!SetOutputAdapter(iMonitor)) return FALSE;
|
||||
if (!SetOutputAdapter(iMonitor)) return false;
|
||||
// success!
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1696,16 +1696,8 @@ bool CStdDDraw::Init(CStdApp * pApp, BOOL Fullscreen, BOOL fUsePageLock, unsigne
|
|||
// store default gamma
|
||||
SaveDefaultGammaRamp(pApp->pWindow);
|
||||
|
||||
DebugLog("Init DX");
|
||||
DebugLog(" Create DirectDraw...");
|
||||
|
||||
if (!CreateDirectDraw())
|
||||
return Error(" CreateDirectDraw failure.");
|
||||
|
||||
DebugLog(" Create Device...");
|
||||
|
||||
if (!CreatePrimarySurfaces(Fullscreen, iXRes, iYRes, iBitDepth, iMonitor))
|
||||
return Error(" CreateDevice failure.");
|
||||
return false;
|
||||
|
||||
DebugLog(" Create Clipper");
|
||||
|
||||
|
|
|
@ -519,14 +519,9 @@ void CStdGL::BlitLandscape(SURFACE sfcSource, float fx, float fy,
|
|||
ResetTexture();
|
||||
}
|
||||
|
||||
BOOL CStdGL::CreateDirectDraw()
|
||||
{
|
||||
Log(" Using OpenGL...");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CStdGLCtx *CStdGL::CreateContext(CStdWindow * pWindow, CStdApp *pApp)
|
||||
{
|
||||
DebugLog(" gl: Create Context...");
|
||||
// safety
|
||||
if (!pWindow) return NULL;
|
||||
// create it
|
||||
|
@ -535,8 +530,6 @@ CStdGLCtx *CStdGL::CreateContext(CStdWindow * pWindow, CStdApp *pApp)
|
|||
{
|
||||
delete pCtx; Error(" gl: Error creating secondary context!"); return NULL;
|
||||
}
|
||||
// reselect current context
|
||||
//if (pCurrCtx) pCurrCtx->Select(); else pCurrCtx=pCtx;
|
||||
// done
|
||||
return pCtx;
|
||||
}
|
||||
|
@ -552,8 +545,6 @@ CStdGLCtx *CStdGL::CreateContext(HWND hWindow, CStdApp *pApp)
|
|||
{
|
||||
delete pCtx; Error(" gl: Error creating secondary context!"); return NULL;
|
||||
}
|
||||
// reselect current context
|
||||
//if (pCurrCtx) pCurrCtx->Select(); else pCurrCtx=pCtx;
|
||||
// done
|
||||
return pCtx;
|
||||
}
|
||||
|
@ -564,6 +555,7 @@ bool CStdGL::CreatePrimarySurfaces(BOOL Playermode, unsigned int iXRes, unsigned
|
|||
//remember fullscreen setting
|
||||
fFullscreen = Playermode && !DDrawCfg.Windowed;
|
||||
|
||||
DebugLog(" gl: SetVideoMode...");
|
||||
// Set window size only in playermode
|
||||
if (Playermode)
|
||||
{
|
||||
|
@ -589,6 +581,7 @@ bool CStdGL::CreatePrimarySurfaces(BOOL Playermode, unsigned int iXRes, unsigned
|
|||
lpPrimary->byBytesPP=byByteCnt;
|
||||
|
||||
// create+select gl context
|
||||
DebugLog(" gl: Create Main Context...");
|
||||
if (!MainCtx.Init(pApp->pWindow, pApp)) return Error(" gl: Error initializing context");
|
||||
|
||||
// BGRA Pixel Formats, Multitexturing, Texture Combine Environment Modes
|
||||
|
@ -771,16 +764,13 @@ bool CStdGL::RestoreDeviceObjects()
|
|||
if (!lpPrimary) return false;
|
||||
// delete any previous objects
|
||||
InvalidateDeviceObjects();
|
||||
bool fSuccess=true;
|
||||
// restore primary/back
|
||||
RenderTarget=lpPrimary;
|
||||
//lpPrimary->AttachSfc(NULL);
|
||||
lpPrimary->byBytesPP=byByteCnt;
|
||||
|
||||
// set states
|
||||
fSuccess = pCurrCtx ? (pCurrCtx->Select()) : MainCtx.Select();
|
||||
// activate if successful
|
||||
Active=fSuccess;
|
||||
Active = pCurrCtx ? (pCurrCtx->Select()) : MainCtx.Select();
|
||||
// restore gamma if active
|
||||
if (Active)
|
||||
EnableGamma();
|
||||
|
@ -937,7 +927,7 @@ void CStdGL::TaskOut()
|
|||
// deactivate
|
||||
// backup textures
|
||||
if (pTexMgr && fFullscreen) pTexMgr->IntLock();
|
||||
// shotdown gl
|
||||
// shutdown gl
|
||||
InvalidateDeviceObjects();
|
||||
if (pCurrCtx) pCurrCtx->Deselect();
|
||||
}
|
||||
|
|
|
@ -17,12 +17,6 @@
|
|||
#include <Standard.h>
|
||||
#include <StdNoGfx.h>
|
||||
|
||||
BOOL CStdNoGfx::CreateDirectDraw()
|
||||
{
|
||||
Log(" Graphics disabled");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CStdNoGfx::CStdNoGfx()
|
||||
{
|
||||
Default();
|
||||
|
@ -36,6 +30,7 @@ CStdNoGfx::~CStdNoGfx()
|
|||
|
||||
bool CStdNoGfx::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor)
|
||||
{
|
||||
Log("Graphics disabled.");
|
||||
// Save back color depth
|
||||
byByteCnt = iColorDepth / 8;
|
||||
// Create dummy surface
|
||||
|
|
Loading…
Reference in New Issue