Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/branches/guiMerge: minor

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