Best resources for game engine making?(C++)

Started by
26 comments, last by arshadbarves 1 year, 6 months ago

JoeJ said:
Programmer71 said:

Please don't feed the troll.

-- Tom Sloper -- sloperama.com

Advertisement

I spent a year writing my own game engine from scratch using C# and XNA, starting with a single triangle rendered to the screen. Here's a 2 minute video of the final result:
Game Dev Progress - Dec 2014 - YouTube

I currently work at Electronic Arts on the Frostbite Engine.

I don't recommend creating game engines anymore unless you're doing it purely for academic reasons. Instead, use an existing engine which is mature (Unreal Engine, Unity, etc.). Otherwise, you'll end up spending weeks to develop an engine feature which other engines have already implemented and done better than you ever will. Existing engines also go through rigorous QA, performance benchmarking, and build processes to ensure cross platform compatibility and stability and to ensure other parts of the engine don't break after a change list has been submitted. So, stand on the shoulders of the thousands of engineers who have come before you and take advantage of their work.

If you are passionate about engine development and not game development, then download Unreal Engine 5 and dive into the part of the engine source code which calls to you and work to try to understand it and make contributions to it. Step through the code in a debugger and see how various engine features are architected. Look at the raw assembly and see if there's ways to optimize it to get benchmark performance increases. Or, develop new features and capabilities! If you feel particularly strongly about the quality and value of your contribution, you can even submit a pull request and get it included in the next engine release to developers around the world.

@slayemin Thank you, Eric.

Try reading the book the guys have mentioned, and also learn a bit about programming patterns - helps solving problems that are related not only to game engines.

I had the same dream 3 years ago after I thought I became fluent in C++ (which turns out I was not) and I started looking at code or resources to make a game engine, and as you probably found, they are not many, and they are either high-level that doesn't give enough information or too low-level making it very complex.

Below I will list resources that helped me build my first game engine, but first, let me explain the stages I went through. (bear with me it is a long journey, but It got me a job. so It was worth it)
I will assume you want to create things yourself and not use off-the-shelf tools. (each stage will have resources in it later)

Stage one: creating a platform abstraction allowing me to get a window and receive events
Stage two: drawing basic 2D shapes, by filling a pixel buffer, attached to that window
Stage three: moving 2D objects in space using linear algebra
Stage four: creating 3D objects by filling triangles
Stage five: load objects from external files (like obj files), and apply transformations to them through matrices (Translation rotation, projection, etc.)
Stage six: moving my drawings to the GPU to use dedicated graphics API (OpenGL in my case) instead of filling a pixel buffer.

at the end of the day, a basic game engine allows you to load a model, move it in space, receive some basic input and interact with your scene. I want to emphasize in my experience, your time should not be wasted on any of the following:
- Modern C++ practices (totally useless for games and game engines)
- Memory management (allocate everything upfront, your basic game engine will unlikely use more than 2GB at the early stages, don't even waste a single second of managing memory or using smart pointers, allocate a single giant block, when you need memory, grab it from that chunk and never free it, if you have a case of creating objects and destroying them over and over, just reuse the same memory, and again don't worry at all about freeing)
- Multi-Threading, while you will definitely want to do so in later stages, for your first game engine, you will not notice a difference, and you will not benefit from it, in fact, it will only complicate your code.
- Application design, entity component system, Entity manager, design patterns, etc. Those are probably the worst thing that people try to do, if you are trying to do any of these fancy terms (specifically design patterns and principles) you are doing something wrong. The stages mentioned should be easily implemented with very little code, anything you try to do to architect your first engine is not only a waste of time but also an extra complexity to your code that makes it harder for you to re-write some parts of it later, go for minimal and specific approaches, never ever try to make anything generic (you will notice it, the moment you are using templates, it means you are doing something wrong).

Probably it might sound weird that those are things that I am saying don't waste your time, but I know a good amount of people who just wasted months over months trying to architect stuff that is completely not needed (and surprisingly to me even after I got my job, aside from multi-threading, the rest are still completely useless) but I am talking from 5 years of experience so far, time is much better spent on algorithms, math than any of those things (the only time, you will ever need to touch any of those things is when you try to do generic stuff, like writing a library, as long as you know what your code should do, those are a waste of time)

now for the resources:

1- You need to have an application that allows drawing, and playing audio, user input (and a few other things like loading assets, etc.) for that, you need what is usually referred platform abstraction layer, a piece of code that abstracts away the OS interface for you, such as creating a window, sound buffers, giving you file handles, etc.
I highly recommend you only do graphics first and user input first, no audio no fancy stuff at all. MSDN is your best friend, they have a lot of examples for creating a window from scratch using windows.h, win32 API and receiving events, and then Drawing using GDI (software renderer). this will surely be slow compared to using a dedicated graphics card and a graphics API like D3D11 or OpenGL (more on that later) but will keep your application small and easy to extend later.

2- if you can draw objects, as simple as rectangles, the next step will be to move them in space, scale, and rotate them, for that you need math (linear algebra), many good books are there, and many free online courses on youtube. I am a bit dated about it. but the youtube channel insights into mathematics has a great intro, but that is my preference, you can get the standard introduction to linear algebra by one of the MIT professors.

3- you can draw basic shapes (rectangles) and you can move them, now time to go 3D, a 3D object is just a 2D surface made of triangles, learn how to draw a triangle, then how to fill a triangle, any introduction to computer graphics course should cover it, and if you want something very specific, pikuma 3D graphics from scratch has some nice course (only for a beginner level)

There is also this course from UC Davis Academia and Cem Yuksel has two introductory courses for graphics.

Don't get overwhelmed by the many resources, pick any of them, what you want is nothing more than the algorithms to deal with 3D objects because at this stage, you should have a window and you should be able to fill objects yourself, so it doesn't matter what API to use, now you should be able to just take some algorithm and implement it.

there was also this book that many of my friends recommends but I have not read it myself, (only the first few chapters) which looks also good
https://gamemath.com/book/intro.html

4- Now you can take a simple obj file and load it, using any obj loader (or simply write one yourself, it is very easy) and apply the transformation of 3D algorithms to it, the courses I mentioned cover basic stuff of lights, shadows, deformation, etc. for this you can look into a bit into (but not needed) into Cherno youtube channel game engine series. or Pikuma. this is a simple stage but it will very rewarding to load a scene and move the camera and apply some lighting and shadows to it.

5- Finally, when you have lighting, many 3D objects, and shadows, you might start to feel that it is getting a bit slow, no worries because at this stage you should have a good understanding of the underlying basics that makes your engine works, so you can move to a 3D API, I hear a lot that people should stop using OpenGL on windows, but what I learned and what I am using at work is openGL, so you might look for other resources if you want to do DirectX instead of OpenGL but honestly many of the principles will be the same, so knowing one will help you to learn the other.
Interactive computer graphics top-down approach with OpenGL book is really good, there is also Cherno's OpenGL Series, also learnopengl.com (I don't like that website that much but it is not bad, to say the least, and has full source code, so it can be very good reference example). There is also a Programming guide for OpenGL the red, it is an API reference page, if you want to know why the API looks like that, and what is the idea behind it, use that book if you don't care, leave it.

6- if you now have a basic understanding of a graphics API and a basic game engine (which is a renderer that loads 3D objects and can move them) what is left is just to get more math, and implement what you want (you want animations? ray tracing ? scene editor? pick what you like, implement it)

very good books that I can recommend are:
1- Fundamentals of Computer Graphics, Fourth Edition by Steve Marschner, Peter Shirley (the same author has a very nice book called ray tracing in a weekend)
2- computer graphics principles and practices 2nd edition (not the 3rd, it is really bad)
3- Real-time collision detection 2005,

Recently I read the foundation-of-the-game-engine series and I can recommend it, it is very concise and heavy but serves as a good reference.

Again the topics that come from this point on should be influenced by your interest and what your engine should look like, some people want to do physically based rendering to get very realistic images, and the free book Physically based rendering from theory to implementation got you covered, also real-time rendering 4th edition discusses, well real-time rendering (like games), the website of the book has a bunch of books that you can pick from, some are free some are not, but the website itself is a great resource with many articles.

Again, don't be intimidated, pick a book finish it, and go for the next if the topic interests you, I mentioned many books and I finished the majority of them, but now I just pick a topic of interest and implement it in my free time.

Now, for some good coding references:
my favorite of all time
HandMade hero is a series written by a guy who has 30+ years of experience in game-dev and builds an entire 2D/3D engine from scratch, literally from scratch entirely on stream, every little single line of code. Needless to say, the series is a gold mine of algorithms, coding tricks, good design decisions, tradeoffs, and many countless small and large gems.
why on earth I didn't mention it at the beginning? because the series is not meant for complete beginners, yes he writes the entire thing from scratch, explaining every single, but it is hard to keep up if you are a beginner. but I always look it up as a coding reference on how to implement XYZ stuff.

There is also this channel
https://www.youtube.com/user/ryanries09
which

None

@AliAbdulKareem Thanks for the information.

This topic is closed to new replies.

Advertisement