Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/qt_gui/src/lib/gui/qt_gui/gui_video.cc @ 7555

Last change on this file since 7555 was 7555, checked in by bensch, 18 years ago

orxonox/qt_gui: more elaborate Saveables

File size: 4.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 <QtGui/QLayout>
30#include "sdlincl.h"
31#include "debug.h"
32
33#include "qt_gui_elements.h"
34
35namespace OrxGui
36{
37  /**
38   *  Creates the Video-Option-Frame
39  */
40  GuiVideo::GuiVideo(OrxGui::Gui* gui)
41      : Element("Video", gui), QGroupBox()
42  {
43    QGridLayout* layout = new QGridLayout(this);
44
45    {
46      QtGuiCheckBox* fullscreen = new QtGuiCheckBox("FullScreen", this);
47      //fullscreen->setName();
48      layout->addWidget(fullscreen, 0, 0);
49
50      QtGuiCheckBox* wireframe = new QtGuiCheckBox("Wireframe mode", this);
51      layout->addWidget(wireframe, 1, 0);
52
53      {
54        QComboBox* resolution = new QComboBox();
55        layout->addWidget(resolution, 2, 0);
56        std::vector<QString> resolutions;
57        this->getResolutions(resolutions);
58        for (unsigned int i = 0; i < resolutions.size(); ++i)
59          resolution->addItem(resolutions[i]);
60      }
61
62
63      QGroupBox* advanced = new QGroupBox("advanced");
64      {
65        QGridLayout* advLayout = new QGridLayout(advanced);              //!< Advanced Layout
66        {
67          QtGuiCheckBox* shadows = new QtGuiCheckBox("Shadows", this);         //!< CheckBox for shadows
68          advLayout->addWidget(shadows, 0,0);
69          QtGuiCheckBox* fog = new QtGuiCheckBox("Fog", this);                 //!< CheckBox for fog.
70          advLayout->addWidget(fog, 1,0);
71          QtGuiCheckBox* reflections = new QtGuiCheckBox("reflections", this);  //!< CheckBox for reflections
72          advLayout->addWidget(reflections, 2, 0);
73          QtGuiCheckBox* textures = new QtGuiCheckBox("textures", this);       //!< CheckBox for textures
74          advLayout->addWidget(textures, 3, 0);
75          /*
76          Menu* textureDetail;      //!< Menu for the Texture-Detail.
77          Label* modelDetailLabel;  //!< Label for model-detail.
78          Menu* modelDetail;        //!< model-detail.
79          CheckBox* particles;   //!< If the Particles should be enabled
80          Label* antiAliasingLabel; //!< Label for the anti-aliasing mode.
81          Menu* antiAliasing;       //!< Menu for the Antialiasing-mode.
82          Label* filterMethodLabel; //!< Label for filtering-Method.
83          Menu* filterMethod;       //!< Menu for filtering Method.
84          Button* closeButton;      //!< A Button to close the Advanced-settingsWindow.
85          */
86        }
87      }
88
89      layout->addWidget(advanced, 0, 2, 4, 1);
90
91    }
92  }
93
94  /**
95   *  Destructs the Video-stuff
96  */
97  GuiVideo::~GuiVideo()
98  {
99    // nothing to do here.
100  }
101
102  /**
103   *  sets all resolutions to the menu
104   * @param menu the Menu to set The resolutions to.
105  */
106  void GuiVideo::getResolutions(std::vector<QString>& resolutionList)
107  {
108    SDL_Init(SDL_INIT_VIDEO);
109    SDL_Rect **modes;
110    int i;
111    int x = 0,y =0; // check for difference
112    char tmpChar[100];
113
114    /* Get available fullscreen/hardware modes */
115    modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
116
117    /* Check is there are any modes available */
118    if(modes == (SDL_Rect **)0)
119    {
120      PRINTF(2)("No video-modes available!\n");
121      exit(-1);
122    }
123
124    /* Check if our resolution is restricted */
125    if(modes == (SDL_Rect **)-1)
126    {
127      PRINTF(2)("All resolutions available.\n");
128    }
129    else
130    {
131      /* Print valid modes */
132      PRINT(5)("Available Modes\n");
133      for(i = 0; modes[i] ;++i)
134      {
135        if (x != modes[i]->w || y != modes[i]->h)
136        {
137          PRINTF(5)("  %d x %d\n", modes[i]->w, modes[i]->h);
138          sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h);
139          resolutionList.push_back(QString(tmpChar));
140          x = modes[i]->w; y = modes[i]->h;
141        }
142      }
143    }
144    SDL_QuitSubSystem(SDL_INIT_VIDEO);
145    SDL_Quit();
146  }
147
148}
Note: See TracBrowser for help on using the repository browser.