void RenderManager::DetectRenderingCapabilities() { #if defined(__DAVAENGINE_MACOS__) caps.isHardwareCursorSupported = true; #elif defined (__DAVAENGINE_IPHONE__) || defined (__DAVAENGINE_ANDROID__) caps.isHardwareCursorSupported = false; #endif #if defined(__DAVAENGINE_IPHONE__) caps.isPVRTCSupported = IsGLExtensionSupported("GL_IMG_texture_compression_pvrtc"); caps.isETCSupported = false; caps.isDXTSupported = false; caps.isBGRA8888Supported = IsGLExtensionSupported("GL_APPLE_texture_format_BGRA8888"); caps.isFloat16Supported = IsGLExtensionSupported("GL_OES_texture_half_float"); caps.isFloat32Supported = IsGLExtensionSupported("GL_OES_texture_float"); #elif defined(__DAVAENGINE_ANDROID__) //TODO: added correct caps.isPVRTCSupported = IsGLExtensionSupported("GL_IMG_texture_compression_pvrtc"); caps.isETCSupported = IsGLExtensionSupported("GL_OES_compressed_ETC1_RGB8_texture"); caps.isDXTSupported = IsGLExtensionSupported("GL_EXT_texture_compression_s3tc"); caps.isBGRA8888Supported = false; caps.isFloat16Supported = IsGLExtensionSupported("GL_OES_texture_half_float"); caps.isFloat32Supported = IsGLExtensionSupported("GL_OES_texture_float"); #elif defined(__DAVAENGINE_MACOS__) caps.isPVRTCSupported = false; caps.isDXTSupported = IsGLExtensionSupported("GL_EXT_texture_compression_s3tc"); caps.isETCSupported = IsGLExtensionSupported("GL_OES_compressed_ETC1_RGB8_texture"); caps.isBGRA8888Supported = IsGLExtensionSupported("GL_IMG_texture_format_BGRA8888"); caps.isFloat16Supported = IsGLExtensionSupported("GL_ARB_half_float_pixel"); caps.isFloat32Supported = IsGLExtensionSupported("GL_ARB_texture_float"); #elif defined(__DAVAENGINE_WIN32__) caps.isPVRTCSupported = false; caps.isETCSupported = IsGLExtensionSupported("GL_OES_compressed_ETC1_RGB8_texture"); caps.isBGRA8888Supported = IsGLExtensionSupported("GL_IMG_texture_format_BGRA8888"); caps.isFloat16Supported = IsGLExtensionSupported("GL_ARB_half_float_pixel"); caps.isFloat32Supported = IsGLExtensionSupported("GL_ARB_texture_float"); caps.isDXTSupported = IsGLExtensionSupported("GL_EXT_texture_compression_s3tc"); #endif // caps.isDXTSupported = IsGLExtensionSupported("GL_EXT_texture_compression_s3tc"); }
void RenderManager::DetectRenderingCapabilities() { #if defined(__DAVAENGINE_MACOS__) caps.isHardwareCursorSupported = true; #elif defined (__DAVAENGINE_IPHONE__) || defined (__DAVAENGINE_ANDROID__) caps.isHardwareCursorSupported = false; #endif #if defined(__DAVAENGINE_IPHONE__) caps.isPVRTCSupported = IsGLExtensionSupported("GL_IMG_texture_compression_pvrtc"); caps.isPVRTC2Supported = IsGLExtensionSupported("GL_IMG_texture_compression_pvrtc2"); caps.isETCSupported = false; caps.isDXTSupported = false; caps.isBGRA8888Supported = IsGLExtensionSupported("GL_APPLE_texture_format_BGRA8888"); caps.isFloat16Supported = IsGLExtensionSupported("GL_OES_texture_half_float"); caps.isFloat32Supported = IsGLExtensionSupported("GL_OES_texture_float"); caps.isATCSupported = IsGLExtensionSupported("GL_AMD_compressed_ATC_texture"); #elif defined(__DAVAENGINE_ANDROID__) //TODO: added correct caps.isPVRTCSupported = IsGLExtensionSupported("GL_IMG_texture_compression_pvrtc"); caps.isPVRTC2Supported = IsGLExtensionSupported("GL_IMG_texture_compression_pvrtc2"); caps.isETCSupported = IsGLExtensionSupported("GL_OES_compressed_ETC1_RGB8_texture"); caps.isDXTSupported = IsGLExtensionSupported("GL_EXT_texture_compression_s3tc"); caps.isBGRA8888Supported = false; caps.isFloat16Supported = IsGLExtensionSupported("GL_OES_texture_half_float"); caps.isFloat32Supported = IsGLExtensionSupported("GL_OES_texture_float"); caps.isATCSupported = IsGLExtensionSupported("GL_AMD_compressed_ATC_texture"); caps.isGlDepth24Stencil8Supported = IsGLExtensionSupported("GL_DEPTH24_STENCIL8") || IsGLExtensionSupported("GL_OES_packed_depth_stencil"); caps.isGlDepthNvNonLinearSupported = IsGLExtensionSupported("GL_DEPTH_COMPONENT16_NONLINEAR_NV"); # if (__ANDROID_API__ < 18) InitFakeOcclusion(); # endif #elif defined(__DAVAENGINE_MACOS__) || defined(__DAVAENGINE_WIN32__) caps.isPVRTCSupported = false; #if defined(GL_COMPRESSED_RGB_S3TC_DXT1_EXT) || defined(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) || defined(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) || defined(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) caps.isDXTSupported = IsGLExtensionSupported("GL_EXT_texture_compression_s3tc"); #else //DXT caps.isDXTSupported = false; #endif //DXT #if defined(GL_ETC1_RGB8_OES) caps.isETCSupported = IsGLExtensionSupported("GL_OES_compressed_ETC1_RGB8_texture"); #else //ETC1 caps.isETCSupported = false; #endif //ETC1 #if defined(GL_ATC_RGB_AMD) || defined(GL_ATC_RGBA_EXPLICIT_ALPHA_AMD) || defined(GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD) caps.isATCSupported = IsGLExtensionSupported("GL_AMD_compressed_ATC_texture"); #else //ATC caps.isATCSupported = false; #endif //ATC caps.isBGRA8888Supported = IsGLExtensionSupported("GL_IMG_texture_format_BGRA8888"); caps.isFloat16Supported = IsGLExtensionSupported("GL_ARB_half_float_pixel"); caps.isFloat32Supported = IsGLExtensionSupported("GL_ARB_texture_float"); #endif caps.isOpenGLES3Supported = (renderer == Core::RENDERER_OPENGL_ES_3_0); PixelFormatDescriptor::InitializePixelFormatDescriptors(); int maxVertexTextureUnits = 0; glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &maxVertexTextureUnits); caps.isVertexTextureUnitsSupported = (maxVertexTextureUnits > 0); caps.isFramebufferFetchSupported = IsGLExtensionSupported("GL_EXT_shader_framebuffer_fetch"); }
void gkGLExtension::Init() { EXTENSIONS = glGetString(GL_EXTENSIONS); TCHAR* str = (TCHAR*)EXTENSIONS; #ifdef UNICODE const char* org = (const char*)EXTENSIONS; str = new TCHAR[ strlen(org) + 1 ]; MultiByteToWideChar( CP_ACP, NULL, org, -1, str, strlen(org) + 1); #endif gkLogMessage( _T("GLEXT: \n --------------------------- \n %s"), str ); gkLogMessage( _T("--------------------------- \n") ); // VAO EXT glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC) GLEXTGetProcAddress(glBindVertexArrayOES); glDeleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOESPROC) GLEXTGetProcAddress(glDeleteVertexArraysOES); glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC) GLEXTGetProcAddress(glGenVertexArraysOES); glIsVertexArrayOES = (PFNGLISVERTEXARRAYOESPROC) GLEXTGetProcAddress(glIsVertexArrayOES); if (glBindVertexArrayOES || glDeleteVertexArraysOES || glGenVertexArraysOES || glIsVertexArrayOES ) { gkLogMessage( _T("RendererGLES2: Device support ext [VAO].") ); //EXT_VAO = true; #ifdef OS_IOS EXT_VAO = true; #endif } glMapBufferOES = (PFNGLMAPBUFFEROESPROC) GLEXTGetProcAddress(glMapBufferOES); glUnmapBufferOES = (PFNGLUNMAPBUFFEROESPROC) GLEXTGetProcAddress(glUnmapBufferOES); glGetBufferPointervOES = (PFNGLGETBUFFERPOINTERVOESPROC) GLEXTGetProcAddress(glGetBufferPointervOES); if (glMapBufferOES || glUnmapBufferOES || glGetBufferPointervOES ) { gkLogMessage( _T("RendererGLES2: Device support ext [map_buffer_oes].") ); MAP_BUFFER = true; #ifdef OS_IOS MAP_BUFFER = true; #endif } else { MAP_BUFFER = false; } int max_vs_uniforms = 0; glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS , &max_vs_uniforms); int max_ps_uniforms = 0; glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS , &max_ps_uniforms); gkLogMessage( _T("RendererGLES2: max uniforms [vs:%d] [ps:%d]."), max_vs_uniforms, max_ps_uniforms ); #if defined( GL_OES_vertex_half_float ) && defined( GL_OES_vertex_type_10_10_10_2 ) COMPRESS_VERTEX = true; #endif if ( IsGLExtensionSupported("GL_OES_element_index_uint") ) { INDEX_32BIT = true; } #ifdef OS_ANDROID //COMPRESS_VERTEX = false; EXT_VAO = false; #endif #ifdef OS_WIN32 COMPRESS_VERTEX = false; #endif ////////////////////////////////////////////////////////////////////////// // check ext support bool bIsPVRTCSupported = gkGLExtension::IsGLExtensionSupported("GL_IMG_texture_compression_pvrtc"); #ifndef OS_IOS bool bIsBGRA8888Supported = gkGLExtension::IsGLExtensionSupported("GL_IMG_texture_format_BGRA8888"); #else bool bIsBGRA8888Supported = gkGLExtension::IsGLExtensionSupported("GL_APPLE_texture_format_BGRA8888"); #endif bool bIsFloat16Supported = gkGLExtension::IsGLExtensionSupported("GL_OES_texture_half_float"); bool bIsFloat32Supported = gkGLExtension::IsGLExtensionSupported("GL_OES_texture_float"); #ifndef OS_IOS bool bIsETCSupported = gkGLExtension::IsGLExtensionSupported("GL_OES_compressed_ETC1_RGB8_texture"); #endif }
/*!**************************************************************************** @Function InitView @Return bool true if no error occured @Description Code in InitView() will be called by PVRShell upon initialization or after a change in the rendering context. Used to initialize variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.) ******************************************************************************/ bool OGLES2BinaryShader::InitView() { // Initialise a colour to draw our triangle // (For this training course, binary loaded shaders use a different colour // To show which is being used. Red means it had to compile the shaders, // green shows that it retrieved the binary from memory. float afColour[]={0.0,0.0,0.0}; // Filename and path strings. char* pWritePath = (char*)PVRShellGet(prefWritePath); char* shaderPath = new char[strlen(pWritePath) + 13]; sprintf(shaderPath, "%sShaderBinary", pWritePath); //Checks if the program binary handling extension is supported. m_bBinaryShaderSupported=IsGLExtensionSupported("GL_OES_get_program_binary"); #if !defined (TARGET_OS_IPHONE) glGetProgramBinaryOES=0; glProgramBinaryOES=0; // Retrieves the functions needed to use the extension. if (m_bBinaryShaderSupported) { glGetProgramBinaryOES = (PFNGLGETPROGRAMBINARYOESPROC) PVRGetProcAddress(glGetProgramBinaryOES); glProgramBinaryOES = (PFNGLPROGRAMBINARYOESPROC) PVRGetProcAddress(glProgramBinaryOES); } #endif // If binary shaders are not supported or there isn't a valid binary shader stored, recompile the shaders. if (!m_bBinaryShaderSupported || !loadBinaryProgram(shaderPath,m_uiProgramObject)) { { // Fragment shader code const char* pszFragShader = "\ uniform lowp vec3 myColour;\ void main (void)\ {\ gl_FragColor = vec4(myColour, 1.0);\ }"; // Create the fragment shader object m_uiFragShader = glCreateShader(GL_FRAGMENT_SHADER); // Load the source code into it glShaderSource(m_uiFragShader, 1, (const char**)&pszFragShader, NULL); // Compile the source code glCompileShader(m_uiFragShader); // Check if compilation succeeded GLint bShaderCompiled; glGetShaderiv(m_uiFragShader, GL_COMPILE_STATUS, &bShaderCompiled); if (!bShaderCompiled) { // An error happened, first retrieve the length of the log message int i32InfoLogLength, i32CharsWritten; glGetShaderiv(m_uiFragShader, GL_INFO_LOG_LENGTH, &i32InfoLogLength); // Allocate enough space for the message and retrieve it char* pszInfoLog = new char[i32InfoLogLength]; glGetShaderInfoLog(m_uiFragShader, i32InfoLogLength, &i32CharsWritten, pszInfoLog); /* Displays the message in a dialog box when the application quits using the shell PVRShellSet function with first parameter prefExitMessage. */ char* pszMsg = new char[i32InfoLogLength+256]; strcpy(pszMsg, "Failed to compile fragment shader: "); strcat(pszMsg, pszInfoLog); PVRShellSet(prefExitMessage, pszMsg); delete [] pszMsg; delete [] pszInfoLog; delete [] shaderPath; return false; } }