It i possible to have multiple ofApp.cpp for multiple


I have a question. It is possible to have a .cpp for each activity?
Let 's say ofAppA.h runs in and ofAppb.c runs in
Talking about multiOFActivities example.


Good question.


I see that the new 10.1 of has a different native loading system than the old versions. Even if you start a new ofActivity, it uses the same core oF.

In the Android concepts, whenever you start a new activity, you start a new context. But the core oF remains same. That may be a misimplementation but I don’t want to discuss on the architecture. Instead, I would discuss how to implement your need in the current architecture.

I think that the simplest (most practical) way for you may be using same ofApp.cpp, but writing code on 2 different canvasses (one for each activity), and invoking the relevant canvas from the ofApp.cpp.

A pseudo code may look like that:

ofApp::setup() {
    canvasA = new CanvasA(this);

    canvasB = new CanvasB(this);


ofApp::update() {
    if (activityChanged) selectCanvas();

ofApp.draw() {

ofApp::selectCanvas() {
    if (activityA) currentCanvas = canvasA;
    else if (activityB) currentCanvas = canvasB;

Hope I could somehow explain the sub-architecture.

1 Like

canvasA what kind of variable or function is?