+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
+
+ // Only change gles version for the device that support above gles 3.0.
+ if(mGlesVersion >= INITIAL_GLES_VERSION)
+ {
+ GLint majorVersion, minorVersion;
+ glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
+ glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
+ mGlesVersion = majorVersion * 10 + minorVersion;
+ }
+
+ if(mGlesVersion >= GLES_VERSION_SUPPORT_BLEND_EQUATION_ADVANCED)
+ {
+ mIsAdvancedBlendEquationSupported = true;
+ }
+ else
+ {
+ // when mIsAdvancedBlendEquationSupported is cached, we don't need to check all the extensions.
+ if(!mIsAdvancedBlendEquationSupportedCached)
+ {
+ const char* const extensionStr = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
+ std::istringstream stream(extensionStr);
+ std::string currentExtension;
+ while(std::getline(stream, currentExtension, ' '))
+ {
+ if(currentExtension == KHR_BLEND_EQUATION_ADVANCED)
+ {
+ mIsAdvancedBlendEquationSupported = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if(!mShadingLanguageVersionCached)
+ {
+ std::istringstream shadingLanguageVersionStream(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
+ std::string token;
+ uint32_t tokenCount = 0;
+ while(std::getline(shadingLanguageVersionStream, token, ' '))
+ {
+ if(tokenCount == 3 && token == "ES")
+ {
+ std::getline(shadingLanguageVersionStream, token, '.');
+ mShadingLanguageVersion = std::atoi(token.c_str());
+ mShadingLanguageVersion *= 100;
+ std::getline(shadingLanguageVersionStream, token, '.');
+ mShadingLanguageVersion += std::atoi(token.c_str());
+ break;
+ }
+ tokenCount++;
+ }
+ }
+
+ {
+ ConditionalWait::ScopedLock lock(mContextCreatedWaitCondition);
+ mIsContextCreated = true;
+ mContextCreatedWaitCondition.Notify(lock);
+ }
+ }
+
+ void SetGlesVersion(const int32_t glesVersion)
+ {
+ if(mGlesVersion / 10 != glesVersion / 10)