Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/gui/gui/orxonox_gui_video.cc @ 3630

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

orxonox/trunk: gui: little patch, now only one resolution will be shown, if multiple bpp's are availiable

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