Differences between QQuickFramebufferObject and QQuickItem? - c++

I am working on an application where I want to embed openGL scenes into a QML item. I want my custom QML items to be driven by C++, and this article gives an overview of how to do so with a QQuickFramebufferObject.
However, I've noticed that very similar things can be done by simply using a QQuickItem, the distinction seeming to be that QQuickItem has different methods (paint()) compared to the QQuickFrameBufferObject (synchronize(), render(), createFramebufferObject()).
So what are the advantages of one over the other? Are these compatible? What is the best way to render a scene with these options? I've heard that the QQuickFrameBufferObject provides more flexibility with using custom openGL, but that means relatively little to me.

Related

Can I write an OpenGL application without binding it to a certain windowing library?

As I mentioned in a question before, I am trying to make a simple game engine in C++ with OpenGL.
I am currently using GLFW for drawing the OpenGL context and I chose it because I heard it's one of the faster ones out there. However, it doesn't support widgets and I really don't want to write them myself. So I decided to get into Qt a bit, because it would allow me to have a pane for the render context and different handy bars as well as all the fancy elements for editing a world map, setting OpenGL rules, etc.
I want to use GLFW on the exported version of that game, though. Is that possible without an abstraction layer of some kind?
Thanks in advance! :)
Yes it is definitely possibile, infact I'm writing a 3D engine that is not coupled to any windowing library and can be used with Qt, SDL or whatever.
You of course have just to wrap regular GL calls into a higher level layer, this require you don't call "SwapBuffers" inside your GL code.
If by abstraction layer you mean "inversion of control" so, you don't want to override a "Render/Update" method that's exactly what I done. If by "abstraction layer" you mean you want to use GL directly than it is still possible.
Basically every windowing system have "some place" where you can make your GL calls (between MakeCurrent and SwapBuffers). Just read documentation of your windowing system.

How to get started on custom GUI widgets

I would like to exercise programming software with non-standard graphical interfaces such as the ones in the following images. I know how to create a GUI using basic widgets, but I have no idea on how to create my own custom widgets. I am familiar with GTK 3.0 and Qt. The GTK tutorial, for instance, has a link on how to do custom drawing. I just don't know if this is the usual and correct way to create custom widgets. There's also things such as: selections, mouse handling, zoom, scrolling, animations and so on that tutorials do not teach.
So here is my question: what kind of documentation, keywords, tutorials and algorithms should I look for? For my first project, I would like to start with something similar to the first and second images below. My current knowledge is C/C++ and Qt and GTK, but I can learn new languages and tools if necessary.
http://hobby-electrons.sourceforge.net/tutorials/gEDA/simple-schematic-in-gschem.png
http://www.cburch.com/logisim/docs/2.7/pt/html/images/screen-shot.png
http://eeweb.poly.edu/labs/nanovlsi/tutorials/soctutorials/figures/ENCFinalDesign.gif
http://www.ccm.ece.vt.edu:8088/etextiles/projects/arch_images/simulation.jpg
http://j-algo.binaervarianz.de/images/avl_avltest.png
The Qt Graphics view Framework is what you should use if you go with Qt. There are several examples covering the basics of creating components.
To be able to mimic those samples, most of the work is going to be on implementing custom graphic view items. Like widgets it means providing a paint method, specialized event handlers and properties.

Which graphics technology does Qt uses to render its custom UI?

I inspected the Qt GUI interfaces using window spy tools and I know that it does not use windows common controls or any custom window class to create its UI elements and animation effects. I asked before here about developing a custom GUI framework using GDI/GDI+ but most people responded against these technologies, so the question remains which graphics technology Qt or any other equivalent appropriator system uses to render their UI?
I am aware of DirectX/OpenGL but isn't it overkill for simple requirements? If the answer is going to be one of the above then again I wonder how one could implement robust font rendering and vector graphics solutions with these polygon rendering technology? the full featured text editor is another huge challenge.
Also there already exists solutions based on directx/opengl like MyGUI and CEGUI but I think they look ugly and nowhere near how Qt looks.
First things first, Qt-5 introduced a new rendering model, which can (but is not required to) use OpenGL for rendering the UI elements. The upshot of this is, that one can truly mix custom OpenGL rendering with Qt widgets. The downside is, that some kind of OpenGL support is required, which not all systems have.
So Qt also has these two other drawing systems: Native, which will use the hosts systems native graphics primitives (GDI, CoreGraphics, X11/XRender) and raster which does a complete rasterization of a whole window into pixel buffers, where then only those are blitted over to the underlying graphics system. raster is the slowest of the graphics backends, but it gives consistent results for all plattforms and target systems. Hence raster is usually used for programs where consistent appearance is strictly required.

Qt - effects on no-opengl widgets

i wanna make some nice user interface, but still using just classic ui elements from Qt.
For instance i have 2 forms and i wanna make some transition between them. For instance rotate first ui screen and make it disappear. It's possible in some way to use shader? Is any way how to do complex ui animations with classic ui elements?
Qt has a whole animation framework. It works on both the QML widgets and for the classic UI elements that you're using. There's some examples of use here, that should be able to get you started.
The simplest way to do it would be to use the Qt Declarative a.k.a. Qt Quick 1. It's based on QGraphicsScene, with the latter offering a reasonable way of integrating legacy widgets. It'll be likely the simplest way to offer animations with widgets.
You may wish to see an overview of GUI technologies available in Qt 5, to see how Qt Quick 1 fits in.

Qt library for 2D/3D game development

As a hobby, I've been working on remaking an old video game, and I want to avoid reinventing the wheel where possible. The game is heavily GUI-based, but the GUI needs to be customized in terms of look-and-feel, and also needs to work with 3D OpenGL rendering for a few game screens.
To give you an idea, here's a screenshot from the initial prototype:
There's a lot of animation used, and 3D also, but the GUI widgets behave much the same as in a standard desktop application.
Thus far, I've been using my own GUI library (it's not robust or complete, and I've been running into some problems).
I've been considering migrating to Qt given it's reputation and impressive features, and some of the nice screenshots on the Qt website. But I've never used Qt before, so I don't really have an idea of what it's capable of, or what kind of time investment would be required to learn it. (Note I've used FLTK).
My question is: would it be possible / practical to use Qt in this situation?
UPDATE: After mocking up some game screens in Qt, I've decided not to use it. While it supports many of the features I need out-of-the-box (particularly through Style Sheets), I need to support custom bitmap-based pre-rendered fonts (I can't convert/replace them). And I can't subclass QFont, or reimplement it without it breaking in future Qt releases. That said, I was extremely impressed with Qt (both in its ease of use, and good documentation). I will be borrowing some of its features for my own engine. Thank you to all who provided input.
It's hard to know everything your game needs to do based on a screenshot; however, I will echo the sentiments of other posters here and provide a couple of avenues for you to look at.
One, is that you might want to consider QtQuick over the GraphicsView Framework, but this REALLY depends on what you need to do. I just want to throw it out there as an alternative so you don't miss it. This tutorial uses QtQuick to put together a really slick looking connect four style game. This may be more simplistic than what you want to go for, but then again, maybe it isn't, it depends on what you need to do.
Second, before writing custom paint events for all of your buttons, I would consider using Qt Style Sheets and style your widgets in a CSS like syntax. This will allow you to change the look and feel of your GUI in a very flexible way really quickly. Based on your screenshot, I think you can get what you want out of style sheets much faster than subclassing and rolling your own setup. But once again, it's hard to know based on one screenshot. Here's an example of a dark and orange GUI that was implemented using only Qt Style Sheets. The border-radius property of QPushButton's style sheet would give you the rounded buttons (ref).
The simple answer has been given above but to throw some more thoughts in: yes it's possible, you probably won't need to fight against Qt too much. For the most part the recommended advice for going to heavily customised widgets like that is subclass and implemented the paint event yourself.
You can then use a load of basic drawing primitives to get the basic shapes for the elements and expand from there. There's actually a couple of questions on here with really good resources about how to do it.