Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/gui/gui/gui_video.cc @ 4091

Last change on this file since 4091 was 4091, checked in by bensch, 19 years ago

orxonox/trunk: now All options get loaded in new style (be aware, quiting only works with ESCAPE, not q, but of corse you can change this now in the GUI

File size: 6.9 KB
Line 
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
29#include "gui_gtk.h"
30#include "glincl.h"
31#include <stdlib.h>
32
33/**
34   \brief Creates the Video-Option-Frame
35*/
36GuiVideo::GuiVideo(void)
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->saveability();
54      videoBox->fill(fullscreen);
55      resolution = new Menu(CONFIG_NAME_RESOLUTION);
56      getResolutions(resolution);
57      resolution->saveability();
58      resolution->setFlagName("resolution", "r", 0);
59      videoBox->fill(resolution);
60      wireframe = new CheckButton(CONFIG_NAME_WIREFRAME);
61      wireframe->setFlagName("wireframe", "w", 0);
62      wireframe->saveability();
63      videoBox->fill(wireframe);
64
65      videoBox->fill(advancedWindowCreate());
66    }
67    videoFrame->fill(videoBox);
68  }
69  setMainWidget(videoFrame);
70}
71
72/**
73   \brief Destructs the Video-stuff
74*/
75GuiVideo::~GuiVideo(void)
76{
77  // nothing to do here.
78}
79
80/**
81   \brief Creates a window, and all it contains for the Source-update.
82*/
83Widget* GuiVideo::advancedWindowCreate(void)
84{
85  // advanced-Performance-Options
86  Window* advancedWindow;   //!< A Window to display advanced options.
87  Button* advancedButton;   //!< A Button to open the Advanced Video Performance Window.
88  // the button, that opens this Window.
89  advancedButton = new Button("advanced");
90
91  // the Window itself
92  advancedWindow = new Window("Advanced Video Options");
93  advancedWindow->setGroupName(CONFIG_SECTION_VIDEO_ADVANCED);
94  {
95    Box* advancedBox;         //!< A Box to pack the options into.
96
97    advancedBox = new Box('v');
98    {
99      CheckButton* shadows;     //!< CheckButton for shadows
100      CheckButton* fog;         //!< CheckButton for fog.
101      CheckButton* reflections; //!< CheckButton for reflections
102      CheckButton* textures;    //!< CheckButton for textures
103      Menu* textureDetail;      //!< Menu for the Texture-Detail.
104      Label* modelDetailLabel;  //!< Label for model-detail.
105      Menu* modelDetail;        //!< model-detail.
106      Label* antiAliasingLabel; //!< Label for the anti-aliasing mode.
107      Menu* antiAliasing;       //!< Menu for the Antialiasing-mode.
108      Label* filterMethodLabel; //!< Label for filtering-Method.
109      Menu* filterMethod;       //!< Menu for filtering Method.
110      Button* closeButton;      //!< A Button to close the Advanced-settingsWindow.
111
112      // Advanced Performance Options
113      shadows = new CheckButton(CONFIG_NAME_SHADOWS);
114      shadows->saveability();
115      advancedBox->fill(shadows);
116     
117      fog = new CheckButton(CONFIG_NAME_FOG);
118      fog->saveability();
119      advancedBox->fill(fog);
120     
121      reflections = new CheckButton(CONFIG_NAME_REFLECTIONS);
122      reflections->saveability();
123      advancedBox->fill(reflections);
124     
125      textures = new CheckButton(CONFIG_NAME_TEXTURES);
126      textures->saveability();
127      advancedBox->fill(textures);
128     
129      textureDetail = new Menu(CONFIG_NAME_TEXTURE_DETAIL, "low", "medium", "high", "lastItem");
130      textureDetail->setDefaultValue(1);
131      textureDetail->saveability();
132      advancedBox->fill(textureDetail);
133     
134      modelDetailLabel = new Label(CONFIG_NAME_MODEL_DETAIL);
135      advancedBox->fill(modelDetailLabel);
136      modelDetail = new Menu(CONFIG_NAME_MODEL_DETAIL, "low", "high", "lastItem");
137      modelDetail->setDefaultValue(1);
138      modelDetail->saveability();
139      advancedBox->fill(modelDetail);
140     
141      antiAliasingLabel = new Label("Anti-Aliasing-depth:");
142      advancedBox->fill(antiAliasingLabel);
143      antiAliasing = new Menu(CONFIG_NAME_ANTI_ALIASING, "0", "1", "2", "4", "8",  "lastItem");
144      antiAliasing->setDefaultValue(2);
145      antiAliasing->saveability();
146      advancedBox->fill(antiAliasing);
147     
148      filterMethodLabel = new Label("Filtering Method:");
149      advancedBox->fill(filterMethodLabel);
150      filterMethod = new Menu(CONFIG_NAME_FILTER_METHOD, "none", "linear", "bilinear", "trilinear", "anisortopic", "lastItem");
151      filterMethod->setDefaultValue(1);
152      filterMethod->saveability();
153      advancedBox->fill(filterMethod);
154 
155      closeButton = new Button("close");
156#ifdef HAVE_GTK2
157      closeButton->connectSignal("button_press_event", advancedWindow, Window::windowClose);
158#endif /* HAVE_GTK2 */
159
160      advancedBox->fill(closeButton);
161    }
162    advancedWindow->fill(advancedBox);
163  }
164#ifdef HAVE_GTK2
165  advancedButton->connectSignal("button_press_event", advancedWindow, Window::windowOpen);
166  advancedWindow->connectSignal("destroy", advancedWindow, Window::windowClose);
167  advancedWindow->connectSignal("delete_event", advancedWindow, Window::windowClose);
168#endif /* HAVE_GTK2 */
169  Window::addWindow(advancedWindow);
170
171  return advancedButton;
172}
173
174/**
175   \brief sets all resolutions to the menu
176   \param menu the Menu to set The resolutions to.
177*/
178void GuiVideo::getResolutions(Menu* menu)
179{
180  SDL_Init(SDL_INIT_VIDEO);
181  SDL_Rect **modes;
182  int i;
183  int x = 0,y =0; // check for difference
184  char tmpChar[100];
185 
186  /* Get available fullscreen/hardware modes */
187  modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
188 
189  /* Check is there are any modes available */
190  if(modes == (SDL_Rect **)0){
191    PRINTF(2)("No video-modes available!\n");
192    exit(-1);
193  }
194 
195  /* Check if our resolution is restricted */
196  if(modes == (SDL_Rect **)-1){
197    PRINTF(2)("All resolutions available.\n");
198  }
199  else{
200    /* Print valid modes */
201    PRINT(4)("Available Modes\n");
202    for(i = 0; modes[i] ;++i)
203      {
204        if (x != modes[i]->w || y != modes[i]->h)
205          { 
206            PRINT(4)("  %d x %d\n", modes[i]->w, modes[i]->h);
207            sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h);
208            menu->addItem(tmpChar);
209            x = modes[i]->w; y = modes[i]->h;
210          }
211      }
212  }
213  SDL_Quit();
214}
Note: See TracBrowser for help on using the repository browser.