Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: menus now show something useFull…

File size: 5.7 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 "glincl.h"
30#include <stdlib.h>
31
32/**
33   \brief Creates the Video-Option-Frame
34*/
35GuiVideo::GuiVideo(void)
36{
37  this->videoFrame = new Frame("Video-Options:");
38  this->videoBox = new Box('v');
39  this->videoFrame->setGroupName("video");
40 
41  this->fullscreen = new CheckButton("Fullscreen-mode");
42  this->fullscreen->setFlagName("windowed", "q", 1);
43  this->fullscreen->saveability();
44  this->videoBox->fill(this->fullscreen);
45  this->resolution = new Menu("Resolution");
46  this->getResolutions(this->resolution);
47  this->resolution->saveability();
48  this->resolution->setFlagName("resolution", "r", 0);
49  this->videoBox->fill(this->resolution);
50  this->wireframe = new CheckButton("WireFrame-mode");
51  this->wireframe->setFlagName("wireframe", "w", 0);
52  this->wireframe->saveability();
53  this->videoBox->fill(this->wireframe);
54
55  this->advancedWindowCreate();
56  this->videoBox->fill(this->advancedWindowGetButton());
57
58  this->videoFrame->fill(videoBox);
59  this->setMainWidget(this->videoFrame);
60}
61
62/**
63   \brief Destructs the Video-stuff
64*/
65GuiVideo::~GuiVideo(void)
66{
67  // nothing to do here.
68}
69
70/**
71   \brief Creates a window, and all it contains for the Source-update.
72*/
73void GuiVideo::advancedWindowCreate(void)
74{
75  // the button, that opens this Window.
76  this->advancedButton = new Button("advanced");
77
78  // the Window itself
79  this->advancedWindow = new Window("Advanced Video Options");
80  this->advancedWindow->setGroupName("advancedVideoOptions");
81
82  this->advancedBox = new Box('v');
83
84  // Advanced Performance Options
85  this->shadows = new CheckButton("Shadows");
86  this->shadows->saveability();
87  this->advancedBox->fill(this->shadows);
88
89  this->fog = new CheckButton("Fog");
90  this->fog->saveability();
91  this->advancedBox->fill(this->fog);
92
93  this->reflections = new CheckButton("Reflections");
94  this->reflections->saveability();
95  this->advancedBox->fill(this->reflections);
96
97  this->textures = new CheckButton("Textures");
98  this->textures->saveability();
99  this->advancedBox->fill(this->textures);
100
101  this->textureDetail = new Menu("Texture Detail", "low", "medium", "high", "lastItem");
102  this->textureDetail->setDefaultValue(1);
103  this->textureDetail->saveability();
104  this->advancedBox->fill(this->textureDetail);
105
106  this->modelDetailLabel = new Label("Model Detail");
107  this->advancedBox->fill(this->modelDetailLabel);
108  this->modelDetail = new Menu("Model Detail", "low", "high", "lastItem");
109  this->modelDetail->setDefaultValue(1);
110  this->modelDetail->saveability();
111  this->advancedBox->fill(this->modelDetail);
112
113  this->antiAliasingLabel = new Label("Anti-Aliasing-depth:");
114  this->advancedBox->fill(this->antiAliasingLabel);
115  this->antiAliasing = new Menu("Anti Aliasing", "0", "1", "2", "4", "8",  "lastItem");
116  this->antiAliasing->setDefaultValue(2);
117  this->antiAliasing->saveability();
118  this->advancedBox->fill(this->antiAliasing);
119
120  this->filterMethodLabel = new Label("Filtering Method:");
121  this->advancedBox->fill(this->filterMethodLabel);
122  this->filterMethod = new Menu("Filtering Method", "none", "linear", "bilinear", "trilinear", "anisortopic", "lastItem");
123  this->filterMethod->setDefaultValue(1);
124  this->filterMethod->saveability();
125  this->advancedBox->fill(this->filterMethod);
126 
127  this->closeButton = new Button("close");
128  this->advancedBox->fill(this->closeButton);
129
130  this->advancedWindow->fill(advancedBox);
131#ifdef HAVE_GTK2
132  this->advancedButton->connectSignal("button_press_event", this->advancedWindow, Window::windowOpen);
133  this->closeButton->connectSignal("button_press_event", this->advancedWindow, Window::windowClose);
134  this->advancedWindow->connectSignal("destroy", this->advancedWindow, Window::windowClose);
135  this->advancedWindow->connectSignal("delete_event", this->advancedWindow, Window::windowClose);
136#endif /* HAVE_GTK2 */
137   Window::addWindow(this->advancedWindow);
138
139}
140
141/**
142   \returns A Pointer to the Button of the UpdaterSourceWindow
143*/
144Button* GuiVideo::advancedWindowGetButton(void)
145{
146  return this->advancedButton;
147}
148
149void GuiVideo::getResolutions(Menu* menu)
150{
151  SDL_Init(SDL_INIT_VIDEO);
152  SDL_Rect **modes;
153  int i;
154  int x = 0,y =0; // check for difference
155  char tmpChar[100];
156 
157  /* Get available fullscreen/hardware modes */
158  modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
159 
160  /* Check is there are any modes available */
161  if(modes == (SDL_Rect **)0){
162    PRINTF(2)("No video-modes available!\n");
163    exit(-1);
164  }
165 
166  /* Check if our resolution is restricted */
167  if(modes == (SDL_Rect **)-1){
168    PRINTF(2)("All resolutions available.\n");
169  }
170  else{
171    /* Print valid modes */
172    PRINT(4)("Available Modes\n");
173    for(i = 0; modes[i] ;++i)
174      {
175        if (x != modes[i]->w || y != modes[i]->h)
176          { 
177            PRINT(4)("  %d x %d\n", modes[i]->w, modes[i]->h);
178            sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h);
179            menu->addItem(tmpChar);
180            x = modes[i]->w; y = modes[i]->h;
181          }
182      }
183  }
184  SDL_Quit();
185}
Note: See TracBrowser for help on using the repository browser.