2d image in a qt3d scene
Hi, I am trying to include a 2d image in my qt3d scene node. I do not want to open the image in a separate window. I want to include it in the scene where my camera and cube is lying. I tried to use QPixmap.
@void CubeView::paintGL(QGLPainter *painter)
How can I include it in my scene? Thanks
Are you new to c++? You are calling load on an uninitialized pointer.
Also what type is cube? I doubt that it has draw() methods that take both a painter and a pixmap. These are separate concepts.
Do you want to texture the cube with that pixmap or display it separately on a piece of geometry?
Cube is an object of class cubeview.
class CubeView : public QGLView
CubeView(QWindow *parent = 0);
void paintGL(QGLPainter *painter);
The following code puts the image as a texture on the cube.
builder << QGL::Faceted << QGLCube(1.5f);
cube = builder.finalizedSceneNode();
QGLMaterial *mat = new QGLMaterial; mat->setColor(QColor(170, 202, 0)); QUrl url; url.setPath(QLatin1String(":/qtlogo.png")); url.setScheme(QLatin1String("file")); mat->setTextureUrl(url); texture = mat->texture(); cube->setMaterial(mat); cube->setEffect(QGL::LitDecalTexture2D);
void CubeView::paintGL(QGLPainter *painter)
painter->modelViewMatrix().rotate(45.0f, 1.0f, 1.0f, 1.0f);
I want to display an image in the scene. But not as a texture on the cube. How should I do it?
[edit: corrected coding tag position SGaist]