Qt Alternative c++ IDEs and compilers

Here are some Qt alternative c++ compilers and IDEs I’ve been experimenting with:

MinGW pre-compiled c++ headers and compilers:

Code::Block IDE:

MinGW64:

Qt has the awesome QtCreator IDE to work with your projects. But I haven’t progressed beyond Qt 4.8.x so I’m stuck with targeting 32-bit platforms, even though I’m developing on a 64-bit machine.

Code::Block is another noteworthy IDE and apparently runs competently out of the box. I downloaded their minGW installer and it detected all the existing kits on my system. I had to do some minor linking to dependency libraries, but otherwise it was really easy to target 64-bit platforms. But the 64-bit Windows exe uses a lot of CPU resources for some reason. So there might be some extra stuff compiled into it that I’m not familiar with. Otherwise, no fuss.

Lastly, using rubenvb’s precompiled minGW files and compiling through Windows Command Prompt, I’ve been able to successfully target 64-bit platforms. The 64-bit Windows exe runs optimally and doesn’t use up much CPU resources like the ones compiled through Code::Block. But there are some minor quirks like the cursor not adjusting automatically. For example, if you resize the window, the cursor doesn’t revert back to default arrow cursor. So I have to manually set the cursor.

Most of the setup is the same. You download and install your kits and source files, ie, DirectX SDKs, Microsoft SDKs, OpenGL SDKs, Qt SDKs, etc. Then go to Windows Environment Variables and add the correct paths to these kit locations manually. But if your IDEs are robust enough, they might be able to automatically do it for you. If not, you need to find the feature that allows you to set the proper paths to these kits and files. Otherwise, you have to use Windows Command Prompt, which is very clunky, but when it works, you know you can rely on it because it “keeps it simple stupid”.

Have fun playing around with c++ on Windows! And it’s free, you just have to learn a bit! It’s worth it, kids.

Tips and tricks for c++ pointers and operators

If you really want to get the best performance from your c++ coding adventures, you’re gonna have to really get deep into the low-level experience. That means learning how to use pointers and directly accessing memory and data, which is always risky, but with care and proper practices, it shouldn’t even make you flinch. So here are some tips on how to master even c++ pointers and operators.

Usually when you’re accessing a pointer to a member of a class or object, you can do so in c++ like this:

//accessing member of object 10 in the someObject array/list
someObject[10].member

The [] operator is no different than this: Continue reading “Tips and tricks for c++ pointers and operators”

32-bit Color Blending Hints

When you’re programming graphics, you’ll be dealing with color blending and pixels and bitmaps and images and pointers and scanlines and compression, alladat jazz. If you’re not fully trained, it could get quite overwhelming. If you want a super simplified explanation of graphics, it’s just a HUGE array of numbers. And an array itself is like a container, a piece of memory in your computer that stores all those numbers. Continue reading “32-bit Color Blending Hints”

How to use Windows API all-purpose PVOID* structure

If you’re into modern Windows API c++ programming, it seems things have gotten just slightly easier. Naming conventions for classes, functions, structs, enums, etc. just aren’t as confusing anymore. I’m sure technical experts know how to move virtual memory around, which is essentially what programming and problem solving is, but if you’re just sitting down for some casual tinkering, it’s going to be a nightmare. You’re relying on the developers before you to name things intuitively.

So now Windows API documentation has been trying to promote using their generic PVOID struct more. It’s safer, maybe. It’s nothing special. It’s a generic struct to get a pointer to some data, any data. But you have to cast the data type yourself.

Here’s an example of how you can do something: Continue reading “How to use Windows API all-purpose PVOID* structure”

Using Now Patent-Free MP3 Audio Format For Your Indie Games

I’m super late posting this, as the news happened THREE YEARS AGO and the media didn’t spread the word. Anyway, as of 2017, the MP3 audio format is now patent-free. It doesn’t mean that you can now pirate all the commercial songs you want. What it actually means is now that the audio format is patent-free, you can implement an MP3 encoder/decoder into your game engine! That’s sweet! Continue reading “Using Now Patent-Free MP3 Audio Format For Your Indie Games”

Disabling antialiasing when drawing fonts in Qt 4.8.x

When you draw text in Qt using QPainter and desire it to be pixel crisp and sharp, you might do something like this:

QPainter painter(&this);
painter.setRenderHint(QPainter::TextAntialiasing, false);
painter.drawText(this.rect(), "Some Text");
Qt 4.8.x QPainter drawing text with default anti-aliasing on
Qt 4.8.x QPainter drawing text with default anti-aliasing on

However, sometimes it doesn’t work. Your text might be drawn with antialiasing no matter what, which results in soft blurry sometimes ugly font. Continue reading “Disabling antialiasing when drawing fonts in Qt 4.8.x”

Knowing when to use [ ] vs .at( ) in Qt to read vs write data to objects

Knowing when to use [ ] vs .at( ) in Qt to read vs write data to objects

In Qt c++, you can directly access members of an object, whether it’s a class or struct, by using the square brackets [ and ] after the name of the object. For example:

classObject[0].classMember

Using square brackets [ and ] on an object allows you to directly READ AND WRITE to the member. However, knowing the difference between WHEN to use it could help increase the performance of the data handling cycles. In order to directly access that member data, and to allow read AND write access, Qt has to create a new pointer to the object itself in memory to do so. And creating pointers costs a lot of memory. And if you’re dealing with hundreds of thousands of objects and their hundreds of members, then things can get sluggish. Continue reading “Knowing when to use [ ] vs .at( ) in Qt to read vs write data to objects”

3D Graphics Performance Optimization Techniques

Although the tips in the following link are only concerning DirectX9, it may still be useful in Qt:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb147263(v=vs.85).aspx

Notably:

  • Only redraw to the image buffer when you need to
  • Use smaller textures
  • Draw objects from front to back
  • Constantly test your code’s performance
  • Use one large array/buffer of vertices
  • Draw only what needs to be drawn, so culling and z-ordering can only help more

The ideal is to get a higher framerate which is perceivably better experience for the user. For 2D graphics, 16 frames per second is satisfactory. But for 3D graphics, 30 frames per second seems to be tolerable, but 60 frames per second is the minimal. But if you’re just learning 3D graphics programming, don’t worry about frames per second, just worry about the geometry and math to make sure it is correct. Then you can optimize it when you’re confident you understand how it all works.

Windows 10 drops support for Qt 4.8.x after Qt.4.8.6

The main reason I had to rollback to using Qt 4.8.5 since I was developing on Qt 4.8.7 on a Windows 7 machine was because after upgrading to Windows 10, my 4.8.7 apps failed in so many levels. Something as simple as loading an image was completely broken. I did a little digging and it turns out since Qt 4.8.6, support for versions of Windows before version 10 was dropped. So instead of gambling with newer versions of Qt that just won’t work on my “old” development Windows machine, I have to count on the versions of Qt that will. And Qt 4.8.5 was the last functioning version that seemed to be supported by most Windows versions.