How to draw from another class?

I have some basic app with custom classes:

class CustomDerivedClass : public CustomClass
{
    public:
        // stuff
};

class testApp : public ofBaseApp
{
    public:
        void setup();
        void draw();
};

void testApp::setup()
{
}

void testApp::draw()
{
}

Does anyone knows how to draw from CustomDerivedClass?

Have an instance of CustomDerivedClass in your testApp class, have a draw method in CustomDerivedClass and call it in your testApp::draw method. Something like this :

class CustomDerivedClass : public CustomClass
{
    public:
        void draw();
};

class testApp : public ofBaseApp
{
    public:
        void setup();
        void draw();

        CustomDerivedClass myCustomDerivedClassInstance;
};

void testApp::setup()
{
}

void testApp::draw()
{
    myCustomDerivedClassInstance.draw();
}
1 Like

Thank you, @Mat , it works! :blush: