本文整理汇总了C++中QEglProperties::properties方法的典型用法代码示例。如果您正苦于以下问题:C++ QEglProperties::properties方法的具体用法?C++ QEglProperties::properties怎么用?C++ QEglProperties::properties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QEglProperties
的用法示例。
在下文中一共展示了QEglProperties::properties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createContext
// Create the EGLContext.
bool QEglContext::createContext(QEglContext *shareContext, const QEglProperties *properties)
{
// We need to select the correct API before calling eglCreateContext().
#ifdef QT_OPENGL_ES
#ifdef EGL_OPENGL_ES_API
if (apiType == QEgl::OpenGL)
eglBindAPI(EGL_OPENGL_ES_API);
#endif
#else
#ifdef EGL_OPENGL_API
if (apiType == QEgl::OpenGL)
eglBindAPI(EGL_OPENGL_API);
#endif
#endif //defined(QT_OPENGL_ES)
#ifdef EGL_OPENVG_API
if (apiType == QEgl::OpenVG)
eglBindAPI(EGL_OPENVG_API);
#endif
// Create a new context for the configuration.
QEglProperties contextProps;
if (properties)
contextProps = *properties;
#ifdef QT_OPENGL_ES_2
if (apiType == QEgl::OpenGL)
contextProps.setValue(EGL_CONTEXT_CLIENT_VERSION, 2);
#endif
sharing = false;
if (shareContext && shareContext->ctx == EGL_NO_CONTEXT)
shareContext = 0;
if (shareContext) {
ctx = eglCreateContext(QEgl::display(), cfg, shareContext->ctx, contextProps.properties());
if (ctx == EGL_NO_CONTEXT) {
qWarning() << "QEglContext::createContext(): Could not share context:" << QEgl::errorString();
shareContext = 0;
} else {
sharing = true;
}
}
if (ctx == EGL_NO_CONTEXT) {
ctx = eglCreateContext(display(), cfg, EGL_NO_CONTEXT, contextProps.properties());
if (ctx == EGL_NO_CONTEXT) {
qWarning() << "QEglContext::createContext(): Unable to create EGL context:" << QEgl::errorString();
#ifdef Q_OS_SYMBIAN
S60->eglSurfaceCreationError = true;
#endif
return false;
}
}
return true;
}
示例2: hasOpenGLPbuffers
bool QGLPixelBuffer::hasOpenGLPbuffers()
{
// See if we have at least 1 configuration that matches the default format.
EGLDisplay dpy = QEgl::display();
if (dpy == EGL_NO_DISPLAY)
return false;
QEglProperties configProps;
qt_eglproperties_set_glformat(configProps, QGLFormat::defaultFormat());
configProps.setDeviceType(QInternal::Pbuffer);
configProps.setRenderableType(QEgl::OpenGL);
do {
EGLConfig cfg = 0;
EGLint matching = 0;
if (eglChooseConfig(dpy, configProps.properties(),
&cfg, 1, &matching) && matching > 0)
return true;
} while (configProps.reduceConfiguration());
return false;
}
示例3: createSurface
//.........这里部分代码省略.........
if (widget->testAttribute(Qt::WA_WState_Created))
currentVisualId = XVisualIDFromVisual((Visual*)widget->x11Info().visual());
if (currentVisualId != visualId) {
// The window is either not created or has the wrong visual. Either way, we need
// to create a window with the correct visual and call create() on the widget:
bool visible = widget->isVisible();
if (visible)
widget->hide();
XVisualInfo visualInfo;
visualInfo.visualid = visualId;
{
XVisualInfo *visualInfoPtr;
int matchingCount = 0;
visualInfoPtr = XGetVisualInfo(widget->x11Info().display(), VisualIDMask,
&visualInfo, &matchingCount);
Q_ASSERT(visualInfoPtr); // visualId really should be valid!
visualInfo = *visualInfoPtr;
XFree(visualInfoPtr);
}
Window parentWindow = RootWindow(widget->x11Info().display(), widget->x11Info().screen());
if (widget->parentWidget())
parentWindow = widget->parentWidget()->winId();
XSetWindowAttributes windowAttribs;
QColormap colmap = QColormap::instance(widget->x11Info().screen());
windowAttribs.background_pixel = colmap.pixel(widget->palette().color(widget->backgroundRole()));
windowAttribs.border_pixel = colmap.pixel(Qt::black);
unsigned int valueMask = CWBackPixel|CWBorderPixel;
if (alphaSize > 0) {
windowAttribs.colormap = XCreateColormap(widget->x11Info().display(), parentWindow,
visualInfo.visual, AllocNone);
valueMask |= CWColormap;
}
Window window = XCreateWindow(widget->x11Info().display(), parentWindow,
widget->x(), widget->y(), widget->width(), widget->height(),
0, visualInfo.depth, InputOutput, visualInfo.visual,
valueMask, &windowAttribs);
// This is a nasty hack to get round the fact that we can't be a friend of QWidget:
qt_set_winid_on_widget(widget, window);
if (visible)
widget->show();
}
// At this point, the widget's window should be created and have the correct visual. Now we
// just need to create the EGL surface for it:
EGLSurface surf = eglCreateWindowSurface(QEgl::display(), config, (EGLNativeWindowType)widget->winId(), 0);
if (surf == EGL_NO_SURFACE)
qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
return surf;
}
if (x11PixmapData) {
// X11 Pixmaps are only created with a depth, so that's all we need to check
EGLint configDepth;
eglGetConfigAttrib(QEgl::display(), config, EGL_BUFFER_SIZE , &configDepth);
if (x11PixmapData->depth() != configDepth) {
// The bit depths are wrong which means the EGLConfig isn't compatable with
// this pixmap. So we need to replace the pixmap's existing data with a new
// one which is created with the correct depth:
#ifndef QT_NO_XRENDER
if (configDepth == 32) {
qWarning("Warning: EGLConfig's depth (32) != pixmap's depth (%d), converting to ARGB32",
x11PixmapData->depth());
x11PixmapData->convertToARGB32(true);
} else
#endif
{
qWarning("Warning: EGLConfig's depth (%d) != pixmap's depth (%d)",
configDepth, x11PixmapData->depth());
}
}
QEglProperties surfaceAttribs;
// If the pixmap can't be bound to a texture, it's pretty useless
surfaceAttribs.setValue(EGL_TEXTURE_TARGET, EGL_TEXTURE_2D);
if (alphaSize > 0)
surfaceAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA);
else
surfaceAttribs.setValue(EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB);
EGLSurface surf = eglCreatePixmapSurface(QEgl::display(), config,
(EGLNativePixmapType) x11PixmapData->handle(),
surfaceAttribs.properties());
x11PixmapData->gl_surface = (void*)surf;
QImagePixmapCleanupHooks::enableCleanupHooks(x11PixmapData);
return surf;
}
return EGL_NO_SURFACE;
}