2010-07-06 20:55:05 +08:00
|
|
|
/****************************************************************************
|
2011-03-19 10:34:26 +08:00
|
|
|
Copyright (c) 2010-2011 cocos2d-x.org
|
|
|
|
Copyright (c) 2010 Ricardo Quesada
|
2011-03-19 14:45:51 +08:00
|
|
|
|
2010-07-06 20:55:05 +08:00
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-07-06 11:59:23 +08:00
|
|
|
#include "CCConfiguration.h"
|
|
|
|
#include "ccMacros.h"
|
|
|
|
#include "ccConfig.h"
|
2010-07-06 11:01:14 +08:00
|
|
|
|
|
|
|
using namespace std;
|
2010-08-04 15:46:12 +08:00
|
|
|
namespace cocos2d {
|
2010-07-06 11:01:14 +08:00
|
|
|
|
|
|
|
// singleton stuff
|
2010-10-12 17:15:44 +08:00
|
|
|
static bool g_bInited;
|
|
|
|
static CCConfiguration g_SharedConfiguration;
|
2010-07-06 11:01:14 +08:00
|
|
|
static char *g_pGlExtensions;
|
|
|
|
|
2010-07-12 17:03:27 +08:00
|
|
|
CCConfiguration::CCConfiguration(void)
|
2011-04-01 16:06:53 +08:00
|
|
|
: m_bSupportsBGRA8888(false)
|
|
|
|
, m_bSupportsDiscardFramebuffer(false)
|
|
|
|
, m_bSupportsNPOT(false)
|
|
|
|
, m_bSupportsPVRTC(false)
|
|
|
|
, m_nMaxModelviewStackDepth(0)
|
|
|
|
, m_nMaxSamplesAllowed(0)
|
|
|
|
, m_nMaxTextureSize(0)
|
|
|
|
, m_uOSVersion(0)
|
2010-07-12 17:03:27 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-09-04 12:02:52 +08:00
|
|
|
bool CCConfiguration::init(void)
|
2010-07-06 11:01:14 +08:00
|
|
|
{
|
|
|
|
CCLOG("cocos2d: GL_VENDOR: %s", glGetString(GL_VENDOR));
|
|
|
|
CCLOG("cocos2d: GL_RENDERER: %s", glGetString(GL_RENDERER));
|
|
|
|
CCLOG("cocos2d: GL_VERSION: %s", glGetString(GL_VERSION));
|
|
|
|
|
|
|
|
g_pGlExtensions = (char *)glGetString(GL_EXTENSIONS);
|
|
|
|
|
|
|
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_nMaxTextureSize);
|
|
|
|
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &m_nMaxModelviewStackDepth);
|
|
|
|
|
|
|
|
m_bSupportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc");
|
|
|
|
m_bSupportsNPOT = checkForGLExtension("GL_APPLE_texture_2D_limited_npot");
|
|
|
|
m_bSupportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888");
|
|
|
|
m_bSupportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer");
|
|
|
|
|
2010-07-06 20:55:05 +08:00
|
|
|
CCLOG("cocos2d: GL_MAX_TEXTURE_SIZE: %d", m_nMaxTextureSize);
|
|
|
|
CCLOG("cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: %d",m_nMaxModelviewStackDepth);
|
|
|
|
CCLOG("cocos2d: GL supports PVRTC: %s", (m_bSupportsPVRTC ? "YES" : "NO"));
|
|
|
|
CCLOG("cocos2d: GL supports BGRA8888 textures: %s", (m_bSupportsBGRA8888 ? "YES" : "NO"));
|
|
|
|
CCLOG("cocos2d: GL supports NPOT textures: %s", (m_bSupportsNPOT ? "YES" : "NO"));
|
|
|
|
CCLOG("cocos2d: GL supports discard_framebuffer: %s", (m_bSupportsDiscardFramebuffer ? "YES" : "NO"));
|
2010-08-06 14:04:49 +08:00
|
|
|
|
2010-08-06 14:29:57 +08:00
|
|
|
#if CC_TEXTURE_NPOT_SUPPORT
|
2010-08-06 14:04:49 +08:00
|
|
|
CCLOG("cocos2d: compiled with NPOT support: %s", "YES");
|
2010-07-06 20:55:05 +08:00
|
|
|
#else
|
2010-08-06 14:04:49 +08:00
|
|
|
CCLOG("cocos2d: compiled with NPOT support: %s", "NO");
|
2010-07-06 20:55:05 +08:00
|
|
|
#endif // CC_TEXTURE_NPOT_SUPPORT
|
|
|
|
|
2010-08-06 14:04:49 +08:00
|
|
|
|
2010-08-06 14:29:57 +08:00
|
|
|
#if CC_TEXTURE_ATLAS_USES_VBO
|
2010-08-06 14:04:49 +08:00
|
|
|
CCLOG("cocos2d: compiled with VBO support in TextureAtlas : %s", "YES");
|
2010-07-06 20:55:05 +08:00
|
|
|
#else
|
2010-08-06 14:04:49 +08:00
|
|
|
CCLOG("cocos2d: compiled with VBO support in TextureAtlas : %s", "NO");
|
2010-07-06 20:55:05 +08:00
|
|
|
#endif // CC_TEXTURE_ATLAS_USES_VBO
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2010-09-04 12:02:52 +08:00
|
|
|
return true;
|
2010-07-12 17:03:27 +08:00
|
|
|
|
2010-07-06 11:01:14 +08:00
|
|
|
}
|
|
|
|
|
2010-07-06 11:59:23 +08:00
|
|
|
CCConfiguration* CCConfiguration::sharedConfiguration(void)
|
2010-07-06 11:01:14 +08:00
|
|
|
{
|
2010-10-12 17:15:44 +08:00
|
|
|
if (! g_bInited)
|
2010-07-06 11:01:14 +08:00
|
|
|
{
|
2010-10-12 17:15:44 +08:00
|
|
|
g_SharedConfiguration.init();
|
2010-07-06 11:01:14 +08:00
|
|
|
}
|
|
|
|
|
2010-10-12 17:15:44 +08:00
|
|
|
return &g_SharedConfiguration;
|
2010-07-06 11:01:14 +08:00
|
|
|
}
|
|
|
|
|
2010-07-08 11:58:33 +08:00
|
|
|
bool CCConfiguration::checkForGLExtension(const string &searchName)
|
2010-07-06 11:01:14 +08:00
|
|
|
{
|
2010-07-12 17:03:27 +08:00
|
|
|
bool bRet = false;
|
2010-07-06 20:40:11 +08:00
|
|
|
const char *kSearchName = searchName.c_str();
|
2010-07-06 11:01:14 +08:00
|
|
|
|
2011-03-16 20:53:08 +08:00
|
|
|
if (g_pGlExtensions &&
|
|
|
|
strstr(g_pGlExtensions, kSearchName))
|
|
|
|
{
|
2010-07-12 17:03:27 +08:00
|
|
|
bRet = true;
|
2011-03-16 20:53:08 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 17:03:27 +08:00
|
|
|
return bRet;
|
2010-07-06 11:01:14 +08:00
|
|
|
}
|
2010-08-04 15:46:12 +08:00
|
|
|
}//namespace cocos2d
|