How to integrate a simple game object model with oF

Hi there

I am currently working on a simulation environment and would like to introduce a very simple custom object model. It is a component-based architecture like follows:

The root class is called “GameObject” and it can contain a set of other (standard and custom) objects, for example a “RenderableComponent” which tells the system that this type of object should be rendered on screen.

Each renderable component I use in the system is a child of class “RenderableComponent”

Here is what I would like to do:

  1. Iterate through a collection of GameObjects
  2. See whether they contain a “RenderableComponent” and
  3. If yes, render it.

The iteration and rendering should take place in the “draw()” function of the ofApp main loop.

My question is how to implement “RenderableComponent” within the oF framework to be able to render all children that inherit from it.

Currently, it is simply a stub like:

#pragma once
#include “ofMain.h”

class a7RenderableObject





Solved it. It was actually quite simple: I made RenderableObject abstract, with ‘setup’, ‘draw’ and ‘update’ defined as pure virtual functions.