Calling draw functions outside of testApp.cpp?


I have a “View” class which needs access to the drawing functions, like ofCircle, ofFill, etc. What I intend to do is something like this:

int main( ) {
ofAppGlutWindow window;
ofSetupOpenGL(&window, 1024,768, OF_WINDOW);

ofRunApp( new testApp());

void testApp::draw() {
// Elsewhere I declare view as type View


void View::DrawSomething() {

Currently, my View class doesn’t know about ofSetColor or ofCircle. What’s the most graceful way of giving it access to these drawing functions? I’m wrote the beginnings of an MVC style application in Processing and I’m porting it over. In Processing, my custom classes somehow magically had access to the drawing functions.


  • Bret

OH, I think I figured it out after reading this post:

What I did was inherit from obBaseApp, and my View class was then able to draw to the screen:

class View : public ofBaseApp {


void DrawSomething();


it’s not necessary to inherit from ofBaseApp, indeed it’s not very correct. that class is just the base for the application.

what you want, is to include ofMain, that will give you access to every OF function and class:

#include “ofMain.h”

1 Like