Jump to content

Engine Design


ParaToxic
 Share

Recommended Posts

Hello Guys,I have a question about the current Engine Designs.

 

I try to write a little DirectX 11 Engine(only for HLSL learning) and want to make a good Design for the programming.

 

My first idea was to make a Header named engine.h with the includings for following classes.

And create a new class named Direct3DInit ,where the device,swapchain,context....are defined(initialize).

 

Than I can add the other classes with (Direct3DInit : public Direct3DTriangle,public Direct3DModel ...)

But the problem was ,that I need the device in the other classes ,so I won't work.

 

My 2nd idea was to make a file engine.h ,where all commands are defined in "Containers" and for each Segment of commands I include the cpp file for make the functions.For example:

 

/////////////////Renderer////////////////////
void Render();
void .....
include "Renderer.cpp" //In that file are the functions for Render()...

 

But so I haven't got classes and I think it's not a good design or "framework"

 

I would like to write something like IEngine Engine = Initialize();

 

Can somebody present me a Engine Design or Framework Design ??

Thanks

Link to comment
Share on other sites

..okay..if you interested i could share some experience since im near to complete my very own engine (not entirely as i use some parts of Phyre library)..but before any serious attempt, I highly recommend some straight to the point tutorials and provided documentation. So here is extremely helpful informations, with source code and everything you need to get it up and running, and I found it very helpful.

 

http://www.garrywill...erred-rendering

 

Also, here is complete deferred renderer written in C# (XNA) and it can compile on PC and XBOX 360 (tested/builted myself for sake of learning things). Full step by step building, with descriptions, etc etc. I do not have exact link anymore so i have uploaded PDF file for you and i hope it will help. I know it did 'miracles' for me. Its fully functional, and it works , and you will have all understanding over expansion if you need it. You may not be happy with language (C#) or platform (XNA), but you will learn for sure how everything works and how it has to be structured. Enjoy, I know i did smile.png.

 

http://www.crocko.co...4E/F17D6d01.pdf

 

Link to comment
Share on other sites

I make a GraphicsDriver class, and there is a global "current" instance:

GraphicsDriver::GetCurrent()

 

All created objects store the current graphics driver at the time they are created, in their constructor:

Material::Material()

{

this->graphicsdriver = GraphicsDriver::GetCurrent();

}

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I'm going to give the best advice ever. Make games, not engines.

 

No matter how much planning you put into this, until you have a number of games under your belt you just simply won't have the experience necessary to design an extensible engine for practical use. You just won't know what you need from an engine.

 

Also, I'd highly recommend brushing up on design patterns an OO Design. Right now it looks like you're still in your "C with Classes" stage of learning C++. :D I'd recommend these two books:

Recommended reading for ANY developer. Rockstar or beginner.

There are three types of people in this world. People who make things happen. People who watch things happen. People who ask, "What happened?"

Let's make things happen.

Link to comment
Share on other sites

Thanks a good advice:D

I made a few little games for learning but the point is that I want to work in a company with an engine which is written in DirectX and I want to collect experiences with that stuff.

 

My idea is not to make a engine ,more a little framework to work with shaders and so stuff.I want it in classesn,because I saw a few engines like irrlicht and soone ,which are made with classes ,OO.

 

I think the OO design is the most important for a good functionality.Just one moree question:D

 

When I have lots of classes for the shader,materials.... and they need for example sometimes the created device,swapchain,context,buffers.. from d3d.How can I create them global? The best way would be to have a class like direct3dinit or something like that with the device,swapchain... in it ,but that all classes could use that.Is that possible?

 

(Very good books ,thanks :D)

Link to comment
Share on other sites

When I have lots of classes for the shader,materials.... and they need for example sometimes the created device,swapchain,context,buffers.. from d3d.How can I create them global? The best way would be to have a class like direct3dinit or something like that with the device,swapchain... in it ,but that all classes could use that.Is that possible?

 

Again, I'd look into design patterns an OO Design. I'm not sure you're really grasping the difference between an object (class) and a function or a method.

 

In addition, as I said before, make games not engines. It's pretty clear you don't know what you need yet. I understand you're trying to get a job working with DirectX. You don't need to write a game engine to do that. In fact the chances of you actually working at that low a level are extremely slim. As a developer, all of that will be abstracted away from you.

 

If you still want the experience, make a game with DirectX, not an engine. You'll get the same experience, except you might actually learn something and finish a project.

 

There are no shortcuts when it comes to game development, only setbacks.

There are three types of people in this world. People who make things happen. People who watch things happen. People who ask, "What happened?"

Let's make things happen.

Link to comment
Share on other sites

In addition, as I said before, make games not engines

I wont biggrin.png

 

First I am just 15 years old ,and 2nd I don't want to make an engine.I will learn something about directX 11 and the current techniques,for example make first a simple application to include shaders and work with shaders to learn more about HLSL.

 

The point is that I made a kind of engine before,but with DirectX 9 because I had a very good german book about it biggrin.png

 

Thanks for the links I going to read it,but my english knowledges don't make it easier biggrin.png

 

EDIT: I spoke about the book for DirectX 9 Game programming.In this book is a engine included(developed each chapter) and I see that this engine is made with OOP and I saw in few files,that it use Singleton for getting Device,...

In the Direct3D class is an instance : "static tbDirect3D& Instance();" and the function for example "PDIRECT3DDEVICE9 GetDevice() {return m_pD3DDevice;}" . In the other files you type (here the class named tbDirect3D) ...tbDirect3D::Instance().GetDevice().

 

I think I will make it the same way :D

Thanks for the support :D

Link to comment
Share on other sites

If you just want to experiment with shaders, I highly recommend FX Composer or RenderMonkey.

Also if you want to do more DirectX work, you can use something like Ogre which is a good render engine to test your ideas on.

Ali Salehi | Programmer

 

Intel Core i3 2100 @ 3.0GHz | GeForce GTS 450 | 4GB DDR3 RAM | Windows 7 Ultimate x64

LE 2.50 | Visual Studio 2010 | RenderMonkey 1.82 | gDEBugger 5.8 | FX Composer 2.5 | UU3D 3 | xNormal 3.17

 

 

76561198023085627.png

Link to comment
Share on other sites

One question about singleton.I have one singleton class where I create the device the vertex/index buffer,swapchain.... and a other class named CShader.In CShader I need a pointer to the VertexBuffer and the InputLayout(for vertex shader). When I write &CDirect3D::Instance().GetVertexBuffer it tell me that it isn't a Ivalue ,so I made it like that:

 

ID3D11Buffer* VertexBuffer = CDirect3D::Instance().GetVertexBuffer();
And than in the function
&VertexBuffer

 

Is there a risk for data lost or something like that?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.

 Share

×
×
  • Create New...