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