Hey Guys,
i´m stucked in a very basic problem. I want to getTexture() from a videoGrabber. I also tried the way with ofFbo and ofBuffer. But I cant come to a result. I think its a silly mistake i did. But please help. Thank you!
ofApp.h:
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void mousePressed(int x, int y, int button);
void gotMessage(ofMessage msg);
ofVideoGrabber cam;
ofTexture texture;
ofBufferObject buffer;
ofFbo fbo;
};
ofApp.cpp
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
int w = 320;
int h = 240;
cam.setup(w,h);
texture.allocate(w,h, GL_RGBA);
buffer.allocate();
buffer.bind(GL_TEXTURE_BUFFER);
fbo.allocate(200, 200);
fbo.begin();
ofClear(255,255,255);
fbo.end();
}
//--------------------------------------------------------------
void ofApp::update(){
cam.update();
fbo.begin();
ofClear(255,255,255);
cam.draw(0,0);
fbo.end();
}
//--------------------------------------------------------------
void ofApp::draw(){
cam.draw(0,0);
texture.draw(500,0);
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
//cam.getTexture().copyTo(buffer);
fbo.getTexture().copyTo(buffer);
texture.loadData(buffer, GL_RGBA, GL_UNSIGNED_BYTE);
}