Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created October 11, 2013 20:06
Show Gist options
  • Save roxlu/6941174 to your computer and use it in GitHub Desktop.
Save roxlu/6941174 to your computer and use it in GitHub Desktop.
Example of how to use the ofxLinkDeck addon to interface a decklink capture card.
#include "testApp.h"
//--------------------------------------------------------------
void testApp::setup(){
ldeck.listDevices();
// ldeck.setup(0, bmdModePAL, bmdFormat8BitYUV);
if(!ldeck.setup(0, bmdFormat8BitYUV, bmdModePAL)) {
printf("error: cannot get decklink setup.\n");
::exit(EXIT_FAILURE);
}
if(!ldeck.start()) {
printf("error: cannot start the decklink device.\n");
::exit(EXIT_FAILURE);
}
img.allocate(ldeck.getWidth(), ldeck.getHeight(), OF_IMAGE_COLOR);
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
if(ldeck.hasNewFrame()) {
ldeck.lock();
img.setFromPixels(ldeck.getPixels(), ldeck.getWidth(), ldeck.getHeight(), OF_IMAGE_COLOR);
ldeck.unlock();
ldeck.resetHasNewFrame();
}
img.draw(0, 0, ldeck.getWidth(), ldeck.getHeight());
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
#include <ofxLinkDeck/ofxLinkDeck.h>
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y);
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxLinkDeck ldeck;
ofImage img;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment