Commit 33db61d1 by Geoff Lang

Add support for targetting GLES with DisplayWGL.

BUG=angleproject:1145 Change-Id: I5a0a667621aceedb4662cfb2356d7dbd0d9f7718 Reviewed-on: https://chromium-review.googlesource.com/285557Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 451ed25a
......@@ -176,12 +176,22 @@ rx::DisplayImpl *CreateDisplayFromAttribs(const AttributeMap &attribMap)
#endif
break;
#if defined(ANGLE_ENABLE_OPENGL)
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
#if defined(ANGLE_PLATFORM_WINDOWS)
impl = new rx::DisplayWGL();
#else
// No GLES support on this platform, fail display creation.
impl = nullptr;
#endif
break;
#endif
default:
UNREACHABLE();
break;
}
ASSERT(impl != nullptr);
return impl;
}
......@@ -219,6 +229,12 @@ Display *Display::GetDisplayFromAttribs(void *native_display, const AttributeMap
if (!display->isInitialized())
{
rx::DisplayImpl *impl = CreateDisplayFromAttribs(attribMap);
if (impl == nullptr)
{
// No valid display implementation for these attributes
return nullptr;
}
display->setAttributes(impl, attribMap);
}
......
......@@ -175,6 +175,18 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
ReleaseDC(dummyWindow, dummyDeviceContext);
DestroyWindow(dummyWindow);
const egl::AttributeMap &displayAttributes = display->getAttributeMap();
EGLint requestedDisplayType =
displayAttributes.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE);
if (requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE &&
!mFunctionsWGL->hasExtension("WGL_EXT_create_context_es2_profile") &&
!mFunctionsWGL->hasExtension("WGL_EXT_create_context_es_profile"))
{
return egl::Error(EGL_NOT_INITIALIZED,
"Cannot create an OpenGL ES platform on Windows without "
"the WGL_EXT_create_context_es(2)_profile extension.");
}
// Create the real intermediate context and windows
mWindow = CreateWindowExA(0,
reinterpret_cast<const char *>(mWindowClass),
......@@ -230,14 +242,21 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
// TODO: handle robustness
int mask = 0;
// Request core profile
mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
if (requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE)
{
mask |= WGL_CONTEXT_ES_PROFILE_BIT_EXT;
}
else
{
// Request core profile
mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
}
std::vector<int> contextCreationAttributes;
// Don't request a specific version unless the user wants one. WGL will return the highest version
// that the driver supports if no version is requested.
const egl::AttributeMap &displayAttributes = display->getAttributeMap();
EGLint requestedMajorVersion = displayAttributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, EGL_DONT_CARE);
EGLint requestedMinorVersion = displayAttributes.get(EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, EGL_DONT_CARE);
if (requestedMajorVersion != EGL_DONT_CARE && requestedMinorVersion != EGL_DONT_CARE)
......@@ -248,6 +267,20 @@ egl::Error DisplayWGL::initialize(egl::Display *display)
contextCreationAttributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
contextCreationAttributes.push_back(requestedMinorVersion);
}
else
{
// the ES profile will give us ES version 1.1 unless a higher version is requested.
// Requesting version 2.0 will give us the highest compatible version available (2.0,
// 3.0, 3.1, etc).
if (requestedDisplayType == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE)
{
contextCreationAttributes.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);
contextCreationAttributes.push_back(2);
contextCreationAttributes.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
contextCreationAttributes.push_back(0);
}
}
// Set the flag attributes
if (flags != 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment