I could pass a pointer to the video driver, to the constructor of every sprite/tile and the object will be able to keep the pointer and draw itself using the pointer. I don't know if that is wrong/bad, I haven't really thought about how many sprites will be active but it's for a game engine so some games could have many many small sprites.
Is it bad design to store a pointer like that for every object?
Or..
I could just keep one pointer to the video driver in the main game engine class and pass the video driver to the objects in the draw functions.
Or..
I could store a few pointers to the video driver. One for each manager that would use it. For example, if you had a separate sprite manager, background manager etc..
What is better design? and what kind of differences in performance would I be looking at? More/Less memory, faster/slower?
Code: Select all
inline void Draw(const irr::video::IVideoDriver* pVideoDriver,
const irr::core::position2di ptDest,
const irr::core::recti* clipRect = (irr::core::recti*)NULL,
bool bTrans = false)
{
Draw(pVideoDriver, ptDest.X, ptDest.Y, clipRect, bTrans);
}
Will one way make it more or less dependent on the other files in the game engine?
I just thought, if you can pass the pointer when you draw then you could use different video drivers at will (that is if/when irrlicht can draw textures to multiple video drivers), but even so you could just provide a setVideoDriver function instead.