• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2 
3  @File         OGLES3/PVRTgles3Ext.cpp
4 
5  @Title        OGLES3/PVRTgles3Ext
6 
7  @Version
8 
9  @Copyright    Copyright (c) Imagination Technologies Limited.
10 
11  @Platform     Independent
12 
13  @Description  OpenGL ES 3.0 extensions
14 
15 ******************************************************************************/
16 #include <string.h>
17 
18 #include "PVRTContext.h"
19 #include "PVRTgles3Ext.h"
20 
21 /****************************************************************************
22 ** Local code
23 ****************************************************************************/
24 
25 /****************************************************************************
26 ** Class: CPVRTgles3Ext
27 ****************************************************************************/
28 
29 /*!***************************************************************************
30  @Function			LoadExtensions
31  @Description		Initialises IMG extensions
32 *****************************************************************************/
LoadExtensions()33 void CPVRTgles3Ext::LoadExtensions()
34 {
35 
36     glRenderbufferStorageMultisampleIMG = 0;
37     glFramebufferTexture2DMultisampleIMG = 0;
38     glRenderbufferStorageMultisampleEXT = 0;
39     glFramebufferTexture2DMultisampleEXT = 0;
40 
41     // Supported extensions provide new entry points for OpenGL ES 3.0.
42 
43     const GLubyte *pszGLExtensions;
44 
45     /* Retrieve GL extension string */
46     pszGLExtensions = glGetString(GL_EXTENSIONS);
47 
48 #if !defined(TARGET_OS_IPHONE)
49  /* GL_IMG_multisampled_render_to_texture */
50     if (strstr((char *)pszGLExtensions, "GL_IMG_multisampled_render_to_texture"))
51     {
52         glRenderbufferStorageMultisampleIMG = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) PVRGetProcAddress(glRenderbufferStorageMultisampleIMG);
53         glFramebufferTexture2DMultisampleIMG = (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) PVRGetProcAddress(glFramebufferTexture2DMultisampleIMG);
54     }
55 
56     /* GL_EXT_multisampled_render_to_texture */
57     if (strstr((char *)pszGLExtensions, "GL_EXT_multisampled_render_to_texture"))
58     {
59         glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXT) PVRGetProcAddress(glRenderbufferStorageMultisampleEXT);
60         glFramebufferTexture2DMultisampleEXT = (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXT) PVRGetProcAddress(glFramebufferTexture2DMultisampleEXT);
61     }
62 #endif
63 }
64 
65 /*!***********************************************************************
66 @Function			IsGLExtensionSupported
67 @Input				extension extension to query for
68 @Returns			True if the extension is supported
69 @Description		Queries for support of an extension
70 *************************************************************************/
IsGLExtensionSupported(const char * const extension)71 bool CPVRTgles3Ext::IsGLExtensionSupported(const char * const extension)
72 {
73 	// The recommended technique for querying OpenGL extensions;
74 	// from http://opengl.org/resources/features/OGLextensions/
75 	const GLubyte *extensions = NULL;
76 	const GLubyte *start;
77 	GLubyte *where, *terminator;
78 
79 	/* Extension names should not have spaces. */
80 	where = (GLubyte *) strchr(extension, ' ');
81 	if (where || *extension == '\0')
82 		return 0;
83 
84 	extensions = glGetString(GL_EXTENSIONS);
85 
86 	/* It takes a bit of care to be fool-proof about parsing the
87 	OpenGL extensions string. Don't be fooled by sub-strings, etc. */
88 	start = extensions;
89 	for (;;) {
90 		where = (GLubyte *) strstr((const char *) start, extension);
91 		if (!where)
92 			break;
93 		terminator = where + strlen(extension);
94 		if (where == start || *(where - 1) == ' ')
95 			if (*terminator == ' ' || *terminator == '\0')
96 				return true;
97 		start = terminator;
98 	}
99 
100 	return false;
101 }
102 
103 /*****************************************************************************
104  End of file (PVRTglesExt.cpp)
105 *****************************************************************************/
106 
107