Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/guiMerge/src/lib/gui/gui/gui_video.cc @ 4047

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

orxonox/branches/guiMerge: nameSpace-changes

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