Possible Duplicate:
Should actors in a game be responsible for drawing themselves?
How can I refractor the following, to move my drawing functions from the h-file into a GraphicsManager class?
I have the following scenario:
//drawingFunctions.h
void drawTexturedQuad( Texture texture, Vector2 pos, Vector2 dim) {
// bind texture...
glBegin(...); // draw
//...
glEnd(...);
}
#include "drawingFunctions.h"
class Player {
void drawPlayer(){ drawTexturedQuad( texture, pos, dim) }
};
class Enemy {
void drawEnemy(){ drawTexturedQuad( texture, pos, dim) }
};
class Item {
void drawItem(){ drawTexturedQuad( texture, pos, dim) }
};
// and so on for the other components, you get the idea...
I figured I could make all these classes extend another class, say drawableGameComponent. Would that be a good idea? What are other suggestions?
drawTexturedQuad
function (instead of having the render code in the components themselves). I edited my question to make that clearer. \$\endgroup\$drawTexturedQuad
inside of a class? \$\endgroup\$