make sure viewport width and height are always initialized
This commit is contained in:
parent
16abd5b909
commit
3eda5c5ac4
4 changed files with 15 additions and 8 deletions
|
@ -267,7 +267,7 @@ struct EventCallback {
|
|||
class CVideo
|
||||
{
|
||||
public:
|
||||
CVideo() : Width(0), Height(0), Depth(0), ShaderIndex(0), FullScreen(false) {}
|
||||
CVideo() : Width(0), Height(0), ViewportWidth(0), ViewportHeight(0), Depth(0), ShaderIndex(0), FullScreen(false) {}
|
||||
|
||||
void LockScreen();
|
||||
void UnlockScreen();
|
||||
|
@ -373,10 +373,8 @@ public:
|
|||
|
||||
int Width;
|
||||
int Height;
|
||||
#if defined(USE_OPENGL) || defined(USE_GLES)
|
||||
int ViewportWidth; /// Actual width of the window
|
||||
int ViewportHeight; /// Actual height of the window
|
||||
#endif
|
||||
#if defined(USE_TOUCHSCREEN) && defined(USE_WIN32)
|
||||
SDL_Cursor *blankCursor;
|
||||
#endif
|
||||
|
|
|
@ -301,9 +301,18 @@ static int CclSetVideoResolution(lua_State *l)
|
|||
LuaCheckArgs(l, 2);
|
||||
if (CclInConfigFile) {
|
||||
// May have been set from the command line
|
||||
if (!Video.Width || !Video.Height) {
|
||||
Video.Width = LuaToNumber(l, 1);
|
||||
Video.Height = LuaToNumber(l, 2);
|
||||
if (!Video.ViewportWidth || !Video.ViewportHeight) {
|
||||
Video.ViewportWidth = LuaToNumber(l, 1);
|
||||
Video.ViewportHeight = LuaToNumber(l, 2);
|
||||
#if defined(USE_OPENGL) || defined(USE_GLES)
|
||||
if (!ZoomNoResize) {
|
||||
Video.Height = Video.ViewportHeight;
|
||||
Video.Width = Video.ViewportWidth;
|
||||
}
|
||||
#else
|
||||
Video.Height = Video.ViewportHeight;
|
||||
Video.Width = Video.ViewportWidth;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -612,11 +612,11 @@ void InitVideoSdl()
|
|||
Video.Depth = 32;
|
||||
}
|
||||
|
||||
#if defined(USE_OPENGL) || defined(USE_GLES)
|
||||
if (!Video.ViewportWidth || !Video.ViewportHeight) {
|
||||
Video.ViewportWidth = Video.Width;
|
||||
Video.ViewportHeight = Video.Height;
|
||||
}
|
||||
#if defined(USE_OPENGL) || defined(USE_GLES)
|
||||
TheScreen = SDL_SetVideoMode(Video.ViewportWidth, Video.ViewportHeight, Video.Depth, flags);
|
||||
#else
|
||||
TheScreen = SDL_SetVideoMode(Video.Width, Video.Height, Video.Depth, flags);
|
||||
|
|
|
@ -282,9 +282,9 @@ bool CVideo::ResizeScreen(int w, int h)
|
|||
}
|
||||
#endif
|
||||
TheScreen = SDL_SetVideoMode(w, h, TheScreen->format->BitsPerPixel, TheScreen->flags);
|
||||
#if defined(USE_OPENGL) || defined(USE_GLES)
|
||||
ViewportWidth = w;
|
||||
ViewportHeight = h;
|
||||
#if defined(USE_OPENGL) || defined(USE_GLES)
|
||||
if (ZoomNoResize) {
|
||||
ReloadOpenGL();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue