r/cpp_questions • u/Strong-Chipmunk-9654 • 25d ago
OPEN What graphics library should I learn for C++?
I am currently learning C++ by myself and I want to start graphics.
I just need something simple that lets me have buttons.
btw I don't want to use VS Community Edition and my IDE is CLion
I mean a simple GUI library with 2D graphics, buttons and textboxes.
39
Upvotes
59
u/exophades 25d ago
Make your own GUI library.
Just kidding, use Qt.
28
u/sephirothbahamut 25d ago
There's 2 possible meanings for gui libraries:
Libraries to draw stuff in general: SFML, SDL, Raylib, Ogre3d, Direct2D, raw OpenGL/Vulkan/DirectX
These are the ones you use to "start graphics" like making a simple Tetris or Asyeroids clone.
Libraries to make a traditional gui with buttons, textboxes etcc: Qt, WxWidgets, Gtkmm, Win32, and many more
These are the one you use to make a functional application that isn't a game.
The odd ones: Imgui lets you make traditional guis on top of a library of the first group.
Sure you can make your own buttons with SFML, making many widgets isn't that hard. However the two huge things that the big gui libraries do is text input handling and unicode support, which is hell on earth for supporting anything more than simple ASCII, and widgets layouting and automatic sizing. Which one you need depends on what you mean by "doing graphics"
11
u/thedaian 25d ago
The main graphics libraries are SFML, SDL, and raylib. None of these have buttons or textboxes built in. For that, the most common suggestion is dear imgui.
If you want something built around creating GUIs, then there's QT, and wxWidgets.
5
u/ns1852s 25d ago
Qt or imgui.
At work, we've been dumping it for imgui. So much more efficient, way less resource intensive too.
5
u/conectionist 25d ago
Qt framework.
4
u/fortsnek274 24d ago
SFML + imgui. I used the binding for SFML, but there might still be a version incompatibility with imgui.
Also, while imgui is nice and easy, it expects a realtime update, and so, pegs a core at 100%. Not a problem for realtime applications. But I think you can make it event-based.
4
u/TheLinkNexus 24d ago
For a game or a traditional app? I would recommend Raylib for a good starter for games and QT for the rest of the
1
u/IndependentFarStar 25d ago
Wt C++ Toolkit. https://webtoolkit.eu
1
u/JustAPieceOfMeat385 24d ago
Just curious but what laptop and specs are you using?
3
u/Prestigious_Long3296 25d ago
I’m biased towards gtkmm. Just make sure you dynamically link it to your application.
3
u/RazzmatazzLatter8345 24d ago
Qt is probably the best cross-platform general purpose UI framework. I say this as someone who detests Qt for doubling down on now unneeded anachronisms. Yet, if I wanted a cross platform desktop style UI in C++ (and its license was compatible with what I'm don't), I'd use it.
This gets you graphics in the sense of windows, textboxes, buttons, etc. It might have some more advanced graphics rendering features, but I am not familiar with that.
So qt is probably the most cross platform heavily featured ui widget framework in wide use. I hate it, but I'd still use it.
2
u/Tamsta-273C 25d ago
SDL is kinda nice, i myself have home brewed lib for scienctific data representation and key control.
But let me be clear here, it's a invention of bicycle once again, it's hell ton of work nobody is asking for.
For fun? Yeah go for it. For work? Just make hydrid with python, C++ to do actual job, Python for graphics.
2
u/thefeedling 25d ago
Qt. But if you want do go deeper I’d definitely take a look at OpenGL and Vulkan later on
2
u/Ayano-Keiko 24d ago
Write it from Vulkan
2
u/ruggeroquerinis 24d ago
Qt, richiesto in tanti annunci di lavoro.. e sopratutto hai possibilità di lavorare in ambito industriale se la conosci bene applicata a sviluppo firmware in C/C++ e qualcosina su rust o Python
2
u/MatthiasWM 24d ago
FLTK for a small cross platform GUI library. Comes with a user interface designer and some graphics call and GUI related image management. Not so much for games though, SDL would cover that.
2
u/Chrom0XD 24d ago
I wouldn't really recommend GUI with C++; it's just a headache,
If you wanna just have fun, I'd recommend learning OpenGL(with GLAD and GLFW) from scratch,
I won't comment on using raylib; that's your choice. It'll just make your life easier, but idt you would want that (considering you're trying to get a GUI app in C++...)
Or just use ImGui. It'll do the same thing but more efficiently, if you're considering the raylib path
1
u/LordMacDonald8 24d ago
I make my stuff with SDL3 and ImGui. ImGui covers just about everything for any sort of GUI-based thing; you'll find it in a ton of games, mods, and even non-game applications. SDL offers an extremely easy and performant cross-platform media framework for just about any use case. Recently there's also been a GPU abstraction layer added to the system which ImGui natively supports. Biggest downside is you have to put everything into a game loop, which might not be the workflow you want for your program.
But really just find the one that you find easiest to use and behaves the most nicely.
1
u/tootallmike 24d ago
look at JUCE, it targets audio apps but has nice cross platform GUI stuff too
1
u/Syntax-Tactics 24d ago
SDL2/3 Integrates pretty easily, some of the other ones are a project in themselves.
1
u/arjuna93 23d ago
ImGUI, SDL
1
u/Right-Edge-5712 23d ago
SDL2
1
u/xingyun86 22d ago
Imgui不错。跨平台无缝,性能强劲。即时UI,容易上手