I think when people hear "write your own engine" they imagine a situation where they're writing specific code for each platform just to create a window and an OpenGL (or whatever 3D rendering API) context and then hooking into the message pipe and yadayadayada. I absolutely do not recommend you go around calling CreateWindowEx and doing all of that manually.
There are great free and open source libraries available to do that shit for you. SDL2, RayLib, and many other smaller and less known libraries. I use RayLib in my fantasy console project and I gave the source to a friend who, with almost no alterations, managed to get it running on a Raspberry Pi. This is a solved problem. You don't gotta do this.
What all of these projects offer in some shape or form is the following:
- Create a window
- Interface with audio
- Get input from keyboard, mouse, and gamepad
- Load image files
- Display stuff on the screen
So when people say "make your own engine", they generally don't mean all of that, which I think is an important point to make clear. Things that are part of an engine could be:
- What is a scene or a map? What format is it loaded from?
- How do we render a scene?
- How are we handling volume for different categories of audio?
- How do we translate input device values to in-game functions?
- How do we let the user change resolution or go full-screen?
- How do we handle time keeping?
- How do we update in-game entities?
- How do we localize text?
- How do we save or load a game in progress?
- Particle systems?
But the really funny part is that many engines only answer some of those questions. If you've dealt with many of those questions by yourself, without support from something like Unity or a plugin for it, you've probably already come a lot closer to "making your own engine" than you might think.
A complicating factor tends to be 3D. Loading your own models, animating them, dealing with materials, G-buffers, deferred rendering, all of those can get relatively complex to deal with and you probably don't want to get into that. On the other hand, it's not like it's impossible either. Speaking for myself I've set up a basic lighting model (blinn-phong with fresnel) with shadow mapping, done ray-casting, implemented deferred renderers with FXAA, bloom, SSAO, and HDR with eye-adaption, written my own materials system, loaded (non-animated) models, and more, and I did all of those as short-lived hobby projects and implementing that stuff generally took a lot less time than creating a single game. So it's not exactly impossible, although I probably wouldn't recommend it.
If you're making a 2D game though? Then having access to graphics, audio, and input is really all you need. Back in the days of the 80s and 90s most games rolled an entirely new engine and they generally didn't have dev cycles that lasted 3+ years. And they didn't even get stuff like "draw a thing to the screen" or "poll the gamepad for new inputs" or "play this sound effect" for free, they had to interface straight with the hardware to do those things.
Am I suggesting you should roll your own engine? I mean, probably not (unless you wanna), but I'd prefer people to at least be clear-eyed about what that actually means when attempting to make that decision. It's not impossible, and depending on the type of game you have in mind, it might be a minority of the work you would have to put in to ship.
