I'm making a game in C++ using GLUT, and I have a function that is called in a loop to draw cubes, spheres, etc. I made a few classes that represent these different shapes for example: (objects.hpp)
namespace Objects
{
class SelectionInstance
{
public:
Vector3 Position;
void Draw();
};
class CubeInstance
{
public:
Vector3 Position;
void Draw();
};
};
(objects.cpp)
void Objects::SelectionInstance::Draw()
{
drawSelection(Objects::SelectionInstance::Position.X,
Objects::SelectionInstance::Position.Y,
Objects::SelectionInstance::Position.Z);
}
void Objects::CubeInstance::Draw()
{
drawCube(Objects::SelectionInstance::Position.X, Objects::SelectionInstance::Position.Y, Objects::SelectionInstance::Position.Z);
}
void drawSelection(float x_position, float y_position, float z_position)
{
glScalef(1.0, 1.0, 1.0);
glTranslatef(x_position, y_position, z_position);
glColor3f(255, 0, 0);
glutWireCube(1.0);
}
void drawCube(float x_position, float y_position, float z_position)
{
glScalef(1.0, 1.0, 1.0);
glTranslatef(x_position, y_position, z_position);
glColor3f(255, 0, 0);
glutSolidCube(1.0);
}
How can I call the draw functions of all the instances of these two classes? I want to call them inside the function that is called to render objects...