your engine interface
I would like to know how you have written the interface of your 3D/game engine you have
e.g.
1) split in classes
#include <Engine\RenderSystem.h>
#include <Engine\World.h>
cRenderSystem *rs; <- this would do the rendering
cWorld *world; <- this would be the scenegraph
WinMain(...)
{
rs = new cRenderSystem;
world = new cWorld;
rs->Initialize(...);
...
cEntity *ent = world->CreateEntity( "data\\spaceship.mesh" );
// and the main render loop would go here
while( 1 )
{
ent->Rotate(0.0f, 1.2f, 0.0f);
world->Update();
rs->Update();
...
}
}
2) or you have one access class to the main thing
#include <Engine.h>
cEngine *Engine;
cWorld *world;
WinMain(...)
{
Engine = new cEngine;
Engine->Initialize(...);
...
world = Engine->CreateWorld(...);
cEntity *ent = world->CreateEntity( "data\\spaceship.mesh" );
// and the main render loop would go here
while( 1 )
{
ent->Rotate(0.0f, 1.2f, 0.0f);
world->Update();
rs->Update();
...
}
}
3) or using a namespace instead of the main class
#include <Engine.h>
cRenderSystem *rs; <- this would do the rendering
cWorld *world; <- this would be the scenegraph
WinMain(...)
{
rs = Engine::CreateRenderSystem();
world = Engine::CreateWorld();
rs->Initialize(...);
...
cEntity *ent = world->CreateEntity( "data\\spaceship.mesh" );
// and the main render loop would go here
while( 1 )
{
ent->Rotate(0.0f, 1.2f, 0.0f);
world->Update();
rs->Update();
...
}
}
4) or something else.
Hi,
actually, you can do it in whatever way you want as long as it fits your needs.
Personally, I'm a friend of seperating what can be seperated. Means that I have a renderkernel with functions that handle ie. the renderstate management, the textures and the drawcalls. If I have to pass an objevt to this renderkernel it's done via pure virtual interfaces. My textures are IImages which only have a few access functions which are needed by the renderkernel to push the texture content into ie. the directx surfaces. I also have interfaces for Vertex- and Indexbuffers.
The pure virtual interfaces are implemented in my basic engine library which also contains a world management system, load/save functions and useful implementation such as a 2D output class.
Based on the base engine (specially the 2D output class) I have implemented my gui system.
And so on... and so on...
So I tend to say that 1) is the way I did it except the fact, that I do a heavy use of plug-in dlls.
Metron
actually, you can do it in whatever way you want as long as it fits your needs.
Personally, I'm a friend of seperating what can be seperated. Means that I have a renderkernel with functions that handle ie. the renderstate management, the textures and the drawcalls. If I have to pass an objevt to this renderkernel it's done via pure virtual interfaces. My textures are IImages which only have a few access functions which are needed by the renderkernel to push the texture content into ie. the directx surfaces. I also have interfaces for Vertex- and Indexbuffers.
The pure virtual interfaces are implemented in my basic engine library which also contains a world management system, load/save functions and useful implementation such as a 2D output class.
Based on the base engine (specially the 2D output class) I have implemented my gui system.
And so on... and so on...
So I tend to say that 1) is the way I did it except the fact, that I do a heavy use of plug-in dlls.
Metron
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement