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
RevLine 
[2581]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
[4047]27#include "gui_video.h"
[2018]28
[4064]29#include "gui_gtk.h"
[3624]30#include "glincl.h"
[4049]31#include <stdlib.h>
[3624]32
[3187]33/**
34   \brief Creates the Video-Option-Frame
35*/
[4056]36GuiVideo::GuiVideo(void)
[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);
53      fullscreen->saveability();
54      videoBox->fill(fullscreen);
[4091]55      resolution = new Menu(CONFIG_NAME_RESOLUTION);
[4064]56      getResolutions(resolution);
57      resolution->saveability();
58      resolution->setFlagName("resolution", "r", 0);
59      videoBox->fill(resolution);
[4091]60      wireframe = new CheckButton(CONFIG_NAME_WIREFRAME);
[4064]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);
[2018]70}
71
[2588]72/**
[3423]73   \brief Destructs the Video-stuff
74*/
[4056]75GuiVideo::~GuiVideo(void)
[3423]76{
77  // nothing to do here.
78}
79
80/**
81   \brief Creates a window, and all it contains for the Source-update.
82*/
[4064]83Widget* GuiVideo::advancedWindowCreate(void)
[3423]84{
[4064]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.
[3423]88  // the button, that opens this Window.
[4064]89  advancedButton = new Button("advanced");
[3423]90
91  // the Window itself
[4064]92  advancedWindow = new Window("Advanced Video Options");
[4091]93  advancedWindow->setGroupName(CONFIG_SECTION_VIDEO_ADVANCED);
[4064]94  {
95    Box* advancedBox;         //!< A Box to pack the options into.
[3423]96
[4064]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.
[3423]111
[4064]112      // Advanced Performance Options
[4091]113      shadows = new CheckButton(CONFIG_NAME_SHADOWS);
[4064]114      shadows->saveability();
115      advancedBox->fill(shadows);
116     
[4091]117      fog = new CheckButton(CONFIG_NAME_FOG);
[4064]118      fog->saveability();
119      advancedBox->fill(fog);
120     
[4091]121      reflections = new CheckButton(CONFIG_NAME_REFLECTIONS);
[4064]122      reflections->saveability();
123      advancedBox->fill(reflections);
124     
[4091]125      textures = new CheckButton(CONFIG_NAME_TEXTURES);
[4064]126      textures->saveability();
127      advancedBox->fill(textures);
128     
[4091]129      textureDetail = new Menu(CONFIG_NAME_TEXTURE_DETAIL, "low", "medium", "high", "lastItem");
[4064]130      textureDetail->setDefaultValue(1);
131      textureDetail->saveability();
132      advancedBox->fill(textureDetail);
133     
[4091]134      modelDetailLabel = new Label(CONFIG_NAME_MODEL_DETAIL);
[4064]135      advancedBox->fill(modelDetailLabel);
[4091]136      modelDetail = new Menu(CONFIG_NAME_MODEL_DETAIL, "low", "high", "lastItem");
[4064]137      modelDetail->setDefaultValue(1);
138      modelDetail->saveability();
139      advancedBox->fill(modelDetail);
140     
141      antiAliasingLabel = new Label("Anti-Aliasing-depth:");
142      advancedBox->fill(antiAliasingLabel);
[4091]143      antiAliasing = new Menu(CONFIG_NAME_ANTI_ALIASING, "0", "1", "2", "4", "8",  "lastItem");
[4064]144      antiAliasing->setDefaultValue(2);
145      antiAliasing->saveability();
146      advancedBox->fill(antiAliasing);
147     
148      filterMethodLabel = new Label("Filtering Method:");
149      advancedBox->fill(filterMethodLabel);
[4091]150      filterMethod = new Menu(CONFIG_NAME_FILTER_METHOD, "none", "linear", "bilinear", "trilinear", "anisortopic", "lastItem");
[4064]151      filterMethod->setDefaultValue(1);
152      filterMethod->saveability();
153      advancedBox->fill(filterMethod);
[3423]154 
[4064]155      closeButton = new Button("close");
[4068]156#ifdef HAVE_GTK2
[4064]157      closeButton->connectSignal("button_press_event", advancedWindow, Window::windowClose);
[4068]158#endif /* HAVE_GTK2 */
[3423]159
[4064]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);
[3423]168#endif /* HAVE_GTK2 */
[4064]169  Window::addWindow(advancedWindow);
[3423]170
[4064]171  return advancedButton;
[3423]172}
173
174/**
[4064]175   \brief sets all resolutions to the menu
176   \param menu the Menu to set The resolutions to.
[3423]177*/
[4056]178void GuiVideo::getResolutions(Menu* menu)
[3624]179{
180  SDL_Init(SDL_INIT_VIDEO);
181  SDL_Rect **modes;
182  int i;
[3630]183  int x = 0,y =0; // check for difference
[3624]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      {
[3630]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          }
[3624]211      }
212  }
213  SDL_Quit();
214}
Note: See TracBrowser for help on using the repository browser.