Mercurial > fife-parpg
comparison engine/core/video/devicecaps.cpp @ 635:3094988564d5
* Added a simple method to query the default video card capabilities. This is still a work in progress. You can now get a list of ScreenModes the device supports. ScreenMode includes information on the screen resolution, if the mode is fullscreen/windowed and if it would use the OpenGL or SDL renderer.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 06 Oct 2010 19:19:08 +0000 |
parents | |
children | f7863bfa92cd |
comparison
equal
deleted
inserted
replaced
634:5f381fa34769 | 635:3094988564d5 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2010 by the FIFE team * | |
3 * http://www.fifengine.net * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE is free software; you can redistribute it and/or * | |
7 * modify it under the terms of the GNU Lesser General Public * | |
8 * License as published by the Free Software Foundation; either * | |
9 * version 2.1 of the License, or (at your option) any later version. * | |
10 * * | |
11 * This library is distributed in the hope that it will be useful, * | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | |
14 * Lesser General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU Lesser General Public * | |
17 * License along with this library; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 // Standard C++ library includes | |
23 #include <iostream> | |
24 | |
25 // 3rd party library includes | |
26 #include <SDL.h> | |
27 #include <SDL_video.h> | |
28 | |
29 // FIFE includes | |
30 // These includes are split up in two parts, separated by one empty line | |
31 // First block: files included from the FIFE root src directory | |
32 // Second block: files included from the same folder | |
33 #include "devicecaps.h" | |
34 | |
35 namespace FIFE { | |
36 | |
37 ScreenMode::ScreenMode() : | |
38 m_width(0), m_height(0), m_bpp(0), m_SDLFlags(0){ | |
39 } | |
40 | |
41 ScreenMode::ScreenMode(uint16_t width, uint16_t height, uint16_t bpp, uint32_t SDLFlags) : | |
42 m_width(width), m_height(height), m_bpp(bpp), m_SDLFlags(SDLFlags){ | |
43 } | |
44 | |
45 ScreenMode::ScreenMode(const ScreenMode& rhs){ | |
46 m_width = rhs.getWidth(); | |
47 m_height = rhs.getHeight(); | |
48 m_bpp = rhs.getBPP(); | |
49 m_SDLFlags = rhs.getSDLFlags(); | |
50 } | |
51 | |
52 DeviceCaps::DeviceCaps() { | |
53 } | |
54 | |
55 | |
56 DeviceCaps::~DeviceCaps() { | |
57 } | |
58 | |
59 void DeviceCaps::fillDeviceCaps() { | |
60 int numBPP = 1; | |
61 int bpps[numBPP]; | |
62 | |
63 int numResolutions = 15; | |
64 | |
65 //FLAGS | |
66 #ifdef HAVE_OPENGL | |
67 int numFlags = 4; | |
68 Uint32 flags[numFlags]; | |
69 | |
70 //OpenGL, windowed, hw accel | |
71 flags[0] = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL; | |
72 //OpenGL, fullscree, hw accel | |
73 flags[1] = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL | SDL_FULLSCREEN; | |
74 //SDL, windowed | |
75 flags[2] = 0; | |
76 //SDL, fullscreen | |
77 flags[3] = SDL_FULLSCREEN; | |
78 #else | |
79 int numFlags = 2; | |
80 Uint32 flags[numFlags]; | |
81 | |
82 //SDL, windowed | |
83 flags[0] = 0; | |
84 //SDL, fullscreen | |
85 flags[1] = SDL_FULLSCREEN; | |
86 #endif | |
87 //BITS PER PIXEL | |
88 | |
89 bpps[0] = 32; | |
90 | |
91 | |
92 //RESOLUTIONS | |
93 int resolutions[15][2] = { | |
94 {640, 480}, | |
95 {800, 600}, | |
96 {1024, 768}, | |
97 {1152, 864}, | |
98 {1280, 768}, | |
99 {1280, 800}, | |
100 {1280, 960}, | |
101 {1280, 1024}, | |
102 {1366, 768}, | |
103 {1440, 900}, | |
104 {1600, 900}, | |
105 {1600, 1200}, | |
106 {1680, 1050}, | |
107 {1920, 1080}, | |
108 {1920, 1200} | |
109 }; | |
110 | |
111 int bpp; | |
112 | |
113 for (int i = 0; i < numBPP; i++){ | |
114 for (int j = 0; j < numFlags; j++) { | |
115 for (int k = 0; k < numResolutions; k++) { | |
116 bpp = SDL_VideoModeOK(resolutions[k][0], resolutions[k][1], bpps[i], flags[j]); | |
117 if (bpp > 0) { | |
118 // std::cout << resolutions[k][0] << "x" << resolutions[k][1] << ":" << bpp << std::endl; | |
119 ScreenMode mode = ScreenMode(resolutions[k][0], resolutions[k][1], bpps[i], flags[j]); | |
120 m_screenModes.push_back(mode); | |
121 } | |
122 } | |
123 } | |
124 } | |
125 | |
126 } | |
127 | |
128 } //FIFE |