openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.98k stars 2.55k forks source link

ofFbo android render #6023

Open kashimAstro opened 6 years ago

kashimAstro commented 6 years ago

when i use a fbo on android without fbo.draw() do i still get the fbo render.

a simple example of code to reproduce the problem:

/* ofApp.h */
#pragma once

#include "ofMain.h"
#include "ofxAndroid.h"

class ofApp : public ofxAndroidApp{

    public:     
    void setup();
    void update();
    void draw();
    ofFbo fbo;
        ofTexture tex;
        ofImage img;
};

/* ofApp.cpp */
#include "ofApp.h"

void ofApp::setup()
{
    img.load("img.jpg");
    fbo.allocate(img.getWidth(),img.getHeight());
}

//--------------------------------------------------------------
void ofApp::update()
{
    fbo.begin();
        img.draw(0,0);
    fbo.end();
}

//--------------------------------------------------------------
void ofApp::draw()
{

}

/* main.cpp */
#include "ofMain.h"
#include "ofApp.h"

int main(){
    ofSetupOpenGL(1024,768, OF_WINDOW);         // <-------- setup the GL context

    // this kicks off the running of my app
    // can be OF_WINDOW or OF_FULLSCREEN
    // pass in width and height too:
    ofRunApp( new ofApp() );
    return 0;
}

#ifdef TARGET_ANDROID
void ofAndroidApplicationInit()
{
    //application scope init
}

void ofAndroidActivityInit()
{
    //activity scope init
    main();
}
#endif

my device: Huawei p20 or Huawei P20 pro with android version 8.1.0 and openframeworks v0.10.0

Ciao Dario

kashimAstro commented 6 years ago

can there be a correlation with the fact that now the update method of ofxAndroidApp is able to draw?

in the sense that, if i run this example:

#include "ofApp.h"

//--------------------------------------------------------------
void ofApp::setup(){
}

//--------------------------------------------------------------
void ofApp::update(){
        cam.begin();
            ofEnableDepthTest();
            ofFill();
            ofSetColor(ofColor::red);
            ofDrawBox(300);
            ofNoFill();
            ofSetColor(ofColor::black);
            ofDrawBox(300);
            ofDisableDepthTest();
        cam.end();
}

//--------------------------------------------------------------
void ofApp::draw(){

}

i get the rendering on my surface. although actually ofxAndroidApp seems to inherit properties from ofBaseApp

if i run this example on my linux machine with OF v0.10.0 i do not get this result exactly as expected.

arturoc commented 6 years ago

I'm testing this with my phone and it works just fine. so not sure what's going on.

kashimAstro commented 6 years ago

Hi @arturoc, sorry for long delay.

maybe it's a specific problem for my device... now I'm on the travel, I check when I return to Italy.

you can close this if you prefer.

Ciao!