Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

Game Engine Programming

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
37 replies to this topic

#21 darkleemar   Members   -  Reputation: 111


Posted 23 August 2012 - 09:13 AM

To develop an engine you need at first and only: Motivation
Without a game in mind which will use the game, you will lost your motivation very fast. Or why do you write it?

I myself started to develop an engine when I was 15 or 16... I had a game in mind... a big multiplayer first person shooter which was located in an open world. So I started... but don't find a good starting point... I really lost my motivation very fast. But this was not the end. After that I started to make an animation film... Again, I failed. Then I started a novel and understand that I really don't want to play or make a game.
I only wanted to tell a story. So I started my novel and continued to write it even today. I also continued my engine and it grew and grew... Today it is not finished, but this time my motivation is to make a game for my novel and to design huge software architectures. I really love design and this is the reason why my engine is alife even after 5 or 4 years.

What does that have to do with engine development?
Very much. Motivation is the most important basis you can have. But don't let it fly away. Fix it to something. I wrote myself a novel. What have you done?

Also buy books... many books... ten is not enough Posted Image
Like Game Engine Architecture. Read all of them. Love them and of course understand them.

When you really only want to make a simple game you should use other available engines. Like Ogre, Irrlicht or maybe Unreal, Unity and if you really love high end, the CryEngine.
You have to invest a lot of time before you get something useful which you can call an engine. You will rewrite it many times. And everytime it will be easier. You will understand more and it will make you more fun. Of course there are also times where the motivation is down. Don't make you mad, you don't need pressure of time. I failed many times and I'm failing even today, but don't lost your motivation.

Maybe I've told a lot, but someday you will understand.

So at the end my suggestion to you:
Do it! Start your game engine development adventure!

Happy coding!


wow you just motivated me to make an account and get better at C++! Thanks!!


#22 omercan   Members   -  Reputation: 370


Posted 23 August 2012 - 11:22 AM

wow you just motivated me to make an account and get better at C++! Thanks!!

Really? Cool Posted Image It makes me happy and proud when I could help one person.

This probably does not affect the plans of the OP but still: Networking and prediction last? Yikes!I'd say work your way through the list but leave all sorts of networking out of your first engine. Then, when you fell like you would like to add networking, start over again (probably using the parts of the first engine that you feel are working well) but plan the engine with networking in mind from day one.
I implemented things like NAT punch through, lobby servers and matchmaking before my engine could even create a window, and it has really payed off. I feel this is the only good way to create a networked game engine. This might be why you feel that "networking is the worst thing you will have to deal with".
That said, you can probably create a fully functional renderer and use it in a networked game engine just fine, as long as the renderer is separeted from the game logic, but only start create the GAME engine systems when you have your network layer figured out.
Just my two cents...

I also think that Network shouldn't be the last option. But it is also not the most important part. Design the framework with Network in mind.
You need at first a good object and class system. But please not a huge hierarchy tree. Also one root class like the QObject class in Qt is not really useful in game development (but in GUI developing).
My second suggestion: Don't make the underlying classes too general. You will lost much power and performance and in the end you will get spaghetti code because everything is done with the preprocessor and the template system.
To make a sophisticated design, I recommend UML tools.


PS: And on my mind don't use something like a signal slot system and over think the use of callbacks. But this all is up to you.
Reading, Reading, Reading... why do you read not more?
I have a blog: omercan1993.wordpress.com look there for more content :)
And I also do some art: omercan1993.deviantart.com
And whats about the Pear3DEngine? Never heard of it? Go and look!
Yeah, and currently I do this: SimuWorld

PS: Please look at this poll on my blog about scripting languages: A opinion poll about scripting language

#23 EngineProgrammer   Members   -  Reputation: 295


Posted 23 August 2012 - 12:19 PM

Honestly, I Am following that given list. Posted Image

Video of what I have written so far: http://www.youtube.com/watch?v=WasDe6NUEso&feature=youtu.be

Now I'm implementing the converter into my program to win more development time.

I also have written a camera and system class so far. So I can check all input of the keyboard and mouse and change my camera with the input.

Hmmm strange, my video is shaking and I have no idea why.. Recorded it with CamStudio.

Edited by EngineProgrammer, 23 August 2012 - 01:01 PM.

#24 omercan   Members   -  Reputation: 370


Posted 23 August 2012 - 12:25 PM

Great! It looks good :)
So now your engine has more graphic then my Pear3DEngine, haha :D
Reading, Reading, Reading... why do you read not more?
I have a blog: omercan1993.wordpress.com look there for more content :)
And I also do some art: omercan1993.deviantart.com
And whats about the Pear3DEngine? Never heard of it? Go and look!
Yeah, and currently I do this: SimuWorld

PS: Please look at this poll on my blog about scripting languages: A opinion poll about scripting language

#25 caldiar   Members   -  Reputation: 702


Posted 23 August 2012 - 01:41 PM

I might have missed this but, why do you want to make a game engine? What is your goal? Is this purely for education to help you learn programming as it's related to videogame development or is this to build an engine to use for a game you want to make?

There are plenty of existing solutions out there for game engines. If this is an educational experience I would say you would be better served downloading the source code to an existing game engine (idtech4's source was released recently) and modifying a piece at a time. You will see more immediate results and get a look at how things are typically done (with the idtech4 suggestion this applys to the way id software writes FPS games).

Writing an engine first with the intention of using it to build a game will only limit what you can do in the game later on. Perhaps you didn't forsee a certain condition in your game that your engine wasn't designed to handle. Changing that could mean a major refactor. Alternatively, if you focused on just building a game first, an engine will naturally develop as a consequence of developing games repeatedly and identifying chunks of code that you use over and over again which you can set aside and bundle into what would be your engine (a big hunk of reusable code).

Also be careful when trying to become familiar with a ton of different areas of programming at once. Don't mistake the notion of being familiar with a concept and actually truely knowing a concept. When I was first starting out I would focus on a ton of different concepts only to declare that I "know" an area of programming and can move on to the next. This was not the case. I had a shaky understanding of what is kind of going on. What I'm trying to say here is that you should pick an area that's interesting to you first to focus on. Put your time and energy into one area whether it be physics simulations, artificial intelligence, shader programming, particle systems, whatever. Keep building your programs around that specific subject and keep working on that until you truely know it. Simply glossing over the details will only be doing wrong by yourself. Don't cheat yourself out of properly learning the ideas.

#26 EngineProgrammer   Members   -  Reputation: 295


Posted 23 August 2012 - 02:35 PM

For our school projects we may only use the Game Engines given from our school or we may use our own Game engine.
And because the game engines at school are very bad ( bad framework, lots of bugs, etc ) I'm writing a Game engine for the school project I am going to make.
The school project must be finished in may so I have plenty of time left.

And I'm also doing this to learn how to engine program. It's quite fun. :-)

#27 Dmytry   Members   -  Reputation: 1148


Posted 27 August 2012 - 12:35 AM

Also, does someone have any tips for me I can use to create an efficient engine?

Yes; don't write an engine.

Write a game, extract parts from it, reuse those parts in another game and repeat. In time the reusable parts will form an 'engine' as you become more experianced.

Attempting to sit down and write an engine without a game to focus it will result in unusable junk which you will just end up re-writing as soon as you want to use it in any real sense. Lack of experiance making games will just make this problem even worse.

EVERY good game engine out there has grown out of being used in a game (or series of games) first and then recycled. This is the only way to ensure you get something usable.

Exactly. Just make a game, with some re-usability in mind but don't over-sweat it if it gets in the way of getting game done (it shouldn't get in the way of getting things done anyhow). If you want to get a game done it may, in most cases, be better to use something like Ogre.

On the timeframe, it can vary wildly with regards to what you want to do and how experienced and productive you are. Keep in mind that even old engines (Quake 2 for example) took a lot of manpower.
My game The Polynomial is now available on Steam. | The Polynomial homepage | Cloud and terrain rendering |Everything i said in that post is obviously ABSOLUTE TRUTH my unhumble opinion.

#28 tonelow   Members   -  Reputation: 101


Posted 28 August 2012 - 10:32 AM


Should release in the reverse order of allocation to avoid deadlock (in general)

#29 EngineProgrammer   Members   -  Reputation: 295


Posted 28 August 2012 - 12:15 PM

I have already read the article Write Game, Not Engines. I do know engine programming isn't necessary for my future games I'll be writing. But if I enjoy doing it why discourage me? Posted Image

I love all those low-level programming of Win32 Posted Image
But yes indeed, I need to write games, get the reusable code from it and make my engine that way.
I'll do that but to write my game I also need to write some 'engine' code. Posted Image

Here is an example of what I have so far.
- Specular shading
- Bump mapping
- Camera that can move around
- I have also made a modelreader ( .obj ).
- ( And many more: text, 2D bitmaps, textureshaders, multitextureshader, etc )

But now. I'm not working with Mesh Loader of DirectX yet. I found the algorithm to read in obj files into C++. But I have a little problem now. As you can see in the video I don't have smoothing groups yet.

Can someone help me out a bit for that? In the .obj file there is this kind of data:
s 4
f 1/1/1 2/2/2 3/3/3
f 3/3/3 4/4/4 1/1/1
f 5/5/5 6/6/6 3/3/3
f 3/3/3 2/2/2 5/5/5
f 7/7/7 8/8/8 6/6/6
f 6/6/6 5/5/5 7/7/7
f 9/9/9 10/10/10 8/8/8
f 8/8/8 7/7/7 9/9/9
f 11/11/11 12/12/12 13/13/13
f 13/13/13 14/14/14 11/11/11
s 1
f 15/15/15 16/16/16 17/17/17
f 17/17/17 18/18/18 15/15/15
f 15/15/15 19/19/19 20/20/20
f 20/20/20 16/16/16 15/15/15
f 19/19/19 21/21/21 22/22/22
f 22/22/22 20/20/20 19/19/19
f 21/21/21 23/23/23 24/24/24
f 24/24/24 22/22/22 21/21/21

s : smoothing group
f : faces

How do I enable the smoothing into my model? The normals I read in should normally create the smooth rendering but it doesn't. So I'm missing something but I dont' know what. Also what do I need to do with the value for the smoothing?

Should release in the reverse order of allocation to avoid deadlock (in general)

Yes I noticed. Already changed it 2 days ago. Thanks! Posted Image

Edited by EngineProgrammer, 28 August 2012 - 04:27 PM.

#30 Steve_Segreto   Crossbones+   -  Reputation: 1539


Posted 29 August 2012 - 10:50 AM

Have a look at this link: http://www.martinreddy.net/gfx/3d/OBJ.spec

It appears the integer after the "s" is the smoothing group number. It also appears that if the file did not contain vertex normals (vn) then you may have to create some yourself and then interpolate them across smoothing groups (groups of vertices).

#31 Hodgman   Moderators   -  Reputation: 30958


Posted 29 August 2012 - 11:11 AM

As I said, I would put some code down. Here you go:

So this is a basic code of my WinMain.
Creating Engine objects using Singleton design.
Asking the Game class for the properties and initialize engine with it.

I'd suggest using constructors/destructors and not using the singleton anti-pattern:
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow )
	T_Engine engine;
	T_Window window( hInstance, nCmdShow );
	T_System system( engine, window );

	StarBattle starBattle(engine, window, system);

	// Run the Message loop
	MSG msg = {};
	int iTickCount = 0, iTickTrigger = 0;
	while( msg.message != WM_QUIT )
		if( PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE) )
			iTickCount = GetTickCount();
			if( iTickCount > iTickTrigger )
				iTickTrigger = iTickCount + 1000/engine.GetFramerate();

	return TRUE;

Should release in the reverse order of allocation

This is good advice, and N.B. this happens automatically in the above re-write, when not over-engineering things Posted Image

Edited by Hodgman, 29 August 2012 - 11:14 AM.

#32 EngineProgrammer   Members   -  Reputation: 295


Posted 31 August 2012 - 03:12 PM

I've read the article of .obj completely! Yet, not a single sentence says how to link the smoothing groups with the faces.
But I've asked my docent at school and he told me a way to do it. So should work now.. When I've written the code. Posted Image

About the singleton, yes I've already changed my framework for that. Posted Image

So last thing I want to say is kinda off-topic.
I'm starting a journal so you guys can watch my progress! Posted Image
Feel free to follow my blog.

I'll post Part 1 with some code this night. First I want to be sure everything runs smoothly so I don't show you bad code. Posted Image

#33 MarekKnows.com   Members   -  Reputation: 666


Posted 01 September 2012 - 04:57 AM

A tip when building your game engine, make sure you break your development down into small manageable chunks with clear goals at each stage. It is very easy to become unmotivated if you can't see progress from one day to the next. When I was making my engine I always started by defining a game that I wanted to make first. Then as I build the game, I would break things down into small pieces of reusable code that I would put into my engine for reuse on the next game that I was going to make. After creating 5 or more games, you start to see some structure in the engine.

Free C++, OpenGL, and Game Development Video Tutorials @
Play my free games: Ghost Toast, Zing, Jewel Thief

#34 EngineProgrammer   Members   -  Reputation: 295


Posted 01 September 2012 - 07:20 AM

Thanks, yes normally a better plan is just to write games and collect all the reusable code.

But for every game I need graphics, models, shaders, sounds, etc. So I can directly put all of those into my engine so I don't need to worry about them anymore later on.
But I'm putting all those piece of codes in small classes to have a nice overview of my engine. I love clean code. Posted Image

My motivation breaks down sometime because I want to rewrite the whole framework when it's "bad". This is my 5th try to get a nice framework and it's already looking good so I think I have a good structure now. Posted Image But then, when I have rewritten the framework I can continue even faster than the last framework so then I get motivated again. Posted Image

#35 EngineProgrammer   Members   -  Reputation: 295


Posted 01 September 2012 - 07:30 AM

Ah I have a question:

Everyone remembers this line of code?
static LRESULT CALLBACK WndProc(...)

When you got this method:
LRESULT CALLBACK Class::HandleEvents(...)
What did you do to be able of calling that method?

There are some possibilities.
- Using singleton design
- Using a global pointer
- Creating the pointer using WM_CREATE and then make calls when the pointer exists.

That's all what I can think of at the moment.
I've found something ,even better, you don't need anything of the three above!!
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
	return ((Window*)GetWindow(hWnd, 0))->HandleEvents(hWnd, msg, wParam, lParam);
Now the strange part comes up.
This pointer that is returned is always nullptr. Never it will be allocated or initialized with an existing pointer. But.. The is not a single crash, he can call every method inside that class.

But does someone knows the disadvantage of this code? Because in all those years of programming I can't be the first one who noticed this? Is this an "unstable" line of code?


Edited by EngineProgrammer, 01 September 2012 - 07:31 AM.

#36 Spartan322   Members   -  Reputation: 107


Posted 28 October 2013 - 11:17 AM

This is a good idea to read as it can be easy to write 2d engine if you want to waste about a year to make it good but you don't need to waste the reiventing the wheel just use previous libraries to shorten time, strain, and many other annoying stuff than you can design the game but for directx you may need some different libraries and for 3d you may need to search for 3d graphic and physic library

Seriously it's acutally not hard and can be short if you know what to do but if you are building a new unity or trying to build something with a UI than waste 2 years at least if you are new so I suggest the explaination

#37 Paradigm Shifter   Crossbones+   -  Reputation: 5407


Posted 28 October 2013 - 11:39 AM

Dude this thread was over a year old...

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#38 Spartan322   Members   -  Reputation: 107


Posted 28 October 2013 - 01:46 PM

When I was searching for game engine creation tutorials I was looking for how should I build it but unfortunately I could never find any thing I was looking for so what I'm trying to do is add to the internet as much information to the public as possible so people have an easier time finding it because seriously there seems to be a giant gap between people who know how to build game engines and people who don't like there isn't anyone who is learning how to by doing of which I am so now I will do my best to make a new class of people to learn how to build game engines as most people who try seem to only know bits and pieces until they finish but they don't think the same as before or anywhere near that before time so it is harder for people that want to learn to get clear information. I'm sorry if this was overexplained.

And if you ask have you been here before, yes it seems that you are always forced to the older stuff first than newer stuff comes up


What does one year matter if you get information to people who need it as this was one of the five game engine disscussions that came up of which barely helped

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.