[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 | |
---|
[2018] | 27 | #include "orxonox_gui_video.h" |
---|
| 28 | |
---|
[3624] | 29 | #include "glincl.h" |
---|
| 30 | |
---|
[3187] | 31 | /** |
---|
| 32 | \brief Creates the Video-Option-Frame |
---|
| 33 | */ |
---|
[3423] | 34 | OrxonoxGuiVideo::OrxonoxGuiVideo(void) |
---|
[2018] | 35 | { |
---|
[3423] | 36 | this->videoFrame = new Frame("Video-Options:"); |
---|
| 37 | this->videoBox = new Box('v'); |
---|
| 38 | this->videoFrame->setGroupName("video"); |
---|
[2018] | 39 | |
---|
[3423] | 40 | this->fullscreen = new CheckButton("Fullscreen-mode"); |
---|
| 41 | this->fullscreen->setFlagName("windowed", "q", 1); |
---|
| 42 | this->fullscreen->saveability(); |
---|
[3452] | 43 | this->videoBox->fill(this->fullscreen); |
---|
[3624] | 44 | this->resolution = new Menu("Resolution"); |
---|
| 45 | this->getResolutions(this->resolution); |
---|
[3452] | 46 | this->resolution->saveability(); |
---|
| 47 | this->videoBox->fill(this->resolution); |
---|
[3423] | 48 | this->wireframe = new CheckButton("WireFrame-mode"); |
---|
| 49 | this->wireframe->setFlagName("wireframe", "w", 0); |
---|
| 50 | this->wireframe->saveability(); |
---|
[3452] | 51 | this->videoBox->fill(this->wireframe); |
---|
[2018] | 52 | |
---|
[3423] | 53 | this->advancedWindowCreate(); |
---|
| 54 | this->videoBox->fill(this->advancedWindowGetButton()); |
---|
| 55 | |
---|
| 56 | this->videoFrame->fill(videoBox); |
---|
[2018] | 57 | } |
---|
| 58 | |
---|
[2588] | 59 | /** |
---|
[3423] | 60 | \brief Destructs the Video-stuff |
---|
| 61 | */ |
---|
| 62 | OrxonoxGuiVideo::~OrxonoxGuiVideo(void) |
---|
| 63 | { |
---|
| 64 | // nothing to do here. |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | /** |
---|
[2588] | 68 | \return Returns the Video-frame |
---|
| 69 | */ |
---|
[3423] | 70 | Widget* OrxonoxGuiVideo::getWidget(void) |
---|
[2018] | 71 | { |
---|
[3423] | 72 | return this->videoFrame; |
---|
[2018] | 73 | } |
---|
[3423] | 74 | |
---|
| 75 | |
---|
| 76 | /** |
---|
| 77 | \brief Creates a window, and all it contains for the Source-update. |
---|
| 78 | */ |
---|
| 79 | void 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 | */ |
---|
| 146 | Button* OrxonoxGuiVideo::advancedWindowGetButton(void) |
---|
| 147 | { |
---|
| 148 | return this->advancedButton; |
---|
| 149 | } |
---|
| 150 | |
---|
[3624] | 151 | void OrxonoxGuiVideo::getResolutions(Menu* menu) |
---|
| 152 | { |
---|
| 153 | SDL_Init(SDL_INIT_VIDEO); |
---|
| 154 | SDL_Rect **modes; |
---|
| 155 | int i; |
---|
| 156 | char tmpChar[100]; |
---|
| 157 | |
---|
| 158 | /* Get available fullscreen/hardware modes */ |
---|
| 159 | modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); |
---|
| 160 | |
---|
| 161 | /* Check is there are any modes available */ |
---|
| 162 | if(modes == (SDL_Rect **)0){ |
---|
| 163 | PRINTF(2)("No video-modes available!\n"); |
---|
| 164 | exit(-1); |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | /* Check if our resolution is restricted */ |
---|
| 168 | if(modes == (SDL_Rect **)-1){ |
---|
| 169 | PRINTF(2)("All resolutions available.\n"); |
---|
| 170 | } |
---|
| 171 | else{ |
---|
| 172 | /* Print valid modes */ |
---|
| 173 | PRINT(4)("Available Modes\n"); |
---|
| 174 | for(i = 0; modes[i] ;++i) |
---|
| 175 | { |
---|
| 176 | PRINT(4)(" %d x %d\n", modes[i]->w, modes[i]->h); |
---|
| 177 | sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h); |
---|
| 178 | menu->addItem(tmpChar); |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | SDL_Quit(); |
---|
| 182 | } |
---|