@diego_di_battista wrote:
i'm a nebbie in oF and this code dont'work why?
the scader it take from book "open frame work essential", sorry for bad language i italianinclude "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){fbo.allocate(ofGetScreenWidth() , ofGetScreenHeight() , GL_RGBA); // fbo is an ofFbo tex.allocate(ofGetScreenWidth() , ofGetScreenHeight() , ofImageType::OF_IMAGE_COLOR_ALPHA); videomod.allocate(ofGetScreenWidth(), ofGetScreenHeight(), OF_PIXELS_RGB); tex.allocate(videomod); shader.load("kaleido.vert","kaleido.frag");
}
//--------------------------------------------------------------
void ofApp::update(){
if (camera.isInitialized()) camera.update();
{
fbo.begin();
disegno();
tex.draw(0, 0, ofGetScreenWidth(), ofGetScreenHeight());if (schaderacceso == 1) { shader.begin(); shader.setUniform1i("Ksectors",15); shader.setUniform1f("KangleRad", 90); shader.setUniform2f("Kcenter", 500, 500); shader.setUniform2f("KscreenCenter", 500, 600); shader.end(); } fbo.end(); } } //--------------------------------------------------------------
void ofApp::draw(){
fbo.draw(0, 0, ofGetScreenWidth(), ofGetScreenHeight());}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
if (key == 'c')
{ schaderacceso = !schaderacceso;}if (key=='z')
{
camera.setDeviceID(0);
camera.setDesiredFrameRate(30);
camera.initGrabber(camx, camy);}
if (key == 'a'){
volumeR = volumeR + 5;
volumeG = volumeG + 5;
volumeB = volumeB + 5;
if (volumeR >= 255)
{
volumeR = 0;
}
if (volumeG >= 255)
{
volumeG = 0;
}
if (volumeB >= 255)
{
volumeB = 0;
}} if (key == 'r') volumeR = volumeR + 5; { if (volumeR >= 255) { volumeR = 0; } } if (key == 'g') volumeG = volumeG + 5; { if (volumeG >= 255) { volumeG = 0; } } if (key == 'b') volumeB = volumeB + 5;
{
if (volumeB >= 255)
{
volumeB = 0;
}
}
}//--------------------------------------------------------------
void ofApp::keyReleased(int key){}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){}
void ofApp::disegno() {
if (camera.isFrameNew()) {
ofPixels & pixels =camera.getPixels();
int dim = (camx* camy * 3);
for (int i = 0; i < dim ; i++) {
videomod[i]=abs(volumeR- pixels[i]);
i++;
videomod[i] = abs(volumeG - pixels[i]);
i++;
videomod[i] = abs(volumeB - pixels[i]);
}
}
tex.loadData(videomod);
}
Posts: 1
Participants: 1