Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/qt_gui: more stuff

File size: 4.0 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 <qlayout.h>
30#include "sdlincl.h"
31#include "debug.h"
32
33#include <qpushbutton.h>
34#include <qcheckbox.h>
35#include <qcombobox.h>
36
37namespace OrxGui
38{
39  /**
40   *  Creates the Video-Option-Frame
41  */
42  GuiVideo::GuiVideo()
43  : Element("Video")
44  {
45    QGridLayout* layout = new QGridLayout(this);
46    {
47      QCheckBox* fullscreen = new QCheckBox(QString("FullScreen"), NULL);
48      //fullscreen->setName();
49      layout->addWidget(fullscreen, 1, 1);
50
51    }
52
53
54
55/*    Frame* videoFrame;        //!< The Frame that holds the video options.
56
57    videoFrame = new Frame("Video-Options:");
58    videoFrame->setGroupName("video");
59    {
60      Box* videoBox;            //!< The Box that holds the video options.
61
62      videoBox = new Box('v');
63      {
64        CheckButton* fullscreen;  //!< CheckButton for fullscreen-mode
65        Menu* resolution;         //!< Menu for the resolution
66        CheckButton* wireframe;   //!< CheckButton for wireframe Mode.
67
68        fullscreen = new CheckButton(CONFIG_NAME_FULLSCREEN);
69        fullscreen->setFlagName("windowed", "q", 1);
70        fullscreen->setDescription("Starts orxonox in windowed mode");
71        fullscreen->saveability();
72        videoBox->fill(fullscreen);
73        resolution = new Menu(CONFIG_NAME_RESOLUTION);
74        getResolutions(resolution);
75        resolution->saveability();
76        resolution->setFlagName("resolution", "r", 0);
77        resolution->setDescription("Sets the resolution of orxonox");
78        videoBox->fill(resolution);
79        wireframe = new CheckButton(CONFIG_NAME_WIREFRAME);
80        wireframe->setFlagName("wireframe", "w", 0);
81        wireframe->setDescription("Starts orxonox in wireframe mode");
82        wireframe->saveability();
83        videoBox->fill(wireframe);
84
85        videoBox->fill(advancedWindowCreate());
86      }
87      videoFrame->fill(videoBox);
88    }
89    setMainWidget(videoFrame);*/
90  }
91
92  /**
93   *  Destructs the Video-stuff
94  */
95  GuiVideo::~GuiVideo()
96  {
97    // nothing to do here.
98  }
99
100  /**
101   *  sets all resolutions to the menu
102   * @param menu the Menu to set The resolutions to.
103  */
104  void GuiVideo::getResolutions(std::vector<std::string>& resolutionList)
105  {
106    SDL_Init(SDL_INIT_VIDEO);
107    SDL_Rect **modes;
108    int i;
109    int x = 0,y =0; // check for difference
110    char tmpChar[100];
111
112    /* Get available fullscreen/hardware modes */
113    modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
114
115    /* Check is there are any modes available */
116    if(modes == (SDL_Rect **)0)
117    {
118      PRINTF(2)("No video-modes available!\n");
119      exit(-1);
120    }
121
122    /* Check if our resolution is restricted */
123    if(modes == (SDL_Rect **)-1)
124    {
125      PRINTF(2)("All resolutions available.\n");
126    }
127    else
128    {
129      /* Print valid modes */
130      PRINT(5)("Available Modes\n");
131      for(i = 0; modes[i] ;++i)
132      {
133        if (x != modes[i]->w || y != modes[i]->h)
134        {
135          PRINTF(5)("  %d x %d\n", modes[i]->w, modes[i]->h);
136          sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h);
137          resolutionList.push_back(std::string(tmpChar));
138          x = modes[i]->w; y = modes[i]->h;
139        }
140      }
141    }
142    SDL_QuitSubSystem(SDL_INIT_VIDEO);
143    SDL_Quit();
144  }
145
146}
Note: See TracBrowser for help on using the repository browser.