d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > How Would You Do > Graphic Engine.
Add Reply New Topic New Poll
Member
Posts: 7,002
Joined: Feb 15 2010
Gold: Locked
Trader: Scammer
Warn: 30%
Nov 18 2012 10:01pm
Working on a simple 2d game engine and was wondering about how people would do for the graphic engine.
I saw 2 ( or 3 ) way to do the rendering and want to know which you prefer/ would do.

First , the "Graphic interfaces" having their own "draw" function taking a pointer to the graphic engine as parameter, and the graphic engine drawing each ressources

<code>
//the classe function
GraphicInterface::draw( GraphicEngine * g)
{
loop_on_each_ressources
{
g->draw(&ressource);
}
}

//used in the game engine
Game::display()
{
current_interface.draw( &GraphicEngine );
}
</code>

Second one ( which i personnaly prefer .. ) is the Graphic engine taking a pointer to the interface , which has a function to return the ressources , and draw the ressources
<code>
GraphicEngine::draw(GraphicInterface * gi)
{
some_iterator = gi.ressources();

looping_on_iterator
{
GraphicEngine::draw(iterator);
}
}
</code>

Thanks for your opinion.
Member
Posts: 7,002
Joined: Feb 15 2010
Gold: Locked
Trader: Scammer
Warn: 30%
Nov 18 2012 10:03pm
Code

//the classe function
GraphicInterface::draw( GraphicEngine * g)
{
loop_on_each_ressources
{
g->draw(&ressource);
}
}

//used in the game engine
Game::display()
{
current_interface.draw( &GraphicEngine );
}


Second one ( which i personnaly prefer .. ) is the Graphic engine taking a pointer to the interface , which has a function to return the ressources , and draw the ressources

Code
GraphicEngine::draw(GraphicInterface * gi)
{
some_iterator = gi.ressources();

looping_on_iterator
{
GraphicEngine::draw(iterator);
}
}


Failed so reposted ( can't edit .. sorry )
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 20 2012 05:35pm
why not just have both?
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll