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 // Get renderer 00065 const GLubyte* pcRenderer = glGetString(GL_RENDERER); 00066 tmpStr = (const char*)pcRenderer; 00067 LogManager::getSingleton().logMessage("GL_RENDERER = " + tmpStr); 00068 00069 // Set extension list 00070 std::stringstream ext; 00071 String str; 00072 00073 const GLubyte* pcExt = glGetString(GL_EXTENSIONS); 00074 LogManager::getSingleton().logMessage("GL_EXTENSIONS = " + String((const char*)pcExt)); 00075 00076 assert(pcExt && "Problems getting GL extension string using glGetString"); 00077 00078 ext << pcExt; 00079 00080 while(ext >> str) 00081 { 00082 extensionList.insert(str); 00083 } 00084 00085 ext.str(""); 00086 } 00087 00088 bool GLSupport::checkMinGLVersion(const String& v) const 00089 { 00090 unsigned int first, second, third; 00091 unsigned int cardFirst, cardSecond, cardThird; 00092 if(v == mVersion) 00093 return true; 00094 00095 String::size_type pos = v.find("."); 00096 if(pos == String::npos) 00097 return false; 00098 00099 String::size_type pos1 = v.rfind("."); 00100 if(pos1 == String::npos) 00101 return false; 00102 00103 first = ::atoi(v.substr(0, pos).c_str()); 00104 second = ::atoi(v.substr(pos + 1, pos1 - (pos + 1)).c_str()); 00105 third = ::atoi(v.substr(pos1 + 1, v.length()).c_str()); 00106 00107 pos = mVersion.find("."); 00108 if(pos == String::npos) 00109 return false; 00110 00111 pos1 = mVersion.rfind("."); 00112 if(pos1 == String::npos) 00113 return false; 00114 00115 cardFirst = ::atoi(mVersion.substr(0, pos).c_str()); 00116 cardSecond = ::atoi(mVersion.substr(pos + 1, pos1 - (pos + 1)).c_str()); 00117 cardThird = ::atoi(mVersion.substr(pos1 + 1, mVersion.length()).c_str()); 00118 00119 if(first <= cardFirst && second <= cardSecond && third <= cardThird) 00120 return true; 00121 00122 return false; 00123 } 00124 00125 bool GLSupport::checkExtension(const String& ext) const 00126 { 00127 if(extensionList.find(ext) == extensionList.end()) 00128 return false; 00129 00130 return true; 00131 } 00132 00133 }
Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:26 2004