(svn r13537) -Fix [FS#2090](r13523): QSortT won't work this way, use Dimension instead of uint16[2] for resolutions

This commit is contained in:
smatz
2008-06-16 19:38:41 +00:00
parent b08db89d30
commit e00df941fa
14 changed files with 57 additions and 62 deletions

View File

@@ -206,8 +206,8 @@ static void QZ_UpdateVideoModes()
count = _cocoa_subdriver->ListModes(modes, lengthof(modes));
for (i = 0; i < count; i++) {
_resolutions[i][0] = modes[i].x;
_resolutions[i][1] = modes[i].y;
_resolutions[i].width = modes[i].x;
_resolutions[i].height = modes[i].y;
}
_num_resolutions = count;
@@ -317,8 +317,8 @@ const char *VideoDriver_Cocoa::Start(const char * const *parm)
/* Don't create a window or enter fullscreen if we're just going to show a dialog. */
if (_cocoa_video_dialog) return NULL;
width = _cur_resolution[0];
height = _cur_resolution[1];
width = _cur_resolution.width;
height = _cur_resolution.height;
bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
_cocoa_subdriver = QZ_CreateSubdriver(width, height, bpp, _fullscreen, true);

View File

@@ -138,10 +138,10 @@ const char *VideoDriver_Dedicated::Start(const char * const *parm)
{
int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth();
if (bpp == 0) _dedicated_video_mem = NULL;
else _dedicated_video_mem = MallocT<byte>(_cur_resolution[0] * _cur_resolution[1] * (bpp / 8));
else _dedicated_video_mem = MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8));
_screen.width = _screen.pitch = _cur_resolution[0];
_screen.height = _cur_resolution[1];
_screen.width = _screen.pitch = _cur_resolution.width;
_screen.height = _cur_resolution.height;
ScreenSizeChanged();
SetDebugString("net=6");

View File

@@ -15,8 +15,8 @@ static FVideoDriver_Null iFVideoDriver_Null;
const char *VideoDriver_Null::Start(const char* const *parm)
{
this->ticks = GetDriverParamInt(parm, "ticks", 1000);
_screen.width = _screen.pitch = _cur_resolution[0];
_screen.height = _cur_resolution[1];
_screen.width = _screen.pitch = _cur_resolution.width;
_screen.height = _cur_resolution.height;
ScreenSizeChanged();
/* Do not render, nor blit */

View File

@@ -96,7 +96,7 @@ static void DrawSurfaceToScreen()
}
}
static const uint16 default_resolutions[][2] = {
static const Dimension default_resolutions[] = {
{ 640, 480},
{ 800, 600},
{1024, 768},
@@ -134,12 +134,12 @@ static void GetVideoModes()
if (w >= 640 && h >= 480) {
int j;
for (j = 0; j < n; j++) {
if (_resolutions[j][0] == w && _resolutions[j][1] == h) break;
if (_resolutions[j].width == w && _resolutions[j].height == h) break;
}
if (j == n) {
_resolutions[j][0] = w;
_resolutions[j][1] = h;
_resolutions[j].width = w;
_resolutions[j].height = h;
if (++n == lengthof(_resolutions)) break;
}
}
@@ -160,21 +160,21 @@ static void GetAvailableVideoMode(int *w, int *h)
// is the wanted mode among the available modes?
for (i = 0; i != _num_resolutions; i++) {
if (*w == _resolutions[i][0] && *h == _resolutions[i][1]) return;
if (*w == _resolutions[i].width && *h == _resolutions[i].height) return;
}
// use the closest possible resolution
best = 0;
delta = abs((_resolutions[0][0] - *w) * (_resolutions[0][1] - *h));
delta = abs((_resolutions[0].width - *w) * (_resolutions[0].height - *h));
for (i = 1; i != _num_resolutions; ++i) {
uint newdelta = abs((_resolutions[i][0] - *w) * (_resolutions[i][1] - *h));
uint newdelta = abs((_resolutions[i].width - *w) * (_resolutions[i].height - *h));
if (newdelta < delta) {
best = i;
delta = newdelta;
}
}
*w = _resolutions[best][0];
*h = _resolutions[best][1];
*w = _resolutions[best].width;
*h = _resolutions[best].height;
}
#ifndef ICON_DIR
@@ -441,7 +441,7 @@ const char *VideoDriver_SDL::Start(const char * const *parm)
DEBUG(driver, 1, "SDL: using driver '%s'", buf);
GetVideoModes();
CreateMainSurface(_cur_resolution[0], _cur_resolution[1]);
CreateMainSurface(_cur_resolution.width, _cur_resolution.height);
MarkWholeScreenDirty();
SDL_CALL SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
@@ -534,7 +534,7 @@ bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen)
{
_fullscreen = fullscreen;
GetVideoModes(); // get the list of available video modes
if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution[0], _cur_resolution[1])) {
if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution.width, _cur_resolution.height)) {
// switching resolution failed, put back full_screen to original status
_fullscreen ^= true;
return false;

View File

@@ -6,6 +6,7 @@
#define VIDEO_VIDEO_DRIVER_HPP
#include "../driver.h"
#include "../core/geometry_type.hpp"
class VideoDriver: public Driver {
public:
@@ -35,7 +36,7 @@ public:
extern VideoDriver *_video_driver;
extern char _ini_videodriver[32];
extern int _num_resolutions;
extern uint16 _resolutions[32][2];
extern uint16 _cur_resolution[2];
extern Dimension _resolutions[32];
extern Dimension _cur_resolution;
#endif /* VIDEO_VIDEO_DRIVER_HPP */

View File

@@ -36,7 +36,7 @@ bool _force_full_redraw;
bool _window_maximize;
uint _display_hz;
uint _fullscreen_bpp;
static uint16 _bck_resolution[2];
static Dimension _bck_resolution;
#if !defined(UNICODE)
uint _codepage;
#endif
@@ -371,10 +371,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
return 0;
case WM_DESTROY:
if (_window_maximize) {
_cur_resolution[0] = _bck_resolution[0];
_cur_resolution[1] = _bck_resolution[1];
}
if (_window_maximize) _cur_resolution = _bck_resolution;
return 0;
case WM_LBUTTONDOWN:
@@ -530,10 +527,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
/* Set maximized flag when we maximize (obviously), but also when we
* switched to fullscreen from a maximized state */
_window_maximize = (wParam == SIZE_MAXIMIZED || (_window_maximize && _fullscreen));
if (_window_maximize) {
_bck_resolution[0] = _cur_resolution[0];
_bck_resolution[1] = _cur_resolution[1];
}
if (_window_maximize) _bck_resolution = _cur_resolution;
ClientSizeChanged(LOWORD(lParam), HIWORD(lParam));
}
return 0;
@@ -713,7 +707,7 @@ static bool AllocateDibSection(int w, int h)
return true;
}
static const uint16 default_resolutions[][2] = {
static const Dimension default_resolutions[] = {
{ 640, 480 },
{ 800, 600 },
{ 1024, 768 },
@@ -746,7 +740,7 @@ static void FindResolutions()
uint j;
for (j = 0; j < n; j++) {
if (_resolutions[j][0] == dm.dmPelsWidth && _resolutions[j][1] == dm.dmPelsHeight) break;
if (_resolutions[j].width == dm.dmPelsWidth && _resolutions[j].height == dm.dmPelsHeight) break;
}
/* In the previous loop we have checked already existing/added resolutions if
@@ -754,8 +748,8 @@ static void FindResolutions()
* looped all and found none, add the new one to the list. If we have reached the
* maximum amount of resolutions, then quit querying the display */
if (j == n) {
_resolutions[j][0] = dm.dmPelsWidth;
_resolutions[j][1] = dm.dmPelsHeight;
_resolutions[j].width = dm.dmPelsWidth;
_resolutions[j].height = dm.dmPelsHeight;
if (++n == lengthof(_resolutions)) break;
}
}
@@ -784,13 +778,13 @@ const char *VideoDriver_Win32::Start(const char * const *parm)
FindResolutions();
DEBUG(driver, 2, "Resolution for display: %dx%d", _cur_resolution[0], _cur_resolution[1]);
DEBUG(driver, 2, "Resolution for display: %dx%d", _cur_resolution.width, _cur_resolution.height);
// fullscreen uses those
_wnd.width_org = _cur_resolution[0];
_wnd.height_org = _cur_resolution[1];
_wnd.width_org = _cur_resolution.width;
_wnd.height_org = _cur_resolution.height;
AllocateDibSection(_cur_resolution[0], _cur_resolution[1]);
AllocateDibSection(_cur_resolution.width, _cur_resolution.height);
MakeWindow(_fullscreen);
MarkWholeScreenDirty();