title: Engine to render different types of graphic objects
body: <p>I'm trying to write a class (some sort of graphics engine) basically it's purpose is to render ANYTHING that I pass into it. In most tutorials I've seen, objects draw themselves. I'm not sure if that's how things are supposed to work. I've been searching the internet trying to come up with different ways to handle this problem, I've been reviewing function templates and class templates over and over again (which sounds like the solution I could be looking for) but when I try using templates, it just seems messy to me (possibly because I don't fully understand how to use them) and then I'll feel like taking the template class down, then I'll give it a second try but then I just take it down again, I'm not sure if that's the way to go but it might be. Originally it was tiled-based only (including a movable player on screen along with a camera system), but now I've trying to code up a tile map editor which has things such as tool bars, lists, text, possibly even primitives on screen in the future, etc. and I'm wondering how I will draw all those elements onto the screen with a certain procedure (the procedure isn't important right now, I'll find that out later). If any of you were going to write a graphics engine class, how would you have it distinguish different types of graphic objects from one another, such as a primitive not being drawn as a sprite or a sphere primitive not being drawn as a triangle primitive, etc.? Any help would be appreciated. :)</p>
  
  <p>This is the header for it, it's not functional right now because I've been doing some editing on it, Just ignore the part where I'm using the "new" keyword, I'm still learning that, but I hope this gives an idea for what I'm trying to accomplish:</p>
  
  <pre><code>//graphicsEngine.h
  
  #pragma once
  #include&lt;allegro5\allegro.h&gt;
  #include&lt;allegro5\allegro_image.h&gt;
  #include&lt;allegro5\allegro_primitives.h&gt;
  
  template &lt;class graphicObjectData&gt;
  class graphicsEngine
  {
  public:
  
      static graphicObjectData graphicObject[];
      static int numObjects;
  
      static void setup()
      {
          al_init_image_addon();
          al_init_primitives_addon();
          graphicObject = new graphicObjectData [1]; //ignore this line
      }
  
      template &lt;class graphicObjectData&gt; static void registerObject(graphicObjectData &amp;newGraphicObject) //I'm trying to use a template function to take any type of graphic object
      {
          graphicObject[numObjects] = &amp;newObject; 
          numObjects++;
      }
  
      static void process() //This is the main process where EVERYTHING is supposed be drawn
      {
          int i;
          al_clear_to_color(al_map_rgb(0,0,0));
          for (i=0;i&lt;numObjects;i++) drawObject(graphicObject[i]);
          al_flip_display();
      }
  
  };
  </code></pre>