1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | This program 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 |
---|
14 | GNU General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU General Public License |
---|
17 | along with this program; if not, write to the Free Software Foundation, |
---|
18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | |
---|
21 | ### File Specific: |
---|
22 | main-programmer: Benjamin Grauer |
---|
23 | |
---|
24 | */ |
---|
25 | |
---|
26 | |
---|
27 | #include "gui_video.h" |
---|
28 | #include "sdlincl.h" |
---|
29 | #include "debug.h" |
---|
30 | |
---|
31 | namespace OrxGui |
---|
32 | { |
---|
33 | /** |
---|
34 | * Creates the Video-Option-Frame |
---|
35 | */ |
---|
36 | GuiVideo::GuiVideo() |
---|
37 | { |
---|
38 | /* Frame* videoFrame; //!< The Frame that holds the video options. |
---|
39 | |
---|
40 | videoFrame = new Frame("Video-Options:"); |
---|
41 | videoFrame->setGroupName("video"); |
---|
42 | { |
---|
43 | Box* videoBox; //!< The Box that holds the video options. |
---|
44 | |
---|
45 | videoBox = new Box('v'); |
---|
46 | { |
---|
47 | CheckButton* fullscreen; //!< CheckButton for fullscreen-mode |
---|
48 | Menu* resolution; //!< Menu for the resolution |
---|
49 | CheckButton* wireframe; //!< CheckButton for wireframe Mode. |
---|
50 | |
---|
51 | fullscreen = new CheckButton(CONFIG_NAME_FULLSCREEN); |
---|
52 | fullscreen->setFlagName("windowed", "q", 1); |
---|
53 | fullscreen->setDescription("Starts orxonox in windowed mode"); |
---|
54 | fullscreen->saveability(); |
---|
55 | videoBox->fill(fullscreen); |
---|
56 | resolution = new Menu(CONFIG_NAME_RESOLUTION); |
---|
57 | getResolutions(resolution); |
---|
58 | resolution->saveability(); |
---|
59 | resolution->setFlagName("resolution", "r", 0); |
---|
60 | resolution->setDescription("Sets the resolution of orxonox"); |
---|
61 | videoBox->fill(resolution); |
---|
62 | wireframe = new CheckButton(CONFIG_NAME_WIREFRAME); |
---|
63 | wireframe->setFlagName("wireframe", "w", 0); |
---|
64 | wireframe->setDescription("Starts orxonox in wireframe mode"); |
---|
65 | wireframe->saveability(); |
---|
66 | videoBox->fill(wireframe); |
---|
67 | |
---|
68 | videoBox->fill(advancedWindowCreate()); |
---|
69 | } |
---|
70 | videoFrame->fill(videoBox); |
---|
71 | } |
---|
72 | setMainWidget(videoFrame);*/ |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Destructs the Video-stuff |
---|
77 | */ |
---|
78 | GuiVideo::~GuiVideo() |
---|
79 | { |
---|
80 | // nothing to do here. |
---|
81 | } |
---|
82 | |
---|
83 | /** |
---|
84 | * sets all resolutions to the menu |
---|
85 | * @param menu the Menu to set The resolutions to. |
---|
86 | */ |
---|
87 | void GuiVideo::getResolutions(std::vector<std::string>& resolutionList) |
---|
88 | { |
---|
89 | SDL_Init(SDL_INIT_VIDEO); |
---|
90 | SDL_Rect **modes; |
---|
91 | int i; |
---|
92 | int x = 0,y =0; // check for difference |
---|
93 | char tmpChar[100]; |
---|
94 | |
---|
95 | /* Get available fullscreen/hardware modes */ |
---|
96 | modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); |
---|
97 | |
---|
98 | /* Check is there are any modes available */ |
---|
99 | if(modes == (SDL_Rect **)0) |
---|
100 | { |
---|
101 | PRINTF(2)("No video-modes available!\n"); |
---|
102 | exit(-1); |
---|
103 | } |
---|
104 | |
---|
105 | /* Check if our resolution is restricted */ |
---|
106 | if(modes == (SDL_Rect **)-1) |
---|
107 | { |
---|
108 | PRINTF(2)("All resolutions available.\n"); |
---|
109 | } |
---|
110 | else |
---|
111 | { |
---|
112 | /* Print valid modes */ |
---|
113 | PRINT(5)("Available Modes\n"); |
---|
114 | for(i = 0; modes[i] ;++i) |
---|
115 | { |
---|
116 | if (x != modes[i]->w || y != modes[i]->h) |
---|
117 | { |
---|
118 | PRINTF(5)(" %d x %d\n", modes[i]->w, modes[i]->h); |
---|
119 | sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h); |
---|
120 | resolutionList.push_back(std::string(tmpChar)); |
---|
121 | x = modes[i]->w; y = modes[i]->h; |
---|
122 | } |
---|
123 | } |
---|
124 | } |
---|
125 | SDL_QuitSubSystem(SDL_INIT_VIDEO); |
---|
126 | SDL_Quit(); |
---|
127 | } |
---|
128 | |
---|
129 | } |
---|