Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4734 was 4427, checked in by bensch, 20 years ago

orxonox/trunk: moved the gui to a more usefull directory

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