• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
KingDuck

Approaching Engine Design

8 posts in this topic

I'm a C++ programmer who's interested in programming a decent game engine, a long with one of my friends. I've been going at this for more than a year.

By "decent game engine," I'm talking about an organized, abstracting framework which supports nice 3D graphical features-- such as procedural animation, complex & massive scene graphs, persistent procedural game-worlds, advanced level of detail and so on.

So far, I've made two attempts, which I've decided are poorly designed from the start. Now I need some help.

1) I want to abstract Direct3D 9 in a good way for expanding to other renderers (D3D 11, OpenGL). What might be the best way of doing this? Example?
2) How do I make my engine "modular" ? I really have no clue how this works. Am I supposed to put every "module" in its own *.hpp and *.cpp file pair? Then, besides that, what would be a module?
3) Really, I just want an all around general example of how the engine should be built from ground up.

Please, just answer my questions as best you can.

Thanks,
- King Duck
0

Share this post


Link to post
Share on other sites
First, write games.

Next, one approach to support multiple renderers is to inherit the implementation of each renderer from a single, abstract class. This allows your higher level logic to interact with the rendering sections of your game without knowing or caring which underlying API it is using. For example,

[code]
// Base Class
class __declspec(novtable) AbstractRenderer
{
AbstractRenderer(void) {};
virtual ~AbstractRenderer() {};

virtual bool InitDevice() = 0;
virtual bool InitSwapChain() = 0;
virtual bool OnResizedSwapChain() = 0;
virtual void OnDraw() = 0;
// etc.
};

// Derived Class
class D3D9Renderer : public AbstractRenderer
{
D3D9Renderer(void);
~D3D9Renderer();

bool InitDevice();
bool InitSwapChain();
// etc.
};

// Somewhere in higher level code land...
std::shared_ptr<AbstractRenderer> renderer;
renderer = std::shared_ptr<D3D9Renderer>( new D3D9Renderer() );
// Or Maybe...
// renderer = std::shared_ptr<D3D10Renderer>( new D3D10Renderer() );
// renderer = std::shared_ptr<D3D11Renderer>( new D3D11Renderer() );
// renderer = std::shared_ptr<OpenGLRenderer>( new OpenGLRenderer() );
// etc.

bool result = renderer->InitDevice();
[/code]

If you want to pursue something like this further, check out Ogre3D. I'm pretty sure this is how they support directX and openGL.

Finally, in terms of modularity, I'm hesitant to link [url="http://software.intel.com/en-us/articles/designing-the-framework-of-a-parallel-game-engine/"]this[/url], but, I'm going to link it anyways. It's pretty overkill for what you asked, however, I think it's a good example of modular design. Their systems are decoupled in such a way they can begin to attack the problem of concurrency.

I wouldn't be worried about building a concurrent engine. However, decoupling a game's underlying systems would be a reasonable goal.
1

Share this post


Link to post
Share on other sites
[center] [b][img]http://www.hpquest.com/DOSP/Architecture_sm.jpg[/img][/b]
[b][url="http://www.hpquest.com/DOSP/Architecture.png"]Super 3D Game Platform Architecture (Click for Full View)[/url][/b]
[/center][b]
[/b] HI King Duck, my advice to you is to put your engine design on the drawing board first. It really helps to get a [i]Big Picture[/i] on how all systems, classes, etc, tie together. I elected to use [url="http://www.ogre3d.org/"]OGRE [/url]which provides a very well engineered abstraction for Direct3D/OpenGL. I've also adopted some the coding techniques used in OGRE into my own Framework code.
1

Share this post


Link to post
Share on other sites
Do you really want to spend time programming on a flawless game engine or would you rather concentrate on creating a flawless game? :rolleyes:
-1

Share this post


Link to post
Share on other sites
[quote name='King Duck' timestamp='1310133056' post='4832774']1) I want to abstract Direct3D 9 in a good way for expanding to other renderers (D3D 11, OpenGL). What might be the best way of doing this?[/quote]Generally through compile-time inheritance like SapphireStorm showed -- though I'd disagree with the use of [font="Courier New"]virtual[/font] and [font="Courier New"]__declspec(novtable)[/font], I'd instead recommend a portable [font="Courier New"]#ifdef[/font] implementation of this concept ;)[quote]2) How do I make my engine "modular" ? I really have no clue how this works. Am I supposed to put every "module" in its own *.hpp and *.cpp file pair? Then, besides that, what would be a module?[/quote]"Modular" is a buzzword. It generally either means "[i]loosely coupled code[/i]" or "[i]over-engineered plug-in framework[/i]".
[url="http://en.wikipedia.org/wiki/Loose_coupling"]Loose-coupling[/url] is just a feature of good design. Books like "[url="http://www.google.com.au/search?q=Large-Scale+C%2B%2B+Software+Design"]Large-Scale C++ Software Design[/url]" ([i]AKA 'the tome of knowledge' at work[/i]) might be of use here.

At work, we make a folder for each "module" of the engine. e.g. there might be a renderer folder, a scene-management folder, an audio-player folder, etc...
If the code in one of these folder includes code from another folder, then that's a dependency between modules. We use a python script to automatically generate a diagram with a circle for each module, and arrows showing the dependencies between them. You could obviously also do this by hand, but the automatic approach allows our lead to realise when people add unnecessary dependencies, and to go and tell them to fix up their design ;)
Ideally, there should be no cyclic-dependencies between modules -- e.g. if [font="Courier New"]scene[/font] depends on [font="Courier New"]renderer[/font], then [font="Courier New"]renderer[/font] [u]must not[/u] depend on [font="Courier New"]scene[/font].
The modules and their dependencies end up forming a tree, where at the bottom you've got more isolated "engine-type" modules, like rendering, audio, file-systems, etc... and at the top you've got more "game-type" modules, like character-animation, or special-effects, etc...

If you think that two modules need to communicate with each other ([i]i.e. a type of cyclic dependency[/i]), you can usually resolve this design ([i]flaw[/i]) by adding a 3rd module which is dependent on both of them. This way the first two modules stay dependency-free and easily maintainable, and the 3rd module's sole responsibility is handling communication between them.
[quote]3) Really, I just want an all around general example of how the engine should be built from ground up.[/quote]It depends on [A] what the game design is, [B] what the art/content team's requirements are, and [C] what kind of game-play code needs to be developed. The engine is just a platform that enables those 3 groups of clients to do their job. Without knowing those 3 things, you can't design an engine for them -- hence the whole "make games" attitude when people say that they're making an engine (without also developing a game at the same time).
2

Share this post


Link to post
Share on other sites
[quote name='King Duck' timestamp='1310133056' post='4832774']
1) I want to abstract Direct3D 9 in a good way for expanding to other renderers (D3D 11, OpenGL). What might be the best way of doing this? Example?
[/quote]

Direct3D and OpenGL have pretty different APIs, so unless you have experience with both, trying to nail a common interface for the two will be nearly impossible. As for D3D9 vs. D3D11, you should really consider developing in D3D11 and porting back to D3D9. It's much easier follow the new structure which makes heavy use of creation-time validation and "port" that back to D3D9 than it is to take the "make state changes whenever you want" approach from D3D9 and get it running at high performance on D3D11. However, if you're only on PC, you can probably forget D3D9 even exists.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0