Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreGLSupport.cpp

Go to the documentation of this file.
00001 
00002 /*
00003 -----------------------------------------------------------------------------
00004 This source file is part of OGRE
00005     (Object-oriented Graphics Rendering Engine)
00006 For the latest info, see http://www.ogre3d.org/
00007 
00008 Copyright © 2000-2002 The OGRE Team
00009 Also see acknowledgements in Readme.html
00010 
00011 This program is free software; you can redistribute it and/or modify it under
00012 the terms of the GNU Lesser General Public License as published by the Free Software
00013 Foundation; either version 2 of the License, or (at your option) any later
00014 version.
00015 
00016 This program is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00019 
00020 You should have received a copy of the GNU Lesser General Public License along with
00021 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00022 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00023 http://www.gnu.org/copyleft/lesser.txt.
00024 -----------------------------------------------------------------------------
00025 */
00026 
00027 
00028 #include "OgreGLSupport.h"
00029 #include "OgreLogManager.h"
00030 
00031 namespace Ogre {
00032 
00033     void GLSupport::setConfigOption(const String &name, const String &value)
00034     {
00035         ConfigOptionMap::iterator it = mOptions.find(name);
00036 
00037         if (it != mOptions.end())
00038             it->second.currentValue = value;
00039     }
00040 
00041     ConfigOptionMap& GLSupport::getConfigOptions(void)
00042     {
00043         return mOptions;
00044     }
00045 
00046     void GLSupport::initialiseExtensions(void)
00047     {
00048         // Set version string
00049         const GLubyte* pcVer = glGetString(GL_VERSION);
00050 
00051 
00052         assert(pcVer && "Problems getting GL version string using glGetString");
00053        
00054         String tmpStr = (const char*)pcVer;
00055         LogManager::getSingleton().logMessage("GL_VERSION = " + tmpStr);
00056         mVersion = tmpStr.substr(0, tmpStr.find(" "));
00057 
00058         // Get vendor
00059         const GLubyte* pcVendor = glGetString(GL_VENDOR);
00060         tmpStr = (const char*)pcVendor;
00061         LogManager::getSingleton().logMessage("GL_VENDOR = " + tmpStr);
00062         mVendor = tmpStr.substr(0, tmpStr.find(" "));
00063 
00064         // Set extension list
00065         std::stringstream ext;
00066         String str;
00067 
00068         const GLubyte* pcExt = glGetString(GL_EXTENSIONS);
00069         LogManager::getSingleton().logMessage("GL_EXTENSIONS = " + String((const char*)pcExt));
00070 
00071         assert(pcExt && "Problems getting GL extension string using glGetString");
00072 
00073         ext << pcExt;
00074 
00075         while(ext >> str)
00076         {
00077             extensionList.insert(str);
00078         }
00079 
00080         ext.str("");
00081     }
00082 
00083     bool GLSupport::checkMinGLVersion(const String& v) const
00084     {
00085         unsigned int first, second, third;
00086         unsigned int cardFirst, cardSecond, cardThird;
00087         if(v == mVersion)
00088             return true;
00089 
00090         String::size_type pos = v.find(".");
00091         if(pos == String::npos)
00092             return false;
00093 
00094         String::size_type pos1 = v.rfind(".");
00095         if(pos1 == String::npos)
00096             return false;
00097 
00098         first = ::atoi(v.substr(0, pos).c_str());
00099         second = ::atoi(v.substr(pos + 1, pos1 - (pos + 1)).c_str());
00100         third = ::atoi(v.substr(pos1 + 1, v.length()).c_str());
00101 
00102         pos = mVersion.find(".");
00103         if(pos == String::npos)
00104             return false;
00105 
00106         pos1 = mVersion.rfind(".");
00107         if(pos1 == String::npos)
00108             return false;
00109 
00110         cardFirst  = ::atoi(mVersion.substr(0, pos).c_str());
00111         cardSecond = ::atoi(mVersion.substr(pos + 1, pos1 - (pos + 1)).c_str());
00112         cardThird  = ::atoi(mVersion.substr(pos1 + 1, mVersion.length()).c_str());
00113 
00114         if(first <= cardFirst && second <= cardSecond && third <= cardThird)
00115           return true;
00116 
00117         return false;
00118     }
00119 
00120     bool GLSupport::checkExtension(const String& ext) const
00121     {
00122         if(extensionList.find(ext) == extensionList.end())
00123             return false; 
00124         
00125         return true;
00126     }
00127 
00128 }

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:13 2004