[SOLVED] Calling draw methods in a child class

EDIT: Of course two minutes later I realised that it’s ofDrawRectangle() and not ofDrawRect(), which is why I was having this error. Thank you OF Forum, for forcing me to go through my code … though I only noticed too late! Leaving this here as an example for others though. :smile:
Love, no_u


Hello! I’m kind of new to this and I’m having trouble understanding how classes I write can use the OF functions (like ofDrawRect()).

I have three classes, which are pretty straightforward (they don’t inherit from one another, but they do interact.) I want these classes to be able to use OF functions.

The header, MyClasses.h:

#ifndef _MYCLASSES
#define _MYCLASSES

#include "ofMain.h"

class MyClassOne : public ofBaseApp{
public:
    // Constructor:
    Geomancy();
    void setup();
};

class MyClassTwo : public ofBaseApp{
public:
    // Constructor:
    MyClassTwo();
    void setup();
    void draw();
private:

};

class MyClassThree : public ofBaseApp{
public:
    // Constructor:
    MyClassThree();
    void setup();
    void draw(int whichType);
};

#endif

MyClasses.cpp:

#include "ofApp.h"
#include "MyClasses.h"


MyClassOne::MyClassOne() {
}

MyClassTwo::MyClassTwo() {
}

MyClassThree::MyClassThree() {
}

void MyClassOne::setup() {
// some stuff
}

void MyClassTwo::setup() {
// some more stuff
}

void MyClassThree::setup() {
    ofSetColor(ofRandom(255), ofRandom(255), ofRandom(255));
}

void MyClassThree::draw(int whichType) {
// This line is where xCode says the error is:
    ofDrawRect(tileX, tileY, TILE_DIM, TILE_DIM);
}

Weirdly, xCode doesn’t complain about using ofSetColor() if I call it, but when I try to use MyClassThree::draw(int whichType) xCode says the following:

Use of undeclared identifier 'ofDrawRect'

Obviously I’m misunderstanding something here. Any pointers gratefully received! :slight_smile: