Example #1
0
bool CCConfiguration::init()
{
	m_pGlExtensions = (char*)glGetString(GL_EXTENSIONS);

	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_nMaxTextureSize);

	m_bSupportsNPOT = checkForGLExtension("GL_APPLE_texture_2D_limited_npot");
	m_bSupportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888");

	return true;
}
void Configuration::gatherGPUInfo()
{
	_valueDict["gl.vendor"] = Value((const char*)glGetString(GL_VENDOR));
	_valueDict["gl.renderer"] = Value((const char*)glGetString(GL_RENDERER));
	_valueDict["gl.version"] = Value((const char*)glGetString(GL_VERSION));

    _glExtensions = (char *)glGetString(GL_EXTENSIONS);

    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_maxTextureSize);
	_valueDict["gl.max_texture_size"] = Value((int)_maxTextureSize);

    glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_maxTextureUnits);
	_valueDict["gl.max_texture_units"] = Value((int)_maxTextureUnits);

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    glGetIntegerv(GL_MAX_SAMPLES_APPLE, &_maxSamplesAllowed);
	_valueDict["gl.max_samples_allowed"] = Value((int)_maxSamplesAllowed);
#endif
    
    _supportsETC1 = checkForGLExtension("GL_OES_compressed_ETC1_RGB8_texture");
    _valueDict["gl.supports_ETC1"] = Value(_supportsETC1);
    
    _supportsS3TC = checkForGLExtension("GL_EXT_texture_compression_s3tc");
    _valueDict["gl.supports_S3TC"] = Value(_supportsS3TC);
    
    _supportsATITC = checkForGLExtension("GL_AMD_compressed_ATC_texture");
    _valueDict["gl.supports_ATITC"] = Value(_supportsATITC);
    
    _supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc");
	_valueDict["gl.supports_PVRTC"] = Value(_supportsPVRTC);

    _supportsNPOT = true;
	_valueDict["gl.supports_NPOT"] = Value(_supportsNPOT);
	
    _supportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888");
	_valueDict["gl.supports_BGRA8888"] = Value(_supportsBGRA8888);

    _supportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer");
	_valueDict["gl.supports_discard_framebuffer"] = Value(_supportsDiscardFramebuffer);

    _supportsShareableVAO = checkForGLExtension("vertex_array_object");
	_valueDict["gl.supports_vertex_array_object"] = Value(_supportsShareableVAO);
    
    _supportsOESDepth24 = checkForGLExtension("GL_OES_depth24");
    _valueDict["gl.supports_OES_depth24"] = Value(_supportsOESDepth24);

    
    _supportsOESPackedDepthStencil = checkForGLExtension("GL_OES_packed_depth_stencil");
    _valueDict["gl.supports_OES_packed_depth_stencil"] = Value(_supportsOESPackedDepthStencil);


    CHECK_GL_ERROR_DEBUG();
}
bool CCConfiguration::init(void)
{
	CCLOG("cocos2d: GL_VENDOR:     %s", glGetString(GL_VENDOR));
	CCLOG("cocos2d: GL_RENDERER:   %s", glGetString(GL_RENDERER));
	CCLOG("cocos2d: GL_VERSION:    %s", glGetString(GL_VERSION));

	m_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");

	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"));
	
#if CC_TEXTURE_NPOT_SUPPORT
	CCLOG("cocos2d: compiled with NPOT support: %s", "YES");
#else
	CCLOG("cocos2d: compiled with NPOT support: %s", "NO");
#endif // CC_TEXTURE_NPOT_SUPPORT 

	
#if CC_TEXTURE_ATLAS_USES_VBO
	CCLOG("cocos2d: compiled with VBO support in TextureAtlas : %s", "YES");
#else
	CCLOG("cocos2d: compiled with VBO support in TextureAtlas : %s", "NO");
#endif // CC_TEXTURE_ATLAS_USES_VBO

	return true;
}
	void G2DConfiguration::initConfiguration()
	{
		if (!s_inited) {
			//TODO get os version
			oa_debug("GL_VENDOR:   %s", glGetString(GL_VENDOR));
			oa_debug("GL_RENDERER: %s", glGetString(GL_RENDERER));
			oa_debug("GL_VERSION:  %s", glGetString(GL_VERSION));

			s_glExtensions = (char*) glGetString(GL_EXTENSIONS);
			s_glExtensionsString = s_glExtensions;

			s_inited = true;

			glGetIntegerv(GL_MAX_TEXTURE_SIZE, &s_maxTextureSize);
			glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &s_maxModelviewStackDepth);

			s_maxSamplesAllowed = 0; //always 0 on Android

			s_supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc");
			s_supportsNPOT = checkForGLExtension("GL_APPLE_texture_2D_limited_npot");
			bool bgra8a = checkForGLExtension("GL_IMG_texture_format_BGRA8888");
			bool bgra8b = checkForGLExtension("GL_APPLE_texture_format_BGRA8888");
			s_supportsBGRA8888 = bgra8a | bgra8b;

			s_supportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer");

			oa_debug("GL_MAX_TEXTURE_SIZE: %d", s_maxTextureSize);
			oa_debug("GL_MAX_MODELVIEW_STACK_DEPTH: %d", s_maxModelviewStackDepth);
			oa_debug("GL_MAX_SAMPLES: %d", s_maxSamplesAllowed);
			oa_debug("GL supports PVRTC: %s", (s_supportsPVRTC ? "YES" : "NO"));
			oa_debug(
					"GL supports BGRA8888 textures: %s", (s_supportsBGRA8888 ? "YES" : "NO"));
			oa_debug("GL supports NPOT textures: %s", (s_supportsNPOT ? "YES" : "NO"));
			oa_debug(
					"GL supports discard_framebuffer: %s", (s_supportsDiscardFramebuffer ? "YES" : "NO"));
			oa_debug("compiled with NPOT support: %s",
#if CC_TEXTURE_NPOT_SUPPORT
					"YES"
#else
					"NO"
#endif
					);
			oa_debug("compiled with VBO support in TextureAtlas : %s",
#if CC_USES_VBO
					"YES"
#else
					"NO"
#endif
			);

			oa_debug("compiled with Affine Matrix transformation in CCNode : %s",
#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
					"YES"
#else
					"NO"
#endif
					);

			oa_debug("compiled with Profiling Support: %s",
#if CC_ENABLE_PROFILERS
					"YES - *** Disable it when you finish profiling ***"
#else
					"NO"
#endif
					);

			CHECK_GL_ERROR();
		}
	}