Skip to main content
GameDev.net gamedev.net
🔒 Locked

3d Graphics Engine

Started by strider44 Dec 10, 2002 at 11:51 PM 5 replies 1.1k views
Original Post
strider44
strider44
Hi, How should I go about starting a (as small as possible, definitely for starters) 3d graphics engine? I have programmed alot, know C++ pretty well I think and have done quite a bit of openGL (made games and such - I love making addictive ones that have no end . . .) and have gone through quite a bit of WinAPI programming (although I must admit I''m not entirely confident with it - I''m learning as well though) but I wouldn''t have a clue at how to make a graphics engine. I''ve ordered 3d Game Engine Design (Eberly) - supposed to be a good maths book, maths'' no trouble for me and I''ll go right through it as soon as I get it Does anyone have any ideas other than that book, eg. tutorials or websites or such? Thanks!
The Love Of Trees
SturmNacht
SturmNacht
Here, on gamedev itself there are many good tutorials and stuff for 3D graphics Engines

guess why it''s called game-dev...

Secondly, i think Engine programming is more or less an art, which you can''t just learn


Ones again... life goes on...
-----------------Live for the LordRide for the Lordwww.sturmnacht.de.vu
strider44
strider44
lol try me

Don''t worry the maths part will be fine - I have a VERY strong understanding of linier algebra I have a gift for maths and I have a big brother who could help if I get stuck

I''m crap at English so I thought I''d better learn another language as quickly as possible

quote:
English is only my second language. My first is bad English
The Love Of Trees
TheGilb
TheGilb
Design patterns.

On a high level, what you wish to do does not involve maths, and it does not involve creativity. What you are attempting to create can only be perfected by time and practise. First you will need some reference material; Try finding open sourced game engines. I have personally seen around 3 dozen decent ones. Then learn some systems analysis and UML.

Good luck
llvllatrix
llvllatrix
Said it before and ill say it again - "code on the cob" - the article series is under gamedev''s game programming articles.

"Free advice is seldom cheap."
-- Rule of Acquisition #59
Cobra
Cobra
Well, having written a few 3d engines in my time now (and about 50 that I aborted), I'll post a little bit of info here.


For a start, engine programming is an art, I don't care how many people say "you can study the workings of a good engine", at the end of the day it's an art. And like becoming a good artist, you must be prepared to draw a lot of bad pictures and throw away a lot of canvas
In other words, you have to make, remake, improve and remake ur engines and eventually you'll get it to a point where they work exactly as you want them to.

With that said and done, my engine proceedure usually goes like this now (not that this'll be perfect for you, but it might help you skip a few wasted engine attempts)

NOTE: Here I'm assuming you want to keep gamecode seperate, in a dll (like I do, so the engine becomes more re-usable).

1) Plan the dll-interface, if you're going to use one, how you're going to have it working, do you want to use LoadLibrary and GetProcAddress or do you just want to share a header full of functions with the dll? e.t.c e.t.c Do you want mod support? (if so, you best be using LoadLibrary e.t.c), and so on.

2) Plan how much of it you want in the exe's and how much you want inside the game dll... do you want the texture loading code inside the exe? or do you want to make a function_call to the engine but keep the texture-loading loop inside the gamecode? e.t.c Same for level code, player animation code, e.t.c.. do you want the player-animation-enum inside the gamecode or the exe? e.t.c

3) Plan what type of game you ultimately want to make, you dont have to have the whole game planned to think about how the engine will work, but the type of game you want to make will change what you need inside the exe

Right, that's a fair bit of planning, onto some of the good stuff, adding those juicy engine functions for your dll to call later on. Here's my usual order. You'll notice that how I do it keeps things nice and seperate, modularised so that I can just focus on one thing at a time without worrying about how they affect other things e.t.c

4) Code your codebase, window initialisation, e.t.c
5) Code in the config-parsing, so that the window's size e.t.c is set by the config file on window initialisation.
6) Code a log-system, these are infinitely useful when it comes to debugging later on, or just seeing what's going on.
7) Add texture-loading code (I usually add BMP, TGA and JPEG, seeing as more often than not you'll want to use all of them for various things)
8) Add sound code (mp3, midi, wav).
9) Add a section to your engine that you'll use for math functions, this'll be where you store all your dot product e.t.c functions later on (I cant say "write all math functions here" e.t.c, because you'll find you add things as you need them).
10) Add Input code.. (yup, I do this important thing after all the above... because I dont need it for any of the above, and it keeps things clean and focused in my head above this point... once you've added the input code (directInput8 for me), you end up focusing on what it can be used for e.t.c and things become confused slightly.
11) Add camera class. This'll be your engine's "viewer" so to speak, the thing you'll use to fly around your maps e.t.c later on, but you want it in now, before you've got level code so that later on you dont have to worry about it. You can test this by simply drawing a polygon at the origin and then moving around it with the camera class and the input code (10).
The camera class should involve all movement code too, like MoveCamera(speed) will move the camera foward at value speed, e.t.c
12) Add your level loading code now... with all of the above, by this point you'll be "flying" (with the camera) around your new levels with somee kinda sound effects e.t.c e.t.c if you want them.
13) Once I have a level format, I then generally add the code to put someone in it... namely the player-loading code... although at the moment there are of course no physics e.t.c, so you'll just have a player model loaded up and floating in-front of the camera (but by this point you should be able to see where we're going with this!).
14) If you add physics to your player model, and make THAT your players origin, then anchor the camera to it (so that you're actually moving the player, not the camera, the camera moves itself with the player), then all of a sudden you've got a person running around a world, with sound support should you need it.

After this point you'll want to add things like a particle system, e.t.c e.t.c, fancy it up a bit, focus on the lighting and what-not.

Of course, loading the player model, the map, e.t.c will all be CALLED from your dll, so it's game-specific. The functions to load the model, or to load the map, e.t.c will be in your exe though (your engine, the big archive of useful functions), and the dll can call them to create your "tech-demo" of a guy running around a world with sound effects..
From here it's easy to see how you'd go about working that into a full-blown engine, and developing a game on it.


oooooo long post!.. sorry, didn't mean to write this much Enjoy, hope it's given some kind of useful information to you, or at least a structure of sorts you can follow (although I'd advise just practicing until you have your own engine-creation structure.. mine isnt perfect by any measure, but it's been refined over a LOT of engine rewrites).

[edited by - Cobra on December 14, 2002 10:17:39 PM]
"Build a man a fire, and he will be warm for a day. Set a man on fire, and he will have warmth for the rest of his life"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.