forked from Mirrors/openclonk
SDL: Fix runtime resolution changes
parent
18d653e096
commit
4d3f5a28f9
|
@ -1155,7 +1155,7 @@ bool C4StartupOptionsDlg::TryNewResolution(int32_t iResX, int32_t iResY)
|
|||
if (!Application.SetVideoMode(iResX, iResY,Config.Graphics.BitDepth, Config.Graphics.Monitor,!DDrawCfg.Windowed))
|
||||
{
|
||||
StdCopyStrBuf strChRes(LoadResStr("IDS_MNU_SWITCHRESOLUTION"));
|
||||
pScreen->ShowMessage(FormatString(LoadResStr("IDS_ERR_SWITCHRES"), lpDDraw->GetLastError()).getData(), strChRes.getData(), C4GUI::Ico_Clonk, NULL);
|
||||
pScreen->ShowMessage(FormatString(LoadResStr("IDS_ERR_SWITCHRES"), Application.GetLastError()).getData(), strChRes.getData(), C4GUI::Ico_Clonk, NULL);
|
||||
return false;
|
||||
}
|
||||
// implied font change
|
||||
|
|
|
@ -227,7 +227,6 @@ class CStdDDraw
|
|||
bool Active; // set if device is ready to render, etc.
|
||||
CGammaControl Gamma; // gamma
|
||||
CGammaControl DefRamp; // default gamma ramp
|
||||
StdStrBuf sLastError;
|
||||
int MaxTexSize;
|
||||
protected:
|
||||
BYTE byByteCnt; // bytes per pixel (2 or 4)
|
||||
|
@ -262,7 +261,6 @@ class CStdDDraw
|
|||
virtual bool OnResolutionChanged(unsigned int iXRes, unsigned int iYRes) = 0; // reinit clipper for new resolution
|
||||
virtual bool IsOpenGL() { return false; }
|
||||
virtual bool IsShaderific() { return false; }
|
||||
const char *GetLastError() { return sLastError.getData(); }
|
||||
// Palette
|
||||
BOOL SetPrimaryPalette(BYTE *pBuf, BYTE *pAlphaBuf=NULL);
|
||||
BOOL SetPrimaryPaletteQuad(BYTE *pBuf);
|
||||
|
|
|
@ -394,6 +394,8 @@ public:
|
|||
#endif
|
||||
}
|
||||
void MessageDialog(const char * message);
|
||||
const char *GetLastError() { return sLastError.getData(); }
|
||||
void Error(const char * m) { sLastError.Copy(m); }
|
||||
#ifdef _WIN32
|
||||
|
||||
private:
|
||||
|
@ -465,6 +467,7 @@ protected:
|
|||
unsigned int KeyMask;
|
||||
#endif
|
||||
const char *szCmdLine;
|
||||
StdStrBuf sLastError;
|
||||
bool fDspModeSet; // true if display mode was changed
|
||||
virtual bool DoInit() = 0;
|
||||
|
||||
|
|
|
@ -502,7 +502,6 @@ void CStdDDraw::Default()
|
|||
|
||||
void CStdDDraw::Clear()
|
||||
{
|
||||
sLastError.Clear();
|
||||
DisableGamma();
|
||||
Active=BlitModulated=fUseClrModMap=false;
|
||||
dwBlitMode = 0;
|
||||
|
@ -1190,7 +1189,7 @@ BOOL CStdDDraw::BlitRotate(SURFACE sfcSource, int fx, int fy, int fwdt, int fhgt
|
|||
|
||||
bool CStdDDraw::Error(const char *szMsg)
|
||||
{
|
||||
sLastError.Copy(szMsg);
|
||||
if (pApp) pApp->Error(szMsg);
|
||||
Log(szMsg); return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -147,10 +147,15 @@ bool CStdApp::GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32_t *pi
|
|||
}
|
||||
|
||||
bool CStdApp::SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int iColorDepth, unsigned int iMonitor, bool fFullScreen) {
|
||||
// Multi-monitor support not implemented.
|
||||
// As far as I can tell, SDL doesn't support it to begin with.
|
||||
SDL_SetVideoMode(iXRes, iYRes, iColorDepth, SDL_OPENGL | (fFullScreen ? SDL_FULLSCREEN : 0));
|
||||
// SDL doesn't support multiple monitors.
|
||||
if(!SDL_SetVideoMode(iXRes, iYRes, iColorDepth, SDL_OPENGL | (fFullScreen ? SDL_FULLSCREEN : 0))) {
|
||||
sLastError.Copy(SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
pWindow->SetSize(iXRes, iYRes);
|
||||
OnResolutionChanged(iXRes, iYRes);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CStdApp::RestoreVideoMode() {
|
||||
|
|
|
@ -304,7 +304,12 @@ bool CStdApp::SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int
|
|||
{
|
||||
#ifdef USE_DIRECTX
|
||||
if (pD3D)
|
||||
return pD3D->SetVideoMode(iXRes, iYRes, iColorDepth, iMonitor, fFullScreen);
|
||||
{
|
||||
if(!pD3D->SetVideoMode(iXRes, iYRes, iColorDepth, iMonitor, fFullScreen))
|
||||
return false;
|
||||
OnResolutionChanged(iXRes, iYRes);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
bool fFound=false;
|
||||
DEVMODE dmode;
|
||||
|
@ -357,6 +362,7 @@ bool CStdApp::SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int
|
|||
{
|
||||
ChangeDisplaySettings(NULL, CDS_RESET);
|
||||
fDspModeSet = false;
|
||||
OnResolutionChanged(iXRes, iYRes);
|
||||
return true;
|
||||
}
|
||||
// save original display mode
|
||||
|
@ -378,6 +384,8 @@ bool CStdApp::SetVideoMode(unsigned int iXRes, unsigned int iYRes, unsigned int
|
|||
}
|
||||
}
|
||||
SetWindowPos(pWindow->hWindow, 0, MonitorRect.left, MonitorRect.top, dspMode.dmPelsWidth, dspMode.dmPelsHeight, 0);
|
||||
if (fDspModeSet)
|
||||
OnResolutionChanged(iXRes, iYRes);
|
||||
return fDspModeSet;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue