本文整理汇总了C++中egl::AttributeMap::getAsInt方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeMap::getAsInt方法的具体用法?C++ AttributeMap::getAsInt怎么用?C++ AttributeMap::getAsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类egl::AttributeMap
的用法示例。
在下文中一共展示了AttributeMap::getAsInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeContext
egl::Error DisplayEGL::initializeContext(const egl::AttributeMap &eglAttributes)
{
gl::Version eglVersion(mEGL->majorVersion, mEGL->minorVersion);
EGLint requestedMajor =
eglAttributes.getAsInt(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE);
EGLint requestedMinor =
eglAttributes.getAsInt(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, EGL_DONT_CARE);
bool initializeRequested = requestedMajor != EGL_DONT_CARE && requestedMinor != EGL_DONT_CARE;
static_assert(EGL_CONTEXT_MAJOR_VERSION == EGL_CONTEXT_MAJOR_VERSION_KHR,
"Major Version define should match");
static_assert(EGL_CONTEXT_MINOR_VERSION == EGL_CONTEXT_MINOR_VERSION_KHR,
"Minor Version define should match");
std::vector<std::vector<EGLint>> contextAttribLists;
if (eglVersion >= gl::Version(1, 5) || mEGL->hasExtension("EGL_KHR_create_context"))
{
if (initializeRequested)
{
contextAttribLists.push_back({EGL_CONTEXT_MAJOR_VERSION, requestedMajor,
EGL_CONTEXT_MINOR_VERSION, requestedMinor, EGL_NONE});
}
else
{
// clang-format off
const gl::Version esVersionsFrom2_0[] = {
gl::Version(3, 2),
gl::Version(3, 1),
gl::Version(3, 0),
gl::Version(2, 0),
};
// clang-format on
for (const auto &version : esVersionsFrom2_0)
{
contextAttribLists.push_back(
{EGL_CONTEXT_MAJOR_VERSION, static_cast<EGLint>(version.major),
EGL_CONTEXT_MINOR_VERSION, static_cast<EGLint>(version.minor), EGL_NONE});
}
}
}
else
{
if (initializeRequested && (requestedMajor != 2 || requestedMinor != 0))
{
return egl::Error(EGL_BAD_ATTRIBUTE, "Unsupported requested context version");
}
contextAttribLists.push_back({EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE});
}
for (auto &attribList : contextAttribLists)
{
mContext = mEGL->createContext(mConfig, EGL_NO_CONTEXT, attribList.data());
if (mContext != EGL_NO_CONTEXT)
{
return egl::Error(EGL_SUCCESS);
}
}
return egl::Error(mEGL->getError(), "eglCreateContext failed");
}