source: OGRE/trunk/ogrenew/RenderSystems/GL/src/GLX/OgreGLXGLSupport.cpp @ 692

Revision 692, 5.9 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6 
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9 
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14 
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25
26#include "OgreException.h"
27#include "OgreLogManager.h"
28#include "OgreStringConverter.h"
29#include "OgreRoot.h"
30
31#include "OgreGLXGLSupport.h"
32
33#include "OgreGLXWindow.h"
34#include "OgreGLTexture.h"
35
36#include "OgreGLXRenderTexture.h"
37
38namespace Ogre {
39
40GLXGLSupport::GLXGLSupport():
41mDisplay(0) {}
42
43GLXGLSupport::~GLXGLSupport() {}
44
45void GLXGLSupport::addConfig(void) {
46        ConfigOption optFullScreen;
47        ConfigOption optVideoMode;
48        ConfigOption optBitDepth;
49    ConfigOption optFSAA;
50        ConfigOption optRTTMode;
51
52        // FS setting possiblities
53        optFullScreen.name = "Full Screen";
54        optFullScreen.possibleValues.push_back("Yes");
55        optFullScreen.possibleValues.push_back("No");
56        optFullScreen.currentValue = "Yes";
57        optFullScreen.immutable = false;
58
59        // Video mode possiblities
60        optVideoMode.name = "Video Mode";
61        optVideoMode.immutable = false;
62
63        // We could query Xrandr here, but that wouldn't work in the non-fullscreen case
64        // or when that extension is disabled. Anyway, this list of modes is fairly
65        // complete.
66        optVideoMode.possibleValues.push_back("640 x 480");
67        optVideoMode.possibleValues.push_back("800 x 600");
68        optVideoMode.possibleValues.push_back("1024 x 768");
69        optVideoMode.possibleValues.push_back("1280 x 960");
70        optVideoMode.possibleValues.push_back("1280 x 1024");
71        optVideoMode.possibleValues.push_back("1600 x 1200");
72
73        optVideoMode.currentValue = "800 x 600";
74
75    //FSAA possibilities
76    optFSAA.name = "FSAA";
77    optFSAA.possibleValues.push_back("0");
78    optFSAA.possibleValues.push_back("2");
79    optFSAA.possibleValues.push_back("4");
80    optFSAA.possibleValues.push_back("6");
81    optFSAA.currentValue = "0";
82    optFSAA.immutable = false;
83
84        optRTTMode.name = "RTT Preferred Mode";
85        optRTTMode.possibleValues.push_back("FBO");
86        optRTTMode.possibleValues.push_back("PBuffer");
87        optRTTMode.possibleValues.push_back("Copy");
88        optRTTMode.currentValue = "FBO";
89        optRTTMode.immutable = false;
90
91
92        mOptions[optFullScreen.name] = optFullScreen;
93        mOptions[optVideoMode.name] = optVideoMode;
94    mOptions[optFSAA.name] = optFSAA;
95        mOptions[optRTTMode.name] = optRTTMode;
96}
97
98String GLXGLSupport::validateConfig(void) {
99        return String("");
100}
101
102RenderWindow* GLXGLSupport::createWindow(bool autoCreateWindow, GLRenderSystem* renderSystem, const String& windowTitle)
103{
104        if (autoCreateWindow) {
105                ConfigOptionMap::iterator opt = mOptions.find("Full Screen");
106                if (opt == mOptions.end())
107                        OGRE_EXCEPT(999, "Can't find full screen options!", "GLXGLSupport::createWindow");
108                bool fullscreen = (opt->second.currentValue == "Yes");
109
110                opt = mOptions.find("Video Mode");
111                if (opt == mOptions.end())
112                        OGRE_EXCEPT(999, "Can't find video mode options!", "GLXGLSupport::createWindow");
113                String val = opt->second.currentValue;
114                String::size_type pos = val.find('x');
115                if (pos == String::npos)
116                        OGRE_EXCEPT(999, "Invalid Video Mode provided", "GLXGLSupport::createWindow");
117
118                unsigned int w = StringConverter::parseUnsignedInt(val.substr(0, pos));
119                unsigned int h = StringConverter::parseUnsignedInt(val.substr(pos + 1));
120
121        // Parse FSAA config
122                NameValuePairList winOptions;
123                winOptions["title"] = windowTitle;
124        int fsaa_x_samples = 0;
125        opt = mOptions.find("FSAA");
126        if(opt != mOptions.end())
127        {
128                        winOptions["FSAA"] = opt->second.currentValue;
129        }
130
131                return renderSystem->createRenderWindow(windowTitle, w, h, fullscreen, &winOptions);
132        } else {
133                // XXX What is the else?
134                return NULL;
135        }
136}
137
138RenderWindow* GLXGLSupport::newWindow(const String &name, unsigned int width, unsigned int height,
139        bool fullScreen, const NameValuePairList *miscParams)
140{
141        GLXWindow* window = new GLXWindow(mDisplay);
142        window->create(name, width, height, fullScreen, miscParams);
143        return window;
144}
145
146void GLXGLSupport::start() {
147        LogManager::getSingleton().logMessage(
148                "******************************\n"
149                "*** Starting GLX Subsystem ***\n"
150                "******************************");
151        mDisplay = XOpenDisplay(NULL);
152        if(!mDisplay) {
153                OGRE_EXCEPT(999, "Couldn`t open X display", "GLXGLSupport::start");
154        }
155
156}
157
158void GLXGLSupport::stop() {
159        LogManager::getSingleton().logMessage(
160                "******************************\n"
161                "*** Stopping GLX Subsystem ***\n"
162                "******************************");
163        if(mDisplay)
164                XCloseDisplay(mDisplay);
165        mDisplay = 0;
166}
167
168extern "C" {
169extern void (*glXGetProcAddressARB(const GLubyte *procName))( void );
170};
171
172void* GLXGLSupport::getProcAddress(const String& procname) {
173        return (void*)glXGetProcAddressARB((const GLubyte*)procname.c_str());
174}
175
176
177bool GLXGLSupport::supportsPBuffers()
178{
179    return true;
180}
181GLPBuffer *GLXGLSupport::createPBuffer(PixelComponentType format, size_t width, size_t height)
182{
183    return new GLXPBuffer(format, width, height);
184}
185
186}
Note: See TracBrowser for help on using the repository browser.