r/cpp_questions • • 13h ago

OPEN How should I go about learning C++ for low-level gamedev?

7 Upvotes

Good day,

I am an intermediate game developer coming from Unity, and I'd like to deepen my knowledge of game development. Let me tell you about myself first and how I got here.

Over the summer I've learnt a considerable amount. I've learnt about OOP. I can realize design patterns, refactor code according to SOLID principles, and write systems which are clean and scalable. I've come to realize that objects, such as classes and interfaces, aren't just magic words I put into the IDE. They're actual abstract objects which have their own properties and relationships between one another (I'm still in high school so I don't really know any comp sci theory other than what I use to create games). In June I've created a game featuring an AI which uses a complex Hierarchical State Machine governed my emotional dynamics and external events. My implementation of the State machine pattern allowed me to use it all over the game without issue or extra modifications.

I've also learnt about Data-Oriented Design. Over July I've gotten the feel for Unity's Data-Oriented Technology Stack. I've learnt to think in terms of ECS, be cognizant of the memory I'm using, and parallelize code. I've written an N-Body simulation which uses the Barnes-Hut algorithm. Coupled with multi-threading (Jobs) and the Burst compiler, the sim can handle ~100K bodies with collision at a presentable framerate.

In August I've joined a team to participate in the National Technological Olympiad in Russia to go to uni, so I know what "readable" code means, how to use version control and how to write professional, clean and beautiful code. However, that's besides the point.

As I've matured as a programmer, I learnt about the concept of low-level game development. I've come to realize that Unity isn't a magic box. Previously, I didn't even consider that there's something under the hood of the game engine. I just wrote code, clicked buttons, and it all just worked. However with time, I've come to realize that this isn't the case. Unity is yet another program which hides a considerable amount from me. I realized this mainly in July, when I needed to know how the CPU worked more-or-less (when things like cache lines and race conditions became important). Then I realized that I really am at the very tip of this metaphorical iceberg of programming, looking down at the deep water below.

Here's when I've learnt about C++. I know that this language is often regarded as the foundation of just about everything, including games. I've used it briefly before. Long ago, I've written a little Pong project with C++ and built it with CMake, having used SFML to render objects to the window. I've also used C++ to solve simple Codeforces problems, so I do have the rudimentary knowledge of input/output on C++. But that's about it. My aim is to use the language to learn about low-level game development, to "break free" from the game engine and expand the domain of my expertise (maybe to even write my own game engine in the future). I can learn the API of the language rather quickly (e.g. how to write lambdas, how to import libraries, anything I can already do in C#), however I know that's not all that I'll need.

I am aware of the gaps in my skills. I have the high-level knowledge, just not the low-level knowledge. Even though I know how to use DOTS to write parallelized, Data-Oriented systems, I can't really tell you how to resolve even a simple race condition, or what a memory leak actually looks like, or how the CPU and RAM are laid out, or how things actually work on the low level. Even though I can use the API Unity and C# provide to use OOP to write clean and modular code, I don't really know how a class actually works, what differentiates data types from reference types (other than "something, something, pointers, something, something"), and how things actually look like inside memory. Unity hid all those troubles from me. So I know that these gaps must be addressed for me to proceed in my learning journey. I learn fast though (as I've shown), so it's not that big of a deal.

Here's where I need your help. I know that to learn efficiently I first need a plan, a roadmap per se. Given my experience, how should I approach learning low-level gamedev on C++? What stuff do I need to learn about? And in what order? What is your advice?

I'd love to hear from you wonderful people.


r/cpp_questions • • 23h ago

OPEN C++26 template for loop std::span<T,N>

9 Upvotes

Hi, C++26 added "template for" operator , https://cppreference.com/cpp/language/template_for .
GCC 16.2 it supported. It works with std::tuple, std::array, but can't compile with std::span<T,N> fixed size.

How to achieve that, std::span<T,N> also worked with "template for" ?

https://godbolt.org/z/6s9MfzTeb

It be very useful for hand-by unroll loop.

I try specialize std::tuple_size, std::tuple_element, std::get for std::span<T,N> , but it don't helped.


r/cpp_questions • • 1h ago

OPEN Getting better at C++ for coding interviews?

• Upvotes

I dont mean Leetcode, but enough to be able to debug thoroughly, write out basic functions, etc. Not DSA, but just smaller code snippets, anywhere from 20-100 lines, where an interviewer says do this for me, or debug this.

How can I get better at that? right now I've mostly done coursework involving it (long time ago), but not much internship experience using cpp


r/cpp_questions • • 19h ago

OPEN Qt Quick + QML GUI App Tutorial Series Suggestions?

3 Upvotes

I am a freshly minted C++ Qt developer in that I just completed an online course for C++ and the basics of the Qt framework within the past few days.

I am looking for video tutorials on how to build a GUI application using the Qt framework using Qt Quick and QML. For reference, I am not completely new to programming. I am a full-stack mobile and web developer who has been developing both types of applications for years. My tech stack in React (Next.js)/React Native on the front-end and pure Django or Django REST Framework + Django Channels on the backend.

What originally got me into web development was Corey Schafer's Django tutorial series which guided me through developing a web application using Django assuming I already knew HTML, CSS, and Python. That is when I learned that I learn best with YouTube video series I can follow along while the instructor explains what I'm coding. Is there any such series for Qt Quick and QML like building a notepad app? YouTube search results only turn up outdated tutorial series using Qt Widgets which IS NOT what I'm using and am avoiding because I want to construct the UI using QML files, not the widget picker.

Thanks in advance for your help!


r/cpp_questions • • 8h ago

OPEN I am searching for a cpp "engine"

2 Upvotes

Hello, I have been using c++ for the last few months and I am pretty satisfied with it and I think that it is going to be and stay as my main language. I have looked at the alternatives like C#, GDScript, Rust etc. and want to get into game developement. My current issue is that i can't seem to find a good engine/framework. I tried Godot with GDExtension, but the implementation for c++ was quite tedious and not integrated - Unreal Engine is a bit too much functionality for me, as I only want to do simple games. Engines like Flax oder O3DE seem to unknown, so I am currently thinking about using a framework wich fullfills the tasks of an engine, like rendering, physics etc. I have used raylib and sfml before and managed to get a small architecture to run(mostly through a small render class, very limited in functionality). If anyone had similar issues finding something to work with c++, please do tell me your suggestion for what I could use


r/cpp_questions • • 15h ago

OPEN IntelliSense marks an error where the compiler is fine (VCStudio 2022)

1 Upvotes

I have these three lines inside my constructor. I'm using C++23, configured through CMake. IntelliSense complains because SubCursor is non-copyable and non-movable:

function BooksReport::Group::Cursor::Cursor(BooksReport::Group::Cursor &&) cannot be referenced. It is a deleted function

If I understand correctly, copy elision should bypass copying in these examples:

    using SubCursor = BooksReport::Group::Cursor;

    subCursors.push_back(std::unique_ptr<SubCursor>(new SubCursor(booksReport->uniform.getCursor())));
    subCursors.push_back(std::unique_ptr<SubCursor>(new SubCursor(booksReport->nonUniform.getCursor())));
    subCursors.push_back(std::unique_ptr<SubCursor>(new SubCursor(booksReport->singles.getCursor())));

This implementation is due to the fact that SubCursor registers its address within the parent Group object upon creation. Normally a SubCursor is created during loop initialization and thus corresponds to an object on the stack. In this specific case I need objects stored in a list, hence my attempt to put them on a heap and store unique_ptr for easy memory management.

Like I said, the compiler is completely fine with this, but IntelliSense isn't. I hate red squiggly lines. Does anyone know if this can be solved?


r/cpp_questions • • 7h ago

OPEN How to master? What courses to watch?

0 Upvotes

How can i write my own network stack? How can i code using linux syscalls and header. Idk what to do. Please help me im so confused. I got the basics of cpp btw