diff --git a/src/include/video.h b/src/include/video.h index d79bacd11..05bc68b81 100644 --- a/src/include/video.h +++ b/src/include/video.h @@ -214,7 +214,7 @@ struct EventCallback { class CVideo { public: - CVideo() : Width(0), Height(0), ViewportWidth(0), ViewportHeight(0), Depth(0), ShaderIndex(0), FullScreen(false) {} + CVideo() : Width(0), Height(0), Depth(0), ShaderIndex(0), FullScreen(false) {} void LockScreen(); void UnlockScreen(); @@ -287,8 +287,6 @@ public: int Width; int Height; - int ViewportWidth; /// Actual width of the window - int ViewportHeight; /// Actual height of the window SDL_Cursor *blankCursor; int Depth; int ShaderIndex; diff --git a/src/stratagus/mainloop.cpp b/src/stratagus/mainloop.cpp index f892456a6..b7d7bc525 100644 --- a/src/stratagus/mainloop.cpp +++ b/src/stratagus/mainloop.cpp @@ -170,7 +170,7 @@ void UpdateDisplay() { if (GameRunning || Editor.Running == EditorEditing) { // to prevent empty spaces in the UI - Video.FillRectangleClip(ColorBlack, 0, 0, Video.ViewportWidth, Video.ViewportHeight); + Video.FillRectangleClip(ColorBlack, 0, 0, Video.Width, Video.Height); DrawMapArea(); DrawMessages(); diff --git a/src/stratagus/stratagus.cpp b/src/stratagus/stratagus.cpp index ff8ace885..2747ba6d9 100644 --- a/src/stratagus/stratagus.cpp +++ b/src/stratagus/stratagus.cpp @@ -567,16 +567,14 @@ void ParseCommandLine(int argc, char **argv, Parameters ¶meters) Usage(); exit(-1); } - Video.ViewportHeight = atoi(sep + 1); + Video.Height = atoi(sep + 1); *sep = 0; - Video.ViewportWidth = atoi(optarg); - if (!Video.ViewportHeight || !Video.ViewportWidth) { + Video.Width = atoi(optarg); + if (!Video.Height || !Video.Width) { fprintf(stderr, "%s: incorrect format of video mode resolution -- '%sx%s'\n", argv[0], optarg, sep + 1); Usage(); exit(-1); } - Video.Height = Video.ViewportHeight; - Video.Width = Video.ViewportWidth; continue; } case 'W': diff --git a/src/tolua/video.pkg b/src/tolua/video.pkg index 7636dfaed..940cc17f6 100644 --- a/src/tolua/video.pkg +++ b/src/tolua/video.pkg @@ -11,8 +11,6 @@ class CVideo public: int Width; int Height; - int ViewportWidth; - int ViewportHeight; int Depth; int ShaderIndex; bool FullScreen; diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index e07163e01..a4706b907 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -305,8 +305,8 @@ void UiToggleBigMap() UI.MapArea.X = 0; UI.MapArea.Y = 0; - UI.MapArea.EndX = Video.ViewportWidth - 1; - UI.MapArea.EndY = Video.ViewportHeight - 1; + UI.MapArea.EndX = Video.Width - 1; + UI.MapArea.EndY = Video.Height - 1; SetViewportMode(UI.ViewportMode); diff --git a/src/ui/script_ui.cpp b/src/ui/script_ui.cpp index 79986d261..510fd4b1d 100644 --- a/src/ui/script_ui.cpp +++ b/src/ui/script_ui.cpp @@ -212,11 +212,9 @@ static int CclSetVideoResolution(lua_State *l) LuaCheckArgs(l, 2); if (CclInConfigFile) { // May have been set from the command line - if (!Video.ViewportWidth || !Video.ViewportHeight) { - Video.ViewportWidth = LuaToNumber(l, 1); - Video.ViewportHeight = LuaToNumber(l, 2); - Video.Height = Video.ViewportHeight; - Video.Width = Video.ViewportWidth; + if (!Video.Width || !Video.Height) { + Video.Width = LuaToNumber(l, 1); + Video.Height = LuaToNumber(l, 2); } } return 0; diff --git a/src/video/png.cpp b/src/video/png.cpp index 38187121d..4b4037456 100644 --- a/src/video/png.cpp +++ b/src/video/png.cpp @@ -321,8 +321,8 @@ void SaveScreenshotPNG(const char *name) png_init_io(png_ptr, fp); int pngw, pngh; - pngw = Video.ViewportWidth; - pngh = Video.ViewportHeight; + pngw = Video.Width; + pngh = Video.Height; png_set_IHDR(png_ptr, info_ptr, pngw, pngh, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); diff --git a/src/video/sdl.cpp b/src/video/sdl.cpp index 43c41f735..2f1b5ed46 100644 --- a/src/video/sdl.cpp +++ b/src/video/sdl.cpp @@ -315,8 +315,6 @@ void InitVideoSdl() } if (!Video.Width || !Video.Height) { - Video.ViewportWidth = Video.Width; - Video.ViewportHeight = Video.Height; Video.Width = 640; Video.Height = 480; } @@ -333,13 +331,8 @@ void InitVideoSdl() win_title = Parameters::Instance.applicationName.c_str(); } - if (!Video.ViewportWidth || !Video.ViewportHeight) { - Video.ViewportWidth = Video.Width; - Video.ViewportHeight = Video.Height; - } - TheWindow = SDL_CreateWindow(win_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - Video.ViewportWidth, Video.ViewportHeight, flags); + Video.Width, Video.Height, flags); if (TheWindow == NULL) { fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n", Video.Width, Video.Height, Video.Depth, SDL_GetError()); @@ -514,9 +507,6 @@ static void SdlDoEvent(const EventCallback &callbacks, SDL_Event &event) && (event.motion.x != UI.MouseWarpPos.x || event.motion.y != UI.MouseWarpPos.y)) { int xw = UI.MouseWarpPos.x; int yw = UI.MouseWarpPos.y; - // Scale mouse-coordinates to viewport - xw = (Uint16)floorf(xw * float(Video.ViewportWidth) / Video.Width); - yw = (Uint16)floorf(yw * float(Video.ViewportHeight) / Video.Height); UI.MouseWarpPos.x = -1; UI.MouseWarpPos.y = -1; SDL_WarpMouseInWindow(TheWindow, xw, yw); @@ -764,7 +754,6 @@ void ToggleFullScreen() { Uint32 flags; flags = SDL_GetWindowFlags(TheWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP; - SDL_GetWindowSize(TheWindow, &Video.ViewportWidth, &Video.ViewportHeight); #ifdef USE_WIN32 diff --git a/src/video/video.cpp b/src/video/video.cpp index c05734f2c..2ce378ae9 100644 --- a/src/video/video.cpp +++ b/src/video/video.cpp @@ -267,8 +267,6 @@ void CVideo::ClearScreen() bool CVideo::ResizeScreen(int w, int h) { if (VideoValidResolution(w, h)) { - ViewportWidth = w; - ViewportHeight = h; Width = w; Height = h;