source: OGRE/trunk/ogrenew/RenderSystems/GL/src/OgreGLSupport.cpp @ 657

Revision 657, 4.6 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1
2/*
3-----------------------------------------------------------------------------
4This source file is part of OGRE
5    (Object-oriented Graphics Rendering Engine)
6For the latest info, see http://www.ogre3d.org/
7
8Copyright (c) 2000-2005 The OGRE Team
9Also see acknowledgements in Readme.html
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GNU Lesser General Public License as published by the Free Software
13Foundation; either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public License along with
21this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://www.gnu.org/copyleft/lesser.txt.
24-----------------------------------------------------------------------------
25*/
26
27
28#include "OgreGLSupport.h"
29#include "OgreGLTexture.h"
30#include "OgreLogManager.h"
31
32namespace Ogre {
33
34        void GLSupport::setConfigOption(const String &name, const String &value)
35        {
36                ConfigOptionMap::iterator it = mOptions.find(name);
37
38        if (it != mOptions.end())
39            it->second.currentValue = value;
40        }
41
42        ConfigOptionMap& GLSupport::getConfigOptions(void)
43        {
44                return mOptions;
45        }
46
47    void GLSupport::initialiseExtensions(void)
48    {
49        // Set version string
50        const GLubyte* pcVer = glGetString(GL_VERSION);
51
52
53        assert(pcVer && "Problems getting GL version string using glGetString");
54       
55        String tmpStr = (const char*)pcVer;
56        LogManager::getSingleton().logMessage("GL_VERSION = " + tmpStr);
57        mVersion = tmpStr.substr(0, tmpStr.find(" "));
58
59        // Get vendor
60        const GLubyte* pcVendor = glGetString(GL_VENDOR);
61        tmpStr = (const char*)pcVendor;
62        LogManager::getSingleton().logMessage("GL_VENDOR = " + tmpStr);
63        mVendor = tmpStr.substr(0, tmpStr.find(" "));
64
65        // Get renderer
66        const GLubyte* pcRenderer = glGetString(GL_RENDERER);
67        tmpStr = (const char*)pcRenderer;
68        LogManager::getSingleton().logMessage("GL_RENDERER = " + tmpStr);
69
70        // Set extension list
71                std::stringstream ext;
72        String str;
73
74        const GLubyte* pcExt = glGetString(GL_EXTENSIONS);
75        LogManager::getSingleton().logMessage("GL_EXTENSIONS = " + String((const char*)pcExt));
76
77        assert(pcExt && "Problems getting GL extension string using glGetString");
78
79        ext << pcExt;
80
81        while(ext >> str)
82        {
83            extensionList.insert(str);
84        }
85
86        ext.str("");
87    }
88
89        void GLSupport::initialiseCapabilities(RenderSystemCapabilities &caps) {
90                // Do nothing by default
91        }
92
93    bool GLSupport::checkMinGLVersion(const String& v) const
94    {
95        unsigned int first, second, third;
96        unsigned int cardFirst, cardSecond, cardThird;
97        if(v == mVersion)
98            return true;
99
100        String::size_type pos = v.find(".");
101        if(pos == String::npos)
102            return false;
103
104        String::size_type pos1 = v.rfind(".");
105        if(pos1 == String::npos)
106            return false;
107
108        first = ::atoi(v.substr(0, pos).c_str());
109        second = ::atoi(v.substr(pos + 1, pos1 - (pos + 1)).c_str());
110        third = ::atoi(v.substr(pos1 + 1, v.length()).c_str());
111
112        pos = mVersion.find(".");
113        if(pos == String::npos)
114            return false;
115
116        pos1 = mVersion.rfind(".");
117        if(pos1 == String::npos)
118            return false;
119
120        cardFirst  = ::atoi(mVersion.substr(0, pos).c_str());
121        cardSecond = ::atoi(mVersion.substr(pos + 1, pos1 - (pos + 1)).c_str());
122        cardThird  = ::atoi(mVersion.substr(pos1 + 1, mVersion.length()).c_str());
123
124        if(first <= cardFirst && second <= cardSecond && third <= cardThird)
125          return true;
126
127        return false;
128    }
129
130    bool GLSupport::checkExtension(const String& ext) const
131    {
132        if(extensionList.find(ext) == extensionList.end())
133            return false;
134       
135        return true;
136    }
137
138        RenderTexture * GLSupport::createRenderTexture( const String & name, unsigned int width, unsigned int height,
139                TextureType texType, PixelFormat internalFormat,
140                const NameValuePairList *miscParams )
141    {
142        return new GLRenderTexture(name, width, height, texType, internalFormat, miscParams);
143    } 
144
145}
Note: See TracBrowser for help on using the repository browser.