You can directly access a QGLWidget whose context is shared with other Viewport 2.0 resources. This is useful in the case when your plug-in creates OpenGL resources for it's own QGLWidget and you want it to share the plug-in's OpenGL resources with Viewport 2.0.
import PySide2
import PySide2.QtOpenGL
import PySide2.QtWidgets
import shiboken2
# Get the property from the application (as a QWidget)
widget = QtWidgets.qApp.property("mayaSharedQGLWidget")
# Get the raw C++ pointer
ptr = long(shiboken2.getCppPointer(widget)[0])
# Downcast to QGLWidget
glWidget = shiboken2.wrapInstance(ptr, PySide2.QtOpenGL.QGLWidget)
# Print the format of the current rendering context
print glWidget.format()
QVariant v = qApp->property("mayaSharedQGLWidget");
if (v.isValid())
{
QGLWidget glWidget = dynamic_cast<QGLWidget*>(v.value<QWidget*>());
}