本文整理汇总了C++中QSGGeometryNode::setOpaqueMaterial方法的典型用法代码示例。如果您正苦于以下问题:C++ QSGGeometryNode::setOpaqueMaterial方法的具体用法?C++ QSGGeometryNode::setOpaqueMaterial怎么用?C++ QSGGeometryNode::setOpaqueMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSGGeometryNode
的用法示例。
在下文中一共展示了QSGGeometryNode::setOpaqueMaterial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updatePaintNode
QSGNode* MDeclarativeStatusBar::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
{
QSGGeometryNode* node = static_cast<QSGGeometryNode*>(oldNode);
if (!node) {
node = new QSGGeometryNode;
node->setFlags(QSGNode::OwnsGeometry | QSGNode::OwnsMaterial | QSGNode::OwnsOpaqueMaterial);
node->setGeometry(new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4));
}
if (!sharedPixmapHandle) {
node->setMaterial(new QSGFlatColorMaterial);
node->setOpaqueMaterial(new QSGFlatColorMaterial);
node->markDirty(QSGNode::DirtyMaterial);
return node;
}
if (!sharedTexture || updateSharedTexture) {
node->setMaterial(new QSGTextureMaterial);
node->setOpaqueMaterial(new QSGTextureMaterial);
#if defined(HAVE_XLIB)
MDeclarativeScreen* screen = MDeclarativeScreen::instance();
#if defined(QT_OPENGL_ES_2)
static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES");
static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR");
static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR");
static PFNEGLQUERYIMAGENOKPROC eglQueryImageNOK = (PFNEGLQUERYIMAGENOKPROC) eglGetProcAddress("eglQueryImageNOK");
const EGLint attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };
EGLDisplay eglDpy = eglGetDisplay((EGLNativeDisplayType)screen->display());
EGLImageKHR img = eglCreateImageKHR(eglDpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)sharedPixmapHandle, attribs);
GLuint textureId;
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)img);
GLint width = 0;
GLint height = 0;
eglQueryImageNOK(eglDpy, img, EGL_WIDTH, &width);
eglQueryImageNOK(eglDpy, img, EGL_HEIGHT, &height);
sharedTexture.reset(canvas()->createTextureFromId(textureId, QSize(width, height), QQuickCanvas::TextureOwnsGLTexture));
eglDestroyImageKHR(eglDpy, img);
#else
Display* dpy = screen->display();
Window dummy1;
int x, y;
unsigned int width, height, borderwidth, depth;
XGetGeometry(dpy, sharedPixmapHandle, &dummy1, &x, &y, &width, &height, &borderwidth, &depth);
XImage* xi = XGetImage(dpy, sharedPixmapHandle, 0, 0, width, height, ULONG_MAX, ZPixmap);
QImage img = MX11Wrapper::qimageFromXImage(xi);
XDestroyImage(xi);
sharedTexture.reset(canvas()->createTextureFromImage(img));
#endif
#endif // HAVE_XLIB
static_cast<QSGTextureMaterial*>(node->material())->setTexture(sharedTexture.data());
static_cast<QSGOpaqueTextureMaterial*>(node->opaqueMaterial())->setTexture(sharedTexture.data());
node->markDirty(QSGNode::DirtyMaterial);
updateSharedTexture = false;
}
QRectF sourceRect;
sourceRect = QRectF(0, 0, width(), height());
if (mOrientation == MDeclarativeScreen::Portrait || mOrientation == MDeclarativeScreen::PortraitInverted)
sourceRect.moveTop(height());
sourceRect = sharedTexture.data()->convertToNormalizedSourceRect(sourceRect);
QRect targetRect(x(), y(), width(), height());
QSGGeometry::updateTexturedRectGeometry(node->geometry(), targetRect, sourceRect);
node->markDirty(QSGNode::DirtyGeometry);
return node;
}