Jump to content
JohnBobSmith

How hard would it be to write my own game engine in C++?

Recommended Posts

Hello all. So like, I've tried Leadwerks. And I find it... interesting. My biggest setbacks is lack of good, high quality learning material (and I have searched hard for it). Maybe I'm looking in all the wrong places, I'm not sure. Another setback, for me at least, is that it crashes constantly on my system. And because I'm using Linux Mint, I cant report bugs.

 

So my solution is this: Write my own game engine. I'm by no means an expert at software development, nor have I ever gone to school to learn software development. I'm an enthusiast/hobbyist programmer. I would like to adventure into game design and such.

 

The requirements for this engine are as follows:

 

-Must be 3D

-Must use OpenGL

-Must be easy to use with LOTS of documentation

-Must be relatively powerful for someone of my experience level.

-Single player for now.

-Linux only for now (I have no Windows machines available to test on).

 

I've used SDL, and find it fairly straight forward. OpenGL is a step up from SDL, but I doubt it will be that hard to learn.

 

Now, my questions are as follows:

-How hard would writing a game engine be? I'm expecting to have to do a LOT of work. I doubt it will be less than 300,000 lines of code. Not to mention all the dev tools I'd have to write as well.

-What sorts of libraries exist to make the proccess easier?

-Are there any good open source engines for Linux that I could use as a base?

-How hard would physics be to implement? I want a moderate degree of physics. Like rag dolls, somewhat realistic object destruction and movement, stuff along those lines. No vehicles for now.

-What sorts of file formats are easy to support and use? I'm thinking I would like to use something that blender can natively export, and targa or dds for image textures.

-What sort of an environment should I be in? By environment I mean things like the OS, IDE, and other relevant things along those lines. For now I'm using Linux Mint and Code::Blocks.

-What sorts of hardware would I need? I may be able to upgrade over christmas. For now I'm on a laptop with an AMD APU and Radeon HD 7420G.

-What version of OpenGL would be good to use? I'm thinking OpenGL 4. Not sure if an older version would be better.

 

I plan on spending the entire week gathering as much info as I can about the process of writing game engines. I am posting this in hopes that some experienced users can direct me in the right direction.

 

All the best,

JohnBobSmith

Share this post


Link to post

Ok, I'll give my opinion on this.

 

Well, the term "game engine" is very ambiguous. Expecting it to be a certain length depends on what type of features you want to be included in the engine. Also difficulty is ambiguous as well, because that depends a lot on what you are trying to accomplish.

 

Libraries - OpenGL is a start. Again, it's unclear what exactly you may need at this point without a good list of features.

 

Physics - The best option here is to integrate another physics engine. Options: PhysX, Bullet, Havok, or Newton

 

Environment - I don't see why what type of IDE you use matters that much. It's really up to you.

 

Open-Source Examples - Take a look at Ogre3D. It's an open source engine for Linux.

 

File Formats - You'll find SDKs for most normal and free formats. I would start off with more common ones though such as .png. Note that OpenGL takes care of this for you for a lot of file formats. OpenGL actually does a lot of stuff for you surprisingly.

 

Hardware - Unless you are making some ridiculously demanding engine, I'm not sure why you need a super strong computer.

 

OpenGL Version - Use more recent versions. The reason why I say this is because these version have more features. Also, there was a time when OpenGL changed it's rendering methodology from a fixed pipeline to a dynamic pipeline (so a shift towards shaders), and you definitely don't want to choose a version of OpenGL that doesn't use shaders. Otherwise, you'll regret it later on, trust me. :)

 

Also, the 300,000 lines of code thing: you'll not even get close to this unless you are writing some ridiculous engine. You'll find that OpenGL and libraries reduce the amount of code you need to write substantially. While I can't speak from Leadwerks' or professional engines' experience of how many lines there are, I wouldn't think you would even reach close to that. That being said, you'll probably run into more issues such as compatibility and integration issues with libraries and such, and that makes it hard.

 

I will warn you though that I think you have the wrong idea on how to approach this. It can be a good learning experience, but your engine will likely suffer from a lot of issues that developed engines such as Leadwerks have ironed out over the years. These include performance, in particular. Good luck on it if you choose to create an "engine," whatever that entails specifically, but if you are planning to develop games with it, it might be best to just find a new engine or move to Ubuntu.

Share this post


Link to post

I don't plan on making the next Triple-A game with this engine. This is more a learning experience. Let me clear up a few things based on your post...

 

-By "game engine" I mean something like Ogre3D or, say Source (one of my faveorite engines). Think of it as like a car, and the car engine. The "game engine" in my case will do things like rendering, collision detection, input, sound, scripting, etc.

-I do agree that using an already existing physics engine would be good. I'm not trying to re-invent the wheel here, but rather learn how stuff is done under the hood.

-For the IDE, I guess it wouldnt matter that much, lol. So Code::Blocks it is.

-Thanks for mention of Ogre3D, will look at that!

-WIll probably use OpenGL 4. I dont see any reason to not use the latest version of it. No, I don't want bleeding edge. But theres no point in using something oudated.

-All right, the 300,000 lines of code was a very, very rough and broad estimate. The point being is that I know this project will be larger than anything I've done in the past.

-How do I have the wrong idea to approach it? Can you elaborate more?

 

Thanks for the reply!

Share this post


Link to post

Well, I guess i shouldn't have really said wrong approach, but I would get a lot of experience coding with engines before starting my own. I guess I was under the impression that you were new to coding and such, that's where I was going with that.

 

Certain things such as writing shaders are important early when developing using OpenGL, but how do you know you are writing them correctly for instance? What if your shader code is fine but your underlying OpenGL code isn't? You learn a lot of the connection between certain parts by looking at how an engine such as Leadwerks functions. For instance, do you know what a projection matrix is? Engines (including Leadwerks) often provide some lower level operations that you might want to learn how to use first. There are a bunch of matrix commands in Leadwerks that you will need for OpenGL, but it would be easiest to learn them through an established engine than to start from scratch.

 

Unfortunately, open source engines like Ogre3D probably have a dense amount of code that has a lot of interconnected parts, and this can be confusing (I'm just guessing, but it would make sense that a large engine such as that is very complex).

 

Also, how familiar are you with C++? I've never coded with OpenGL using C++, but I imagine it would be quite tedious compared to other languages, but I guess there are a lot of examples online for setting up a basic OpenGL environment.

Share this post


Link to post

I would say I have a moderate ammount of experience with C++. I'm learning new things and techniques as I go.

 

I will probably build something thats fairly good in SDL before moving on to OpenGL. I need to learn more C++ I think, having read some OpenGL stuff. That said, I consider myself to be somewhere between beginner and intermediate. Not completely new, but by no means an expert.

 

For now, I want to get a taste of whats in store for the future, if that makes sense. This OpenGL game engine project is something I plan on doing over the course of a year or more, after I learn more SDL/C++ first.

 

As for tediousness... Yes, C++ is very tedious. But it's also what I'm most familliar with, what will perform the best, and what the industry uses. So I have nothing to lose and everything to gain by using C++.

 

All in all, I will continue my research and look up more C++ tutorials. smile.png

Share this post


Link to post

John you should probably start with something like a Game Engine framework similar to Cocod2d, GamePlay3D, or Ogre3D, then build the tooling you want to accommodate for the types of games you want to build with it, similar to what Leadwreks, Unity3D and Shiva offer for their own Game Engine Frameworks.

 

i am noob, but that is my ¢0.002

Share this post


Link to post

This all sounds a bit pie in the sky to me.Far too ambitious to complete in a few years.

My advice would be use leadwerks with windows and a good GeForce graphics card and you won.t go far wrong.

Share this post


Link to post

There are some problems with AMD's latest Linux driver, and these have been reported to AMD. You are correct that I cannot accept bug reports for Linux distributions other than the officially supported Ubuntu 14.04 64-bit, but I suspect the problem is AMD's driver.

Share this post


Link to post

...if your goal to have a taste of underlying structure, rendering systems uses, and try to acomplish same/similar things for sake of much better understanding of whole thing, i would say, why not..go for it..if your aim to build up entire game engine from scratch, i would issue 'red alert' flag for such operation...game engine is far more complicated system than graphics engine such as Ogre or similar open source solution..from what i can read in your posts, you mostly talking about graphics, so i assume that you trying to build graphics engine from scratch, which may work..however, if your task is aimed towards entire game Engine, then i do not want to discourage you, but i will say just, good luck, as you will need it..

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...