summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-02-02 18:12:41 +0000
committerTim Redfern <tim@getdrop.com>2018-02-02 18:12:41 +0000
commit645e8c6007bdacaf2f37019d871ce9d3281a280d (patch)
treedea64e9e78c9013f732edd2ce3604f31d694e8f7 /gui
parent7c50a03c5857310aa383b1ba89a18792c96724b1 (diff)
many changes
Diffstat (limited to 'gui')
-rw-r--r--gui/addons.make2
-rw-r--r--gui/libs/libndi.3.dylibbin0 -> 2263988 bytes
-rw-r--r--gui/obj/osx/Release/.compiler_flags2
-rw-r--r--gui/src/main.cpp37
-rw-r--r--gui/src/ofApp.cpp216
-rw-r--r--gui/src/ofApp.h41
-rwxr-xr-xgui/start2
7 files changed, 261 insertions, 39 deletions
diff --git a/gui/addons.make b/gui/addons.make
new file mode 100644
index 0000000..50cb51d
--- /dev/null
+++ b/gui/addons.make
@@ -0,0 +1,2 @@
+ofxNDI
+ofxGui
diff --git a/gui/libs/libndi.3.dylib b/gui/libs/libndi.3.dylib
new file mode 100644
index 0000000..d079763
--- /dev/null
+++ b/gui/libs/libndi.3.dylib
Binary files differ
diff --git a/gui/obj/osx/Release/.compiler_flags b/gui/obj/osx/Release/.compiler_flags
index b41c9fb..59cd739 100644
--- a/gui/obj/osx/Release/.compiler_flags
+++ b/gui/obj/osx/Release/.compiler_flags
@@ -1 +1 @@
--Os -mtune=native -DNDEBUG -stdlib=libc++ -Wall -fexceptions -fpascal-strings -mmacosx-version-min=10.9 -D__MACOSX_CORE__ -x objective-c++ -std=c++11 -I../../openFrameworks/libs/FreeImage/include -I../../openFrameworks/libs/boost/include -I../../openFrameworks/libs/boost/include/boost -I../../openFrameworks/libs/cairo/include -I../../openFrameworks/libs/cairo/include/cairo -I../../openFrameworks/libs/curl/include -I../../openFrameworks/libs/curl/include/curl -I../../openFrameworks/libs/fmodex/include -I../../openFrameworks/libs/freetype/include -I../../openFrameworks/libs/freetype/include/freetype2 -I../../openFrameworks/libs/freetype/include/freetype2/freetype -I../../openFrameworks/libs/freetype/include/freetype2/freetype/config -I../../openFrameworks/libs/freetype/include/freetype2/freetype/internal -I../../openFrameworks/libs/freetype/include/freetype2/freetype/internal/services -I../../openFrameworks/libs/glew/include -I../../openFrameworks/libs/glew/include/GL -I../../openFrameworks/libs/glfw/include -I../../openFrameworks/libs/glfw/include/GLFW -I../../openFrameworks/libs/glm/include -I../../openFrameworks/libs/glm/include/glm -I../../openFrameworks/libs/glm/include/glm/detail -I../../openFrameworks/libs/glm/include/glm/gtc -I../../openFrameworks/libs/glm/include/glm/gtx -I../../openFrameworks/libs/glm/include/glm/simd -I../../openFrameworks/libs/json/include -I../../openFrameworks/libs/kiss/include -I../../openFrameworks/libs/pugixml/include -I../../openFrameworks/libs/rtAudio/include -I../../openFrameworks/libs/tess2/include -I../../openFrameworks/libs/uriparser/include -I../../openFrameworks/libs/uriparser/include/uriparser -I../../openFrameworks/libs/utf8/include -I../../openFrameworks/libs/utf8/include/utf8 -I../../openFrameworks/libs/utf8cpp/include -I../../openFrameworks/libs/utf8cpp/include/utf8 -I../../openFrameworks/libs/openFrameworks -I../../openFrameworks/libs/openFrameworks/3d -I../../openFrameworks/libs/openFrameworks/app -I../../openFrameworks/libs/openFrameworks/communication -I../../openFrameworks/libs/openFrameworks/events -I../../openFrameworks/libs/openFrameworks/gl -I../../openFrameworks/libs/openFrameworks/graphics -I../../openFrameworks/libs/openFrameworks/math -I../../openFrameworks/libs/openFrameworks/sound -I../../openFrameworks/libs/openFrameworks/types -I../../openFrameworks/libs/openFrameworks/utils -I../../openFrameworks/libs/openFrameworks/video -I/work/workspace/raverony/gui/src -stdlib=libc++ -mmacosx-version-min=10.9 -v -framework Accelerate -framework QTKit -framework AGL -framework ApplicationServices -framework AudioToolbox -framework CoreAudio -framework CoreFoundation -framework CoreServices -framework OpenGL -framework IOKit -framework Cocoa -framework CoreVideo -framework AVFoundation -framework CoreMedia -framework QuartzCore -framework Security -framework LDAP
+-Os -mtune=native -DNDEBUG -stdlib=libc++ -Wall -fexceptions -fpascal-strings -mmacosx-version-min=10.9 -D__MACOSX_CORE__ -fPIC -x objective-c++ -std=c++11 -I../../openFrameworks/libs/FreeImage/include -I../../openFrameworks/libs/boost/include -I../../openFrameworks/libs/boost/include/boost -I../../openFrameworks/libs/cairo/include -I../../openFrameworks/libs/cairo/include/cairo -I../../openFrameworks/libs/curl/include -I../../openFrameworks/libs/curl/include/curl -I../../openFrameworks/libs/fmodex/include -I../../openFrameworks/libs/freetype/include -I../../openFrameworks/libs/freetype/include/freetype2 -I../../openFrameworks/libs/freetype/include/freetype2/freetype -I../../openFrameworks/libs/freetype/include/freetype2/freetype/config -I../../openFrameworks/libs/freetype/include/freetype2/freetype/internal -I../../openFrameworks/libs/freetype/include/freetype2/freetype/internal/services -I../../openFrameworks/libs/glew/include -I../../openFrameworks/libs/glew/include/GL -I../../openFrameworks/libs/glfw/include -I../../openFrameworks/libs/glfw/include/GLFW -I../../openFrameworks/libs/glm/include -I../../openFrameworks/libs/glm/include/glm -I../../openFrameworks/libs/glm/include/glm/detail -I../../openFrameworks/libs/glm/include/glm/gtc -I../../openFrameworks/libs/glm/include/glm/gtx -I../../openFrameworks/libs/glm/include/glm/simd -I../../openFrameworks/libs/json/include -I../../openFrameworks/libs/kiss/include -I../../openFrameworks/libs/pugixml/include -I../../openFrameworks/libs/rtAudio/include -I../../openFrameworks/libs/tess2/include -I../../openFrameworks/libs/uriparser/include -I../../openFrameworks/libs/uriparser/include/uriparser -I../../openFrameworks/libs/utf8/include -I../../openFrameworks/libs/utf8/include/utf8 -I../../openFrameworks/libs/utf8cpp/include -I../../openFrameworks/libs/utf8cpp/include/utf8 -I../../openFrameworks/libs/openFrameworks -I../../openFrameworks/libs/openFrameworks/3d -I../../openFrameworks/libs/openFrameworks/app -I../../openFrameworks/libs/openFrameworks/communication -I../../openFrameworks/libs/openFrameworks/events -I../../openFrameworks/libs/openFrameworks/gl -I../../openFrameworks/libs/openFrameworks/graphics -I../../openFrameworks/libs/openFrameworks/math -I../../openFrameworks/libs/openFrameworks/sound -I../../openFrameworks/libs/openFrameworks/types -I../../openFrameworks/libs/openFrameworks/utils -I../../openFrameworks/libs/openFrameworks/video -I/work/workspace/raverony/gui/libs -I/work/workspace/raverony/gui/src -I/work/workspace/openFrameworks/addons/ofxNDI/src -I/work/workspace/openFrameworks/addons/ofxNDI/libs -I/work/workspace/openFrameworks/addons/ofxNDI/libs/linndi -I/work/workspace/openFrameworks/addons/ofxNDI/libs/linndi/include -I/work/workspace/openFrameworks/addons/ofxNDI/libs/linndi/lib -I/work/workspace/openFrameworks/addons/ofxNDI/libs/linndi/lib/osx -I/work/workspace/openFrameworks/addons/ofxGui/src -stdlib=libc++ -mmacosx-version-min=10.9 -v -framework Accelerate -framework QTKit -framework AGL -framework ApplicationServices -framework AudioToolbox -framework CoreAudio -framework CoreFoundation -framework CoreServices -framework OpenGL -framework IOKit -framework Cocoa -framework CoreVideo -framework AVFoundation -framework CoreMedia -framework QuartzCore -framework Security -framework LDAP
diff --git a/gui/src/main.cpp b/gui/src/main.cpp
index ed7e18f..d8d06d3 100644
--- a/gui/src/main.cpp
+++ b/gui/src/main.cpp
@@ -8,17 +8,8 @@ int main(int argc, char *argv[]){
ofGLFWWindowSettings settings;
- settings.width = 600;
- settings.height = 1200;
- settings.setPosition(ofVec2f(0,0));
- settings.resizable = true;
-
- //settings.decorated = false; //doesn't suppress FS title bar
- shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(settings);
- guiWindow->setVerticalSync(false);
- // share OpenGL resources with other windows
- settings.shareContextWith = guiWindow;
+
settings.decorated = true;
settings.width = 1200;
@@ -29,14 +20,30 @@ int main(int argc, char *argv[]){
shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
mainWindow->setVerticalSync(false);
+ settings.width = 600;
+ settings.height = 1200;
+ settings.setPosition(ofVec2f(0,0));
+ settings.resizable = true;
+
+ // share OpenGL resources with other windows
+ settings.shareContextWith = mainWindow;
+
+ //settings.decorated = false; //doesn't suppress FS title bar
+ shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(settings);
+ guiWindow->setVerticalSync(false);
+
shared_ptr<ofApp> mainApp(new ofApp);
//mainApp->setupGui();
- ofAddListener(guiWindow->events().draw,mainApp.get(),&ofApp::drawGui);
- ofAddListener(guiWindow->events().windowResized,mainApp.get(),&ofApp::guiWindowResized);
- ofAddListener(guiWindow->events().keyPressed,mainApp.get(),&ofApp::guiKeyPressed);
-
- ofRunApp(mainWindow, mainApp);
+ ofAddListener(mainWindow->events().update,mainApp.get(),&ofApp::updateOutput);
+ ofAddListener(mainWindow->events().draw,mainApp.get(),&ofApp::drawOutput);
+ ofAddListener(mainWindow->events().windowResized,mainApp.get(),&ofApp::outputWindowResized);
+ ofAddListener(mainWindow->events().keyPressed,mainApp.get(),&ofApp::outputKeyPressed);
+ ofAddListener(mainWindow->events().mouseDragged,mainApp.get(),&ofApp::outputMouseDragged);
+ ofAddListener(mainWindow->events().mousePressed,mainApp.get(),&ofApp::outputMousePressed);
+ ofAddListener(mainWindow->events().mouseReleased,mainApp.get(),&ofApp::outputMouseReleased);
+
+ ofRunApp(guiWindow, mainApp);
ofRunMainLoop();
}
\ No newline at end of file
diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp
index 100c107..81e9e0c 100644
--- a/gui/src/ofApp.cpp
+++ b/gui/src/ofApp.cpp
@@ -1,36 +1,210 @@
#include "ofApp.h"
#include "glew.h"
+const ofPoint mainwindowsize=ofPoint(1200,900);
//--------------------------------------------------------------
void ofApp::setup(){
warpframe[0]=glm::vec2(0,0);
- warpframe[1]=glm::vec2(ofGetWidth(),0);
- warpframe[2]=glm::vec2(ofGetWidth(),ofGetHeight());
- warpframe[3]=glm::vec2(0,ofGetHeight());
+ warpframe[1]=glm::vec2(mainwindowsize.x,0);
+ warpframe[2]=glm::vec2(mainwindowsize.x,mainwindowsize.y);
+ warpframe[3]=glm::vec2(0,mainwindowsize.y);
select_warpframe=-1;
bDrawFrame=false;
+
+ gui.setup();
+
+ //==================================================== ofxNDI
+
+ senderName[0] = 0; // The sender name used for display
+ nSenders = 0; // Total number of NDI senders
+ senderWidth = 0; // Sender width
+ senderHeight = 0; // Sender height
+ bNDIreceiver = false; // Receiver creation
+
+ // Create an intial receiving image
+ ndiImage.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR_ALPHA);
+
+ // For received frame fps calculations - independent of the rendering rate
+ startTime = lastTime = frameTime = 0;
+ fps = frameRate = 1; // starting value
+
+ //============================ GUI
+
+ gui.add(NDIthreshold.setup("threshold", 140, 0, 255));
+ gui.add(NDIsimplify.setup("simplify", 0.2f, 0.0f, 1.0f));
+ gui.add(NDIuseColour.setup("use colour", true));
+ gui.add(NDIcolR.setup("red", 140, 0, 255));
+ gui.add(NDIcolR.setup("green", 140, 0, 255));
+ gui.add(NDIcolG.setup("blue", 140, 0, 255));
+
+
}
//--------------------------------------------------------------
-void ofApp::update(){
+void ofApp::updateOutput(ofEventArgs & args){
}
-void ofApp::updateGui(ofEventArgs & args){
+void ofApp::update(){
+
+ // Update the NDI sender list to find new senders
+ // There is no delay if no new senders are found
+ nSenders = ndiReceiver.FindSenders();
+
+ if(nSenders > 0) {
+
+ // Has the user changed the sender index ?
+ if(ndiReceiver.SenderSelected()) {
+ // Release the current receiver.
+ // A new one is then created from the selected sender index.
+ ndiReceiver.ReleaseReceiver();
+ bNDIreceiver = false;
+ }
+
+ // Create a new receiver if one does not exist.
+ // We don't know the sender dimensions until a frame is received.
+ if(!bNDIreceiver) {
+
+ // The receiver will detect which format a sender is using and convert
+ // the pixel buffer to BGRA for return. However, we can specify here
+ // that RGBA is the preferred format.
+ bNDIreceiver = ndiReceiver.CreateReceiver(NDIlib_recv_color_format_e_RGBX_RGBA);
+ // bNDIreceiver = ndiReceiver.CreateReceiver(); // default is BRRA
+
+ //
+ // A receiver is created from an index into a list of sender names.
+ // The current user selected index is saved in the NDIreceiver class
+ // and is used to create the receiver unless you specify a particular index.
+ //
+ // The name of the sender can also be retrieved if you need it.
+ // If you specified a particular sender index to create the receiver
+ // use that index to retrieve it's name.
+ //
+ // In this application we use it to display the sender name.
+ //
+
+ ndiReceiver.GetSenderName(senderName);
+ if(bNDIreceiver)
+ cout << "Created NDI receiver for " << senderName << endl;
+
+ // Reset the starting values for frame rate calulations
+ fps = frameRate = 1;
+ }
+
+ }
+
+ if(bNDIreceiver) {
+
+ unsigned int width = 0;
+ unsigned int height = 0;
+
+ // If the NDI sender uses BGRA format, the received buffer is converted to rgba by ReceiveImage.
+ // Optionally you can flip the image if necessary.
+
+ // !CHECKME MACOS
+ // ReceiveImage needs an unsigned char* so changed
+ // ndiImage.getPixels() to ndiImage.getPixels().getData()
+ // to avoid type error
+ if(ndiReceiver.ReceiveImage(ndiImage.getPixels().getData(), width, height, false)) { // receives as rgba
+
+ ndiImage.update();
+
+ // ----------------------------
+ // Calculate received frame fps
+ lastTime = startTime;
+ startTime = ofGetElapsedTimeMicros();
+ frameTime = (startTime - lastTime)/1000000; // seconds
+ if( frameTime > 0.01) {
+ frameRate = floor(1.0/frameTime + 0.5);
+ // damping from a starting fps value
+ fps *= 0.95;
+ fps += 0.05*frameRate;
+ }
+ // ----------------------------
+
+ // Have the NDI sender dimensions changed ?
+ if(senderWidth != width || senderHeight != height) {
+
+ // Update the sender dimensions
+ senderWidth = width;
+ senderHeight = height;
+
+ // Update the receiving image size
+ ndiImage.allocate(senderWidth, senderHeight, OF_IMAGE_COLOR_ALPHA);
+
+ }
+ }
+
+ }
}
+const ofPoint previewframesize=ofPoint(320,240);
//--------------------------------------------------------------
-void ofApp::drawGui(ofEventArgs & args){
+void ofApp::draw(){
ofBackground(0);
+ ofSetColor(255);
+ ofNoFill();
+
+ gui.draw();
+
+ //================================== NDI
+
+ glPushMatrix();
+
+ glTranslatef(256,0,0);
+
+ ofDrawRectangle(20,20,previewframesize.x+4,previewframesize.y+4);
+
+ char str[256];
+
+ if(bNDIreceiver) {
+
+ ndiImage.draw(22, 22, previewframesize.x, previewframesize.y);
+
+ // Show fps etc.
+ if(nSenders > 0) {
+ if(bNDIreceiver) {
+ #ifdef _MSC_VER
+ sprintf_s(str, 256, "[%s] (%dx%d) - fps %2.0f", senderName, senderWidth, senderHeight, fps);
+ #else
+ // !CHECK MACOS
+ snprintf(str, 256, "[%s] (%dx%d) - fps %2.0f", senderName, senderWidth, senderHeight, fps);
+ str[255] = 0;
+ #endif
+ ofDrawBitmapString(str, 20, previewframesize.y+42);
+ }
+
+ if(nSenders == 1) {
+ ofDrawBitmapString("1 network source", 25, 32);
+ }
+ else {
+ #ifdef _MSC_VER
+ sprintf_s(str, 256, "%d network sources", nSenders);
+ #else
+ // !CHECK MACOS
+ snprintf(str, 256, "%d network sources", nSenders);
+ str[255] = 0;
+ #endif
+ ofDrawBitmapString(str, 25, 32);
+ //ofDrawBitmapString("'SPACE' to list senders or RH click to open sender dialog", 20, ofGetHeight()-20);
+ }
+ }
+ }
+ else {
+ ofDrawBitmapString("Connecting . . .", 25, 32);
+ }
+
+ glPopMatrix();
+
}
-void ofApp::draw(){
+void ofApp::drawOutput(ofEventArgs & args){
ofBackground(0);
//composite output window
@@ -75,7 +249,7 @@ void ofApp::exit() {
//--------------------------------------------------------------
-void ofApp::keyPressed(ofKeyEventArgs &args){
+void ofApp::outputKeyPressed(ofKeyEventArgs &args){
if (args.key==OF_KEY_COMMAND){
commandPressed=true;
@@ -94,7 +268,7 @@ void ofApp::keyPressed(ofKeyEventArgs &args){
}
-void ofApp::guiKeyPressed(ofKeyEventArgs &args){
+void ofApp::keyPressed(ofKeyEventArgs &args){
}
@@ -105,32 +279,42 @@ void ofApp::keyReleased(int key){
}
}
+
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
-void ofApp::mouseDragged(int x, int y, int button){
+void ofApp::outputMouseDragged(ofMouseEventArgs & args){
if (select_warpframe>-1){
- warpframe[select_warpframe]=glm::vec2(x,y);
+ warpframe[select_warpframe]=glm::vec2(args.x,args.y);
}
}
+void ofApp::mouseDragged(int x, int y, int button){
+}
+
//--------------------------------------------------------------
-void ofApp::mousePressed(int x, int y, int button){
+void ofApp::outputMousePressed(ofMouseEventArgs & args){
for (int i=0;i<4;i++){
- if (ofPoint(x,y).distance(warpframe[i])<25){
+ if (ofPoint(args.x,args.y).distance(warpframe[i])<25){
select_warpframe=i;
}
}
}
+void ofApp::mousePressed(int x, int y, int button){
+}
+
//--------------------------------------------------------------
-void ofApp::mouseReleased(int x, int y, int button){
+void ofApp::outputMouseReleased(ofMouseEventArgs & args){
select_warpframe=-1;
}
+void ofApp::mouseReleased(int x, int y, int button){
+}
+
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
@@ -142,11 +326,11 @@ void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
-void ofApp::windowResized(int w, int h){
+void ofApp::outputWindowResized(ofResizeEventArgs &resizeargs){
}
-void ofApp::guiWindowResized(ofResizeEventArgs &resizeargs){
+void ofApp::windowResized(int w, int h){
}
diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h
index d28f393..3f5acc1 100644
--- a/gui/src/ofApp.h
+++ b/gui/src/ofApp.h
@@ -2,19 +2,17 @@
#include "ofMain.h"
#include "lineTransformer.h"
+#include "ofxNDI.h"
+#include "ofxGui.h"
class ofApp: public ofBaseApp {
public:
void setup();
void update();
- void updateGui(ofEventArgs & args);
void draw();
void exit();
- void drawGui(ofEventArgs & args);
- void guiKeyPressed(ofKeyEventArgs & args);
-
void keyPressed(ofKeyEventArgs &keyargs);
void keyReleased(int key);
void mouseMoved(int x, int y );
@@ -25,14 +23,43 @@ class ofApp: public ofBaseApp {
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
-
- void guiWindowResized(ofResizeEventArgs &resizeargs);
+
+ void updateOutput(ofEventArgs & args);
+ void drawOutput(ofEventArgs & args);
+ void outputKeyPressed(ofKeyEventArgs & args);
+ void outputMouseDragged(ofMouseEventArgs & args);
+ void outputMousePressed(ofMouseEventArgs & args);
+ void outputMouseReleased(ofMouseEventArgs & args);
+ void outputWindowResized(ofResizeEventArgs &resizeargs);
bool commandPressed;
-
glm::vec2 warpframe[4];
int select_warpframe;
bool bDrawFrame;
+ ofxPanel gui;
+
+ //======================================== //ofxNDI
+
+ ofxNDIreceiver ndiReceiver;
+ ofImage ndiImage;
+ char senderName[256];
+ int nSenders;
+ unsigned int senderWidth;
+ unsigned int senderHeight;
+ bool bNDIreceiver;
+
+ // For received frame fps calculations
+ double startTime, lastTime, frameTime, frameRate, fps;
+
+ //====== gui
+
+ ofxIntSlider NDIthreshold;
+ ofxIntSlider NDIsimplify;
+ ofxToggle NDIuseColour;
+ ofxIntSlider NDIcolR;
+ ofxIntSlider NDIcolG;
+ ofxIntSlider NDIcolB;
+
};
diff --git a/gui/start b/gui/start
new file mode 100755
index 0000000..42627f0
--- /dev/null
+++ b/gui/start
@@ -0,0 +1,2 @@
+mkdir bin/gui.app/Contents/MacOS/@rpath
+cp libs/libndi.3.dylib bin/gui.app/Contents/MacOS/@rpath/