Ask HN: How to approach making a 3D Game Engine?

8 points by Betelgeuse90 ↗ HN
This has been a project that I knew I wanted to undertake for years now.

I'm slowly reading books, improving my general programming skills in the process (I'm a CS & Math student also working as a developer of educational games in JavaScript using a proprietary engine), but it feels like when I exhaust the general-purpose books aimed at turning me into an all-round better developer (Clean Code, Pragmatic Programmer and Effective C++ are ones that currently have my attention) - I'm left with a giant body of information relevant to the task at hand and no knowledge of where to start.

I want to mess with all the nitty-gritty details, and learn how to write neat, performant and extensible code. Do the math. Do it all.

But I have no focus. All I know is that I want to delve into OpenGL and C++, but I don't really have a clear picture of what should be done with them. What are the basics of engine development that I should start with?

I only have tidbits of information gathered from here and there, but nothing is formed in my brain and it's a bit frustrating.

I'm scared that if I just start with no clear direction, I'm going to end up throwing away lots of code and become discouraged.

Would love to hear your thoughts. Thank you.

13 comments

[ 2.8 ms ] story [ 29.3 ms ] thread
You could start with a simple raytracer? They're considered small enough to be an intro undergrad project, but it's still a very substantial amount of work.
I should have probably mentioned that I'm about to take an introductory computer graphics course at Uni. But I'm thinking a bit more long-term than that.

However I did consider starting out small and making different projects that may accrue into something bigger later on. I feel like my inability to make these decisions really goes to show how lacking in direction I am right now..

What's the smallest, easiest thing that you can make quickly? Make that. Then repeat.
Yes. Make sure it has a definite end, so the end is in sight. The key is you'll gain a lot of information by doing this: from the work, from the obstacles, from things you notice along the way - and especially, a sense of how you feel about it, and what you think is important.

In short, to inform and develop a sense of direction.

Have you used other game engines? If not, I'd suggest you start by building games in a few different game engines so that you can develop good taste.
I haven't, actually. This is something that I have considered but didn't actually know where I should start.

The transition from 2D to 3D is pretty daunting, though. I do know a thing or two about using a 2D engine (assuming they don't differ that much in fundamental ways) just by working where I do.

Do you think I should stick with 2D engines before going on to develop 3D applications?

Don't write a game engine: write a game. You won't really know what features your engine will need until you have specific requirements. The generic parts - the "engine" - can be extracted via refactoring once you have a working system.
Something I didn't do: try making a game using SDL or some other game library before you go all in on your own. From that, you will learn how it can be done, from the public API. It will give you a sense of when things should happen and why.
The best thing you can do is look at the existing engines out there, and gain a grasp on the subject. The fact is that a lot of the major work behind these engines has already been done - again and again - so in the case of the open source engines, you have a lot to gain by reading code.

Crank out the code for OGRE 3D, Minko, Irrlicht, Torque 3D, and Maratis 3D. Heck, even looking at the code for a 3D game like WakeBreaker (demo game for PowerVR) can give you a lot of insight needed to do what you want to do.

Code reading is a very powerful way to make progress with your goals - and so too, is it good for you to be contributing to these projects wherever you can. I'd suggest a program of discovery whereby you go through these engines in multiple passes - get them all installed/set up, run the demo's, order them by complexity and how much personal effort you feel it takes to gain insight into how they work, and then do another pass from top to bottom on your list, adding features if you can, and so on. In a matter of 4 - 6 weeks of discovery, you can learn a great deal - and may even contribute valuable features/bug fixes too. All too often these engines are fantastic but lack some trimming around the edges - test cases, documentation, sample models, demo games, etc. You can gain a lot of experience by filling in these holes in other peoples' projects, and within a few months you should gain enough of an understanding - if you're serious about it - to venture on your own. But you may find that the existing engines give you what you want anyway .. a way to learn the subject and understand the field productively.

Good luck!

(And in case you're interested in game engines in general - I'm particular enamoured by MOAI, which is 2D game engine albeit built on a core 3D engine - it can do 3D as well, so maybe you want to have a look and see if your interest in the subject can help push MOAI into more 3D-specific territory too..)

Thank you so much for your input. This really does sound like the best way to move forward.

At the end of the day I feel like I really want to understand how these engines work, and I felt like the best way to understand that is to create one myself - but I'm not dead-set on that method.

You can't beat code reading for learning these things .. it really helps and its a lot fun as you get into it and your understanding gets wider.
(comment deleted)