Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Qt\QtQuick Tutorial

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
Qt changed a lot from the time I started using QML.

At first it used opengl, later opengl with something to translate to directx and you had to manually choose one, now it seems it's automatic and I think their commercial (or gpl) version has a raster version as well but it is appropriate for embedded linux on machines without opengl.

From what I know it seems that everything in the default QML version is using opengl and also it requires 2.0 or better. This leaves a few old computers even if they have 2.0 compatible graphic cards because usually the driver of old windows versions does not offer it.

I think there is also a 3D module that is gpl which offers you everything you need to code directly into opengl. https://doc.qt.io/qt-5.10/qt3d-index.html

I don't have a lot experience with android/ios but if you Qt I think you will have a bit more work to publish it than if you used other frameworks.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Amazing, you're still alive after 5 years :salute::salute:

I have just read through your old tutorial which was great, but I used a different route by QtWidget application.

Currently what I need is a module that offers me at least 3 geometric primitives: Point, Line and Polygon. The Polygons should be filled, a transparent filling would be ideal. We also need to draw a bit like in a CAD system and of course render background images. And there could theoretically be 10 thousands of geometric primitives in each drawing, but that's not my main worry, it's not necessary to render them all at once and I will optimize this somehow.

I see mention of QPainter being for rendering primitives but also QtQuick (2?), not 100% sure where to begin.

P.S. This is what I got so far :)

Y4gMBh5.jpg


Can you recommend me a book? It would be great if it covers a broad foundation of Qt like makefiles and such, because I have not done C++ in the last 5 years. I have of course a budget now so it would help me if I could get some literature quickly.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
I went to back to being a lurker! =)

You can do everything you want without QML if you use QPainter, there are tools there to help you with this.
Without QML there is also a module to work directly on OpenGL.

If you plan to use QML you probably want to render everything you mentioned and then over it a UI which is what QML does best.
In there you will find a canvas object (http://doc.qt.io/qt-5/qml-qtquick-canvas.html), you can use it like you would a qpainter, but it is made to look like and act like the canvas from html5.

You can paint a background on canvas and then latter render other things, I think I saw a hack to make the canvas transparent but I don't think it's worth it.

The good part is that you can use a lot of html5 canvas examples there so there is a lot of material to study.

A great place to start is looking the official examples. http://doc.qt.io/qt-5/qtexamples.html

I think I saw one once that they render like 10.000 images and you can zoom in and out and turn the camera and it was pretty fast. Since QML works like javascript if you create too many objects there it will slow down but if you use the correct tools you will be able to make it the way you want.

With StarLife I did a code where it would create several objects which are shown as stars, ships and other stuff, since the map was huge as you moved the camera it would need to instantiate new objects and remove the old ones, what I did there was a way to avoid deleting stuff, so old objects would become blank and then be reused as new objects. At the time this would stop the game from crashing since QML was pretty new and removing too many objects too fast would cause an memory error. It made the it pretty fast too, I don't know if this piece of information helps since you will be using a canvas.
 
Joined
Jan 9, 2011
Messages
2,726
Codex 2012 Codex 2013 Codex 2014 PC RPG Website of the Year, 2015 Codex 2016 - The Age of Grimoire Make the Codex Great Again! Grab the Codex by the pussy Insert Title Here RPG Wokedex Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Serpent in the Staglands Dead State Divinity: Original Sin Project: Eternity Torment: Tides of Numenera Wasteland 2 Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. My team has the sexiest and deadliest waifus you can recruit. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
I haven't used any qt in ages, but I do use qt creator. My recommendation is get the latest version (4.6 beta) so you get all the nice tools from clang 5. Then start going through examples and tutorials that are there on the welcome page. I would also recommend going with cmake based projects.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Any suggestion which Qt I should download. I think I downloaded the wrong packages. For now I would be happy with the free LGPL version and targets only Windows and Android, and being able to use the QtQuick / QPainter / OpenGL widgets, to see what can be done. I don't need a definite version right now, only a prototype that shows it can be done.

Ah and I get "undefined reference to `_imp___ZN20QQmlDebuggingEnablerC1Eb'" b/s errors when I move my first QQuickWidget in the designer.
i.e. before I can start programming the Lord has decreed another hurdle. Must now first learn the whole shebang about MinGW compiled libraries and yadda yadda. That's the one thing I never like about C++ but well .. been there before.

Thanks I will have a look at those CAD projects, but I have experience with those "free CAD programs". I expect they will just crush under our DWG drawings. These are not just dog houses, but hueg.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
If you download the windows installer (19MB) you choose the modules, you will see the GPL is separated from the rest.
I don't know but I think the download with contains everything will also ask what module you want to install: https://download.qt.io/official_releases/qt/5.10/5.10.0/

I also saw that there is only one download for windows, so I don't know if it will ask later but there used to be a mingw version and a visual studio version, also 32 and 64 bits version.

Try compiling as release, whenever I try as debug a lot of problems arise and I usually debug using other tools so I didn't bother to try to understand them.

Yeah, free projects also tend to do a lot more than what they initially proposed and can become quite overwhelming, the only part that I would look is how they deal with some code if you both use the same objects and also what they do to initialize the program.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Yeah I tried Debug version with MinGW 32 bit. Everything else was not configured in my installation.

Are you using QtCreator, MSVC or what else?

P.S. Ah, I think I remember now, 5 years ago I also had to install Visual Studio because I could not get a debugger working with QtCreator .. (or the other way around :lol:)

And great talking to you again .. but I start the weekend now.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
I only use QtCreator, if I could use it for other languages I would as well! =)

When you create a project it should create three build configurations, one debug, one release and one called profile (which I'm not sure what it is for), I usually delete the debug profile.

You can check it if you go to project, there is on the top part a 'edit build configuration' which you can change from one to another.

nttGp7g.png
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
BVujwlQ.jpg


This is what I have. And QQuickWidget creates errors, so I must be mixing up different libraries etc. Even if I copy the entire bin directory of qt into the application folder (3GB) it says something about a "platform plugin windows missing".

But I will need to do this step for step, must first learn again what "qmake" is for, and locate all the paths and libraries.
 

tiagocc0

Arcane
Joined
Jun 29, 2007
Messages
2,056
Location
Brazil
I got some of those even when I had the files in the right place. Sometimes I have to delete the build files (temporary on the build folder it creates) so it starts anew with a new makefile.
Sometimes the version is not right one when I had multiple qt versions installed. You probably know this but you have to copy some folders from the plugin folder in the qt installation directory.

Platforms is one folder that you find in the plugin one. So you copy it to where the exe is, along with the necessary dlls and also some folders from the qml dir.

So you have to get files and folders from these guys here from you qt install dir.

9Kf8tn7.png
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Ok, tonight I will start over with a complete reinstall of the commercial version. Whatever it was I downloaded, it appears to be borked and I dont give a fuck which version it uses, it should just be able compile its own default project.

Then I will try to do the 2 short tutorials:

QtWidgets http://doc.qt.io/qt-5/gettingstartedqt.html
QtQuick http://doc.qt.io/qt-5/gettingstartedqml.html

From what I gather, QtWidgets is the old Qt and QtQuick the new shit that allows Windows to be declared in QML, logic in javascript :prosper: and probably sucks ass once you want to start making something really useful. I mean if I only want to declare a few buttons I could also HTML amirite :lol:

Tomorrow I'll see wether I can compile the samples, before that is done I cannot begin doing anything useful with Qt.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
ByAZcmI.jpg


Ok, I try to install the commercial evaluation (looks exactly the same as LGPL :lol:)

Is there a reason to use the libraries for MSVC instead of MinGW if I use QtCreator anyway? I'll try to install only this one package for now, and see what happens. That way the download does not become so incredible bloated.
 

vlzvl

Arcane
Developer
Joined
Aug 7, 2017
Messages
190
Location
Athens
Is there a reason to use the libraries for MSVC instead of MinGW if I use QtCreator anyway? I'll try to install only this one package for now, and see what happens. That way the download does not become so incredible bloated.

I know squat about Qt, but if the choice between MinGW was presented to me, i would take MingGW all day long.
By personal experience, the compilation takes a little more than MSVS but you get more performance.
Plus, the MinGW it's basically GNU and compiles exactly like GCC (if you have coded in some linux), so you are one step closer to code portability.
In addition, i do not know what Qt does with runtime libraries, but based on MSVS version you might need the C++ runtime DLL as well.
Of course the same might happen with MingGW, but you have one version only to choose.
Make sure to choose static linking for C++ in Qt's linking commands.
The executable *will* get bloated with static linking but then you wont have to worry about "MSVCRT_foo.dll not found" crappy windows.
MSVC are producing much bloated code in their .exe or .lib files; I never experienced MingGW bloating in their .exe or . a files.
Plus MinGW is command line and consumes much less disk space (around 400mb per 32-bit/64-bit), in comparison to some GBs of MSVS.
I am not sure but QtCreator still needs a compiler in your system anyway, so keep it less bloated as it will probably use command line scripts anyway.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Cool that there is interest in this topic :salute:

And vlzvl yes, I use MinGW for now. Not because I have preference but because I don't need 6 different compilers right now. I only want to do basic prototyping. The rest comes later when I really know what I am doing.

As I wrote, for now I need to draw 2d polygons, lines, points and raster images plus (if possible) transparent filling. My users are CAD ridden and they would go grazy about transparent brushes because CAD can't really support that, so thats a bonus of going 3d. I think I need to make sure I can draw between a few and 100,000 such 2d primitives, so ideally I need performance. On the other hand the requirement is so low that I can get away with rendering only a few of those objects and not consider anything that's off the viewport (i.e. similar to Google maps but without the option to zoom out)

Currently I'm not sure I already know what I do next. I have a QtWidgets Window with a OpenGLArea enabled, and this probably is the best bet if I want to draw lots of polygons with good performance. (I know there was a problem about triangulating concave polygons, but I think OpenGL supports that). Now I'm just not sure, if I get into OpenGL right away if there's not a simpler way, if Qt offers such primitives in a more high level way. I saw something about a QPainter but cannot say I really had time to look into it. ie I could live with something like GDI+ but with better performance.

So the question is: should I implement the primitves in OpenGL myself (with point and line being trivial) or first check if some popamol classes can do the same?
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Btw, in spite of the reinstall I also still get those linker errors when I compile a QQuickPanel in a QtWidgets window. But that's complete nonsense anyway right? I mean a QtQuick and QtWidgets is like two different types of projects right??
 
Joined
Jan 9, 2011
Messages
2,726
Codex 2012 Codex 2013 Codex 2014 PC RPG Website of the Year, 2015 Codex 2016 - The Age of Grimoire Make the Codex Great Again! Grab the Codex by the pussy Insert Title Here RPG Wokedex Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Serpent in the Staglands Dead State Divinity: Original Sin Project: Eternity Torment: Tides of Numenera Wasteland 2 Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. My team has the sexiest and deadliest waifus you can recruit. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
When you create a project it should create three build configurations, one debug, one release and one called profile (which I'm not sure what it is for), I usually delete the debug profile.

Profile is for profiling, i.e. figuring where your program spends time. You would run such executable under tools like valgrind's callgrind/cachegrind or use it with eBPF on linux. Most often build like that is optimized same way as release build, but does include debug symbols.
 
Joined
Jan 9, 2011
Messages
2,726
Codex 2012 Codex 2013 Codex 2014 PC RPG Website of the Year, 2015 Codex 2016 - The Age of Grimoire Make the Codex Great Again! Grab the Codex by the pussy Insert Title Here RPG Wokedex Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Serpent in the Staglands Dead State Divinity: Original Sin Project: Eternity Torment: Tides of Numenera Wasteland 2 Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. My team has the sexiest and deadliest waifus you can recruit. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
Is there a reason to use the libraries for MSVC instead of MinGW if I use QtCreator anyway?

All depends on what compiler you want to use. C++ doesn't have an Application Binary Interface standardised, so stuff compiled with one complier is not necessarily usable by another one. That's why we have C shims and similar crap. Current Clang and GCC are compatible (or mostly compatible), gcc 5 ABI is NOT compatible with gcc 4 ABI, partially due to changes to implementation of std::string.

MSVC is designed to be used with the Visual Studio compiler (duh). MinGW is port of your standard linux tools to windows - you get your gcc, bash shell (or was it some other?), glibc, libcpp, etc. While your download might be smaller, bear in mind that your users will need to have the runtime libs for mingw installed on their PCs if you run this. An installer will create appropriate package for you, so it's not onerous but can annoy some people. Most folks have the VS runtime installed already (that's all those msvscrt stuff you can sometimes spot during installation).

One obvious benefit of MinGW over MSVC is that you have source code for all the libs, so you can take a look at how things are implemented if you're curious. Sanity meter might drop a bit once you start reading some of the low level code though ;)
 
Joined
Jan 9, 2011
Messages
2,726
Codex 2012 Codex 2013 Codex 2014 PC RPG Website of the Year, 2015 Codex 2016 - The Age of Grimoire Make the Codex Great Again! Grab the Codex by the pussy Insert Title Here RPG Wokedex Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Serpent in the Staglands Dead State Divinity: Original Sin Project: Eternity Torment: Tides of Numenera Wasteland 2 Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. My team has the sexiest and deadliest waifus you can recruit. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
The executable *will* get bloated with static linking but then you wont have to worry about "MSVCRT_foo.dll not found" crappy windows.

While reading the below, please remember that I am not a lawyer, and the below is not legal advice. If in doubt, get a lawyer.

Please note, that you are NOT allowed to statically link Qt libraries if you don't have commerical licence. The LGPL libraries have to be dynamically linked. Doesn't matter much if stuff you make stays on your PC, but as soon as you start distributing it, you have to think about licence compliance. You are free to use use LGPL version of Qt even for commercial projects as long as you dynamically link. Your app doesn't have to be any kind of open source to use Qt libraries either, but if you make any changes to Qt libs, you need to contribute back.
 

vlzvl

Arcane
Developer
Joined
Aug 7, 2017
Messages
190
Location
Athens
While reading the below, please remember that I am not a lawyer, and the below is not legal advice. If in doubt, get a lawyer.

Please note, that you are NOT allowed to statically link Qt libraries if you don't have commerical licence. The LGPL libraries have to be dynamically linked. Doesn't matter much if stuff you make stays on your PC, but as soon as you start distributing it, you have to think about licence compliance. You are free to use use LGPL version of Qt even for commercial projects as long as you dynamically link. Your app doesn't have to be any kind of open source to use Qt libraries either, but if you make any changes to Qt libs, you need to contribute back.

Yes, you are right. An very known example of a LGPL library is OpenAL. If you statically link it, you are breaking the license. This is why everyone is using some .dll version of OpenAL or .so on linux, even Android and iOS. One has 2 options: either 1) link dynamically your library or 2) link statically but provide either his source or an object file so everyone else can link as well, usually with newer version etc. I always found that very annoying. Many people are avoiding GPL licenses because of this "contribution".
But i guess when you are dealing with Qt, i guess some more DLLs / SOs wont be a problem since i assume Qt will be bloated with its own dynamic libs as well.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
Dynamically linked would be ok, all I have to do is put the dlls in the executable folder, right?
 
Joined
Jan 9, 2011
Messages
2,726
Codex 2012 Codex 2013 Codex 2014 PC RPG Website of the Year, 2015 Codex 2016 - The Age of Grimoire Make the Codex Great Again! Grab the Codex by the pussy Insert Title Here RPG Wokedex Strap Yourselves In Codex Year of the Donut Codex+ Now Streaming! Serpent in the Staglands Dead State Divinity: Original Sin Project: Eternity Torment: Tides of Numenera Wasteland 2 Codex USB, 2014 Shadorwun: Hong Kong Divinity: Original Sin 2 BattleTech Bubbles In Memoria A Beautifully Desolate Campaign Pillars of Eternity 2: Deadfire Pathfinder: Kingmaker Steve gets a Kidney but I don't even get a tag. My team has the sexiest and deadliest waifus you can recruit. Pathfinder: Wrath I'm very into cock and ball torture I helped put crap in Monomyth
.dll/.so don't need to be in exec folder either, can be installed in system-wide location as well. However, people frequently do drop required libs in installation folder to avoid dll hell. On windows I think it works without any fiddling, as windows executable loader looks for dlls in local folder first. On linux, you either have to to LD_PRELOAD or LD_LIBRARY_PATH thing. Also, using dynamic libs has some security implications, but it doesn't sound like you need to care about this aspect now.
 

Burning Bridges

Enviado de meu SM-G3502T usando Tapatalk
Joined
Apr 21, 2006
Messages
27,561
Location
Tampon Bay
I found a demo that shows the basics of rendering in QWidgets

Provided you ticked "Qt samples" during installation, the demo can be found in: \Qt\Examples\Qt-5.10.0\opengl\2dpainting

5C3tUjp.jpg


QPainter is able to render into paint devices provided by QPaintDevice. This could be for example QWidget or QGLWidget.

"Render" means you can draw various primitives like

Code:
painter->drawEllipse(QRectF(radius, -circleRadius, circleRadius * 2, circleRadius * 2));

This must be nested in the window's paint() method. If you have seen GDI+ you should understand roughly know what this entails.

I still haven't rendered the particular primitives I need nor done performance measurements. But it looks like I can use a OpenGL widget without greatly going into OpenGL code, which would be a plus.

Or in other words, it looks like I could provide real hardware accelerated graphics without much more work than a GDI+ window :bounce:
 

vlzvl

Arcane
Developer
Joined
Aug 7, 2017
Messages
190
Location
Athens
I still haven't rendered the particular primitives I need nor done performance measurements. But it looks like I can use a OpenGL widget without greatly going into OpenGL code, which would be a plus.

Or in other words, it looks like I could provide real hardware accelerated graphics without much more work than a GDI+ window

If you are planning a 2D game, then GDI+ might prove efficient enough. However since it is using mostly CPU (it is mostly software), might give you problems if you try adding much stuff in the scene. I would still use OpenGL from the very start to avoid CPU as much as possible. Using some OpenGL wrapper is always preferrable, especially on cross portability since the code differs between different versions of OpenGL (i.e. embedded OpenGL), if you are planning a portable game.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom