Qt Widget inside qt3d window - c++

How to put a label or button into qt3d window? Is it possible? Havent seen any example... I was trying to simply put qt3d in windowcontainer, assign layout to it and layout->addWiget() but it just doesnt work.

I know this is a farily old question but I wanted to give a more detailed answer if anyone else stumbles across this.
I implemented a Qt3D widget which you can find here. Unfortunately it relies on a method to obtain the texture id from QAbstractTexture which is only available from Qt >= 5.13 so that's the minimum version you have to use.
createWindowContainer draws the respective window above everything else. So you'll never be able to draw any buttons inside the container.
You can of course have buttons and everything else around your containered 3D window. But that's specifically not what you wanted.
You can use Dear ImGui - and it's Qt3D integration. ImGui is used to draw GUI elements using vertices in 3D environments.
Of course you can always use QML - there you should be able to place buttons inside the 3D view.

you have both label and (radio)buttons on the first example for C++ into the QT3d documentation, refer to Qt 3D: Basic Shapes C++ Example
QExtrudedTextGeometry seems to be the class for 3D text

Related

Integrate GUI with OpenGL in C++

I need to create a GUI with a file menu and menu in which the user can input parameters. The parameters are then used for drawing rectangles in a canvas which is part of the application window. Is there a way to scale the OpenGL subwindow to just one part of the screen and the parameter input to the other? The application needs to be written in C++.
Is it possible to create a GUI with QT and draw the rectangles in the same window using OpenGL? If not, what is the common way to integrate a GUI with OpenGL? (or any other graphics library which I can use to draw rectangles from points as easy as possible)
EDIT: I am not sure If OpenGL is necessary or there is a way to paint the rectangles on the canvas like you can in Java with paintComponent().
I have never used QT before so I am not aware of its capabilites.
you can use opengl window singly or use this in the common mainwindow. previous example (in first answer) show how to use opengl window in qt singly and without communication with other components of Qt (like menu, toolbar and ...). but you can add a opengl window to a mainwindow (like other widget) and use it alongside other widgets . this example can help you.
Yes, using OpenGL together with Qt is absolutely possible. There is even an example for that and Qt provides classes for a more object oriented way of using OpenGL. Have a look here (Section "OpenGL and OpenGL ES Integration") for more details.

Rendering points, lines, segments interactively in Qt

I am new to Qt and I want to use Qt to make interactive geometry programs using CGAL. I would like the user to input, say points, segments, using the mouse and then push a button to get a CGAL algorithm working on the input.
My environment is CGAL 4.5, Qt 5.6 and QtCreator 3.6.1 on an Ubuntu 14.04 machine.
CGAL has builtin support for its objects to be
rendered using the QtGraphicsViewFramework (http://doc.cgal.org/latest/GraphicsView/index.html )
I don't know how to render CGAL objects -- points, lines, rays, polygons -- onto a Qt window. The page I linked to above assumes a knowledge of Qt to get an application working, and so is not helpful to a Qt beginner.
Thus far, I have created a Qt widgets application project using QtCreator. From what I know, I need to modify the mainwindow.ui file graphically inside QtCreator by dragging and dropping different kinds of widgets onto it and then map signals calling CGAL functions onto slots of whatever the drawing canvas widget will be. (Is this correct? I am shaky on the signals and slots mechanism)
MY QUESTION IS....which widget do I place onto the window as a drawing canvas? Two relevant widgets seem to be GraphicsView and OpenGL widgets
under the DisplayWidgets menu. But how do I use them?
I have no CGAL experience, but I can give you some Qt-related hints:
Use the QGraphicsView + QGraphicsScene. If you want, you can enable OpenGL support like this:
QGraphicsView view = new QGraphicsView(parentWindow);
view->setViewport(new QOpenGLWidget(view));
To draw CGAL objects you have to use either provided graphics item classes (CGAL::Qt::TriangulationGraphicsItem, CGAL::Qt::VoronoiGraphicsItem, ...) or derive your own from the CGAL::Qt::GraphicsItem. To add an item to the scene, use the QGraphicsScene::addItem() method.
To navigate (pan + zoom) the view, CGAL provides the CGAL::Qt::GraphicsViewNavigation class. This is how to use it:
CGAL::Qt::GraphicsViewNavigation* navFilter = new CGAL::Qt::GraphicsViewNavigation(view);
view->viewport()->installEventFilter(navFilter);

libvlc-qt and OpenGL

I'm trying to make an app using libvlc-qt and Qt5.5. Some functionalities require displyaing semi-transparent text and graphics over video widget. I've found this thread, which says: "The video widget is opengl. You should be able to put a new opengl layer above."
My question is how do I approach this? I've tried creating overlapping QOpenGLWidgets and drawing using QPainter on them, and some similar simple solutions, but it resulted with nothing happening or random segfaults. Any ideas?
You can overlap QWidget over QOpenGLWidget, but not the other way around. And specifically, nothing in the parent widget and under the QOpenGLWidget will be visible.

creating starting page for opengl game

I am working on a graphics game project in OpenGL and I want to make a front page of the game containing a image, few buttons and some text. Buttons on click perform different actions e.g. start button for starting the game , Can anyone please suggest me , How can I do it?
How can I do it?
Well, by implementing it. OpenGL is not a game engine, nor a scene graph, nor a UI toolkit. It's merely a drawing API providing you the means to draw nice pictures, and that's it. Anything beyond that is the task of either a 3rd party library/toolkit, or your own code, or a combination of both.
A usual approach to model this behaviour is by introducing application states. Here is a related question.
You could model your StartScreenState by drawing a plane with buttons using an orthogonal projection and not drawing (or not having initialized yet) the rest. When the player clicks on 'start', you can switch to perspective projection and display game contents.
I don't know that I would even use OpenGL for that. OpenGL is for rendering colored/textured triangles/quads so that you can do tons of stuff graphically. There's no such thing as "load an image to coordinate x,y on the screen". The equivalent would be "draw two triangles with these vertices that make up a rectangle and are textured with this image". Which is why I would probably stay away from OpenGL to do this, because you don't really need to use any of the awesome features that OpenGL has.
A very common UI framework that I believe nestles in with OpenGL well if you really want to use the two together is Qt. It should make your life easier in terms of UI stuff. See wiki and dev page.

Size of OPENGL context in SFML WINDOW

i'm currently working on a voxel editor and everything is going fine.
I have my SFML windows and my model to work with. I was just wondering if it was possible with SFML to set the 3D context to a certain specefic size.
I'm asking this because my model is currently shown on the screen with not problem at all, except that now, I want to create some options settings with SFML and my button will on my 3D model. Like, I would like 75% of the left side of my window to be my 3D context and the 25% at the right to be blank with space to fill in my buttons.
To do what you want to do, I believe what you're looking for is this: http://www.sfml-dev.org/documentation/2.0/classsf_1_1View.php#details
I think the context is attached to the window in general. Also be aware that SFML is for 2D graphics. Once you want 3D rendering, you're going to need to use openGL directly. SFML is a wrapper for openGL calls so there's no problem with using SFML to help set up and manage things, and openGL directly for rendering needs.
http://www.sfml-dev.org/tutorials/2.0/window-opengl.php
try:
glViewport(x,y,width,height);
source: https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glViewport.xml