Skip to content

Commit

Permalink
Added video modes
Browse files Browse the repository at this point in the history
According to the original implementation, SDL_ListModes does not work in all cases. Because of that, an explicit video mode enumeration has to be maintained.

Video mode enumeration updated according to [Wikipedia](http://en.wikipedia.org/w/index.php?title=File:Vector_Video_Standards4.svg) and made it easy to manage and extend.
  • Loading branch information
ooxi committed Oct 30, 2012
1 parent fea6598 commit 70a2dd8
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Legend
Upcoming release
----------------

* `[*]` Added more available video modes, since auto detection doesn't seam to work
* `[!]` Fixed i18n support in [issue 62](https://github.com/ooxi/violetland/pull/62)

Release 0.4.3 (2011-10-10)
Expand Down
26 changes: 19 additions & 7 deletions src/system/graphic/VideoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,27 @@ bool VideoManager::isModeAvailable(int w, int h, int bpp, bool fullscreen,
}

std::vector<SDL_Rect> VideoManager::GetAvailableModes() {
/* This way is better than SDL_ListModes because of
* SDL_ListModes returns not all possible modes

/* All possible width
*/
#define EXPAND_VIDEO_MODE(name, width, height) \
width,

static int wL[] = {
#include "VideoModes.h"
};
#undef EXPAND_VIDEO_MODE

/* All possible height
*/
#define EXPAND_VIDEO_MODE(name, width, height) \
height,

static int hL[] = {
#include "VideoModes.h"
};
#undef EXPAND_VIDEO_MODE

// Number of possible modes
int wL[] = { 400, 640, 800, 1024, 1280, 1280, 1280, 1280, 1366, 1600, 1600,
1680, 1920, 1920 };
int hL[] = { 300, 480, 600, 768, 720, 768, 800, 1024, 768, 900, 1200, 1050,
1080, 1200 };

// If the mode is supported, it will be added to the return list
std::vector<SDL_Rect> modes;
Expand Down
71 changes: 71 additions & 0 deletions src/system/graphic/VideoModes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright (c) 2012 ooxi/violetland
* https://github.com/ooxi/violetland
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*/



/**
* According to the original implementation of `VideoManager::GetAvailableModes'
* this way is better than SDL_ListModes because of SDL_ListModes returns not
* all possible modes...
*
* ...except, that you have to manually take care of it and it's not
* configurable at runtime -.-
*
* This list was extracted from http://en.wikipedia.org/w/index.php?title=File:Vector_Video_Standards4.svg
*/
EXPAND_VIDEO_MODE(CGA, 320, 200)
EXPAND_VIDEO_MODE(QVGA, 320, 240)
EXPAND_VIDEO_MODE(CIF, 352, 288)
EXPAND_VIDEO_MODE(SIF, 384, 288)
EXPAND_VIDEO_MODE(HVGA, 480, 320)
EXPAND_VIDEO_MODE(VGA, 640, 480)
EXPAND_VIDEO_MODE(PAL, 768, 576)
EXPAND_VIDEO_MODE(WVGA, 800, 480)
EXPAND_VIDEO_MODE(SVGA, 800, 600)
EXPAND_VIDEO_MODE(WVGA, 854, 480)
EXPAND_VIDEO_MODE(PAL, 1024, 576)
EXPAND_VIDEO_MODE(WSVGA, 1024, 600)
EXPAND_VIDEO_MODE(XGA, 1024, 768)
EXPAND_VIDEO_MODE(UNNAMED, 1152, 768)
EXPAND_VIDEO_MODE(XGA_PLUS, 1152, 864)
EXPAND_VIDEO_MODE(HD, 1280, 720)
EXPAND_VIDEO_MODE(WXGA, 1280, 768)
EXPAND_VIDEO_MODE(WXGA, 1280, 800)
EXPAND_VIDEO_MODE(UNNAMED, 1280, 854)
EXPAND_VIDEO_MODE(UNNAMED, 1280, 960)
EXPAND_VIDEO_MODE(SXGA, 1280, 1024)
EXPAND_VIDEO_MODE(UNNAMED, 1366, 768)
EXPAND_VIDEO_MODE(SXGA_PLUS, 1400, 1050)
EXPAND_VIDEO_MODE(UNNAMED, 1440, 900)
EXPAND_VIDEO_MODE(UNNAMED, 1440, 960)
EXPAND_VIDEO_MODE(UNNAMED, 1440, 1080)
EXPAND_VIDEO_MODE(UXGA, 1600, 1200)
EXPAND_VIDEO_MODE(WSXGA_PLUS, 1680, 1050)
EXPAND_VIDEO_MODE(FULL_HD, 1920, 1080)
EXPAND_VIDEO_MODE(WUXGA, 1920, 1200)
EXPAND_VIDEO_MODE(TWO_K, 2048, 1080)
EXPAND_VIDEO_MODE(QXGA, 2048, 1536)
EXPAND_VIDEO_MODE(WQHD, 2560, 1440)
EXPAND_VIDEO_MODE(WQXGA, 2560, 1600)
EXPAND_VIDEO_MODE(QSXGA, 2560, 2048)

0 comments on commit 70a2dd8

Please sign in to comment.