本文整理汇总了C++中QEglContext::display方法的典型用法代码示例。如果您正苦于以下问题:C++ QEglContext::display方法的具体用法?C++ QEglContext::display怎么用?C++ QEglContext::display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QEglContext
的用法示例。
在下文中一共展示了QEglContext::display方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QEglContext
static QEglContext *createContext(QPaintDevice *device)
{
QEglContext *context;
// Create the context object and open the display.
context = new QEglContext();
context->setApi(QEgl::OpenVG);
if (!context->openDisplay(device)) {
delete context;
return 0;
}
// Set the swap interval for the display.
QByteArray interval = qgetenv("QT_VG_SWAP_INTERVAL");
if (!interval.isEmpty())
eglSwapInterval(context->display(), interval.toInt());
else
eglSwapInterval(context->display(), 1);
// Choose an appropriate configuration for rendering into the device.
QEglProperties configProps;
configProps.setPaintDeviceFormat(device);
int redSize = configProps.value(EGL_RED_SIZE);
if (redSize == EGL_DONT_CARE || redSize == 0)
configProps.setPixelFormat(QImage::Format_ARGB32); // XXX
#ifndef QVG_SCISSOR_CLIP
// If we are using the mask to clip, then explicitly request a mask.
configProps.setValue(EGL_ALPHA_MASK_SIZE, 1);
#endif
#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT |
EGL_VG_ALPHA_FORMAT_PRE_BIT);
configProps.setRenderableType(QEgl::OpenVG);
if (!context->chooseConfig(configProps)) {
// Try again without the "pre" bit.
configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT);
if (!context->chooseConfig(configProps)) {
delete context;
return 0;
}
}
#else
configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT);
configProps.setRenderableType(QEgl::OpenVG);
if (!context->chooseConfig(configProps)) {
delete context;
return 0;
}
#endif
// Construct a new EGL context for the selected configuration.
if (!context->createContext()) {
delete context;
return 0;
}
return context;
}
示例2: beginPaint
void QVGEGLWindowSurfaceVGImage::beginPaint(QWidget *widget)
{
QEglContext *context = ensureContext(widget);
if (context) {
if (recreateBackBuffer || backBufferSurface == EGL_NO_SURFACE) {
// Create a VGImage object to act as the back buffer
// for this window. We have to create the VGImage with a
// current context, so activate the main surface for the window.
context->makeCurrent(mainSurface());
recreateBackBuffer = false;
if (backBufferSurface != EGL_NO_SURFACE) {
eglDestroySurface(context->display(), backBufferSurface);
backBufferSurface = EGL_NO_SURFACE;
}
if (backBuffer != VG_INVALID_HANDLE) {
vgDestroyImage(backBuffer);
}
VGImageFormat format = qt_vg_config_to_vg_format(context);
backBuffer = vgCreateImage
(format, size.width(), size.height(),
VG_IMAGE_QUALITY_FASTER);
if (backBuffer != VG_INVALID_HANDLE) {
// Create an EGL surface for rendering into the VGImage.
backBufferSurface = eglCreatePbufferFromClientBuffer
(context->display(), EGL_OPENVG_IMAGE,
(EGLClientBuffer)(backBuffer),
context->config(), NULL);
if (backBufferSurface == EGL_NO_SURFACE) {
vgDestroyImage(backBuffer);
backBuffer = VG_INVALID_HANDLE;
}
}
}
if (backBufferSurface != EGL_NO_SURFACE)
context->makeCurrent(backBufferSurface);
else
context->makeCurrent(mainSurface());
isPaintingActive = true;
}
}