• Advertisement
Sign in to follow this  

Game Engine Programming

This topic is 1545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. :-)

Share this post


Link to post
Share on other sites
Advertisement
[quote name='phantom' timestamp='1345481424' post='4971539']
[quote name='EngineProgrammer' timestamp='1345429694' post='4971301']
Also, does someone have any tips for me I can use to create an efficient engine?
[/quote]

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.
[/quote]

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.

Share this post


Link to post
Share on other sites
[quote name='EngineProgrammer' timestamp='1345430497' post='4971306']
T_Engine::ReleaseInstance();
T_Window::ReleaseInstance();
T_System::ReleaseInstance();
[/quote]

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

Share this post


Link to post
Share on other sites
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? [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I love all those low-level programming of Win32 [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
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. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

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 )

[media]http://www.youtube.com/watch?v=8mltl2GJADw[/media]
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:
[CODE]
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
[/CODE]

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?

[quote]Should release in the reverse order of allocation to avoid deadlock (in general)[/quote]
Yes I noticed. Already changed it 2 days ago. Thanks! [img]http://public.gamedev.net//public/style_emoticons/default/happy.png[/img] Edited by EngineProgrammer

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
[quote name='EngineProgrammer' timestamp='1345430497' post='4971306']
As I said, I would put some code down. Here you go:
[CODE]...[/CODE]
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.
[/quote]I'd suggest using constructors/destructors and not using the singleton anti-pattern:[code]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) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
iTickCount = GetTickCount();
if( iTickCount > iTickTrigger )
{
iTickTrigger = iTickCount + 1000/engine.GetFramerate();
starBattle.GameUpdate();
starBattle.GameRender();
}
else
{
Sleep(1);
}
}
}

return TRUE;
}[/code][quote name='tonelow' timestamp='1346171572' post='4974161']
Should release in the reverse order of allocation
[/quote]This is good advice, and N.B. this happens automatically in the above re-write, when not over-engineering things [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img] Edited by Hodgman

Share this post


Link to post
Share on other sites
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. [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]

About the singleton, yes I've already changed my framework for that. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

So last thing I want to say is kinda off-topic.
I'm starting a journal so you guys can watch my progress! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
Feel free to follow my blog.

http://www.gamedev.net/blog/1543/entry-2255042-creotex-engine-introduction/
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. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]

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. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] But then, when I have rewritten the framework I can continue even faster than the last framework so then I get motivated again. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites
Ah I have a question:

Everyone remembers this line of code?
[CODE]static LRESULT CALLBACK WndProc(...) [/CODE]

When you got this method:
[CODE]LRESULT CALLBACK Class::HandleEvents(...)[/CODE]
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!!
[CODE]
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return ((Window*)GetWindow(hWnd, 0))->HandleEvents(hWnd, msg, wParam, lParam);
}
[/CODE]
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?


~EngineProgrammer Edited by EngineProgrammer

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement