[692] | 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-2005 The OGRE Team
|
---|
| 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 | */
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | #include "OgreGLSupport.h"
|
---|
| 29 | #include "OgreGLTexture.h"
|
---|
| 30 | #include "OgreLogManager.h"
|
---|
| 31 |
|
---|
| 32 | namespace 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 | bool GLSupport::checkMinGLVersion(const String& v) const
|
---|
| 90 | {
|
---|
| 91 | unsigned int first, second, third;
|
---|
| 92 | unsigned int cardFirst, cardSecond, cardThird;
|
---|
| 93 | if(v == mVersion)
|
---|
| 94 | return true;
|
---|
| 95 |
|
---|
| 96 | String::size_type pos = v.find(".");
|
---|
| 97 | if(pos == String::npos)
|
---|
| 98 | return false;
|
---|
| 99 |
|
---|
| 100 | String::size_type pos1 = v.rfind(".");
|
---|
| 101 | if(pos1 == String::npos)
|
---|
| 102 | return false;
|
---|
| 103 |
|
---|
| 104 | first = ::atoi(v.substr(0, pos).c_str());
|
---|
| 105 | second = ::atoi(v.substr(pos + 1, pos1 - (pos + 1)).c_str());
|
---|
| 106 | third = ::atoi(v.substr(pos1 + 1, v.length()).c_str());
|
---|
| 107 |
|
---|
| 108 | pos = mVersion.find(".");
|
---|
| 109 | if(pos == String::npos)
|
---|
| 110 | return false;
|
---|
| 111 |
|
---|
| 112 | pos1 = mVersion.rfind(".");
|
---|
| 113 | if(pos1 == String::npos)
|
---|
| 114 | return false;
|
---|
| 115 |
|
---|
| 116 | cardFirst = ::atoi(mVersion.substr(0, pos).c_str());
|
---|
| 117 | cardSecond = ::atoi(mVersion.substr(pos + 1, pos1 - (pos + 1)).c_str());
|
---|
| 118 | cardThird = ::atoi(mVersion.substr(pos1 + 1, mVersion.length()).c_str());
|
---|
| 119 |
|
---|
| 120 | if(first <= cardFirst && second <= cardSecond && third <= cardThird)
|
---|
| 121 | return true;
|
---|
| 122 |
|
---|
| 123 | return false;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | bool GLSupport::checkExtension(const String& ext) const
|
---|
| 127 | {
|
---|
| 128 | if(extensionList.find(ext) == extensionList.end())
|
---|
| 129 | return false;
|
---|
| 130 |
|
---|
| 131 | return true;
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | bool GLSupport::supportsPBuffers()
|
---|
| 135 | {
|
---|
| 136 | return false;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | GLPBuffer* GLSupport::createPBuffer(PixelComponentType format, size_t width, size_t height)
|
---|
| 140 | {
|
---|
| 141 | return 0;
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | }
|
---|