OpenGL/D3D: Remove some remains from the DirectDraw days

Mostly error messages, debug output and function names, but still.
stable-5.2
Günther Brammer 2009-06-03 01:59:04 +02:00
parent 8da93e68dd
commit d7de58b7ad
8 changed files with 20 additions and 52 deletions

View File

@ -155,7 +155,6 @@ class CStdD3D : public CStdDDraw
BOOL FindDisplayMode(unsigned int iXRes, unsigned int iYRes, D3DFORMAT format, unsigned int iMonitor); 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); virtual bool CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
bool SetOutputAdapter(unsigned int iMonitor); bool SetOutputAdapter(unsigned int iMonitor);
BOOL CreateDirectDraw();
inline bool HasShaders() const { return !!pShaders[0]; } inline bool HasShaders() const { return !!pShaders[0]; }

View File

@ -367,7 +367,6 @@ class CStdDDraw
bool CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes); 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; virtual bool CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor) = 0;
bool Error(const char *szMsg); bool Error(const char *szMsg);
virtual BOOL CreateDirectDraw() = 0;
void DebugLog(const char *szMsg) void DebugLog(const char *szMsg)
{ {
#ifdef _DEBUG #ifdef _DEBUG

View File

@ -145,7 +145,6 @@ class CStdGL : public CStdDDraw
protected: protected:
bool CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor); bool CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
BOOL CreateDirectDraw();
bool CheckGLError(const char *szAtOp); bool CheckGLError(const char *szAtOp);
#ifdef USE_X11 #ifdef USE_X11

View File

@ -26,7 +26,6 @@ class CStdNoGfx : public CStdDDraw
public: public:
CStdNoGfx(); CStdNoGfx();
virtual ~CStdNoGfx(); virtual ~CStdNoGfx();
virtual BOOL CreateDirectDraw();
public: public:
virtual bool PageFlip(RECT *pSrcRt=NULL, RECT *pDstRt=NULL, CStdWindow * pWindow = NULL) { return true; } virtual bool PageFlip(RECT *pSrcRt=NULL, RECT *pDstRt=NULL, CStdWindow * pWindow = NULL) { return true; }
virtual bool BeginScene() { return true; } virtual bool BeginScene() { return true; }

View File

@ -81,12 +81,6 @@ void CStdD3D::Clear()
/* Direct3D initialization */ /* 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) bool CStdD3D::PageFlip(RECT *pSrcRt, RECT *pDstRt, CStdWindow * pWindow)
{ {
// call from gfx thread only! // 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) bool CStdD3D::SetOutputAdapter(unsigned int iMonitor)
{ {
// set var
//pApp->Monitor = iMonitor;
// get associated monitor rect // get associated monitor rect
HMONITOR hMon = lpD3D->GetAdapterMonitor(iMonitor); HMONITOR hMon = lpD3D->GetAdapterMonitor(iMonitor);
if (!hMon) return false; if (!hMon) return Error("GetAdapterMonitor error");
MONITORINFO nfo; ZeroMemory(&nfo, sizeof(nfo)); MONITORINFO nfo; ZeroMemory(&nfo, sizeof(nfo));
nfo.cbSize = sizeof(MONITORINFO); nfo.cbSize = sizeof(MONITORINFO);
if (!GetMonitorInfo(hMon, &nfo)) return false; if (!GetMonitorInfo(hMon, &nfo)) return Error("GetMonitorInfo error");
//pApp->MonitorRect = nfo.rcMonitor;
return true; return true;
} }
bool CStdD3D::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor) 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) // set monitor info (Monitor-var and target rect)
DebugLog(" SetOutput adapter..."); DebugLog(" SetOutput adapter...");
if (!SetOutputAdapter(iMonitor)) if (!SetOutputAdapter(iMonitor))
@ -514,6 +508,7 @@ bool CStdD3D::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigne
HRESULT hr; HRESULT hr;
HWND hWindow = pApp->pWindow->hWindow; HWND hWindow = pApp->pWindow->hWindow;
DebugLog(" Create Device...");
if (Fullscreen) if (Fullscreen)
{ {
// fullscreen mode // fullscreen mode
@ -582,15 +577,15 @@ bool CStdD3D::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigne
} }
switch (hr) switch (hr)
{ {
case D3DERR_INVALIDCALL: return Error(" CreateDevice: D3DERR_INVALIDCALL"); case D3DERR_INVALIDCALL: return Error("CreateDevice: D3DERR_INVALIDCALL");
case D3DERR_NOTAVAILABLE: return Error(" CreateDevice: D3DERR_NOTAVAILABLE"); case D3DERR_NOTAVAILABLE: return Error("CreateDevice: D3DERR_NOTAVAILABLE");
case D3DERR_OUTOFVIDEOMEMORY: return Error(" CreateDevice: D3DERR_OUTOFVIDEOMEMORY"); case D3DERR_OUTOFVIDEOMEMORY: return Error("CreateDevice: D3DERR_OUTOFVIDEOMEMORY");
case D3DERR_DRIVERINTERNALERROR: return Error(" CreateDevice: D3DERR_DRIVERINTERNALERROR"); case D3DERR_DRIVERINTERNALERROR: return Error("CreateDevice: D3DERR_DRIVERINTERNALERROR");
case D3D_OK: break; case D3D_OK: break;
default: return Error(" CreateDevice: unknown error"); default: return Error("CreateDevice: unknown error");
} }
// device successfully created? // device successfully created?
if (!lpDevice) return FALSE; if (!lpDevice) return Error("CreateDevice: unreported error");
// store color depth // store color depth
byByteCnt=iColorDepth/8; byByteCnt=iColorDepth/8;
PrimarySrfcFormat=d3dpp.BackBufferFormat; PrimarySrfcFormat=d3dpp.BackBufferFormat;
@ -611,7 +606,7 @@ bool CStdD3D::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigne
return FALSE; return FALSE;
} }
// update monitor rect by new screen size // update monitor rect by new screen size
if (!SetOutputAdapter(iMonitor)) return FALSE; if (!SetOutputAdapter(iMonitor)) return false;
// success! // success!
return TRUE; return TRUE;
} }

View File

@ -1696,16 +1696,8 @@ bool CStdDDraw::Init(CStdApp * pApp, BOOL Fullscreen, BOOL fUsePageLock, unsigne
// store default gamma // store default gamma
SaveDefaultGammaRamp(pApp->pWindow); 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)) if (!CreatePrimarySurfaces(Fullscreen, iXRes, iYRes, iBitDepth, iMonitor))
return Error(" CreateDevice failure."); return false;
DebugLog(" Create Clipper"); DebugLog(" Create Clipper");

View File

@ -519,14 +519,9 @@ void CStdGL::BlitLandscape(SURFACE sfcSource, float fx, float fy,
ResetTexture(); ResetTexture();
} }
BOOL CStdGL::CreateDirectDraw()
{
Log(" Using OpenGL...");
return TRUE;
}
CStdGLCtx *CStdGL::CreateContext(CStdWindow * pWindow, CStdApp *pApp) CStdGLCtx *CStdGL::CreateContext(CStdWindow * pWindow, CStdApp *pApp)
{ {
DebugLog(" gl: Create Context...");
// safety // safety
if (!pWindow) return NULL; if (!pWindow) return NULL;
// create it // create it
@ -535,8 +530,6 @@ CStdGLCtx *CStdGL::CreateContext(CStdWindow * pWindow, CStdApp *pApp)
{ {
delete pCtx; Error(" gl: Error creating secondary context!"); return NULL; delete pCtx; Error(" gl: Error creating secondary context!"); return NULL;
} }
// reselect current context
//if (pCurrCtx) pCurrCtx->Select(); else pCurrCtx=pCtx;
// done // done
return pCtx; return pCtx;
} }
@ -552,8 +545,6 @@ CStdGLCtx *CStdGL::CreateContext(HWND hWindow, CStdApp *pApp)
{ {
delete pCtx; Error(" gl: Error creating secondary context!"); return NULL; delete pCtx; Error(" gl: Error creating secondary context!"); return NULL;
} }
// reselect current context
//if (pCurrCtx) pCurrCtx->Select(); else pCurrCtx=pCtx;
// done // done
return pCtx; return pCtx;
} }
@ -564,6 +555,7 @@ bool CStdGL::CreatePrimarySurfaces(BOOL Playermode, unsigned int iXRes, unsigned
//remember fullscreen setting //remember fullscreen setting
fFullscreen = Playermode && !DDrawCfg.Windowed; fFullscreen = Playermode && !DDrawCfg.Windowed;
DebugLog(" gl: SetVideoMode...");
// Set window size only in playermode // Set window size only in playermode
if (Playermode) if (Playermode)
{ {
@ -589,6 +581,7 @@ bool CStdGL::CreatePrimarySurfaces(BOOL Playermode, unsigned int iXRes, unsigned
lpPrimary->byBytesPP=byByteCnt; lpPrimary->byBytesPP=byByteCnt;
// create+select gl context // create+select gl context
DebugLog(" gl: Create Main Context...");
if (!MainCtx.Init(pApp->pWindow, pApp)) return Error(" gl: Error initializing context"); if (!MainCtx.Init(pApp->pWindow, pApp)) return Error(" gl: Error initializing context");
// BGRA Pixel Formats, Multitexturing, Texture Combine Environment Modes // BGRA Pixel Formats, Multitexturing, Texture Combine Environment Modes
@ -771,16 +764,13 @@ bool CStdGL::RestoreDeviceObjects()
if (!lpPrimary) return false; if (!lpPrimary) return false;
// delete any previous objects // delete any previous objects
InvalidateDeviceObjects(); InvalidateDeviceObjects();
bool fSuccess=true;
// restore primary/back // restore primary/back
RenderTarget=lpPrimary; RenderTarget=lpPrimary;
//lpPrimary->AttachSfc(NULL); //lpPrimary->AttachSfc(NULL);
lpPrimary->byBytesPP=byByteCnt; lpPrimary->byBytesPP=byByteCnt;
// set states // set states
fSuccess = pCurrCtx ? (pCurrCtx->Select()) : MainCtx.Select(); Active = pCurrCtx ? (pCurrCtx->Select()) : MainCtx.Select();
// activate if successful
Active=fSuccess;
// restore gamma if active // restore gamma if active
if (Active) if (Active)
EnableGamma(); EnableGamma();
@ -937,7 +927,7 @@ void CStdGL::TaskOut()
// deactivate // deactivate
// backup textures // backup textures
if (pTexMgr && fFullscreen) pTexMgr->IntLock(); if (pTexMgr && fFullscreen) pTexMgr->IntLock();
// shotdown gl // shutdown gl
InvalidateDeviceObjects(); InvalidateDeviceObjects();
if (pCurrCtx) pCurrCtx->Deselect(); if (pCurrCtx) pCurrCtx->Deselect();
} }

View File

@ -17,12 +17,6 @@
#include <Standard.h> #include <Standard.h>
#include <StdNoGfx.h> #include <StdNoGfx.h>
BOOL CStdNoGfx::CreateDirectDraw()
{
Log(" Graphics disabled");
return TRUE;
}
CStdNoGfx::CStdNoGfx() CStdNoGfx::CStdNoGfx()
{ {
Default(); Default();
@ -36,6 +30,7 @@ CStdNoGfx::~CStdNoGfx()
bool CStdNoGfx::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor) bool CStdNoGfx::CreatePrimarySurfaces(BOOL Fullscreen, unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor)
{ {
Log("Graphics disabled.");
// Save back color depth // Save back color depth
byByteCnt = iColorDepth / 8; byByteCnt = iColorDepth / 8;
// Create dummy surface // Create dummy surface