Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8456 was 8145, checked in by bensch, 18 years ago

trunk: merged the gui back
merged with command:
svn merge -r8114:HEAD https://svn.orxonox.net/orxonox/branches/gui .
→ no conflicts

File size: 7.4 KB
RevLine 
[4777]1/*
[2581]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,
[4777]18   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
[2581]19
20
21   ### File Specific:
22   main-programmer: Benjamin Grauer
23
24*/
25
26
[4047]27#include "gui_video.h"
[2018]28
[4064]29#include "gui_gtk.h"
[4381]30#include "sdlincl.h"
[4049]31#include <stdlib.h>
[3624]32
[3187]33/**
[4836]34 *  Creates the Video-Option-Frame
[3187]35*/
[4746]36GuiVideo::GuiVideo()
[2018]37{
[4064]38  Frame* videoFrame;        //!< The Frame that holds the video options.
[2018]39
[4064]40  videoFrame = new Frame("Video-Options:");
41  videoFrame->setGroupName("video");
42  {
43    Box* videoBox;            //!< The Box that holds the video options.
[3423]44
[4064]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
[4091]51      fullscreen = new CheckButton(CONFIG_NAME_FULLSCREEN);
[4064]52      fullscreen->setFlagName("windowed", "q", 1);
[4132]53      fullscreen->setDescription("Starts orxonox in windowed mode");
[4064]54      fullscreen->saveability();
55      videoBox->fill(fullscreen);
[4091]56      resolution = new Menu(CONFIG_NAME_RESOLUTION);
[4064]57      getResolutions(resolution);
58      resolution->saveability();
59      resolution->setFlagName("resolution", "r", 0);
[4132]60      resolution->setDescription("Sets the resolution of orxonox");
[4064]61      videoBox->fill(resolution);
[4091]62      wireframe = new CheckButton(CONFIG_NAME_WIREFRAME);
[4064]63      wireframe->setFlagName("wireframe", "w", 0);
[4132]64      wireframe->setDescription("Starts orxonox in wireframe mode");
[4064]65      wireframe->saveability();
66      videoBox->fill(wireframe);
67
68      videoBox->fill(advancedWindowCreate());
69    }
70    videoFrame->fill(videoBox);
71  }
72  setMainWidget(videoFrame);
[2018]73}
74
[2588]75/**
[4836]76 *  Destructs the Video-stuff
[3423]77*/
[4746]78GuiVideo::~GuiVideo()
[3423]79{
80  // nothing to do here.
81}
82
83/**
[4836]84 *  Creates a window, and all it contains for the Source-update.
[3423]85*/
[4746]86Widget* GuiVideo::advancedWindowCreate()
[3423]87{
[4064]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.
[3423]91  // the button, that opens this Window.
[4064]92  advancedButton = new Button("advanced");
[3423]93
94  // the Window itself
[4064]95  advancedWindow = new Window("Advanced Video Options");
[4091]96  advancedWindow->setGroupName(CONFIG_SECTION_VIDEO_ADVANCED);
[4064]97  {
98    Box* advancedBox;         //!< A Box to pack the options into.
[3423]99
[4064]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.
[4176]109      CheckButton* particles;   //!< If the Particles should be enabled
[4064]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.
[3423]115
[4064]116      // Advanced Performance Options
[4091]117      shadows = new CheckButton(CONFIG_NAME_SHADOWS);
[4064]118      shadows->saveability();
119      advancedBox->fill(shadows);
[4777]120
[4091]121      fog = new CheckButton(CONFIG_NAME_FOG);
[4064]122      fog->saveability();
123      advancedBox->fill(fog);
[4777]124
[4091]125      reflections = new CheckButton(CONFIG_NAME_REFLECTIONS);
[4064]126      reflections->saveability();
127      advancedBox->fill(reflections);
[4777]128
[4091]129      textures = new CheckButton(CONFIG_NAME_TEXTURES);
[4777]130      textures->setDefaultValue(1);
[4064]131      textures->saveability();
132      advancedBox->fill(textures);
[4777]133
[4091]134      textureDetail = new Menu(CONFIG_NAME_TEXTURE_DETAIL, "low", "medium", "high", "lastItem");
[4064]135      textureDetail->setDefaultValue(1);
136      textureDetail->saveability();
137      advancedBox->fill(textureDetail);
[4777]138
[4091]139      modelDetailLabel = new Label(CONFIG_NAME_MODEL_DETAIL);
[4064]140      advancedBox->fill(modelDetailLabel);
[4091]141      modelDetail = new Menu(CONFIG_NAME_MODEL_DETAIL, "low", "high", "lastItem");
[4064]142      modelDetail->setDefaultValue(1);
143      modelDetail->saveability();
144      advancedBox->fill(modelDetail);
[4777]145
[4176]146      particles = new CheckButton(CONFIG_NAME_PARTICLES_ENABLED);
147      particles->saveability();
148      particles->setDefaultValue(1);
149      advancedBox->fill(particles);
150
[4064]151      antiAliasingLabel = new Label("Anti-Aliasing-depth:");
152      advancedBox->fill(antiAliasingLabel);
[4091]153      antiAliasing = new Menu(CONFIG_NAME_ANTI_ALIASING, "0", "1", "2", "4", "8",  "lastItem");
[4064]154      antiAliasing->setDefaultValue(2);
155      antiAliasing->saveability();
156      advancedBox->fill(antiAliasing);
[4777]157
[4064]158      filterMethodLabel = new Label("Filtering Method:");
159      advancedBox->fill(filterMethodLabel);
[4091]160      filterMethod = new Menu(CONFIG_NAME_FILTER_METHOD, "none", "linear", "bilinear", "trilinear", "anisortopic", "lastItem");
[4064]161      filterMethod->setDefaultValue(1);
162      filterMethod->saveability();
163      advancedBox->fill(filterMethod);
[4176]164
165
[4777]166
[4064]167      closeButton = new Button("close");
[4068]168#ifdef HAVE_GTK2
[4064]169      closeButton->connectSignal("button_press_event", advancedWindow, Window::windowClose);
[4068]170#endif /* HAVE_GTK2 */
[3423]171
[4064]172      advancedBox->fill(closeButton);
173    }
174    advancedWindow->fill(advancedBox);
175  }
176#ifdef HAVE_GTK2
177  advancedButton->connectSignal("button_press_event", advancedWindow, Window::windowOpen);
178  advancedWindow->connectSignal("destroy", advancedWindow, Window::windowClose);
179  advancedWindow->connectSignal("delete_event", advancedWindow, Window::windowClose);
[3423]180#endif /* HAVE_GTK2 */
[4064]181  Window::addWindow(advancedWindow);
[3423]182
[4064]183  return advancedButton;
[3423]184}
185
186/**
[4836]187 *  sets all resolutions to the menu
188 * @param menu the Menu to set The resolutions to.
[3423]189*/
[4056]190void GuiVideo::getResolutions(Menu* menu)
[3624]191{
192  SDL_Init(SDL_INIT_VIDEO);
193  SDL_Rect **modes;
194  int i;
[3630]195  int x = 0,y =0; // check for difference
[3624]196  char tmpChar[100];
[4777]197
[3624]198  /* Get available fullscreen/hardware modes */
199  modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
[4777]200
[3624]201  /* Check is there are any modes available */
202  if(modes == (SDL_Rect **)0){
203    PRINTF(2)("No video-modes available!\n");
204    exit(-1);
205  }
[4777]206
[3624]207  /* Check if our resolution is restricted */
208  if(modes == (SDL_Rect **)-1){
209    PRINTF(2)("All resolutions available.\n");
210  }
211  else{
212    /* Print valid modes */
[4132]213    PRINT(5)("Available Modes\n");
[3624]214    for(i = 0; modes[i] ;++i)
215      {
[4777]216        if (x != modes[i]->w || y != modes[i]->h)
217          {
218            PRINTF(5)("  %d x %d\n", modes[i]->w, modes[i]->h);
219            sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h);
220            menu->addItem(tmpChar);
221            x = modes[i]->w; y = modes[i]->h;
222          }
[3624]223      }
224  }
[5024]225  SDL_QuitSubSystem(SDL_INIT_VIDEO);
[3624]226  SDL_Quit();
227}
Note: See TracBrowser for help on using the repository browser.