├── logo.icns ├── addons.make ├── bin └── data │ ├── settings │ ├── brushes │ │ └── brush.png │ ├── media │ │ └── warp │ │ │ └── grid-2k.png │ └── shaders │ │ ├── hap.vert │ │ ├── vdome.vert │ │ ├── hap.frag │ │ └── vdome.frag │ └── settings.xml ├── src ├── vdome │ ├── input │ │ ├── spout │ │ │ ├── SpoutSDK │ │ │ │ ├── SpoutGLDXinterop.cpp │ │ │ │ ├── readme.txt │ │ │ │ ├── Spout.h │ │ │ │ ├── SpoutCommon.h │ │ │ │ ├── SpoutSharedMemory.h │ │ │ │ ├── SpoutSender.h │ │ │ │ ├── SpoutReceiver.h │ │ │ │ ├── SpoutDirectX.h │ │ │ │ ├── SpoutMemoryShare.h │ │ │ │ ├── SpoutSharedMemory.cpp │ │ │ │ ├── SpoutSender.cpp │ │ │ │ ├── SpoutReceiver.cpp │ │ │ │ ├── SpoutSenderNames.h │ │ │ │ ├── SpoutGLDXinterop.h │ │ │ │ └── SpoutSDK.h │ │ │ ├── spoutR.h │ │ │ └── spoutR.cpp │ │ ├── media │ │ │ ├── image.h │ │ │ ├── image.cpp │ │ │ ├── video │ │ │ │ ├── videoDS.h │ │ │ │ ├── videoWin.h │ │ │ │ ├── videoWMF.h │ │ │ │ ├── videoWMF.cpp │ │ │ │ └── videoWin.cpp │ │ │ ├── video.h │ │ │ ├── media.h │ │ │ ├── video.cpp │ │ │ └── media.cpp │ │ ├── color.h │ │ ├── capture.h │ │ ├── color.cpp │ │ ├── capture.cpp │ │ ├── input.h │ │ └── input.cpp │ ├── menu │ │ ├── command.h │ │ ├── socket.h │ │ ├── saveThread.h │ │ ├── command.cpp │ │ ├── menu.h │ │ ├── socket.cpp │ │ └── commands.h │ ├── renderer │ │ ├── projector │ │ │ ├── curves.h │ │ │ ├── mask.h │ │ │ ├── plane.h │ │ │ ├── cornerpin.h │ │ │ ├── projector.h │ │ │ ├── curves.cpp │ │ │ ├── mask.cpp │ │ │ └── plane.cpp │ │ ├── model.h │ │ ├── window.h │ │ ├── model.cpp │ │ └── window.cpp │ └── vdome.h └── main.cpp ├── vDome.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcuserdata │ └── Charles.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── xcshareddata │ └── xcschemes │ ├── vdome Debug.xcscheme │ └── vdome Release.xcscheme ├── icon.rc ├── Makefile ├── vDome.workspace ├── .gitignore ├── vDome.user ├── Project.xcconfig ├── openFrameworks-Info.plist ├── vDome.vcxproj.user ├── vDome.sln ├── README.md └── config.make /logo.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/charlesveasey/vDome/HEAD/logo.icns -------------------------------------------------------------------------------- /addons.make: -------------------------------------------------------------------------------- 1 | ofxBezierSurface 2 | ofxCurvesTool 3 | ofxOpenCv 4 | ofxOsc 5 | ofxWMFVideoPlayer 6 | -------------------------------------------------------------------------------- /bin/data/settings/brushes/brush.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/charlesveasey/vDome/HEAD/bin/data/settings/brushes/brush.png -------------------------------------------------------------------------------- /bin/data/settings/media/warp/grid-2k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/charlesveasey/vDome/HEAD/bin/data/settings/media/warp/grid-2k.png -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutGLDXinterop.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/charlesveasey/vDome/HEAD/src/vdome/input/spout/SpoutSDK/SpoutGLDXinterop.cpp -------------------------------------------------------------------------------- /vDome.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /bin/data/settings/shaders/hap.vert: -------------------------------------------------------------------------------- 1 | #version 150 2 | uniform mat4 modelViewProjectionMatrix; 3 | in vec4 position; 4 | in vec2 texcoord; 5 | out vec2 vtexcoord; 6 | void main(){ 7 | gl_Position = modelViewProjectionMatrix * position; 8 | vtexcoord = texcoord; 9 | } -------------------------------------------------------------------------------- /icon.rc: -------------------------------------------------------------------------------- 1 | // Icon Resource Definition 2 | #define MAIN_ICON 102 3 | 4 | #if defined(_DEBUG) 5 | MAIN_ICON ICON "icon_debug.ico" 6 | #else 7 | MAIN_ICON ICON "icon.ico" 8 | #endif 9 | -------------------------------------------------------------------------------- /bin/data/settings/shaders/vdome.vert: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform mat4 modelViewProjectionMatrix; 4 | 5 | in vec4 position; 6 | in vec2 texcoord; 7 | 8 | out vec2 vtexcoord; 9 | 10 | void main() { 11 | gl_Position = modelViewProjectionMatrix * position; 12 | vtexcoord = texcoord; 13 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=../../.. 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /vDome.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/vdome/input/media/image.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | namespace vd{ 4 | 5 | class Image { 6 | 7 | public: 8 | Image(); 9 | 10 | void open(string filepath); 11 | void close(); 12 | bool isLoaded(); 13 | float getWidth(); 14 | float getHeight(); 15 | 16 | void bind(); 17 | void unbind(); 18 | 19 | ofPixels& getPixels(); 20 | 21 | private: 22 | bool bLoaded; 23 | ofImage img; 24 | }; 25 | } -------------------------------------------------------------------------------- /src/vdome/input/color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | namespace vd{ 4 | 5 | class Color { 6 | 7 | public: 8 | Color(); 9 | void setup(); 10 | void fill(int r, int g, int b); 11 | void fillBlack(); 12 | void fillWhite(); 13 | void fillGrey(); 14 | void close(); 15 | void setResolution(int r); 16 | void bind(); 17 | void unbind(); 18 | 19 | ofPixels& getPixels(); 20 | 21 | private: 22 | ofImage image; 23 | int resolution; 24 | }; 25 | } -------------------------------------------------------------------------------- /bin/data/settings/shaders/hap.frag: -------------------------------------------------------------------------------- 1 | #version 150 2 | in vec2 vtexcoord; 3 | out vec4 outputColor; 4 | uniform sampler2D cocgsy_src; 5 | const vec4 offsets = vec4(-0.50196078431373, -0.50196078431373, 0.0, 0.0); 6 | 7 | void main() 8 | { 9 | vec4 CoCgSY = texture(cocgsy_src, vtexcoord); 10 | 11 | CoCgSY += offsets; 12 | float scale = ( CoCgSY.z * ( 255.0 / 8.0 ) ) + 1.0; 13 | float Co = CoCgSY.x / scale; 14 | float Cg = CoCgSY.y / scale; 15 | float Y = CoCgSY.w; 16 | vec4 rgba = vec4(Y + Co - Cg, Y + Cg, Y - Co - Cg, 1.0); 17 | outputColor = rgba; 18 | } -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "vdome.h" 3 | 4 | //#define VDOME_DEBUG // define for debug console 5 | 6 | int main( ){ 7 | 8 | #ifdef VDOME_DEBUG 9 | ofSetLogLevel(OF_LOG_VERBOSE); 10 | #else 11 | ofSetLogLevel(OF_LOG_SILENT); 12 | #endif 13 | 14 | // hide console window 15 | #ifdef TARGET_WIN32 16 | #ifndef VDOME_DEBUG 17 | HWND handleWindow; 18 | AllocConsole(); 19 | handleWindow = FindWindowA("ConsoleWindowClass", NULL); 20 | ShowWindow(handleWindow, 0); 21 | #endif 22 | #endif 23 | 24 | vd::vdome vdome; 25 | vdome.setup(); 26 | } 27 | -------------------------------------------------------------------------------- /src/vdome/input/spout/spoutR.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include ".\SpoutSDK\Spout.h" // Spout SDK 4 | 5 | class SpoutR { 6 | 7 | public: 8 | void setup(); 9 | void update(); 10 | void bind(); 11 | void unbind(); 12 | void exit(); 13 | 14 | SpoutReceiver *spoutreceiver; // A Spout receiver object 15 | bool bInitialized; // Initialization result 16 | ofTexture texture; // Texture used for texture share transfers 17 | char SenderName[256]; // Sender name used by a receiver 18 | int g_Width, g_Height; // Used for checking sender size change 19 | }; 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.so 6 | *.dylib 7 | *.lai 8 | *.la 9 | *.a 10 | *.suo 11 | *.sdf 12 | *.xcuserstate 13 | *.plist 14 | *.xcbkptlist 15 | *.DS_Store 16 | *.gitkeep 17 | *.dll 18 | *.ilk 19 | *.lib 20 | *.pdb 21 | *.exe 22 | *.opensdf 23 | *.exp 24 | *.xccheckout 25 | *.xcsettings 26 | *.ply 27 | *.layout 28 | 29 | # Bin 30 | vDome.app 31 | vDomeDebug.app 32 | vDome.exe 33 | vDome_debug.exe 34 | vDome_debug.exp 35 | bin/vDome 36 | 37 | # Folders 38 | obj/ 39 | bin/data/media/video 40 | bin/data/settings/masks 41 | bin/data/settings/warp 42 | bin/data/settings/color 43 | vdome.xcodeproj/xcuserdata 44 | bin/vDome_debug 45 | -------------------------------------------------------------------------------- /src/vdome/input/capture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofVideoGrabber.h" 3 | namespace vd{ 4 | class Capture { 5 | 6 | public: 7 | Capture(); 8 | void open(); 9 | void update(); 10 | void play(); 11 | void stop(); 12 | void close(); 13 | bool isOpen(); 14 | void setResolution(int r); 15 | void setFramerate(int frate); 16 | float getRealWidth(); 17 | float getRealHeight(); 18 | 19 | ofPixels & getPixels(); 20 | 21 | void bind(); 22 | void unbind(); 23 | 24 | private: 25 | ofVideoGrabber grabber; 26 | int resolution; 27 | }; 28 | } -------------------------------------------------------------------------------- /vDome.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(ProjectDir)/bin 5 | WindowsLocalDebugger 6 | 7 | 8 | $(ProjectDir)/bin 9 | WindowsLocalDebugger 10 | 11 | -------------------------------------------------------------------------------- /bin/data/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) 17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 18 | -------------------------------------------------------------------------------- /src/vdome/menu/command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | using namespace std; 5 | namespace vd { 6 | 7 | class Command { 8 | public: 9 | virtual ~Command(); 10 | virtual void execute() = 0; 11 | virtual void undo() = 0; 12 | virtual void redo() = 0; 13 | }; 14 | 15 | class CommandHistory { 16 | public : 17 | CommandHistory(); 18 | ~CommandHistory(); 19 | 20 | void execute(Command* command); 21 | void undo(); 22 | void redo(); 23 | int getIndex(); 24 | int getLastCommand(); 25 | int getSize(); 26 | 27 | private : 28 | vector history; 29 | 30 | int index; 31 | int lastCommand; // 0 = exec, 1 = undo, 2 = redo 32 | }; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.ofapp 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/vdome/input/media/image.cpp: -------------------------------------------------------------------------------- 1 | #include "image.h" 2 | using namespace vd; 3 | 4 | Image::Image() { 5 | bLoaded = false; 6 | } 7 | 8 | void Image::open(string filepath){ 9 | img.clear(); 10 | bLoaded = img.load(filepath); 11 | } 12 | 13 | void Image::close(){ 14 | img.clear(); 15 | bLoaded = false; 16 | } 17 | 18 | bool Image::isLoaded(){ 19 | return bLoaded; 20 | } 21 | 22 | float Image::getWidth(){ 23 | return img.getWidth(); 24 | } 25 | 26 | float Image::getHeight(){ 27 | return img.getHeight(); 28 | } 29 | 30 | ofPixels& Image::getPixels(){ 31 | return img.getPixels(); 32 | } 33 | 34 | void Image::bind(){ 35 | img.getTexture().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER); 36 | img.getTexture().bind(); 37 | } 38 | 39 | void Image::unbind() { 40 | img.getTexture().unbind(); 41 | } -------------------------------------------------------------------------------- /src/vdome/input/media/video/videoDS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofVideoPlayer.h" 3 | namespace vd { 4 | 5 | class Video { 6 | 7 | public: 8 | Video(); 9 | 10 | bool open(string filepath); 11 | void update(); 12 | 13 | void play(); 14 | void stop(); 15 | void close(); 16 | void seek(float f); 17 | 18 | bool isPlaying(); 19 | bool isLoaded(); 20 | void setLoop(bool lp); 21 | float getPosition(); 22 | float getDuration(); 23 | bool getIsMovieDone(); 24 | void setVolume(float v); 25 | float getWidth(); 26 | float getHeight(); 27 | 28 | ofVideoPlayer player; 29 | ofPixels pixels; 30 | ofEvent endEvent; 31 | ofPixels& getPixels(); 32 | ofTexture& getTexture(); 33 | 34 | private: 35 | bool bEnded; 36 | ofLoopType loopT; 37 | }; 38 | } -------------------------------------------------------------------------------- /src/vdome/input/media/video.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofVideoPlayer.h" 3 | namespace vd{ 4 | 5 | class Video{ 6 | 7 | public: 8 | Video(); 9 | 10 | bool open(string filepath); 11 | void update(); 12 | 13 | void play(); 14 | void stop(); 15 | void close(); 16 | void seek(float f); 17 | 18 | bool isPlaying(); 19 | bool isLoaded(); 20 | void setLoop(bool lp); 21 | float getPosition(); 22 | float getDuration(); 23 | bool getIsMovieDone(); 24 | void setVolume(float v); 25 | float getWidth(); 26 | float getHeight(); 27 | 28 | void bind(); 29 | void unbind(); 30 | 31 | ofEvent endEvent; 32 | ofPixels& getPixels(); 33 | 34 | private: 35 | ofVideoPlayer player; 36 | bool bEnded; 37 | ofLoopType loopT; 38 | }; 39 | } -------------------------------------------------------------------------------- /src/vdome/menu/socket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "ofxOsc.h" 4 | #include "input.h" 5 | #include "model.h" 6 | namespace vd { 7 | class Input; 8 | class Model; 9 | 10 | class Socket { 11 | 12 | public: 13 | Socket(); 14 | void setup(); 15 | void update(); 16 | void sendDuration(); 17 | void sendEnd(); 18 | void loadXML(ofXml &xml); 19 | void saveXML(ofXml &xml); 20 | 21 | string host; 22 | int send; 23 | int receive; 24 | bool enabled; 25 | Input *input; 26 | Model *model; 27 | 28 | static ofEvent sourceEvent; 29 | static ofEvent formatEvent; 30 | 31 | private: 32 | ofxOscSender oscSender; 33 | ofxOscReceiver oscReceiver; 34 | ofxOscMessage sMsg; 35 | ofxOscMessage rMsg; 36 | 37 | float lastInputPosition; 38 | }; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/vdome/menu/saveThread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | 4 | class SaveThread : public ofThread{ 5 | 6 | public: 7 | SaveThread(){ 8 | saved = false; 9 | } 10 | 11 | void save(){ 12 | saved = false; 13 | startThread(); 14 | } 15 | 16 | void threadedFunction(){ 17 | while( isThreadRunning() != 0 ){ 18 | if( lock() ){ 19 | for (int i=0; i save(files[i]); 21 | } 22 | for (int i=0; i save(imageFiles[i]); 24 | } 25 | saved = true; 26 | unlock(); 27 | stopThread(); 28 | } 29 | } 30 | } 31 | 32 | bool saved; 33 | vector xml; 34 | vector files; 35 | vector image; 36 | vector imageFiles; 37 | }; 38 | -------------------------------------------------------------------------------- /src/vdome/input/color.cpp: -------------------------------------------------------------------------------- 1 | #include "color.h" 2 | using namespace vd; 3 | 4 | Color::Color() { 5 | resolution = 2048; 6 | } 7 | 8 | void Color::setup(){ 9 | image.setUseTexture(true); 10 | image.allocate(resolution, resolution, OF_IMAGE_COLOR); 11 | } 12 | 13 | void Color::fill(int r, int g, int b){ 14 | image.setColor(ofColor(r,g,b)); 15 | image.update(); 16 | } 17 | 18 | void Color::fillBlack(){ 19 | fill(0,0,0); 20 | } 21 | 22 | void Color::fillWhite(){ 23 | fill(255,255,255); 24 | } 25 | 26 | void Color::fillGrey(){ 27 | fill(127,127,127); 28 | } 29 | 30 | void Color::close(){ 31 | image.clear(); 32 | } 33 | 34 | void Color::setResolution(int r){ 35 | resolution = r; 36 | } 37 | 38 | void Color::bind() { 39 | image.getTexture().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER); 40 | image.getTexture().bind(); 41 | } 42 | 43 | void Color::unbind() { 44 | image.getTexture().unbind(); 45 | } 46 | 47 | ofPixels & Color::getPixels(){ 48 | return image.getPixels(); 49 | } 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/vdome/input/media/video/videoWin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "videoWMF.h" 3 | #include "../video.h" 4 | namespace vd{ 5 | 6 | class VideoWin { 7 | 8 | public: 9 | VideoWin(); 10 | 11 | void open(string filepath); 12 | void update(); 13 | void play(); 14 | void stop(); 15 | void close(); 16 | void seek(float f); 17 | bool isPlaying(); 18 | void setLoop(bool lp); 19 | float getPosition(); 20 | float getDuration(); 21 | bool getIsMovieDone(); 22 | void setVolume(float v); 23 | bool isLoaded(); 24 | float getWidth(); 25 | float getHeight(); 26 | 27 | void bind(); 28 | void unbind(); 29 | 30 | ofPixels& getPixels(); 31 | 32 | enum VideoTypes {WMF,DS}; 33 | string forceVideoRenderer; 34 | ofEvent endEvent; 35 | 36 | private: 37 | VideoTypes parseForceRenderer(string renderer); 38 | VideoTypes vType; 39 | 40 | VideoWMF vWMF; 41 | Video vDS; 42 | 43 | bool bLoop; 44 | bool bEnd; 45 | string fPath; 46 | bool bLoaded; 47 | }; 48 | } -------------------------------------------------------------------------------- /vDome.xcodeproj/xcuserdata/Charles.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | vDome Debug.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 1 11 | 12 | vDome Release.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 2 16 | 17 | vdome Debug.xcscheme_^#shared#^_ 18 | 19 | orderHint 20 | 0 21 | 22 | vdome Release.xcscheme_^#shared#^_ 23 | 24 | orderHint 25 | 1 26 | 27 | 28 | SuppressBuildableAutocreation 29 | 30 | E4B69B5A0A3A1756003C02F2 31 | 32 | primary 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/vdome/input/media/video/videoWMF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofxWMFVideoPlayer.h" 3 | namespace vd{ 4 | 5 | class VideoWMF{ 6 | 7 | public: 8 | VideoWMF(); 9 | 10 | bool open(string filepath); 11 | void update(); 12 | void play(); 13 | void stop(); 14 | void close(); 15 | void seek(float f); 16 | bool isPlaying(); 17 | void setLoop(bool lp); 18 | float getPosition(); 19 | float getDuration(); 20 | bool getIsMovieDone(); 21 | bool isSupported(); 22 | bool isLoaded(); 23 | void setVolume(float v); 24 | float getWidth(); 25 | float getHeight(); 26 | void bind(); 27 | void unbind(); 28 | 29 | ofPixels& getPixels(); 30 | 31 | private: 32 | void videoLoaded(bool &success); 33 | 34 | bool bLoop; 35 | bool bLoaded; 36 | bool bSupported; 37 | bool bEnded; 38 | bool markEnd; 39 | float positionRequest; 40 | int positionRequestFrameCnt; 41 | float storePositionFix; 42 | int storePositionFrameCnt; 43 | float seekPositionStore; 44 | int seekPositionFrameCnt; 45 | bool bPaused; 46 | 47 | ofxWMFVideoPlayer player; 48 | 49 | }; 50 | } -------------------------------------------------------------------------------- /src/vdome/input/capture.cpp: -------------------------------------------------------------------------------- 1 | #include "capture.h" 2 | using namespace vd; 3 | 4 | Capture::Capture() { 5 | resolution = 2048; 6 | } 7 | 8 | void Capture::open(){ 9 | grabber.setUseTexture(true); 10 | grabber.initGrabber(resolution, resolution); 11 | } 12 | 13 | void Capture::update(){ 14 | if (isOpen()){ 15 | grabber.update(); 16 | } 17 | } 18 | 19 | void Capture::close(){ 20 | if (isOpen()){ 21 | grabber.close(); 22 | } 23 | } 24 | 25 | bool Capture::isOpen(){ 26 | return grabber.isInitialized(); 27 | } 28 | 29 | void Capture::setResolution(int r){ 30 | resolution = r; 31 | } 32 | 33 | void Capture::setFramerate(int frate){ 34 | close(); 35 | grabber.setDesiredFrameRate(frate); 36 | close(); 37 | } 38 | 39 | float Capture::getRealWidth(){ 40 | return grabber.getWidth(); 41 | } 42 | 43 | float Capture::getRealHeight(){ 44 | return grabber.getHeight(); 45 | } 46 | 47 | ofPixels& Capture::getPixels(){ 48 | return grabber.getPixels(); 49 | } 50 | 51 | void Capture::bind(){ 52 | grabber.getTexture().bind(); 53 | } 54 | 55 | void Capture::unbind(){ 56 | grabber.getTexture().unbind(); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /vDome.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(ProjectDir)/bin 5 | WindowsLocalDebugger 6 | 7 | 8 | $(ProjectDir)/bin 9 | WindowsLocalDebugger 10 | 11 | 12 | $(ProjectDir)/bin 13 | WindowsLocalDebugger 14 | 15 | 16 | $(ProjectDir)/bin 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /src/vdome/renderer/projector/curves.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxCurvesTool.h" 5 | namespace vd { 6 | 7 | class Curves { 8 | public: 9 | Curves(); 10 | void init(int i); 11 | void setup(); 12 | void update(); 13 | void draw(int x, int y); 14 | void keyPressed(int key); 15 | 16 | void incrementPoint(float inc); 17 | void setLabelPosition(); 18 | void setLabelPosition(int x, int y); 19 | 20 | void save(int projectorStartingIndex); 21 | void load(int projectorStartingIndex); 22 | 23 | bool show; 24 | bool enabled; 25 | 26 | int getCurrentHover(); 27 | void setCurrentHover(int i); 28 | 29 | void setPoint(int i, ofPoint p); 30 | 31 | void nextPoint(); 32 | void prevPoint(); 33 | 34 | void setActive(bool); 35 | 36 | int getColorMode(); 37 | void setColorMode(int i); 38 | 39 | ofTexture& colorlutTextureRef(); 40 | 41 | enum colors {GREY,RED,GREEN,BLUE}; 42 | ofImage colorlut; 43 | 44 | private: 45 | bool active; 46 | int curveCnt; 47 | int lutRes; 48 | int index; 49 | int colorMode; 50 | 51 | vector curvesTools; 52 | ofXml *xml; 53 | }; 54 | 55 | } -------------------------------------------------------------------------------- /src/vdome/vdome.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "window.h" 3 | #include "socket.h" 4 | #include "saveThread.h" 5 | 6 | namespace vd { 7 | 8 | class vdome { 9 | 10 | public: 11 | vdome(); 12 | void setup(); 13 | void update(ofEventArgs & args); 14 | 15 | private: 16 | void loadXML(); 17 | void saveXML(); 18 | void createWindow(ofXml &xml); 19 | void setupInput(); 20 | void updateInputFormat(); 21 | void updateInputTransform(); 22 | void exit(); 23 | void onColorEvent(ofVec3f &color); 24 | void onSourceEvent(int &s); 25 | void onFormatEvent(int &s); 26 | void onSourceColorEvent(int &s); 27 | void keyPressed(int &key); 28 | void keyReleased(int &key); 29 | 30 | #ifdef TARGET_OSX 31 | void updateSyphonInputTransform(); 32 | #endif 33 | 34 | Socket socket; 35 | Input input; 36 | 37 | ofXml xml; 38 | string xmlPath; 39 | SaveThread saveThread; 40 | 41 | bool vsync; 42 | int framerate; 43 | int cKey; 44 | 45 | vector> windows; 46 | vector> baseWindows; 47 | 48 | }; 49 | 50 | } -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/readme.txt: -------------------------------------------------------------------------------- 1 | The Spout SDK files can either be included directly in your project 2 | or compiled as a dll. 3 | 4 | The Spout applications and examples have been compiled with the SDK 5 | files included in the projects and so are not dependent on a Spout dll. 6 | 7 | The installation folders are set up correctly for building the project. 8 | However, building from within the installation folder is not recommended. 9 | Copy the distribution "SPOUTSDK" folder elsewhere before compilation. 10 | Open the "SpoutSDK" solution, change to "Release" and build the project. 11 | Spout.dll and Spout.lib will be in the Win32\Release folder. 12 | 13 | To use the .dll created from this project, in your code define 14 | SPOUT_IMPORT_DLL in your preprocessor compilation defines. 15 | 16 | Thanks and credit to Malcolm Bechard for creating the dll project. 17 | 18 | https://github.com/mbechard 19 | 20 | COMPATIBILITY 21 | 22 | The dll created from this project has the advantage that all the functions 23 | in the Spout SDK classes are available. However, it is only suitable for 24 | use with Visual Studio compilers. For other compilers, see the C compatible 25 | dll in the SPOUTDSK\SPOUTDLL folder. 26 | 27 | -------------------------------------------------------------------------------- /src/vdome/renderer/model.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | namespace vd { 4 | 5 | class Model { 6 | 7 | public: 8 | Model(); 9 | void setup(); 10 | void update(); 11 | void draw(); 12 | void keyPressed(int key); 13 | 14 | void loadXML(ofXml &xml); 15 | void saveXML(ofXml &xml); 16 | void saveMesh(string file); 17 | 18 | bool getTextureFlip(); 19 | void setTextureFlip(bool b); 20 | 21 | float getTextureRotate(); 22 | void setTextureRotate(float f); 23 | 24 | float getTextureTilt(); 25 | void setTextureTilt(float f); 26 | 27 | float getTextureScale(); 28 | void setTextureScale(float f); 29 | 30 | int editMode; 31 | enum editModes{NONE, T_FLIP, T_ROTATE, T_TILT, T_SCALE}; 32 | 33 | float value; 34 | bool textureFlipInternal; 35 | float textureTiltInternal; 36 | float textureScaleInternal; 37 | float textureScaleInternalW; 38 | float textureScaleInternalH; 39 | 40 | private: 41 | ofVboMesh vbo; 42 | int N; 43 | double radius; 44 | float textureScale; 45 | bool textureFlip; 46 | float textureRotate; 47 | float textureTilt; 48 | }; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/vdome/menu/command.cpp: -------------------------------------------------------------------------------- 1 | #include "command.h" 2 | namespace vd { 3 | 4 | extern int maxHistory; 5 | 6 | Command::~Command() {} 7 | 8 | CommandHistory::CommandHistory() : index(0) { 9 | lastCommand = 0; 10 | } 11 | 12 | CommandHistory::~CommandHistory() {} 13 | 14 | void CommandHistory::execute(Command* command) { 15 | if (history.size() >= maxHistory) 16 | history.erase(history.begin()); 17 | if (history.size() > 1 && index < history.size()-1) 18 | history.erase(history.begin() + index, history.end()); 19 | history.push_back(command); 20 | command->execute(); 21 | index = history.size()-1; 22 | lastCommand = 0; 23 | } 24 | 25 | void CommandHistory::undo() { 26 | if (lastCommand == 1) { 27 | if (index > 0) 28 | index--; 29 | } 30 | if (history.size() >= 1) { 31 | history[index]->undo(); 32 | lastCommand = 1; 33 | } 34 | } 35 | 36 | void CommandHistory::redo() { 37 | if (lastCommand != 1) { 38 | if (index < history.size()-1) 39 | index++; 40 | } 41 | history[index]->redo(); 42 | lastCommand = 2; 43 | } 44 | 45 | int CommandHistory::getIndex() { 46 | return index; 47 | } 48 | 49 | int CommandHistory::getLastCommand() { 50 | return lastCommand; 51 | } 52 | 53 | int CommandHistory::getSize() { 54 | return history.size(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/vdome/renderer/projector/mask.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | namespace vd { 4 | 5 | class Mask { 6 | public: 7 | Mask(); 8 | 9 | void init(int i); 10 | void setup(); 11 | void draw(); 12 | void save(int projectorStartingIndex); 13 | void load(int projectorStartingIndex); 14 | int store(int fIndex); 15 | void recall(int fIndex); 16 | void reset(); 17 | 18 | void mousePressed(ofMouseEventArgs& mouseArgs); 19 | void mouseDragged(ofMouseEventArgs& mouseArgs); 20 | void mouseReleased(ofMouseEventArgs& mouseArgs); 21 | 22 | void keyPressed(int key); 23 | void keyReleased(int key); 24 | 25 | ofImage brushImage; 26 | ofMesh brush; 27 | ofFbo maskFbo; 28 | 29 | float brushOpacity; 30 | float brushScale; 31 | 32 | int mouseX; 33 | int mouseY; 34 | float hIndex; 35 | 36 | int tx; 37 | int ty; 38 | 39 | ofImage *maskFboImage; 40 | 41 | int width; 42 | int height; 43 | 44 | private: 45 | void write(string filename); 46 | void read(string filename); 47 | 48 | ofPixels hPixels; 49 | ofPixels maskFboPixels; 50 | 51 | int brushWidth; 52 | int brushHeight; 53 | bool mouseDown; 54 | bool erase; 55 | int pIndex; 56 | bool bufferAllocated; 57 | string filename; 58 | 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /src/vdome/input/media/media.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "image.h" 3 | 4 | #ifdef TARGET_WIN32 5 | #define USE_WMF // windows only, undefine to use direct show 6 | #endif 7 | 8 | #ifdef USE_WMF 9 | #include "videoWMF.h" 10 | #else 11 | #include "video.h" 12 | #endif 13 | 14 | namespace vd{ 15 | 16 | class Media{ 17 | 18 | public: 19 | Media(); 20 | 21 | void open(string filepath); 22 | void update(); 23 | void play(); 24 | void stop(); 25 | void close(); 26 | void seek(float f); 27 | 28 | void setLoop(bool lp); 29 | bool isPlaying(); 30 | float getPosition(); 31 | float getDuration(); 32 | bool getLoop(); 33 | string getFilepath(); 34 | void setVolume(float v); 35 | void setResolution(int w, int h); 36 | bool isLoaded(); 37 | float getRealWidth(); 38 | float getRealHeight(); 39 | 40 | void bind(); 41 | void unbind(); 42 | 43 | ofPixels& getPixels(); 44 | 45 | enum MediaTypes {IMAGE,VIDEO}; 46 | MediaTypes mType; 47 | 48 | ofEvent endEvent; 49 | 50 | 51 | private: 52 | string parseFile(string filepath); 53 | void videoEnd(bool &end); 54 | bool isImageFile(string ext); 55 | 56 | int width; 57 | int height; 58 | bool bLoop; 59 | string fpath; 60 | bool bEnded; 61 | float vol; 62 | 63 | Image image; 64 | 65 | #ifdef USE_WMF 66 | VideoWMF video; 67 | #else 68 | Video video; 69 | #endif 70 | 71 | string ImageTypes[29] = 72 | {"BMP","DDS","EXR","GIF","HDR","ICO","IFF","JBIG","JNG", "JPG", 73 | "JPEG","JIF","KOALA","MNG","PCX","PBM","PFM","PNG","PICT", 74 | "PSD","RAW","RAS","SGI","TARGA","TIFF","WBMP","WEBP","XBM","XPM"}; 75 | }; 76 | } 77 | -------------------------------------------------------------------------------- /src/vdome/renderer/projector/plane.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "cornerpin.h" 4 | #include "ofxBezierSurface.h" 5 | namespace vd { 6 | 7 | class Plane { 8 | 9 | public: 10 | Plane(); 11 | 12 | int width; 13 | int height; 14 | 15 | void setup(int i); 16 | void update(); 17 | void draw(); 18 | void drawConfig(); 19 | 20 | void resetCornerpin(); 21 | void resetGrid(); 22 | 23 | void keyPressed(int key); 24 | void keyReleased(int key); 25 | void onMouseDragged(ofMouseEventArgs& mouseArgs); 26 | void onMousePressed(ofMouseEventArgs& mouseArgs); 27 | void onMouseReleased(ofMouseEventArgs& mouseArgs); 28 | 29 | void load(ofXml &xml, int projectorStartingIndex); 30 | void save(ofXml &xml); 31 | 32 | void setCornerpinPoints(vector pts); 33 | void setGridPoints(vector v); 34 | 35 | vector getGridPoints(); 36 | 37 | ofXml *wXml; 38 | float value; 39 | 40 | ofMatrix4x4 lm; 41 | bool bfirst; 42 | 43 | QuadWarp cornerpin; 44 | ofxBezierSurface grid; 45 | 46 | bool cornerpinActive; 47 | bool gridActive; 48 | vector cornerpinValues; 49 | vector getCornerpinPoints(); 50 | vector position; 51 | 52 | 53 | private: 54 | float index; 55 | bool shift; 56 | ofPoint lastM; 57 | bool group; 58 | bool drawBox; 59 | ofPoint boxOrigin; 60 | ofPoint boxUpdate; 61 | int xRes; 62 | int yRes; 63 | int pointIndex; 64 | 65 | map sel; 66 | vector cornerpinPoints; 67 | }; 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/Spout.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Spout.h 4 | 5 | The main Spout include file for the SDK 6 | 7 | Copyright (c) 2014-1015, Lynn Jarvis. All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without modification, 10 | are permitted provided that the following conditions are met: 11 | 12 | 1. Redistributions of source code must retain the above copyright notice, 13 | this list of conditions and the following disclaimer. 14 | 15 | 2. Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | 30 | */ 31 | #pragma once 32 | 33 | #ifndef __Spout__ 34 | #define __Spout__ 35 | 36 | #include "SpoutSender.h" 37 | #include "SpoutReceiver.h" 38 | 39 | // All documentation in the SDK pdf = SpoutSDK.pdf 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/vdome/renderer/window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "model.h" 3 | #include "projector.h" 4 | #include "menu.h" 5 | 6 | #ifdef TARGET_OSX 7 | #include "ofxSyphon.h" 8 | #endif 9 | 10 | #ifdef TARGET_WIN32 11 | #include "spoutR.h" 12 | #endif 13 | 14 | #include "input.h" 15 | 16 | namespace vd { 17 | class vdome; 18 | 19 | class Window : public ofBaseApp { 20 | 21 | public: 22 | Window(); 23 | 24 | void init(); 25 | void setup(); 26 | void update(); 27 | void draw(); 28 | 29 | void loadXML(ofXml &xml); 30 | void saveXML(ofXml &xml); 31 | 32 | void keyPressed(int key); 33 | void keyReleased(int key); 34 | 35 | void mousePressed(ofMouseEventArgs& mouseArgs); 36 | void mouseDragged(ofMouseEventArgs& mouseArgs); 37 | void mouseReleased(ofMouseEventArgs& mouseArgs); 38 | 39 | ofPoint getPosition(); 40 | void setPosition(int x, int y); 41 | 42 | ofPoint getResolution(); 43 | void setResolution(int w, int h); 44 | 45 | void setVSync(bool val); 46 | void setFrameRate(int val); 47 | 48 | int index; 49 | Input *input; 50 | Menu menu; 51 | Model model; 52 | int projectorStartingIndex; 53 | 54 | enum sources {MEDIA, CAPTURE, SYPHON, SPOUT, GRID, BLACK, WHITE, GREY, COLOR}; 55 | 56 | static ofEvent keyPressEvent; 57 | static ofEvent keyReleaseEvent; 58 | 59 | vector projectors; 60 | 61 | #ifdef TARGET_OSX 62 | ofxSyphonClient syphon; 63 | #endif 64 | 65 | #ifdef TARGET_WIN32 66 | SpoutR spout; 67 | #endif 68 | 69 | private: 70 | int x; 71 | int y; 72 | int width; 73 | int height; 74 | bool fullscreen; 75 | 76 | float ratio; 77 | int maxHistory; 78 | 79 | ofShader shader; 80 | }; 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/vdome/input/media/video.cpp: -------------------------------------------------------------------------------- 1 | #include "video.h" 2 | using namespace vd; 3 | 4 | Video::Video() { 5 | bEnded = false; 6 | } 7 | 8 | bool Video::open(string filepath){ 9 | if (!player.load(filepath)){ 10 | return false; 11 | } 12 | player.setUseTexture(true); 13 | player.play(); 14 | player.setLoopState(loopT); 15 | return true; 16 | } 17 | 18 | void Video::update(){ 19 | player.update(); 20 | 21 | if (getIsMovieDone()) { 22 | bEnded = true; 23 | ofNotifyEvent(endEvent,bEnded,this); 24 | } 25 | } 26 | 27 | void Video::play(){ 28 | player.play(); 29 | } 30 | 31 | void Video::stop(){ 32 | player.stop(); 33 | } 34 | 35 | void Video::close(){ 36 | player.stop(); 37 | player.close(); 38 | } 39 | 40 | void Video::seek(float f){ 41 | player.setPosition(f); 42 | } 43 | 44 | bool Video::isPlaying(){ 45 | return player.isPlaying(); 46 | } 47 | 48 | bool Video::isLoaded(){ 49 | return player.isLoaded();; 50 | } 51 | 52 | void Video::setLoop(bool lp){ 53 | loopT = (lp ? OF_LOOP_NORMAL : OF_LOOP_NONE); 54 | player.setLoopState(loopT); 55 | } 56 | 57 | float Video::getPosition(){ 58 | return player.getPosition(); 59 | } 60 | 61 | float Video::getDuration(){ 62 | return player.getDuration(); 63 | } 64 | 65 | bool Video::getIsMovieDone(){ 66 | return player.getIsMovieDone(); 67 | } 68 | 69 | void Video::setVolume(float v){ 70 | player.setVolume(v); 71 | } 72 | 73 | float Video::getWidth(){ 74 | return player.getWidth(); 75 | } 76 | 77 | float Video::getHeight(){ 78 | return player.getHeight(); 79 | } 80 | 81 | ofPixels& Video::getPixels(){ 82 | return player.getPixels(); 83 | } 84 | 85 | void Video::bind(){ 86 | player.getTexture().setTextureWrap(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER); 87 | player.getTexture().bind(); 88 | } 89 | 90 | void Video::unbind() { 91 | player.getTexture().unbind(); 92 | } -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutCommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Spout.h 4 | 5 | The main Spout include file for the SDK 6 | 7 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without modification, 10 | are permitted provided that the following conditions are met: 11 | 12 | 1. Redistributions of source code must retain the above copyright notice, 13 | this list of conditions and the following disclaimer. 14 | 15 | 2. Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | 30 | */ 31 | #pragma once 32 | 33 | #ifndef __SpoutCommon__ 34 | #define __SpoutCommon__ 35 | 36 | #if defined(_MSC_VER) 37 | #if defined(SPOUT_BUILD_DLL) 38 | #define SPOUT_DLLEXP __declspec(dllexport) 39 | #elif defined(SPOUT_IMPORT_DLL) 40 | #define SPOUT_DLLEXP __declspec(dllimport) 41 | #else 42 | #define SPOUT_DLLEXP 43 | #endif 44 | #else // _MSC_VER 45 | #define SPOUT_DLLEXP 46 | #endif // _MSC_VERR 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /vDome.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 14 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vDome", "vDome.vcxproj", "{7FD42DF7-442E-479A-BA76-D0022F99702A}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openframeworksLib", "..\..\..\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj", "{5837595D-ACA9-485C-8E76-729040CE4B0B}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Win32 = Debug|Win32 10 | Debug|x64 = Debug|x64 11 | Release|Win32 = Release|Win32 12 | Release|x64 = Release|x64 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.ActiveCfg = Debug|Win32 16 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.Build.0 = Debug|Win32 17 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.ActiveCfg = Debug|x64 18 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.Build.0 = Debug|x64 19 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.ActiveCfg = Release|Win32 20 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.Build.0 = Release|Win32 21 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.ActiveCfg = Release|x64 22 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.Build.0 = Release|x64 23 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.ActiveCfg = Debug|Win32 24 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.Build.0 = Debug|Win32 25 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.ActiveCfg = Debug|x64 26 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.Build.0 = Debug|x64 27 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.ActiveCfg = Release|Win32 28 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.Build.0 = Release|Win32 29 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.ActiveCfg = Release|x64 30 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.Build.0 = Release|x64 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | EndGlobal 36 | -------------------------------------------------------------------------------- /src/vdome/input/input.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "socket.h" 4 | #include "media.h" 5 | #include "capture.h" 6 | #include "color.h" 7 | #include "model.h" 8 | 9 | #ifdef TARGET_WIN32 10 | #include "spoutR.h" 11 | #endif 12 | 13 | #ifdef TARGET_OSX 14 | #include "ofxSyphon.h" 15 | #endif 16 | 17 | namespace vd { 18 | class Socket; 19 | 20 | class Input { 21 | 22 | public: 23 | Input(); 24 | 25 | void setup(); 26 | void update(); 27 | 28 | void play(); 29 | void stop(); 30 | void close(); 31 | void seek(float f); 32 | bool isPlaying(); 33 | 34 | void loadXML(ofXml &xml); 35 | void saveXML(ofXml &xml); 36 | 37 | void setLoop(bool b); 38 | bool getLoop(); 39 | 40 | string getSource(); 41 | int getSourceInt(); 42 | void setSourceInt(int i); 43 | int convertSourceString(string s); 44 | 45 | void setFormatInt(int i); 46 | void setFormat(); 47 | int getFormatInt(); 48 | int convertFormatString(string s); 49 | 50 | float getPosition(); 51 | float getDuration(); 52 | 53 | void setResolution(int r); 54 | string getFilepath(); 55 | 56 | void setVolume(float v); 57 | void setColor(int r, int g, int b); 58 | 59 | void openFile(string file); 60 | void setFile(string file); 61 | void keyPressed(int key); 62 | void setFramerate(int frate); 63 | 64 | void bind(); 65 | void unbind(); 66 | 67 | ofPixels& getPixels(); 68 | 69 | int source; 70 | enum sources {MEDIA, CAPTURE, SYPHON, SPOUT, GRID, BLACK, WHITE, GREY, COLOR}; 71 | 72 | int format; 73 | enum format {DOMEMASTER, HD}; 74 | 75 | Media media; 76 | Capture capture; 77 | Color color; 78 | Socket *socket; 79 | 80 | float ratio; 81 | bool durationSent; 82 | 83 | private: 84 | void mediaEnd(bool &end); 85 | 86 | string filepath; 87 | bool loop; 88 | bool endSent; 89 | int framerate; 90 | bool isVideo; 91 | int resolution; 92 | 93 | ofColor cColor; 94 | }; 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/vdome/renderer/projector/cornerpin.h: -------------------------------------------------------------------------------- 1 | // 2 | // QuadWarp.h 3 | // Created by lukasz karluk on 19/06/11. 4 | // 5 | 6 | // modified by Charles Veasey 7 | // - mouse position is now delta 8 | 9 | #pragma once 10 | 11 | #include "ofMain.h" 12 | #include "ofxOpenCv.h" 13 | namespace vd { 14 | 15 | class QuadWarp 16 | { 17 | public: 18 | QuadWarp(); 19 | ~QuadWarp(); 20 | 21 | void setup(); 22 | 23 | void setPosition(float x, float y); 24 | void setAnchorSize(float w, float h); 25 | 26 | void setSourceRect(ofRectangle rect); 27 | void setSourcePoints(vector points); 28 | ofPoint* getSourcePoints(); 29 | void setTargetRect(ofRectangle rect); 30 | void setTargetPoints(vector points); 31 | ofPoint* getTargetPoints(); 32 | void setMatrix(ofMatrix4x4 matrix); 33 | 34 | void enable(); 35 | void disable(); 36 | 37 | void update(); 38 | void reset(); 39 | 40 | ofMatrix4x4 getMatrix(); 41 | ofMatrix4x4 getMatrixInverse(); 42 | ofMatrix4x4 getMatrix(ofPoint * srcPoints, ofPoint * dstPoints); 43 | 44 | void setCorners(vector corners); 45 | void setCorner(ofPoint p, int cornerIndex); 46 | void setTopLeftCornerPosition(ofPoint p); 47 | void setTopRightCornerPosition(ofPoint p); 48 | void setBottomRightCornerPosition(ofPoint p); 49 | void setBottomLeftCornerPosition(ofPoint p); 50 | 51 | void onMousePressed(ofMouseEventArgs& mouseArgs); 52 | void onMouseDragged(ofMouseEventArgs &mouseArgs); 53 | void onMouseReleased(ofMouseEventArgs& mouseArgs); 54 | void keyPressed(ofKeyEventArgs& keyArgs); 55 | void keyReleased(ofKeyEventArgs& keyArgs); 56 | 57 | void show(); 58 | void hide(); 59 | void toggleShow(); 60 | 61 | void draw(); 62 | void drawCorners(); 63 | void drawQuadOutline(); 64 | 65 | void loadPoints(); 66 | void savePoints(); 67 | 68 | ofPoint srcPoints[4]; 69 | ofPoint dstPoints[4]; 70 | bool bShow; 71 | bool isCornerSelected(int cornerIndex) { return selectedCornerIndex == cornerIndex; } 72 | 73 | float value; 74 | 75 | protected: 76 | ofPoint position; 77 | ofPoint anchorSize; 78 | ofPoint anchorSizeHalf; 79 | int selectedCornerIndex; 80 | bool bEnabled; 81 | ofPoint lastMouse; 82 | int cKey; 83 | }; 84 | 85 | } 86 | -------------------------------------------------------------------------------- /bin/data/settings/shaders/vdome.frag: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | // TEXTURE INPUT 4 | uniform sampler2DRect texsampler; 5 | in vec2 vtexcoord; 6 | vec4 t; 7 | 8 | // contrast, saturation, brightness 9 | uniform float brightness; 10 | uniform float contrast; 11 | uniform float saturation; 12 | vec3 cCSB; 13 | const float AvgLumR = 0.5; 14 | const float AvgLumG = 0.5; 15 | const float AvgLumB = 0.5; 16 | const vec3 LumCoeff = vec3 (0.2125, 0.7154, 0.0721); 17 | 18 | /// COLOR: CURVES 19 | uniform sampler2DRect colorlut; 20 | uniform int interp; 21 | uniform float mapdim; 22 | uniform float amt; 23 | vec4 set; 24 | float rout; 25 | float gout; 26 | float bout; 27 | vec4 mapped; 28 | vec4 t2; 29 | 30 | // MASK 31 | uniform sampler2DRect maskTex; 32 | 33 | // TEXTURE OUTPUT 34 | out vec4 outputColor; 35 | 36 | /* 37 | ** Contrast, saturation, brightness 38 | ** Code of this function is from TGM's shader pack 39 | ** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 40 | */ 41 | 42 | // For all settings: 1.0 = 100% 0.5=50% 1.5 = 150% 43 | vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con) { 44 | vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); 45 | vec3 brtColor = color * brt; 46 | vec3 intensity = vec3(dot(brtColor, LumCoeff)); 47 | vec3 satColor = mix(intensity, brtColor, sat); 48 | vec3 conColor = mix(AvgLumin, satColor, con); 49 | return conColor; 50 | } 51 | 52 | void main() { 53 | //input 54 | t = texture(texsampler, vtexcoord); 55 | 56 | cCSB = ContrastSaturationBrightness(t.rgb, brightness, saturation, contrast); 57 | 58 | t2 = vec4(cCSB.rgb, t.a); 59 | 60 | // grey curve 61 | set = mix(floor(t2*mapdim),t2*mapdim,float(interp)); //multiply color value for LUT range 62 | rout = float (texture(colorlut, vec2(set.r,0.)).a); //look up red 63 | gout = float (texture(colorlut, vec2(set.g,0.)).a); //look up green 64 | bout = float (texture(colorlut, vec2(set.b,0.)).a); //look up blue 65 | mapped = vec4 (rout, gout, bout,t2.a); 66 | t2 = mix(t2, mapped, amt); 67 | 68 | // color curves 69 | set = mix(floor(t2*mapdim),t2*mapdim,float(interp)); //multiply color value for LUT range 70 | rout = float (texture(colorlut, vec2(set.r,0.)).r); //look up red 71 | gout = float (texture(colorlut, vec2(set.g,0.)).g); //look up green 72 | bout = float (texture(colorlut, vec2(set.b,0.)).b); //look up blue 73 | mapped = vec4 (rout, gout, bout,t2.a); 74 | t2 = mix(t2, mapped, amt); 75 | 76 | // mask 77 | float mask = texture(maskTex, vtexcoord).a; 78 | 79 | // output 80 | outputColor = vec4(t2.rgb, 1-mask); 81 | } 82 | 83 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutSharedMemory.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | spoutSharedMemory.h 4 | 5 | Thanks and credit to Malcolm Bechard the author of this class 6 | 7 | https://github.com/mbechard 8 | 9 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without modification, 13 | are permitted provided that the following conditions are met: 14 | 15 | 1. Redistributions of source code must retain the above copyright notice, 16 | this list of conditions and the following disclaimer. 17 | 18 | 2. Redistributions in binary form must reproduce the above copyright notice, 19 | this list of conditions and the following disclaimer in the documentation 20 | and/or other materials provided with the distribution. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 23 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | #pragma once 34 | 35 | #ifndef __SpoutSharedMemory_ // standard way as well 36 | #define __SpoutSharedMemory_ 37 | 38 | #include "SpoutCommon.h" 39 | #include 40 | #include 41 | #include 42 | 43 | enum SpoutCreateResult 44 | { 45 | SPOUT_CREATE_FAILED = 0, 46 | SPOUT_CREATE_SUCCESS, 47 | SPOUT_ALREADY_EXISTS, 48 | SPOUT_ALREADY_CREATED, 49 | }; 50 | 51 | class SPOUT_DLLEXP SpoutSharedMemory { 52 | public: 53 | SpoutSharedMemory(); 54 | ~SpoutSharedMemory(); 55 | 56 | 57 | // Create a new memory segment, or attachs to an existing one 58 | SpoutCreateResult Create(const char* name, int size); 59 | 60 | // Opens an existing one 61 | bool Open(const char* name); 62 | void Close(); 63 | 64 | // Returns the buffer 65 | char* Lock(); 66 | void Unlock(); 67 | 68 | void Debug(); 69 | private: 70 | char* m_pBuffer; 71 | HANDLE m_hMap; 72 | HANDLE m_hMutex; 73 | 74 | int m_lockCount; 75 | 76 | const char* m_pName; 77 | int m_size; 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/vdome/input/media/video/videoWMF.cpp: -------------------------------------------------------------------------------- 1 | #include "videoWMF.h" 2 | using namespace vd; 3 | 4 | VideoWMF::VideoWMF() { 5 | bLoop = false; 6 | markEnd = false; 7 | positionRequestFrameCnt = 0; 8 | positionRequest = -1; 9 | storePositionFix =-1; 10 | seekPositionFrameCnt = 0; 11 | ofAddListener(player.videoLoadEvent, this, &VideoWMF::videoLoaded); 12 | } 13 | 14 | bool VideoWMF::open(string filepath){ 15 | bLoaded = false; 16 | bSupported = false; 17 | bEnded = false; 18 | markEnd = false; 19 | positionRequestFrameCnt = 0; 20 | storePositionFrameCnt = 0; 21 | positionRequest = -1; 22 | storePositionFix = -1; 23 | player.loadMovie(filepath); 24 | play(); 25 | player.setLoop(bLoop); 26 | return true; 27 | } 28 | 29 | void VideoWMF::update(){ 30 | 31 | player.update(); 32 | 33 | if (markEnd){ 34 | bEnded = true; 35 | markEnd = false; 36 | } 37 | 38 | if (player.getPosition() > 0.99){ 39 | markEnd = true; 40 | }else { 41 | markEnd = false; 42 | } 43 | 44 | if (positionRequest >= 0){ 45 | positionRequestFrameCnt++; 46 | } 47 | if (positionRequestFrameCnt > 20){ 48 | positionRequestFrameCnt = -1; 49 | player.setPosition(positionRequest); 50 | if (bPaused) stop(); 51 | positionRequest = -1; 52 | storePositionFix = -1; 53 | } 54 | 55 | if (seekPositionFrameCnt > 40) 56 | seekPositionFrameCnt = 0; 57 | 58 | if (seekPositionFrameCnt > 0) 59 | seekPositionFrameCnt++; 60 | } 61 | 62 | void VideoWMF::play(){ 63 | bPaused = false; 64 | player.play(); 65 | } 66 | 67 | void VideoWMF::stop(){ 68 | bPaused = true; 69 | player.pause(); 70 | } 71 | 72 | void VideoWMF::close(){ 73 | player.stop(); 74 | //player.close(); 75 | //player.forceExit(); 76 | } 77 | 78 | void VideoWMF::seek(float f){ 79 | seekPositionStore = f; 80 | seekPositionFrameCnt = 1; 81 | storePositionFrameCnt = 0; 82 | positionRequest = f; 83 | storePositionFix = positionRequest; 84 | } 85 | 86 | bool VideoWMF::isPlaying(){ 87 | return player.isPlaying(); 88 | } 89 | 90 | void VideoWMF::setLoop(bool lp){ 91 | bLoop = lp; 92 | player.setLoop(lp); 93 | } 94 | 95 | float VideoWMF::getPosition(){ 96 | if ( seekPositionFrameCnt > 0 ) { 97 | return seekPositionStore; 98 | } 99 | return player.getPosition(); 100 | } 101 | 102 | float VideoWMF::getDuration(){ 103 | return player.getDuration(); 104 | } 105 | 106 | bool VideoWMF::getIsMovieDone(){ 107 | return bEnded; 108 | } 109 | 110 | void VideoWMF::videoLoaded(bool &success){ 111 | bLoaded = true; 112 | bSupported = success; 113 | } 114 | 115 | bool VideoWMF::isLoaded(){ 116 | return bLoaded; 117 | } 118 | 119 | bool VideoWMF::isSupported(){ 120 | return bSupported; 121 | } 122 | 123 | void VideoWMF::setVolume(float v){ 124 | player.setVolume(v); 125 | } 126 | 127 | float VideoWMF::getWidth(){ 128 | return player.getWidth(); 129 | } 130 | 131 | float VideoWMF::getHeight(){ 132 | return player.getHeight(); 133 | } 134 | 135 | void VideoWMF::bind() { 136 | return player.bind(); 137 | } 138 | 139 | void VideoWMF::unbind() { 140 | return player.unbind(); 141 | } 142 | 143 | ofPixels& VideoWMF::getPixels() { 144 | //fix: WMF doesn't return pixels 145 | ofPixels pixels; 146 | return pixels; 147 | } -------------------------------------------------------------------------------- /vDome.xcodeproj/xcshareddata/xcschemes/vdome Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /vDome.xcodeproj/xcshareddata/xcschemes/vdome Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutSender.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SpoutSender.h 4 | 5 | 6 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without modification, 9 | are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 14 | 2. Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | */ 29 | #pragma once 30 | 31 | #ifndef __SpoutSender__ 32 | #define __SpoutSender__ 33 | 34 | #include "spoutSDK.h" 35 | 36 | class SPOUT_DLLEXP SpoutSender { 37 | 38 | public: 39 | 40 | SpoutSender(); 41 | ~SpoutSender(); 42 | 43 | bool CreateSender(char *Sendername, unsigned int width, unsigned int height, DWORD dwFormat = 0); 44 | bool UpdateSender(char *Sendername, unsigned int width, unsigned int height); 45 | void ReleaseSender(DWORD dwMsec = 0); 46 | 47 | bool SendImage(unsigned char* pixels, unsigned int width, unsigned int height, GLenum glFormat = GL_RGBA, bool bAlignment = true, bool bInvert=true); 48 | bool SendTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, bool bInvert=true, GLuint HostFBO = 0); 49 | bool DrawToSharedTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = true, GLuint HostFBO = 0); 50 | 51 | bool SelectSenderPanel(const char* message = NULL); 52 | 53 | bool SetMemoryShareMode(bool bMemoryMode = true); 54 | bool GetMemoryShareMode(); 55 | 56 | bool SetDX9(bool bDX9 = true); // set to use DirectX 9 (default is DirectX 11) 57 | bool GetDX9(); 58 | 59 | void SetDX9compatible(bool bCompatible = true); // DirectX 11 format compatible with DirectX 9 60 | bool GetDX9compatible(); 61 | 62 | int GetNumAdapters(); // Get the number of graphics adapters in the system 63 | bool GetAdapterName(int index, char *adaptername, int maxchars); // Get an adapter name 64 | bool SetAdapter(int index = 0); // Set required graphics adapter for output 65 | int GetAdapter(); // Get the current adapter index 66 | 67 | bool SetVerticalSync(bool bSync = true); 68 | int GetVerticalSync(); 69 | 70 | 71 | bool SenderDebug(char *Sendername, int size); 72 | 73 | Spout spout; // LJ DEBUG - for testing 74 | 75 | protected : 76 | 77 | // Spout spout; 78 | 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutReceiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SpoutReceiver.h 4 | 5 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | */ 28 | #pragma once 29 | 30 | #ifndef __SpoutReceiver__ 31 | #define __SpoutReceiver__ 32 | 33 | #include "spoutSDK.h" 34 | 35 | class SPOUT_DLLEXP SpoutReceiver { 36 | 37 | public: 38 | 39 | SpoutReceiver(); 40 | ~SpoutReceiver(); 41 | 42 | bool CreateReceiver(char* Sendername, unsigned int &width, unsigned int &height, bool bUseActive = false); 43 | bool ReceiveTexture(char* Sendername, unsigned int &width, unsigned int &height, GLuint TextureID = 0, GLuint TextureTarget = 0, bool bInvert = false, GLuint HostFBO = 0); 44 | bool ReceiveImage (char* Sendername, unsigned int &width, unsigned int &height, unsigned char * pixels, GLenum glFormat = GL_RGBA, GLuint HostFBO = 0); 45 | bool GetImageSize (char* Sendername, unsigned int &width, unsigned int &height, bool &bMemoryMode); 46 | void ReleaseReceiver(); 47 | 48 | bool BindSharedTexture(); 49 | bool UnBindSharedTexture(); 50 | bool DrawSharedTexture(float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = true); 51 | 52 | int GetSenderCount(); 53 | bool GetSenderName(int index, char* Sendername, int MaxSize = 256); 54 | bool GetSenderInfo(const char* Sendername, unsigned int &width, unsigned int &height, HANDLE &dxShareHandle, DWORD &dwFormat); 55 | 56 | bool GetActiveSender(char* Sendername); 57 | bool SetActiveSender(char* Sendername); 58 | 59 | bool SelectSenderPanel(const char* message = NULL); 60 | 61 | bool GetMemoryShareMode(); 62 | bool SetMemoryShareMode(bool bMemory = true); 63 | 64 | bool SetDX9(bool bDX9 = true); // set to use DirectX 9 (default is DirectX 11) 65 | bool GetDX9(); 66 | 67 | void SetDX9compatible(bool bCompatible = true); 68 | bool GetDX9compatible(); 69 | 70 | int GetNumAdapters(); // Get the number of graphics adapters in the system 71 | bool GetAdapterName(int index, char *adaptername, int maxchars); // Get an adapter name 72 | bool SetAdapter(int index = 0); // Set required graphics adapter for output 73 | int GetAdapter(); // Get the current adapter index 74 | 75 | bool SetVerticalSync(bool bSync = true); 76 | int GetVerticalSync(); 77 | 78 | Spout spout; // for debug 79 | 80 | protected : 81 | 82 | // Spout spout; 83 | 84 | }; 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/vdome/input/media/media.cpp: -------------------------------------------------------------------------------- 1 | #include "media.h" 2 | using namespace vd; 3 | 4 | Media::Media() { 5 | width = 2048; 6 | height = 2048; 7 | bEnded = false; 8 | vol = 1; 9 | } 10 | 11 | void Media::open(string filepath){ 12 | fpath = filepath; 13 | stop(); 14 | close(); 15 | bEnded = false; 16 | 17 | string mString = parseFile(filepath); 18 | if (mString == "image"){ 19 | mType = IMAGE; 20 | image.open(filepath); 21 | } 22 | else if (mString == "video"){ 23 | mType = VIDEO; 24 | video.setLoop(bLoop); 25 | video.open(filepath); 26 | video.setVolume(vol); 27 | } 28 | } 29 | 30 | void Media::update(){ 31 | switch (mType) { 32 | case IMAGE: break; 33 | case VIDEO: 34 | video.update(); 35 | if (video.getIsMovieDone()) { 36 | bool end = true; 37 | videoEnd(end); 38 | } 39 | break; 40 | } 41 | } 42 | 43 | void Media::play(){ 44 | switch (mType) { 45 | case IMAGE: break; 46 | case VIDEO: video.play(); break; 47 | } 48 | } 49 | 50 | void Media::stop(){ 51 | switch (mType) { 52 | case IMAGE: break; 53 | case VIDEO: video.stop(); break; 54 | } 55 | } 56 | 57 | void Media::close(){ 58 | switch (mType) { 59 | case IMAGE: image.close(); break; 60 | case VIDEO: video.close(); break; 61 | } 62 | } 63 | 64 | void Media::seek(float f){ 65 | switch (mType) { 66 | case IMAGE: break; 67 | case VIDEO: video.seek(f); break; 68 | } 69 | } 70 | 71 | void Media::setLoop(bool lp){ 72 | bLoop = lp; 73 | video.setLoop(lp); 74 | } 75 | 76 | bool Media::getLoop(){ 77 | return bLoop; 78 | } 79 | 80 | bool Media::isPlaying(){ 81 | return video.isPlaying(); 82 | } 83 | 84 | float Media::getPosition(){ 85 | if (mType == VIDEO) 86 | return video.getPosition(); 87 | return 0; 88 | } 89 | 90 | float Media::getDuration(){ 91 | if (mType == VIDEO) 92 | return video.getDuration(); 93 | return 0; 94 | } 95 | 96 | void Media::setResolution(int w, int h){ 97 | width = w; 98 | height = h; 99 | } 100 | 101 | void Media::videoEnd(bool &end){ 102 | bEnded = true; 103 | ofNotifyEvent(endEvent,bEnded,this); 104 | } 105 | 106 | string Media::getFilepath(){ 107 | return fpath; 108 | } 109 | 110 | void Media::setVolume(float v){ 111 | vol = v; 112 | video.setVolume(v); 113 | } 114 | 115 | string Media::parseFile(string filepath){ 116 | ofFile oFile; 117 | oFile.open(filepath); 118 | string mString = ""; 119 | string extension = ofToUpper(oFile.getExtension()); 120 | if (isImageFile(extension)) 121 | mString = "image"; 122 | else 123 | mString = "video"; 124 | oFile.close(); 125 | return mString; 126 | } 127 | 128 | bool Media::isLoaded(){ 129 | switch (mType) { 130 | case IMAGE: return image.isLoaded(); break; 131 | case VIDEO: return video.isLoaded(); break; 132 | } 133 | } 134 | 135 | float Media::getRealWidth(){ 136 | switch (mType) { 137 | case IMAGE: return image.getWidth(); break; 138 | case VIDEO: return video.getWidth(); break; 139 | } 140 | } 141 | 142 | float Media::getRealHeight(){ 143 | switch (mType) { 144 | case IMAGE: return image.getHeight(); break; 145 | case VIDEO: return video.getHeight(); break; 146 | } 147 | } 148 | 149 | ofPixels & Media::getPixels(){ 150 | switch (mType) { 151 | case IMAGE: return image.getPixels(); break; 152 | case VIDEO: return video.getPixels(); break; 153 | } 154 | } 155 | 156 | void Media::bind() { 157 | switch (mType) { 158 | case IMAGE: image.bind(); break; 159 | case VIDEO: video.bind(); break; 160 | } 161 | } 162 | 163 | void Media::unbind() { 164 | switch (mType) { 165 | case IMAGE: image.unbind(); break; 166 | case VIDEO: video.unbind(); break; 167 | } 168 | } 169 | 170 | bool Media::isImageFile(string ext){ 171 | for (auto i : ImageTypes){ 172 | if (i == ext) 173 | return true; 174 | } 175 | return false; 176 | } -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutDirectX.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | spoutDirectX.h 4 | 5 | DirectX functions to manage DirectX 11 texture sharing 6 | 7 | 8 | Copyright (c) 2014 - 2015, Lynn Jarvis. All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without modification, 11 | are permitted provided that the following conditions are met: 12 | 13 | 1. Redistributions of source code must retain the above copyright notice, 14 | this list of conditions and the following disclaimer. 15 | 16 | 2. Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the following disclaimer in the documentation 18 | and/or other materials provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 21 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | #pragma once 32 | #ifndef __spoutDirectX__ 33 | #define __spoutDirectX__ 34 | 35 | #include "SpoutCommon.h" 36 | #include 37 | #include 38 | #include 39 | #include // LJ DEBUG 40 | #include 41 | #include 42 | 43 | #pragma comment (lib, "d3d9.lib") 44 | #pragma comment (lib, "d3d11.lib") 45 | #pragma comment (lib, "DXGI.lib") 46 | 47 | using namespace std; 48 | 49 | class SPOUT_DLLEXP spoutDirectX { 50 | 51 | public: 52 | 53 | spoutDirectX(); 54 | ~spoutDirectX(); 55 | 56 | // DX9 57 | IDirect3D9Ex* CreateDX9object(); // Create a DirectX9 object 58 | IDirect3DDevice9Ex* CreateDX9device(IDirect3D9Ex* pD3D, HWND hWnd); // Create a DirectX9 device 59 | bool CreateSharedDX9Texture(IDirect3DDevice9Ex* pDevice, unsigned int width, unsigned int height, D3DFORMAT format, LPDIRECT3DTEXTURE9 &dxTexture, HANDLE &dxShareHandle); 60 | 61 | // DX11 62 | ID3D11Device* CreateDX11device(); // Create a DX11 device 63 | bool CreateSharedDX11Texture(ID3D11Device* pDevice, unsigned int width, unsigned int height, DXGI_FORMAT format, ID3D11Texture2D** pSharedTexture, HANDLE &dxShareHandle); 64 | bool OpenDX11shareHandle(ID3D11Device* pDevice, ID3D11Texture2D** ppSharedTexture, HANDLE dxShareHandle); 65 | void CloseDX11(); 66 | bool DX11available(); // Verify that the operating system supports DirectX 11 67 | 68 | // Output adapter selection 69 | int GetNumAdapters(); // Get the number of graphics adapters in the system 70 | bool GetAdapterName(int index, char *adaptername, int maxchars); // Get an adapter name 71 | bool SetAdapter(int index); // Set required graphics adapter for output 72 | int GetAdapter(); // Get the current adapter index 73 | 74 | // Mutex locks for DirectX 9 shared texture access 75 | bool CreateAccessMutex(const char *name, HANDLE &hAccessMutex); 76 | void CloseAccessMutex(HANDLE &hAccessMutex); 77 | bool CheckAccess(HANDLE hAccessMutex, ID3D11Texture2D* pSharedTexture = NULL); 78 | void AllowAccess(HANDLE hAccessMutex, ID3D11Texture2D* pSharedTexture = NULL); 79 | 80 | // For debugging only - to toggle texture access locks disable/enable 81 | bool bUseAccessLocks; 82 | 83 | protected: 84 | 85 | IDXGIAdapter* GetAdapterPointer(int index); // Get adapter pointer for DirectX 11 86 | int g_AdapterIndex; // Used for DX9 87 | IDXGIAdapter* g_pAdapterDX11; 88 | ID3D11DeviceContext* g_pImmediateContext; 89 | D3D_DRIVER_TYPE g_driverType; 90 | D3D_FEATURE_LEVEL g_featureLevel; 91 | 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /src/vdome/renderer/projector/projector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "plane.h" 4 | #include "mask.h" 5 | #include "curves.h" 6 | 7 | namespace vd { 8 | class Command; 9 | class Projector { 10 | 11 | public: 12 | void init(int i, int pStartingIndex); 13 | void setup(); 14 | void begin(); 15 | void end(); 16 | void bind(); 17 | void unbind(); 18 | void draw(); 19 | 20 | void drawPlaneConfig(); 21 | void drawKeystone(); 22 | void drawCurves(int x, int y); 23 | 24 | void mousePressed(ofMouseEventArgs& mouseArgs); 25 | void mouseDragged(ofMouseEventArgs& mouseArgs); 26 | void mouseReleased(ofMouseEventArgs& mouseArgs); 27 | 28 | void keyPressed(int key); 29 | void keyReleased(int key); 30 | 31 | void loadXML(ofXml &xml); 32 | void loadXML2(ofXml &xml); 33 | void saveXML(ofXml &xml); 34 | 35 | Command* execute(float v); 36 | Command* executeBrush(); 37 | Command* reset(); 38 | 39 | // plane 40 | ofVec2f getPlanePosition(); 41 | void setPlanePosition(float x, float y); 42 | 43 | ofVec2f getPlaneDimensions(); 44 | void setPlaneDimensions(float w, float h); 45 | 46 | // keystone 47 | bool getKeystoneActive(); 48 | void setKeystoneActive(bool v); 49 | 50 | vector getKeystonePoints(); 51 | void setKeystonePoints(vector pts); 52 | 53 | // grid 54 | bool getGridActive(); 55 | void setGridActive(bool v); 56 | 57 | vector getGridPoints(); 58 | void setGridPoints(vector v); 59 | 60 | // camera 61 | void setCameraTransform(); 62 | 63 | ofVec3f getCameraPosition(); 64 | void setCameraPosition(float azi, float ele, float dis); 65 | 66 | ofVec3f getCameraOrientation(); 67 | void setCameraOrientation(float roll, float tilt, float pan); 68 | 69 | float getCameraFov(); 70 | void setCameraFov(float v); 71 | 72 | ofVec2f getCameraOffset(); 73 | void setCameraOffset(float x, float y); 74 | 75 | ofVec2f getCameraScale(); 76 | void setCameraScale(float x, float y); 77 | 78 | vector getCameraShear(); 79 | void setCameraShear(vector); 80 | ofTexture& getTextureReference(); 81 | 82 | int index; 83 | bool keyboard; 84 | bool mouse; 85 | bool active; 86 | bool enable; 87 | int editMode; 88 | bool mod; 89 | bool all; 90 | void setValue(float v); 91 | Mask mask; 92 | ofFbo renderFbo; 93 | 94 | ofVboMesh renderPlane; 95 | 96 | // intensity 97 | float brightness; 98 | float contrast; 99 | 100 | // color 101 | float hue; 102 | float saturation; 103 | float lightness; 104 | 105 | Plane plane; 106 | 107 | vector lastKey; 108 | vector lastGrid; 109 | 110 | int width, height; 111 | 112 | // color curves 113 | Curves curves; 114 | 115 | int projectorStartingIndex; 116 | 117 | enum editModes{ 118 | BRIGHTNESS,CONTRAST,SATURATION, 119 | CURVES, 120 | CORNERPIN, GRID, 121 | AZIMUTH, ELEVATION, DISTANCE, 122 | ROLL, TILT, PAN, 123 | FOV, OFFSET_X, OFFSET_Y, 124 | NONE, BRUSH_SCALE, BRUSH_OPACITY, WHITE, BLACK, ENABLE}; 125 | 126 | private: 127 | ofVec3f sphToCar(ofVec3f t); 128 | float round(float d); 129 | float roundTo(float val, float n); 130 | 131 | ofCamera camera; 132 | ofFbo fbo; 133 | ofRectangle view; 134 | 135 | float value; 136 | int fboSample; 137 | string xmlPrefix; 138 | 139 | // plane 140 | ofVec2f planePosition; 141 | 142 | // camera 143 | ofVec3f cameraPosition; 144 | ofVec3f cameraOrientation; 145 | float cameraFov; 146 | ofVec2f cameraOffset; 147 | ofVec2f cameraScale; 148 | vector cameraShear; 149 | 150 | ofMatrix4x4 transform; 151 | }; 152 | 153 | 154 | 155 | } 156 | -------------------------------------------------------------------------------- /src/vdome/menu/menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ofMain.h" 3 | #include "projector.h" 4 | 5 | namespace vd { 6 | 7 | class Item { 8 | public: 9 | string str; 10 | bool isParent; 11 | Item(string s){ 12 | str = s; 13 | isParent = false; 14 | } 15 | Item(string s, bool p){ 16 | str = s; 17 | isParent = p; 18 | } 19 | }; 20 | 21 | 22 | class Menu { 23 | public: 24 | Menu(); 25 | 26 | void setup(); 27 | void update(); 28 | 29 | // draw methods 30 | void draw(int i, int labelIndex); 31 | void drawMain(int i); 32 | 33 | void drawProjector(int i); 34 | void drawFPS(int i); 35 | void drawHighlight(); 36 | void drawBackground(); 37 | void drawSaved(); 38 | void drawActive(int i); 39 | void drawWarp(int i); 40 | void drawCurves(int i); 41 | 42 | // navigation 43 | void select(); 44 | void back(); 45 | void setEditMode(); 46 | 47 | // mouse methods 48 | void mousePressed(ofMouseEventArgs& mouseArgs); 49 | void mouseDragged(ofMouseEventArgs& mouseArgs); 50 | void mouseReleased(ofMouseEventArgs& mouseArgs); 51 | 52 | // keyboard methods 53 | void keyPressed(int key); 54 | void keyReleased(int key); 55 | 56 | // utils 57 | void toggle(); 58 | float roundTo(float val, float n); 59 | float round(float d); 60 | 61 | // menu item 62 | struct MenuItem { 63 | int currentItem; 64 | vector items; 65 | int menuId; 66 | MenuItem **parent; 67 | }; 68 | 69 | // menu objects 70 | MenuItem *menuMain; 71 | MenuItem *menuInput; 72 | MenuItem *menuInputVideo; 73 | MenuItem *menuInputTransform; 74 | MenuItem *menuWarp; 75 | MenuItem *menuBlend; 76 | MenuItem *menuBrush; 77 | MenuItem *menuColor; 78 | MenuItem *menuCurves; 79 | MenuItem *menuCurvesGrey; 80 | MenuItem *menuCurvesRed; 81 | MenuItem *menuCurvesGreen; 82 | MenuItem *menuCurvesBlue; 83 | MenuItem *menuSetup; 84 | MenuItem *menuPosition; 85 | MenuItem *menuOrientation; 86 | MenuItem *menuFov; 87 | MenuItem *menuLens; 88 | MenuItem *menuScale; 89 | MenuItem *menuShear; 90 | MenuItem **currentMenu; 91 | 92 | // menu types 93 | enum menus {MAIN, WARP, BLEND, COLOR, 94 | CURVES, CURVES_GREY, CURVES_RED, CURVES_GREEN, CURVES_BLUE, 95 | SETUP, POSITION, ORIENTATION, FIELD_OF_VIEW, LENS, BRUSH}; 96 | 97 | // menu item types 98 | enum mainItems {ENABLE}; 99 | enum warpItems {CORNERPIN, GRID}; 100 | enum blendItems {B_BRUSH}; 101 | enum brushItems {BRUSH_SCALE, BRUSH_OPACITY}; 102 | enum colorItems {BRIGHTNESS, CONTRAST, SATURATION, COLOR_CURVES}; 103 | enum posItems {AZIMUTH, ELEVATION, DISTANCE}; 104 | enum orienItems {TILT, ROLL, PAN}; 105 | enum fovItems {FOV}; 106 | enum lensItems {OFFSET_X, OFFSET_Y}; 107 | 108 | // layout 109 | int px; 110 | int py; 111 | int pw; 112 | int ph; 113 | int padx; 114 | int pady; 115 | 116 | // keyboard 117 | bool all; 118 | int cKey; 119 | 120 | // value 121 | float value; 122 | float orgValue; 123 | float ctrlValue; 124 | float altValue; 125 | 126 | // projector 127 | vector *projectors; // list of projectors 128 | int projCount; // projector count 129 | int projectorStartingIndex; // first projector index within the window 130 | 131 | // input sources 132 | int inputSource; 133 | enum inputSources {SOURCE_MEDIA, SOURCE_CAPTURE, SOURCE_SYPHON, SOURCE_SPOUT, SOURCE_GRID, SOURCE_BLACK, SOURCE_WHITE, SOURCE_GREY, SOURCE_COLOR}; 134 | 135 | // menu states 136 | int frameCnt; // frame cout for saved items 137 | bool saved; // saved state 138 | bool active; // active state 139 | int pActive; // projector active state 140 | int storedSource; // stored source, used for input overrides 141 | ofVec3f currentColor; // current color, used for color overrides 142 | 143 | static ofEvent sourceColorEvent; // event for 144 | static ofEvent colorEvent; 145 | 146 | private: 147 | ofVec3f updateColorFromCurve(int pointIndex, bool forceGrey); 148 | void changeColorCurveMode(int i); 149 | int curvePointIndex; 150 | bool newCurvePointIndex; 151 | }; 152 | 153 | } 154 | -------------------------------------------------------------------------------- /src/vdome/input/media/video/videoWin.cpp: -------------------------------------------------------------------------------- 1 | #include "videoWin.h" 2 | using namespace vd; 3 | 4 | VideoWin::VideoWin() { 5 | forceVideoRenderer = ""; 6 | bLoop = false; 7 | bLoaded = false; 8 | fPath = ""; 9 | } 10 | 11 | void VideoWin::open(string filepath){ 12 | bEnd = false; 13 | fPath = filepath; 14 | bLoaded = false; 15 | if (forceVideoRenderer.length() > 0){ 16 | vType = parseForceRenderer(forceVideoRenderer); 17 | switch (vType) { 18 | case WMF: vWMF.open(filepath); break; 19 | case DS: bLoaded = vDS.open(filepath); break; 20 | } 21 | } 22 | else{ 23 | vType = WMF; 24 | vWMF.open(filepath); 25 | } 26 | } 27 | 28 | void VideoWin::update(){ 29 | switch (vType) { 30 | case WMF: 31 | if (vWMF.isLoaded()){ 32 | if (vWMF.isSupported()){ 33 | bLoaded = true; 34 | } 35 | else if (parseForceRenderer(forceVideoRenderer) != WMF){ 36 | vType = DS; 37 | bLoaded = vDS.open(fPath); 38 | return; 39 | } 40 | } 41 | vWMF.update(); break; 42 | case DS: vDS.update(); break; 43 | } 44 | if (getIsMovieDone()) { 45 | bEnd = true; 46 | ofNotifyEvent(endEvent,bEnd,this); 47 | } 48 | } 49 | 50 | void VideoWin::play(){ 51 | switch (vType) { 52 | case WMF: vWMF.play(); break; 53 | case DS: vDS.play(); break; 54 | } 55 | } 56 | 57 | void VideoWin::stop(){ 58 | switch (vType) { 59 | case WMF: vWMF.stop(); break; 60 | case DS: vDS.stop(); break; 61 | } 62 | } 63 | 64 | void VideoWin::close(){ 65 | switch (vType) { 66 | case WMF: vWMF.close(); break; 67 | case DS: vDS.close(); break; 68 | } 69 | } 70 | 71 | void VideoWin::seek(float f){ 72 | switch (vType) { 73 | case WMF: vWMF.seek(f); break; 74 | case DS: vDS.seek(f); break; 75 | } 76 | } 77 | 78 | bool VideoWin::isPlaying(){ 79 | bool val; 80 | switch (vType) { 81 | case WMF: val = vWMF.isPlaying(); break; 82 | case DS: val = vDS.isPlaying(); break; 83 | } 84 | return val; 85 | } 86 | 87 | void VideoWin::setLoop(bool lp){ 88 | bLoop = lp; 89 | vWMF.setLoop(lp); 90 | vDS.setLoop(lp); 91 | } 92 | 93 | float VideoWin::getPosition(){ 94 | float val; 95 | switch (vType) { 96 | case WMF: val = vWMF.getPosition(); break; 97 | case DS: val = vDS.getPosition(); break; 98 | } 99 | return val; 100 | } 101 | 102 | float VideoWin::getDuration(){ 103 | float val; 104 | switch (vType) { 105 | case WMF: val = vWMF.getDuration(); break; 106 | case DS: val = vDS.getDuration(); break; 107 | } 108 | return val; 109 | } 110 | 111 | bool VideoWin::getIsMovieDone(){ 112 | bool val; 113 | switch (vType) { 114 | case WMF: val = vWMF.getIsMovieDone(); break; 115 | case DS: val = vDS.getIsMovieDone(); break; 116 | } 117 | return val; 118 | } 119 | 120 | void VideoWin::setVolume(float v){ 121 | switch (vType) { 122 | case WMF: vWMF.setVolume(v); break; 123 | case DS: vDS.setVolume(v); break; 124 | } 125 | } 126 | 127 | bool VideoWin::isLoaded(){ 128 | return bLoaded; 129 | } 130 | 131 | VideoWin::VideoTypes VideoWin::parseForceRenderer(string renderer){ 132 | VideoTypes type; 133 | renderer = ofToLower(renderer); 134 | if (renderer == "wmf") 135 | type = WMF; 136 | else 137 | type = DS; 138 | return type; 139 | } 140 | 141 | float VideoWin::getWidth(){ 142 | float val; 143 | switch (vType) { 144 | case WMF: val = vWMF.getWidth(); break; 145 | case DS: val = vDS.getWidth(); break; 146 | } 147 | return val; 148 | } 149 | 150 | float VideoWin::getHeight(){ 151 | float val; 152 | switch (vType) { 153 | case WMF: val = vWMF.getHeight(); break; 154 | case DS: val = vDS.getHeight(); break; 155 | } 156 | return val; 157 | } 158 | 159 | ofPixels& VideoWin::getPixels() { 160 | switch (vType) { 161 | //case WMF: return vWMF.getPixels(); //fix 162 | case DS: return vDS.getPixels(); 163 | } 164 | } 165 | 166 | void VideoWin::bind() { 167 | switch (vType) { 168 | case WMF: return vWMF.bind(); 169 | case DS: return vDS.bind(); 170 | } 171 | } 172 | 173 | void VideoWin::unbind() { 174 | switch (vType) { 175 | case WMF: return vWMF.unbind(); 176 | case DS: return vDS.unbind(); 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutMemoryShare.h: -------------------------------------------------------------------------------- 1 | /* 2 | spoutMemoryShare.h 3 | 4 | Class used for Spout inter-process communication 5 | 6 | Semaphore single reader/writer version 7 | 8 | Last modifed : 11.02.14 9 | 10 | The purpose is to establish a fixed shared memory map for an RGB image the size of the desktop (1920x1080) 11 | and semaphores to control read/write access for sharing a bitmap image between sender and receiver 12 | Only one sender and receiver is assumed. 13 | 14 | bool Initialize(); 15 | Initialize memory map and read/write semaphores 16 | 17 | void DeInitialize(); 18 | Close memory map and semaphore handles 19 | 20 | void CreateSenderMutex(); 21 | // Create a mutex by the sender which is checked by a receiver 22 | 23 | void ReleaseSenderMutex(); 24 | // for a sender to release its mutex on close 25 | 26 | bool CheckSenderMutex(); 27 | // for a receiver to check the presence of a sender 28 | // If the mutex does not exist, the semaphore read wait is skipped 29 | 30 | bool ReadFromMemory(unsigned char *buffer, int numBytes, int offset = 0); 31 | // Read from shared memory 32 | // Offset is useful for example when reading a bitmap to skip the bitmap header 33 | 34 | bool WriteToMemory(unsigned char *buffer, int numBytes); 35 | // Write to shared memory 36 | 37 | void setSharedMemoryName(char* sharedMemoryName); 38 | // to set names of mapping and semaphores externally 39 | // otherwise a default name is used 40 | 41 | 42 | Copyright (c) 2014>, Lynn Jarvis. All rights reserved. 43 | 44 | Redistribution and use in source and binary forms, with or without modification, 45 | are permitted provided that the following conditions are met: 46 | 47 | 1. Redistributions of source code must retain the above copyright notice, 48 | this list of conditions and the following disclaimer. 49 | 50 | 2. Redistributions in binary form must reproduce the above copyright notice, 51 | this list of conditions and the following disclaimer in the documentation 52 | and/or other materials provided with the distribution. 53 | 54 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 55 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 56 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 57 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 58 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 59 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 60 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 61 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 62 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 63 | 64 | */ 65 | 66 | #ifndef __spoutMemoryShare__ 67 | #define __spoutMemoryShare__ 68 | 69 | // #define CONSOLE_DEBUG // to activate debug console messages 70 | 71 | #include "SpoutCommon.h" 72 | #include 73 | #include 74 | 75 | class SPOUT_DLLEXP spoutMemoryShare { 76 | 77 | public: 78 | 79 | spoutMemoryShare(); 80 | ~spoutMemoryShare(); 81 | bool Initialize(); 82 | void DeInitialize(); 83 | // Create a mutex by the sender which is checked by a receiver 84 | // If the mutex does not exist, the semaphore read wait is skipped 85 | void CreateSenderMutex(); // for a sender to set a mutex for a receiver to test 86 | void ReleaseSenderMutex(); // for a receiver to release the mutex if a sender is present 87 | bool CheckSenderMutex(); // for a receiver to check the presence of a sender 88 | bool GetImageSizeFromSharedMemory(unsigned int &width, unsigned int &height); 89 | bool ReadFromMemory(unsigned char *buffer, int numBytes, int offset = 0); 90 | bool WriteToMemory(unsigned char *buffer, int numBytes); 91 | void setSharedMemoryName(char* sharedMemoryName); // to set names of mapping and semaphores externally 92 | char szShareMemoryName[256]; // name of the shared memory (made public for FFGL plugins) 93 | 94 | protected: 95 | 96 | LPTSTR pBuffer; // shared memory pointer 97 | HANDLE hSharedMemory; // handle to shared memory 98 | HANDLE hReadSemaphore; 99 | HANDLE hWriteSemaphore; 100 | HANDLE hSenderMutex; // Mutex that gets set by a sender 101 | char szReadSemaphoreName[256]; // name of the read semaphore 102 | char szWriteSemaphoreName[256]; // name of the read semaphore 103 | 104 | 105 | }; 106 | 107 | #endif 108 | 109 | -------------------------------------------------------------------------------- /src/vdome/input/spout/spoutR.cpp: -------------------------------------------------------------------------------- 1 | #include "spoutR.h" 2 | 3 | /****************************************** 4 | 5 | SETUP 6 | 7 | ********************************************/ 8 | 9 | void SpoutR::setup(){ 10 | spoutreceiver = new SpoutReceiver; // Create a Spout receiver object 11 | bInitialized = false; // Spout receiver initialization 12 | SenderName[0] = 0; // the name will be filled when the receiver connects to a sender 13 | 14 | // Allocate a texture for shared texture transfers 15 | // An openFrameWorks texture is used so that it can be drawn. 16 | g_Width = ofGetWidth(); 17 | g_Height = ofGetHeight(); 18 | 19 | if (texture.getWidth() != g_Width && texture.getHeight() != g_Height) 20 | texture.allocate(g_Width, g_Height, GL_RGBA); // Allocate a texture for shared texture transfers 21 | } 22 | 23 | /****************************************** 24 | 25 | UPDATE 26 | 27 | ********************************************/ 28 | 29 | void SpoutR::update() { 30 | char str[256]; 31 | ofSetColor(255); 32 | unsigned int width, height; 33 | char tempname[256]; // temp name 34 | 35 | // A render window must be available for Spout initialization 36 | // and might not be available in "update", so do it now 37 | // when there is definitely a render window. 38 | // 39 | // INITIALIZE A RECEIVER 40 | // 41 | // The receiver will attempt to connect to the name it is sent. 42 | // Alternatively set the optional bUseActive flag to attempt to connect to the active sender. 43 | // If the sender name is not initialized it will attempt to find the active sender 44 | // If the receiver does not find any senders the initialization will fail 45 | // and "CreateReceiver" can be called repeatedly until a sender is found. 46 | // "CreateReceiver" will update the passed name, and dimensions. 47 | if (!bInitialized) { 48 | // Create the receiver and specify true to attempt to connect to the active sender 49 | if (spoutreceiver->CreateReceiver(SenderName, width, height, true)) { 50 | 51 | // Is the size of the detected sender different ? 52 | if (width != g_Width || height != g_Height) { 53 | // The sender dimensions have changed so update the global width and height 54 | g_Width = width; 55 | g_Height = height; 56 | // Update the local texture to receive the new dimensions 57 | texture.allocate(g_Width, g_Height, GL_RGBA); 58 | } 59 | bInitialized = true; 60 | return; // quit for next round 61 | } // receiver was initialized 62 | else { 63 | sprintf(str, "No sender detected"); 64 | ofDrawBitmapString(str, 20, 20); 65 | } 66 | } // end initialization 67 | 68 | // The receiver has initialized so OK to draw 69 | if (bInitialized) { 70 | 71 | // Save current global width and height - they will be changed 72 | // by ReceiveTexture if the sender changes dimensions 73 | width = g_Width; 74 | height = g_Height; 75 | 76 | // Try to receive into the local the texture at the current size 77 | // NOTE: If a host calls ReceiveTexture with a framebuffer object bound, 78 | // include the FBO id in the ReceiveTexture call so that the binding is restored 79 | // afterwards because Spout makes use of its own FBO for intermediate rendering. 80 | if (spoutreceiver->ReceiveTexture(SenderName, width, height, texture.getTextureData().textureID, texture.getTextureData().textureTarget)) { 81 | 82 | // If the width and height are changed, the local texture has to be resized. 83 | if (width != g_Width || height != g_Height) { 84 | // Update the global width and height 85 | g_Width = width; 86 | g_Height = height; 87 | // Update the local texture to receive the new dimensions 88 | texture.allocate(g_Width, g_Height, GL_RGBA); 89 | return; // quit for next round 90 | } 91 | 92 | } 93 | else { 94 | // A texture read failure might happen if the sender 95 | // is closed. Release the receiver and start again. 96 | spoutreceiver->ReleaseReceiver(); 97 | bInitialized = false; 98 | return; 99 | } 100 | } 101 | } 102 | 103 | /****************************************** 104 | 105 | BIND 106 | 107 | ********************************************/ 108 | 109 | void SpoutR::bind() { 110 | texture.bind(); 111 | } 112 | 113 | void SpoutR::unbind() { 114 | texture.unbind(); 115 | } 116 | 117 | /****************************************** 118 | 119 | EXIT 120 | 121 | ********************************************/ 122 | 123 | void SpoutR::exit() { 124 | spoutreceiver->ReleaseReceiver(); // Release the receiver 125 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vDome 2 | ===== 3 | 4 | Multi-channel projection software designed for domes. Provides real-time warping and slicing for domemaster input. 5 | Developed by Charles Veasey for the Institute of American Indian Arts (IAIA). 6 | 7 | Windows Builds: 8 | https://drive.google.com/drive/folders/0B4gYtwXbgYOhZXlMSUlkV1lCUEU 9 | 10 | v0.1) The version that matches the [manual](https://docs.google.com/document/d/1EHPpExjznFF6X0YTY5acLS0MNkEbtVFsLBCoJ2HHQlQ). 11 | 12 | v0.2) The unfinished version including the media player. 13 | 14 | Note: this project is no longer active. You may want to check out this actively developed software: 15 | https://github.com/paperManu/splash 16 | 17 | 18 | ## Overview 19 | 20 | vDome is an application designed to calibrate multiple projectors on a hemispherical dome surface and display a domemaster formatted video, image, or interactive application. vDome also supports the playback of HD video files. vDome is generally used in two ways: 1) as a media player and 2) as a background process that listens to hardware/software input streams such as cameras, capture cards, and inter-application protocols such as Syphon, Spout, and Video4Linux. 21 | 22 | As a media player vDome utilizes native os media libraries and accepts most common file formats and codecs of the operating system. In general: 23 | - Mac OS X: QuickTime, AV Foundation, HAP 24 | - Win 7/8: Windows Media Foundation, DirectShow, QuickTime, HAP 25 | - Linux: GStreamer 26 | 27 | For optimized video playback, use the following codecs: 28 | - OS X: ProRes 422 and H.264 29 | - Windows 8.1: H.264 and WMF 30 | - Linux Ubuntu: H.264 31 | 32 | To assist in media playback and creating playlists check out the vDome Player interface: 33 | https://github.com/charlesveasey/vDome-player 34 | 35 | Capture and camera inputs are hardware video stream solutions. A capture card is a flexible solution that allows one to run any application on the dome by sending the video output of one computer into another machine running vDome. With this, vDome essentially becomes the 2nd monitor on your production machine. Drag the After Effects or Unity preview window onto the dome and edit in real-time, play videos through your favorite media player: Quicktime, VLC, etc. 36 | 37 | Syphon is a graphic interapplication protocol for OS X: 38 | http://syphon.v002.info 39 | 40 | Spout is a graphic interapplication protocol for Windows: 41 | http://spout.zeal.co 42 | 43 | Video4Linux is a graphic interapplication protocol for Linux: 44 | http://en.wikipedia.org/wiki/Video4Linux 45 | 46 | ## Compiling 47 | #### All 48 | - Download the latest version of openFrameworks (currently v0.8.4): http://www.openframeworks.cc/download/ 49 | - Clone this (vDome) repository to openFrameworks/apps/myApps 50 | - Clone to: openFrameworks/addons: 51 | - https://github.com/charlesveasey/ofxBezierSurface 52 | - https://github.com/charlesveasey/ofxCurvesTool 53 | 54 | #### Mac 55 | - Suggested IDE: Xcode v5.1.1 56 | - Syphon needs to be copied to Frameworks 57 | - Under target, add a Copy Files Build Phase. Drag the Syphon.framework into this phase. 58 | - Clone to: openFrameworks/addons: 59 | - https://github.com/astellato/ofxSyphon 60 | 61 | #### Win 62 | - Suggested IDE: Microsoft Visual Studio Express 2012 63 | - ofxWMFPLayer requries updated GLEW library, follow instructions on its repository 64 | - Clone to: openFrameworks/addons: 65 | - https://github.com/charlesveasey/ofxWMFVideoPlayer 66 | 67 | #### Linux 68 | - Install openFrameworks dependencies, see INSTALL.md in openFrameworks linux package 69 | - Suggested IDE: Code::Blocks 10.04 70 | - Can also run make in root directory 71 | 72 | ## Installation 73 | #### Mac 74 | - To use the HAP codec: 75 | - https://github.com/vidvox/hap-qt-codec 76 | 77 | #### Win 78 | - To use Spout, copy the Spout32.dll to your build directory: 79 | - http://spout.zeal.co/ 80 | - To allow QuickTime video playback install the K-Lite Mega Codec Pack 10.2: 81 | - http://www.free-codecs.com/download/k_lite_mega_codec_pack.htm 82 | 83 | #### Linux 84 | - Install gstreamer codecs, see INSTALL.md in openFrameworks linux package 85 | - To use Video4Linux: 86 | - https://github.com/umlaeute/v4l2loopback 87 | 88 | ## Setup and Calibration 89 | Initial setup is done in XML (setting resolution, number of projectors, and input type). Calibration is done directly on the dome. For more information see the manual: 90 | https://docs.google.com/document/d/1EHPpExjznFF6X0YTY5acLS0MNkEbtVFsLBCoJ2HHQlQ/ 91 | 92 | --- 93 | Funding provided by the United States Department of Defense. Based on prior research from the University of New Mexico (UNM) and IAIA with funding provided by the National Science Foundation. 94 | 95 | Thanks to research by the ARTS Labs at UNM and Paul Bourke at the University of Western Australia. 96 | -------------------------------------------------------------------------------- /src/vdome/renderer/projector/curves.cpp: -------------------------------------------------------------------------------- 1 | #include "Curves.h" 2 | namespace vd { 3 | 4 | extern int cCurveIndex; 5 | 6 | Curves::Curves() { 7 | curveCnt = 4; 8 | lutRes = 256; 9 | show = true; 10 | enabled = false; 11 | index = 0; 12 | colorMode = GREY; 13 | xml = new ofXml; 14 | } 15 | 16 | void Curves::init(int i) { 17 | index = i; 18 | } 19 | 20 | void Curves::setup() { 21 | 22 | for(int i = 0; i < curveCnt; i++) { 23 | curvesTools.push_back(new ofxCurvesTool); 24 | curvesTools.at(i)->setup(); 25 | curvesTools.at(i)->mouseAddsPoint = false; 26 | curvesTools.at(i)->useKey(false); 27 | curvesTools.at(i)->keepFocus = true; 28 | curvesTools.at(i)->mouseMovesPoint = false; 29 | 30 | for(int j = 1; j < 8; j++) { 31 | curvesTools.at(i)->add(ofVec2f(ofClamp(j*lutRes/8, 0, lutRes-1),ofClamp(j*lutRes/8, 0, lutRes-1))); 32 | } 33 | } 34 | 35 | colorlut.allocate(lutRes, lutRes, OF_IMAGE_COLOR_ALPHA); 36 | 37 | for(int x = 0; x < 256; x++) { 38 | for(int y = 0; y < 256; y++) { 39 | colorlut.setColor(x, y, ofColor(x,x,x,x)); 40 | } 41 | } 42 | 43 | setCurrentHover(0); 44 | update(); 45 | 46 | setActive(false); 47 | } 48 | 49 | void Curves::update() { 50 | if (!curvesTools.size()) return; 51 | 52 | bool n = curvesTools.at(colorMode)->isLutNew(); 53 | 54 | for(int x = 0; x < lutRes; x++) { 55 | for(int y = 0; y < lutRes; y++) { 56 | if (n){ 57 | colorlut.setColor(x, y, ofColor( 58 | ofClamp(curvesTools.at(1)->getLut(x), 0, lutRes-1), 59 | ofClamp(curvesTools.at(2)->getLut(x), 0, lutRes-1), 60 | ofClamp(curvesTools.at(3)->getLut(x), 0, lutRes-1), 61 | ofClamp(curvesTools.at(0)->getLut(x), 0, lutRes-1))); 62 | } 63 | } 64 | } 65 | 66 | colorlut.update(); 67 | } 68 | 69 | void Curves::draw(int x, int y) { 70 | if(show || enabled) { 71 | curvesTools.at(colorMode)->draw(x,y); 72 | } 73 | } 74 | 75 | void Curves::keyPressed(int key) { 76 | 77 | if(key == OF_KEY_UP) { 78 | incrementPoint(1); 79 | } 80 | else if(key == OF_KEY_DOWN) { 81 | incrementPoint(-1); 82 | } 83 | 84 | update(); 85 | } 86 | 87 | void Curves::incrementPoint(float inc) { 88 | int cpnt = curvesTools.at(colorMode)->getCurrentHover(); 89 | curvesTools.at(colorMode)->set(cpnt, 90 | ofVec2f( curvesTools.at(colorMode)->getPoint(cpnt).x, 91 | curvesTools.at(colorMode)->getPoint(cpnt).y + inc)); 92 | } 93 | 94 | void Curves::prevPoint() { 95 | curvesTools.at(colorMode)->prevPoint(); 96 | } 97 | 98 | void Curves::nextPoint() { 99 | curvesTools.at(colorMode)->nextPoint(); 100 | } 101 | 102 | void Curves::load(int projectorStartingIndex) { 103 | xml->clear(); 104 | xml->load("settings/color/color-"+ofToString(index+1+projectorStartingIndex)+".xml"); 105 | 106 | xml->setTo("projector"); 107 | 108 | int n = xml->getNumChildren(); 109 | 110 | for(int i = 0; i < n; i++) { 111 | xml->setToChild(i); 112 | curvesTools.at(i)->clear(); 113 | 114 | int nn = xml->getNumChildren(); 115 | 116 | for(int j = 0; j < nn; j++) { 117 | if (xml->exists("point["+ofToString(j)+"][@xy]")) { 118 | string str = xml->getAttribute("point["+ofToString(j)+"][@xy]"); 119 | int x = ofToInt(ofSplitString(str, ",")[0]); 120 | int y = ofToInt(ofSplitString(str, ",")[1]); 121 | curvesTools.at(i)->add(ofVec2f(x,y)); 122 | } 123 | } 124 | xml->setToParent(); 125 | } 126 | 127 | update(); 128 | } 129 | 130 | void Curves::save(int projectorStartingIndex) { 131 | xml->clear(); 132 | xml->addChild("projector"); 133 | xml->setTo("projector"); 134 | 135 | for(int i = 0; i < 4; i++) { 136 | xml->addChild("curve"); 137 | xml->setToChild(i); 138 | 139 | if (i == GREY) 140 | xml->setAttribute("color", "grey"); 141 | if (i == RED) 142 | xml->setAttribute("color", "red"); 143 | if (i == GREEN) 144 | xml->setAttribute("color", "green"); 145 | if (i == BLUE) 146 | xml->setAttribute("color", "blue"); 147 | 148 | vector pnts = curvesTools.at(i)->getControlPoints(); 149 | 150 | for(int j = 0; j < pnts.size(); j++) { 151 | xml->addChild("point"); 152 | xml->setToChild(j); 153 | xml->setAttribute("xy", ofToString(pnts[j].x) + "," + ofToString(pnts[j].y)); 154 | xml->setToParent(); 155 | } 156 | xml->setToParent(); 157 | } 158 | xml->setToParent(); 159 | 160 | xml->save("settings/color/color-"+ofToString(index+1+projectorStartingIndex)+".xml"); 161 | } 162 | 163 | int Curves::getCurrentHover() { 164 | return curvesTools.at(colorMode)->getCurrentHover(); 165 | } 166 | 167 | void Curves::setCurrentHover(int i) { 168 | curvesTools.at(colorMode)->setCurrentHover(i); 169 | } 170 | 171 | int Curves::getColorMode() { 172 | return colorMode; 173 | } 174 | void Curves::setColorMode(int i) { 175 | colorMode = i; 176 | } 177 | 178 | ofTexture & Curves::colorlutTextureRef() { 179 | return colorlut.getTexture(); 180 | } 181 | 182 | void Curves::setLabelPosition() { 183 | curvesTools.at(colorMode)->setLabelPosition(); 184 | } 185 | void Curves::setLabelPosition(int x, int y) { 186 | curvesTools.at(colorMode)->setLabelPosition(x,y); 187 | } 188 | 189 | void Curves::setActive(bool b) { 190 | active = b; 191 | } 192 | 193 | void Curves::setPoint(int i, ofPoint p){ 194 | curvesTools.at(colorMode)->set(i,p); 195 | } 196 | 197 | } -------------------------------------------------------------------------------- /src/vdome/menu/socket.cpp: -------------------------------------------------------------------------------- 1 | #include "socket.h" 2 | namespace vd { 3 | ofEvent Socket::sourceEvent = ofEvent(); 4 | ofEvent Socket::formatEvent = ofEvent(); 5 | 6 | /****************************************** 7 | 8 | CONSTRUCTOR 9 | 10 | ********************************************/ 11 | 12 | Socket::Socket(){ 13 | enabled = true; 14 | host = "localhost"; 15 | send = 3333; 16 | receive = 3334; 17 | } 18 | 19 | /****************************************** 20 | 21 | SETUP 22 | 23 | ********************************************/ 24 | 25 | void Socket::setup(){ 26 | oscSender.setup(host,send); 27 | oscReceiver.setup(receive); 28 | } 29 | 30 | /****************************************** 31 | 32 | UPDATE 33 | 34 | ********************************************/ 35 | 36 | void Socket::update(){ 37 | 38 | // receive 39 | while(oscReceiver.hasWaitingMessages()){ 40 | rMsg.clear(); 41 | oscReceiver.getNextMessage(&rMsg); 42 | 43 | if (rMsg.getAddress() == "/input/"){ 44 | if (rMsg.getArgAsString(0) == "play") 45 | input->play(); 46 | else if (rMsg.getArgAsString(0) == "stop") 47 | input->stop(); 48 | } 49 | else if (rMsg.getAddress() == "/input/loop/") { 50 | if (rMsg.getArgAsString(0) == "on") 51 | input->setLoop(true); 52 | else 53 | input->setLoop(false); 54 | } 55 | else if (rMsg.getAddress() == "/input/seek/") { 56 | input->seek(ofToFloat(rMsg.getArgAsString(0))); 57 | } 58 | else if (rMsg.getAddress() == "/input/source/") { 59 | int s = input->convertSourceString(rMsg.getArgAsString(0)); 60 | ofNotifyEvent(sourceEvent,s,this); 61 | } 62 | else if (rMsg.getAddress() == "/input/file/") { 63 | ofFile oFile; 64 | oFile.open(rMsg.getArgAsString(0)); 65 | string file = oFile.getAbsolutePath(); 66 | input->openFile(file); 67 | } 68 | else if (rMsg.getAddress() == "/input/volume/") { 69 | input->setVolume(ofToFloat(rMsg.getArgAsString(0))); 70 | } 71 | else if (rMsg.getAddress() == "/input/format/") { 72 | int s = input->convertFormatString(rMsg.getArgAsString(0)); 73 | ofNotifyEvent(formatEvent,s,this); 74 | } 75 | 76 | // transform 77 | else if (rMsg.getAddress() == "/input/flip/") { 78 | string s = rMsg.getArgAsString(0); 79 | 80 | if (rMsg.getArgAsString(0) == "on") 81 | model->setTextureFlip(true); 82 | else 83 | model->setTextureFlip(false); 84 | } 85 | else if (rMsg.getAddress() == "/input/scale/") { 86 | float f = ofToFloat(rMsg.getArgAsString(0)); 87 | model->setTextureScale(f); 88 | } 89 | else if (rMsg.getAddress() == "/input/rotate/") { 90 | float f = ofToFloat(rMsg.getArgAsString(0)); 91 | model->setTextureRotate(f); 92 | } 93 | else if (rMsg.getAddress() == "/input/tilt/") { 94 | float f = ofToFloat(rMsg.getArgAsString(0)); 95 | model->setTextureTilt(f); 96 | } 97 | } 98 | 99 | // send 100 | sMsg.clear(); 101 | if (input->getSourceInt() == input->MEDIA) { 102 | if (lastInputPosition != input->getPosition()){ 103 | sMsg.setAddress("/input/position"); 104 | sMsg.addStringArg(ofToString( input->getPosition() )); 105 | oscSender.sendMessage(sMsg); 106 | } 107 | lastInputPosition = input->getPosition(); 108 | } 109 | 110 | } 111 | 112 | 113 | /****************************************** 114 | 115 | SEND 116 | 117 | ********************************************/ 118 | 119 | void Socket::sendDuration(){ 120 | sMsg.clear(); 121 | sMsg.setAddress("/input/duration"); 122 | sMsg.addStringArg(input->getFilepath() + "," + ofToString( input->getDuration() )); 123 | oscSender.sendMessage(sMsg); 124 | } 125 | 126 | void Socket::sendEnd(){ 127 | sMsg.clear(); 128 | sMsg.setAddress("/input/"); 129 | sMsg.addStringArg("end"); 130 | oscSender.sendMessage(sMsg); 131 | } 132 | 133 | /****************************************** 134 | 135 | SETTINGS 136 | 137 | ********************************************/ 138 | 139 | void Socket::loadXML(ofXml &xml) { 140 | if (xml.exists("socket[@enabled]")) { 141 | string str = ofToString(xml.getAttribute("socket[@enabled]")); 142 | if (str == "on") enabled = true; 143 | else enabled = false; 144 | } 145 | 146 | if (xml.exists("socket[@host]")) 147 | host = ofToString( xml.getAttribute("socket[@host]") ); 148 | if (xml.exists("socket[@send]")) 149 | send = ofToInt( xml.getAttribute("socket[@send]") ); 150 | if (xml.exists("socket[@receive]")) 151 | receive = ofToInt( xml.getAttribute("socket[@receive]") ); 152 | 153 | if (enabled) 154 | setup(); 155 | } 156 | 157 | void Socket::saveXML(ofXml &xml) { 158 | xml.setTo("socket"); 159 | 160 | if (enabled) xml.setAttribute("enabled", "on"); 161 | else xml.setAttribute("enabled", "off"); 162 | 163 | xml.setAttribute("host", ofToString(host)); 164 | xml.setAttribute("send", ofToString(send)); 165 | xml.setAttribute("receive", ofToString(receive)); 166 | 167 | xml.setToParent(); 168 | } 169 | 170 | } 171 | -------------------------------------------------------------------------------- /src/vdome/renderer/projector/mask.cpp: -------------------------------------------------------------------------------- 1 | #include "mask.h" 2 | namespace vd { 3 | 4 | extern int maxHistory; 5 | extern vector maskHistory; 6 | 7 | /****************************************** 8 | 9 | CONSTRUCTOR 10 | 11 | ********************************************/ 12 | 13 | Mask::Mask(){ 14 | erase = false; 15 | 16 | mouseX = 0; 17 | mouseY = 0; 18 | 19 | tx = 0; 20 | ty = 0; 21 | 22 | mouseDown = false; 23 | maskFboImage = new ofImage(); 24 | brushImage.setUseTexture(true); 25 | brushImage.setImageType(OF_IMAGE_COLOR_ALPHA); 26 | brushImage.load("settings/brushes/brush.png"); 27 | brushWidth = brushImage.getWidth(); 28 | brushHeight = brushImage.getHeight(); 29 | brushScale = 1; 30 | brushOpacity = 50; 31 | 32 | brush = ofMesh::plane(brushWidth, brushHeight, 2, 2, OF_PRIMITIVE_TRIANGLES); 33 | 34 | hIndex = 0; 35 | bufferAllocated = false; 36 | } 37 | 38 | /****************************************** 39 | 40 | INIT 41 | 42 | ********************************************/ 43 | 44 | void Mask::init(int i){ 45 | pIndex = i; 46 | } 47 | 48 | /****************************************** 49 | 50 | SETUP 51 | 52 | ********************************************/ 53 | 54 | void Mask::setup(){ 55 | 56 | if (maskFbo.getWidth() != width || maskFbo.getHeight() != height) 57 | maskFbo.allocate(width, height, GL_RGBA32F_ARB); 58 | 59 | maskFbo.begin(); 60 | ofClear(255,255,255,0); 61 | maskFbo.end(); 62 | 63 | if (maskFboImage->isAllocated()) { 64 | ofDisableAlphaBlending(); 65 | ofDisableNormalizedTexCoords(); 66 | maskFbo.begin(); 67 | ofSetColor(255, 255, 255, 255); 68 | maskFboImage->draw(0,0, width, height); 69 | maskFbo.end(); 70 | ofEnableNormalizedTexCoords(); 71 | ofEnableAlphaBlending(); 72 | } 73 | } 74 | 75 | /****************************************** 76 | 77 | DRAW 78 | 79 | ********************************************/ 80 | 81 | void Mask::draw(){ 82 | if (mouseDown) { 83 | 84 | if (erase) 85 | ofEnableBlendMode(OF_BLENDMODE_SUBTRACT); 86 | else 87 | ofEnableBlendMode(OF_BLENDMODE_SCREEN); 88 | 89 | maskFbo.begin(); 90 | brushImage.bind(); 91 | ofSetColor(brushOpacity, brushOpacity, brushOpacity, brushOpacity); 92 | ofPushMatrix(); 93 | ofTranslate(mouseX-tx, mouseY); 94 | ofScale(brushScale, brushScale); 95 | brush.draw(); 96 | ofPopMatrix(); 97 | brushImage.unbind(); 98 | maskFbo.end(); 99 | 100 | ofDisableBlendMode(); 101 | ofEnableBlendMode(OF_BLENDMODE_ALPHA); 102 | } 103 | } 104 | 105 | /****************************************** 106 | 107 | MOUSE 108 | 109 | ********************************************/ 110 | 111 | void Mask::mousePressed(ofMouseEventArgs& mouseArgs){ 112 | mouseDown = true; 113 | mouseX = mouseArgs.x; 114 | mouseY = mouseArgs.y; 115 | if (hIndex >= (maxHistory+2) ) 116 | hIndex = 0; 117 | store(hIndex); 118 | } 119 | 120 | void Mask::mouseDragged(ofMouseEventArgs& mouseArgs){ 121 | mouseX = mouseArgs.x; 122 | mouseY = mouseArgs.y; 123 | } 124 | 125 | void Mask::mouseReleased(ofMouseEventArgs& mouseArgs){ 126 | mouseDown = false; 127 | } 128 | 129 | /****************************************** 130 | 131 | KEYBOARD 132 | 133 | ********************************************/ 134 | 135 | void Mask::keyPressed(int key){ 136 | if (key == OF_KEY_CONTROL || key == OF_KEY_COMMAND) { 137 | erase = true; 138 | } 139 | } 140 | 141 | void Mask::keyReleased(int key){ 142 | if (key == OF_KEY_CONTROL || key == OF_KEY_COMMAND) { 143 | erase = false; 144 | } 145 | } 146 | 147 | /****************************************** 148 | 149 | SETTINGS 150 | 151 | ********************************************/ 152 | 153 | void Mask::load(int projectorStartingIndex){ 154 | string filename; 155 | filename = "settings/masks/mask-" + ofToString(pIndex+1+projectorStartingIndex) + ".png"; 156 | read(filename); 157 | } 158 | 159 | void Mask::save(int projectorStartingIndex){ 160 | string filename; 161 | filename = "settings/masks/mask-" + ofToString(pIndex+1+projectorStartingIndex) + ".png"; 162 | write(filename); 163 | } 164 | 165 | void Mask::write(string filename){ 166 | maskFboPixels.clear(); 167 | maskFbo.readToPixels(maskFboPixels); 168 | maskFboImage->setFromPixels(maskFboPixels); 169 | } 170 | 171 | void Mask::read(string filename){ 172 | maskFboImage->clear(); 173 | if (maskFboImage->load(filename)) 174 | setup(); 175 | } 176 | 177 | int Mask::store(int fIndex) { 178 | hIndex = fIndex; 179 | hPixels.clear(); 180 | maskFbo.readToPixels(hPixels); 181 | hPixels.pasteInto(maskHistory[fIndex], 0, 0); 182 | return fIndex; 183 | } 184 | 185 | void Mask::recall(int fIndex) { 186 | maskFboImage->clear(); 187 | maskFboImage->setFromPixels(maskHistory[fIndex]); 188 | setup(); 189 | } 190 | 191 | /****************************************** 192 | 193 | RESET 194 | 195 | ********************************************/ 196 | 197 | void Mask::reset(){ 198 | maskFbo.begin(); 199 | ofClear(255,255,255,0); 200 | maskFbo.end(); 201 | } 202 | 203 | } 204 | -------------------------------------------------------------------------------- /src/vdome/renderer/model.cpp: -------------------------------------------------------------------------------- 1 | #include "model.h" 2 | #include 3 | #include 4 | #include 5 | #include "commands.h" 6 | 7 | namespace vd { 8 | 9 | extern int maxHistory; 10 | extern CommandHistory history; 11 | extern vector maskHistory; 12 | 13 | /****************************************** 14 | 15 | CONSTRUCTOR 16 | 17 | ********************************************/ 18 | 19 | Model::Model(){ 20 | radius = 10; 21 | N = 128; // Mesh resolution, must be multiple of 4 22 | textureScale = 1; 23 | textureFlip = false; 24 | textureRotate = 0; 25 | textureTilt = 0; 26 | textureFlipInternal = false; 27 | textureScaleInternal = 1; 28 | textureTiltInternal = 0; 29 | textureScaleInternalW = 1; 30 | textureScaleInternalH = 1; 31 | } 32 | 33 | /****************************************** 34 | 35 | SETUP 36 | 37 | ********************************************/ 38 | 39 | void Model::setup(){ 40 | int i,j,index = 0; 41 | int i1,i2,i3,i4; 42 | double theta,phi,r; 43 | double len; 44 | double x; 45 | double y; 46 | double z; 47 | double nx; 48 | double ny; 49 | double nz; 50 | double u; 51 | double v; 52 | vbo.clear(); 53 | vbo.enableTextures(); 54 | vbo.enableNormals(); 55 | 56 | vbo.addVertex(ofVec3f(0,0,0)); 57 | vbo.addNormal(ofVec3f(0,0,0)); 58 | vbo.addTexCoord(ofVec2f(0,0)); 59 | 60 | for (j=0;j<=N/4;j++) { 61 | for (i=0;i<=N;i++) { 62 | theta = i * 2 * PI / N; 63 | phi = PI/2 - PI/2 * j / (N/4); 64 | x = radius * cos(phi) * cos(theta); 65 | y = radius * cos(phi) * sin(theta); 66 | z = radius * sin(phi); 67 | vbo.addVertex(ofVec3f(x,y,z)); 68 | 69 | len = sqrt(x*x + y*y + z*z); 70 | nx = x/len; 71 | ny = y/len; 72 | nz = z/len; 73 | vbo.addNormal(ofVec3f(nx,ny,nz)); 74 | 75 | phi = atan2(sqrt(x*x+y*y),z); // 0 ... pi/2 76 | theta = atan2(y,x); // -pi ... pi 77 | r = phi / PI/2 * 4 / (textureScale*textureScaleInternal*textureScaleInternalW*textureScaleInternalH); // 0 ... 1 ---> 78 | u = 0.5 * (r*textureScaleInternalH * cos(theta) + 1); 79 | v = 0.5 * (r*textureScaleInternalW * sin(theta) + 1); 80 | 81 | if (textureFlipInternal){ 82 | if (textureFlip) 83 | vbo.addTexCoord(ofVec2f(u,1-v)); 84 | else 85 | vbo.addTexCoord(ofVec2f(u,v)); 86 | } 87 | else { 88 | if (textureFlip) 89 | vbo.addTexCoord(ofVec2f(u,v)); 90 | else 91 | vbo.addTexCoord(ofVec2f(u,1-v)); // reverse 92 | } 93 | index++; 94 | } 95 | } 96 | 97 | for (j=0;j 39 | #include 40 | 41 | SpoutSharedMemory::SpoutSharedMemory() 42 | { 43 | m_pBuffer = NULL; 44 | m_hMutex = NULL; 45 | m_hMap = NULL; 46 | m_pName = NULL; 47 | m_size = 0; 48 | m_lockCount = 0; 49 | } 50 | 51 | SpoutSharedMemory::~SpoutSharedMemory() 52 | { 53 | Close(); 54 | } 55 | 56 | SpoutCreateResult SpoutSharedMemory::Create(const char* name, int size) 57 | { 58 | DWORD err; 59 | 60 | // Don't call open twice on the same object without a Close() 61 | assert(name); 62 | assert(size); 63 | 64 | if (m_hMap) 65 | { 66 | assert(strcmp(name, m_pName) == 0); 67 | assert(m_pBuffer && m_hMutex); 68 | return SPOUT_ALREADY_CREATED; 69 | } 70 | 71 | m_hMap = CreateFileMappingA ( INVALID_HANDLE_VALUE, 72 | NULL, 73 | PAGE_READWRITE, 74 | 0, 75 | size, 76 | (LPCSTR)name); 77 | 78 | if (m_hMap == NULL) 79 | { 80 | return SPOUT_CREATE_FAILED; 81 | } 82 | 83 | 84 | err = GetLastError(); 85 | 86 | bool alreadyExists = false; 87 | if (err == ERROR_ALREADY_EXISTS) 88 | { 89 | alreadyExists = true; 90 | // We should ensure the already existing mapping is at least 91 | // the size we expect 92 | // LJ - GetFileSizeEx and GetFileSize do not work 93 | } 94 | 95 | m_pBuffer = (char*)MapViewOfFile(m_hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0); 96 | 97 | 98 | if (!m_pBuffer) 99 | { 100 | Close(); 101 | return SPOUT_CREATE_FAILED; 102 | } 103 | 104 | std::string mutexName; 105 | mutexName = name; 106 | mutexName += "_mutex"; 107 | 108 | m_hMutex = CreateMutexA(NULL, FALSE, mutexName.c_str()); 109 | 110 | if (!m_hMutex) 111 | { 112 | Close(); 113 | return SPOUT_CREATE_FAILED; 114 | } 115 | 116 | // m_pName = strdup(name); 117 | m_pName = _strdup(name); 118 | m_size = size; 119 | 120 | return alreadyExists ? SPOUT_ALREADY_EXISTS : SPOUT_CREATE_SUCCESS; 121 | 122 | } 123 | 124 | 125 | bool SpoutSharedMemory::Open(const char* name) 126 | { 127 | // Don't call open twice on the same object without a Close() 128 | assert(name); 129 | 130 | if (m_hMap) 131 | { 132 | assert(strcmp(name, m_pName) == 0); 133 | assert(m_pBuffer && m_hMutex); 134 | return true; 135 | } 136 | 137 | m_hMap = OpenFileMappingA ( FILE_MAP_ALL_ACCESS, 138 | FALSE, 139 | (LPCSTR)name); 140 | 141 | if (m_hMap == NULL) 142 | { 143 | return false; 144 | } 145 | 146 | 147 | DWORD err = GetLastError(); 148 | 149 | if (err == ERROR_ALREADY_EXISTS) 150 | { 151 | // We should ensure the already existing mapping is at least 152 | // the size we expect 153 | } 154 | 155 | m_pBuffer = (char*)MapViewOfFile(m_hMap, FILE_MAP_ALL_ACCESS, 0, 0, 0); 156 | 157 | 158 | if (!m_pBuffer) 159 | { 160 | Close(); 161 | return false; 162 | } 163 | 164 | std::string mutexName; 165 | mutexName = name; 166 | mutexName += "_mutex"; 167 | 168 | m_hMutex = CreateMutexA(NULL, FALSE, mutexName.c_str()); 169 | 170 | if (!m_hMutex) 171 | { 172 | Close(); 173 | return false; 174 | } 175 | 176 | // m_pName = strdup(name); 177 | m_pName = _strdup(name); 178 | m_size = 0; 179 | 180 | return true; 181 | 182 | } 183 | 184 | void 185 | SpoutSharedMemory::Close() 186 | { 187 | if (m_hMutex) 188 | { 189 | CloseHandle(m_hMutex); 190 | m_hMutex = NULL; 191 | } 192 | 193 | if (m_pBuffer) 194 | { 195 | UnmapViewOfFile((LPCVOID)m_pBuffer); 196 | m_pBuffer = NULL; 197 | } 198 | 199 | if (m_hMap) 200 | { 201 | CloseHandle(m_hMap); 202 | m_hMap = NULL; 203 | } 204 | if (m_pName) 205 | { 206 | free((void*)m_pName); 207 | m_pName = NULL; 208 | } 209 | m_size = 0; 210 | m_lockCount = 0; 211 | } 212 | 213 | char* SpoutSharedMemory::Lock() 214 | { 215 | 216 | // ------------------------------ 217 | // LJ DEBUG - disable for testing 218 | // assert(m_pBuffer); 219 | // return m_pBuffer; 220 | // ------------------------------ 221 | 222 | assert(m_lockCount >= 0); 223 | 224 | assert(m_hMutex); 225 | if (m_lockCount > 0) 226 | { 227 | assert(m_pBuffer); 228 | m_lockCount++; 229 | return m_pBuffer; 230 | } 231 | 232 | DWORD waitResult = WaitForSingleObject(m_hMutex, 67); 233 | 234 | if (waitResult != WAIT_OBJECT_0) 235 | { 236 | return NULL; 237 | } 238 | 239 | m_lockCount++; 240 | assert(m_pBuffer); 241 | return m_pBuffer; 242 | } 243 | 244 | void SpoutSharedMemory::Unlock() 245 | { 246 | // ------------------------------ 247 | // LJ DEBUG - disable for testing 248 | // return; 249 | // ------------------------------ 250 | 251 | assert(m_hMutex); 252 | 253 | m_lockCount--; 254 | assert(m_lockCount >= 0); 255 | 256 | if (m_lockCount == 0) 257 | { 258 | ReleaseMutex(m_hMutex); 259 | } 260 | } 261 | 262 | 263 | void SpoutSharedMemory::Debug() 264 | { 265 | /* 266 | if (m_pName) { 267 | printf("(%s) m_hMap = [%x], m_pBuffer = [%x]\n", m_pName, m_hMap, m_pBuffer); 268 | } 269 | else { 270 | printf("Shared Memory Map is not open\n"); 271 | } 272 | */ 273 | } 274 | -------------------------------------------------------------------------------- /config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutSender.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // SpoutSender 3 | // 4 | // Wrapper class so that a sender object can be created independent of a receiver 5 | // 6 | // ==================================================================================== 7 | // Revisions : 8 | // 9 | // 23.09.14 - return DirectX 11 capability in SetDX9 10 | // 28.09.14 - Added GL format for SendImage 11 | // - Added bAlignment (4 byte alignment) flag for SendImage 12 | // - Added Host FBO for SendTexture, DrawToSharedTexture 13 | // 08.02.15 - Changed default texture format for SendImage in header to GL_RGBA 14 | // 29.05.15 - Included SetAdapter for multiple adapters - Franz Hildgen. 15 | // 02.06.15 - Added GetAdapter, GetNumAdapters, GetAdapterName 16 | // 08.06.15 - Added SelectSenderPanel for user adapter output selection 17 | // ==================================================================================== 18 | /* 19 | 20 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 21 | 22 | Redistribution and use in source and binary forms, with or without modification, 23 | are permitted provided that the following conditions are met: 24 | 25 | 1. Redistributions of source code must retain the above copyright notice, 26 | this list of conditions and the following disclaimer. 27 | 28 | 2. Redistributions in binary form must reproduce the above copyright notice, 29 | this list of conditions and the following disclaimer in the documentation 30 | and/or other materials provided with the distribution. 31 | 32 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 33 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 34 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 36 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 37 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 39 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | 42 | */ 43 | #include "SpoutSender.h" 44 | 45 | SpoutSender::SpoutSender() 46 | { 47 | 48 | } 49 | 50 | 51 | //--------------------------------------------------------- 52 | SpoutSender::~SpoutSender() 53 | { 54 | 55 | } 56 | 57 | 58 | 59 | //--------------------------------------------------------- 60 | bool SpoutSender::CreateSender(char *name, unsigned int width, unsigned int height, DWORD dwFormat) 61 | { 62 | return spout.CreateSender(name, width, height, dwFormat); 63 | } 64 | 65 | 66 | //--------------------------------------------------------- 67 | bool SpoutSender::UpdateSender(char *name, unsigned int width, unsigned int height) 68 | { 69 | return spout.UpdateSender(name, width, height); 70 | } 71 | 72 | 73 | //--------------------------------------------------------- 74 | void SpoutSender::ReleaseSender(DWORD dwMsec) 75 | { 76 | spout.ReleaseSender(dwMsec); 77 | } 78 | 79 | 80 | //--------------------------------------------------------- 81 | bool SpoutSender::SendImage(unsigned char* pixels, unsigned int width, unsigned int height, GLenum glFormat, bool bAlignment, bool bInvert) 82 | { 83 | return spout.SendImage(pixels, width, height, glFormat, bAlignment, bInvert); 84 | } 85 | 86 | //--------------------------------------------------------- 87 | bool SpoutSender::SendTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, bool bInvert, GLuint HostFBO) 88 | { 89 | return spout.SendTexture(TextureID, TextureTarget, width, height, bInvert, HostFBO); 90 | } 91 | 92 | //--------------------------------------------------------- 93 | bool SpoutSender::DrawToSharedTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, float max_x, float max_y, float aspect, bool bInvert, GLuint HostFBO) 94 | { 95 | return spout.DrawToSharedTexture(TextureID, TextureTarget, width, height, max_x, max_y, aspect, bInvert, HostFBO); 96 | } 97 | 98 | //--------------------------------------------------------- 99 | bool SpoutSender::SelectSenderPanel(const char* message) 100 | { 101 | return spout.SelectSenderPanel(message); 102 | } 103 | 104 | 105 | //--------------------------------------------------------- 106 | bool SpoutSender::GetMemoryShareMode() 107 | { 108 | return spout.GetMemoryShareMode(); 109 | } 110 | 111 | 112 | //--------------------------------------------------------- 113 | bool SpoutSender::SetMemoryShareMode(bool bMemoryMode) 114 | { 115 | return spout.SetMemoryShareMode(bMemoryMode); 116 | } 117 | 118 | 119 | //--------------------------------------------------------- 120 | bool SpoutSender::SetDX9(bool bDX9) 121 | { 122 | // printf("spoutSender::SetDX9(%d)\n", bDX9); 123 | return spout.SetDX9(bDX9); 124 | } 125 | 126 | 127 | //--------------------------------------------------------- 128 | bool SpoutSender::GetDX9() 129 | { 130 | return spout.interop.isDX9(); 131 | } 132 | 133 | //--------------------------------------------------------- 134 | void SpoutSender::SetDX9compatible(bool bCompatible) 135 | { 136 | if(bCompatible) { 137 | // DX11 -> DX9 only works if the DX11 format is set to DXGI_FORMAT_B8G8R8A8_UNORM 138 | spout.interop.SetDX11format(DXGI_FORMAT_B8G8R8A8_UNORM); 139 | } 140 | else { 141 | // DX11 -> DX11 only 142 | spout.interop.SetDX11format(DXGI_FORMAT_R8G8B8A8_UNORM); 143 | } 144 | } 145 | 146 | 147 | //--------------------------------------------------------- 148 | bool SpoutSender::GetDX9compatible() 149 | { 150 | if(spout.interop.DX11format == DXGI_FORMAT_B8G8R8A8_UNORM) 151 | return true; 152 | else 153 | return false; 154 | 155 | } 156 | 157 | //--------------------------------------------------------- 158 | bool SpoutSender::SetAdapter(int index) 159 | { 160 | return spout.SetAdapter(index); 161 | } 162 | 163 | // Get current adapter index 164 | int SpoutSender::GetAdapter() 165 | { 166 | return spout.GetAdapter(); 167 | } 168 | 169 | // Get the number of graphics adapters in the system 170 | int SpoutSender::GetNumAdapters() 171 | { 172 | return spout.GetNumAdapters(); 173 | } 174 | 175 | // Get an adapter name 176 | bool SpoutSender::GetAdapterName(int index, char *adaptername, int maxchars) 177 | { 178 | return spout.GetAdapterName(index, adaptername, maxchars); 179 | } 180 | 181 | 182 | //--------------------------------------------------------- 183 | bool SpoutSender::SetVerticalSync(bool bSync) 184 | { 185 | return spout.interop.SetVerticalSync(bSync); 186 | } 187 | 188 | //--------------------------------------------------------- 189 | int SpoutSender::GetVerticalSync() 190 | { 191 | return spout.interop.GetVerticalSync(); 192 | } 193 | 194 | //------------------ debugging aid only -------------------- 195 | bool SpoutSender::SenderDebug(char *Sendername, int size) 196 | { 197 | return spout.interop.senders.SenderDebug(Sendername, size); 198 | 199 | } -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutReceiver.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // SpoutReceiver 3 | // 4 | // Wrapper class so that a receiver object can be created independent of a sender 5 | // 6 | // ==================================================================================== 7 | // Revisions : 8 | // 9 | // 27-07-14 - CreateReceiver - bUseActive flag instead of null name 10 | // 03.09.14 - Cleanup 11 | // 23.09.14 - return DirectX 11 capability in SetDX9 12 | // 28.09.14 - Added Host FBO for ReceiveTexture 13 | // 12.10.14 - changed SelectSenderPanel arg to const char 14 | // 23.12.14 - added host fbo arg to ReceiveImage 15 | // 08.02.15 - Changed default texture format for ReceiveImage in header to GL_RGBA 16 | // 29.05.15 - Included SetAdapter for multiple adapters - Franz Hildgen. 17 | // 02.06.15 - Added GetAdapter, GetNumAdapters, GetAdapterName 18 | // 19 | // ==================================================================================== 20 | /* 21 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 22 | 23 | Redistribution and use in source and binary forms, with or without modification, 24 | are permitted provided that the following conditions are met: 25 | 26 | 1. Redistributions of source code must retain the above copyright notice, 27 | this list of conditions and the following disclaimer. 28 | 29 | 2. Redistributions in binary form must reproduce the above copyright notice, 30 | this list of conditions and the following disclaimer in the documentation 31 | and/or other materials provided with the distribution. 32 | 33 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 34 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 35 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 36 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 37 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 38 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 39 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 40 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 41 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | 43 | */ 44 | #include "SpoutReceiver.h" 45 | 46 | SpoutReceiver::SpoutReceiver() 47 | { 48 | 49 | } 50 | 51 | 52 | //--------------------------------------------------------- 53 | SpoutReceiver::~SpoutReceiver() 54 | { 55 | 56 | } 57 | 58 | 59 | //--------------------------------------------------------- 60 | bool SpoutReceiver::ReceiveTexture(char* name, unsigned int &width, unsigned int &height, GLuint TextureID, GLuint TextureTarget, bool bInvert, GLuint HostFBO) 61 | { 62 | return spout.ReceiveTexture(name, width, height, TextureID, TextureTarget, bInvert, HostFBO); 63 | } 64 | 65 | 66 | //--------------------------------------------------------- 67 | bool SpoutReceiver::ReceiveImage(char* name, unsigned int &width, unsigned int &height, unsigned char* pixels, GLenum glFormat, GLuint HostFBO) 68 | { 69 | return spout.ReceiveImage(name, width, height, pixels, glFormat, HostFBO); 70 | } 71 | 72 | 73 | //--------------------------------------------------------- 74 | bool SpoutReceiver::GetImageSize(char* name, unsigned int &width, unsigned int &height, bool &bMemoryMode) 75 | { 76 | return spout.GetImageSize(name, width, height, bMemoryMode); 77 | } 78 | 79 | 80 | //--------------------------------------------------------- 81 | bool SpoutReceiver::CreateReceiver(char* name, unsigned int &width, unsigned int &height, bool bUseActive) 82 | { 83 | return spout.CreateReceiver(name, width, height, bUseActive); 84 | } 85 | 86 | //--------------------------------------------------------- 87 | void SpoutReceiver::ReleaseReceiver() 88 | { 89 | spout.ReleaseReceiver(); 90 | } 91 | 92 | 93 | //--------------------------------------------------------- 94 | bool SpoutReceiver::BindSharedTexture() 95 | { 96 | return spout.BindSharedTexture(); 97 | } 98 | 99 | 100 | //--------------------------------------------------------- 101 | bool SpoutReceiver::UnBindSharedTexture() 102 | { 103 | return spout.UnBindSharedTexture(); 104 | } 105 | 106 | 107 | //--------------------------------------------------------- 108 | int SpoutReceiver::GetSenderCount() 109 | { 110 | return spout.GetSenderCount(); 111 | } 112 | 113 | //--------------------------------------------------------- 114 | bool SpoutReceiver::DrawSharedTexture(float max_x, float max_y, float aspect, bool bInvert) 115 | { 116 | return spout.DrawSharedTexture(max_x, max_y, aspect, bInvert); 117 | } 118 | 119 | 120 | //--------------------------------------------------------- 121 | bool SpoutReceiver::GetSenderName(int index, char* sendername, int MaxNameSize) 122 | { 123 | return spout.GetSenderName(index, sendername, MaxNameSize); 124 | } 125 | 126 | //--------------------------------------------------------- 127 | bool SpoutReceiver::GetActiveSender(char* Sendername) 128 | { 129 | return spout.GetActiveSender(Sendername); 130 | } 131 | 132 | 133 | //--------------------------------------------------------- 134 | bool SpoutReceiver::SetActiveSender(char* Sendername) 135 | { 136 | return spout.SetActiveSender(Sendername); 137 | } 138 | 139 | 140 | //--------------------------------------------------------- 141 | bool SpoutReceiver::GetSenderInfo(const char* sendername, unsigned int &width, unsigned int &height, HANDLE &dxShareHandle, DWORD &dwFormat) 142 | { 143 | return spout.GetSenderInfo(sendername, width, height, dxShareHandle, dwFormat); 144 | } 145 | 146 | 147 | //--------------------------------------------------------- 148 | bool SpoutReceiver::SelectSenderPanel(const char* message) 149 | { 150 | return spout.SelectSenderPanel(message); 151 | } 152 | 153 | //--------------------------------------------------------- 154 | bool SpoutReceiver::GetMemoryShareMode() 155 | { 156 | return spout.GetMemoryShareMode(); 157 | } 158 | 159 | 160 | //--------------------------------------------------------- 161 | bool SpoutReceiver::SetMemoryShareMode(bool bMemory) 162 | { 163 | return spout.SetMemoryShareMode(bMemory); 164 | } 165 | 166 | //--------------------------------------------------------- 167 | bool SpoutReceiver::SetDX9(bool bDX9) 168 | { 169 | return spout.interop.UseDX9(bDX9); 170 | } 171 | 172 | 173 | //--------------------------------------------------------- 174 | bool SpoutReceiver::GetDX9() 175 | { 176 | return spout.interop.isDX9(); 177 | } 178 | 179 | 180 | //--------------------------------------------------------- 181 | void SpoutReceiver::SetDX9compatible(bool bCompatible) 182 | { 183 | if(bCompatible) { 184 | // DX11 -> DX9 only works if the DX11 format is set to DXGI_FORMAT_B8G8R8A8_UNORM 185 | spout.interop.SetDX11format(DXGI_FORMAT_B8G8R8A8_UNORM); 186 | } 187 | else { 188 | // DX11 -> DX11 only 189 | spout.interop.SetDX11format(DXGI_FORMAT_R8G8B8A8_UNORM); 190 | } 191 | } 192 | 193 | 194 | //--------------------------------------------------------- 195 | bool SpoutReceiver::GetDX9compatible() 196 | { 197 | if(spout.interop.DX11format == DXGI_FORMAT_B8G8R8A8_UNORM) 198 | return true; 199 | else 200 | return false; 201 | } 202 | 203 | //--------------------------------------------------------- 204 | bool SpoutReceiver::SetAdapter(int index) 205 | { 206 | return spout.SetAdapter(index); 207 | } 208 | 209 | // Get current adapter index 210 | int SpoutReceiver::GetAdapter() 211 | { 212 | return spout.GetAdapter(); 213 | } 214 | 215 | // Get the number of graphics adapters in the system 216 | int SpoutReceiver::GetNumAdapters() 217 | { 218 | return spout.GetNumAdapters(); 219 | } 220 | 221 | // Get an adapter name 222 | bool SpoutReceiver::GetAdapterName(int index, char *adaptername, int maxchars) 223 | { 224 | return spout.GetAdapterName(index, adaptername, maxchars); 225 | } 226 | 227 | //--------------------------------------------------------- 228 | bool SpoutReceiver::SetVerticalSync(bool bSync) 229 | { 230 | return spout.interop.SetVerticalSync(bSync); 231 | } 232 | 233 | //--------------------------------------------------------- 234 | int SpoutReceiver::GetVerticalSync() 235 | { 236 | return spout.interop.GetVerticalSync(); 237 | } 238 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutSenderNames.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | spoutSenderNames.h 4 | Spout sender management 5 | 6 | LJ - leadedge@adam.com.au 7 | 8 | Thanks and credit to Malcolm Bechard for modifications to this class 9 | 10 | https://github.com/mbechard 11 | 12 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 13 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without modification, 16 | are permitted provided that the following conditions are met: 17 | 18 | 1. Redistributions of source code must retain the above copyright notice, 19 | this list of conditions and the following disclaimer. 20 | 21 | 2. Redistributions in binary form must reproduce the above copyright notice, 22 | this list of conditions and the following disclaimer in the documentation 23 | and/or other materials provided with the distribution. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 26 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 28 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | 35 | 36 | */ 37 | #pragma once 38 | #ifndef __spoutSenderNames__ // standard way as well 39 | #define __spoutSenderNames__ 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #include "SpoutCommon.h" 52 | #include "SpoutSharedMemory.h" 53 | 54 | #define SPOUT_WAIT_TIMEOUT 100 // 100 msec wait for events 55 | #define MaxSenders 10 // Max for list of Sender names 56 | #define SpoutMaxSenderNameLen 256 57 | 58 | // The texture information structure that is saved to shared memory 59 | // and used for communication between senders and receivers 60 | // unsigned __int32 is used for compatibility between 32bit and 64bit 61 | // See : http://msdn.microsoft.com/en-us/library/windows/desktop/aa384203%28v=vs.85%29.aspx 62 | // This is also compatible with wyphon : 63 | // The structure is declared here so that this class is can be independent of opengl 64 | struct SharedTextureInfo { 65 | unsigned __int32 shareHandle; 66 | unsigned __int32 width; 67 | unsigned __int32 height; 68 | DWORD format; // Texture pixel format 69 | DWORD usage; // not used 70 | wchar_t description[128]; // Wyhon compatible description (not used) 71 | unsigned __int32 partnerId; // Wyphon id of partner that shared it with us (not unused) 72 | }; 73 | 74 | using namespace std; 75 | 76 | class SPOUT_DLLEXP spoutSenderNames { 77 | 78 | public: 79 | 80 | spoutSenderNames(); 81 | ~spoutSenderNames(); 82 | 83 | // public functions 84 | 85 | // ------------------------------------------------------------ 86 | // You must first register a sender name being using 87 | // UpdateSender() to update it's texture information 88 | // TODO - revise functions 89 | bool RegisterSenderName(const char* senderName); 90 | bool ReleaseSenderName(const char* senderName); 91 | bool FindSenderName (const char* Sendername); 92 | 93 | // ------------------------------------------------------------ 94 | // Functions to retrieve info about the sender set map and the senders in it 95 | bool GetSenderNames (std::set *Sendernames); 96 | int GetSenderCount(); 97 | bool GetSenderNameInfo (int index, char* sendername, int sendernameMaxSize, unsigned int &width, unsigned int &height, HANDLE &dxShareHandle); 98 | 99 | // ------------------------------------------------------------ 100 | // Functions to read and write info to a sender memory map 101 | bool GetSenderInfo (const char* sendername, unsigned int &width, unsigned int &height, HANDLE &dxShareHandle, DWORD &dwFormat); 102 | bool SetSenderInfo (const char* sendername, unsigned int width, unsigned int height, HANDLE dxShareHandle, DWORD dwFormat); 103 | 104 | // Generic sender map info retrieval 105 | bool getSharedInfo (const char* SenderName, SharedTextureInfo* info); 106 | bool setSharedInfo (const char* SenderName, SharedTextureInfo* info); 107 | 108 | // ------------------------------------------------------------ 109 | // Functions to maintain the active sender 110 | bool SetActiveSender (const char* Sendername); 111 | bool GetActiveSender (char Sendername[SpoutMaxSenderNameLen]); 112 | bool GetActiveSenderInfo (SharedTextureInfo* info); 113 | bool FindActiveSender (char activename[SpoutMaxSenderNameLen], unsigned int &width, unsigned int &height, HANDLE &hSharehandle, DWORD &dwFormat); 114 | 115 | // ------------------------------------------------------------ 116 | // Functions to Create, Find or Update a sender without initializing DirectX or the GL/DX interop functions 117 | bool CreateSender (const char *sendername, unsigned int width, unsigned int height, HANDLE hSharehandle, DWORD dwFormat = 0); 118 | bool UpdateSender (const char *sendername, unsigned int width, unsigned int height, HANDLE hSharehandle, DWORD dwFormat = 0); 119 | bool FindSender (char *sendername, unsigned int &width, unsigned int &height, HANDLE &hSharehandle, DWORD &dwFormat); 120 | bool CheckSender (const char *sendername, unsigned int &width, unsigned int &height, HANDLE &hSharehandle, DWORD &dwFormat); 121 | // ------------------------------------------------------------ 122 | 123 | // Debug function 124 | bool SenderDebug (const char *Sendername, int size); 125 | 126 | protected: 127 | 128 | // Sender name set management 129 | bool CreateSenderSet(); 130 | bool GetSenderSet (std::set& SenderNames); 131 | 132 | // Active sender management 133 | bool setActiveSenderName (const char* SenderName); 134 | bool getActiveSenderName (char SenderName[SpoutMaxSenderNameLen]); 135 | 136 | 137 | // Goes through the full list of sender names and cleans up 138 | // any that shouldn't still be around 139 | void cleanSenderSet(); 140 | 141 | // ------------------------------------------------------------ 142 | // Functions to manage shared memory map access 143 | // 144 | // The way it works : 145 | // 146 | // Creating the map 147 | // A map with a given name and size is created (CreateMap) 148 | // This map is local to this instance and each instance will manage it's own list of senders 149 | // Within this function a matching named mutex is created (CreateMapLock) to lock and unlock access to the map 150 | // 151 | // Using the map 152 | // The required, named map is locked (LockMap). Within this function the map mutex is checked and if it 153 | // does not exist, the function returns NULL. If it does exist there is a wait of 4 frames for access. 154 | // The map is then opened (OpenMap) and a handle and pointer to the map buffer are returned for either 155 | // read or write to the map. 156 | // After map access it is closed (CloseMap), which closes it but does not release it. 157 | // Finally it is unlocked (UnlockMap) 158 | // 159 | // Releasing the map 160 | // At termination of this instance all maps are closed if there is no open view 161 | // i.e. if another sender has an open view, the map is not closed. 162 | // 163 | static void readSenderSetFromBuffer(const char* buffer, std::set& SenderNames); 164 | static void writeBufferFromSenderSet(const std::set& SenderNames, char *buffer); 165 | 166 | SpoutSharedMemory m_senderNames; 167 | SpoutSharedMemory m_activeSender; 168 | 169 | // This should be a unordered_map of sender names ->SharedMemory 170 | // to handle multiple inputs and outputs all going through the 171 | // same spoutSenderNames class 172 | // Make this a pointer to avoid size differences between compilers 173 | // if the .dll is compiled with something different 174 | std::unordered_map* m_senders; 175 | 176 | }; 177 | 178 | #endif 179 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutGLDXinterop.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | spoutGLDXinterop.h 4 | 5 | LJ - leadedge@adam.com.au 6 | 7 | Functions to manage texture sharing using the NVIDIA GL/DX opengl extensions 8 | 9 | https://www.opengl.org/registry/specs/NV/DX_interop.txt 10 | 11 | 12 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without modification, 15 | are permitted provided that the following conditions are met: 16 | 17 | 1. Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimer. 19 | 20 | 2. Redistributions in binary form must reproduce the above copyright notice, 21 | this list of conditions and the following disclaimer in the documentation 22 | and/or other materials provided with the distribution. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 25 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | */ 35 | #pragma once 36 | #ifndef __spoutGLDXinterop__ // standard way as well 37 | #define __spoutGLDXinterop__ 38 | 39 | #include "SpoutCommon.h" 40 | #include "spoutGLextensions.h" 41 | #include "spoutDirectX.h" 42 | #include "spoutSenderNames.h" 43 | #include "SpoutMemoryShare.h" 44 | 45 | #include 46 | #include // DX9 47 | #include // DX11 48 | #include 49 | #include // For glerror 50 | #include // for path functions 51 | 52 | 53 | class SPOUT_DLLEXP spoutGLDXinterop { 54 | 55 | public: 56 | 57 | spoutGLDXinterop(); 58 | ~spoutGLDXinterop(); 59 | 60 | // Initialization functions 61 | bool LoadGLextensions(); // Load required opengl extensions 62 | bool CreateInterop(HWND hWnd, char* sendername, unsigned int width, unsigned int height, DWORD dwFormat, bool bReceive = true); 63 | bool CheckInterop(HWND hWnd); // Check for successful open of the interop 64 | void CleanupInterop(bool bExit = false); // Cleanup with flag to avoid unknown crash bug 65 | 66 | void setSharedMemoryName(char* sharedMemoryName, bool bReceive = true); 67 | bool getSharedInfo(char* sharedMemoryName, SharedTextureInfo* info); 68 | bool setSharedInfo(char* sharedMemoryName, SharedTextureInfo* info); 69 | 70 | bool ReadTexturePixels(unsigned char *pixels, unsigned int width, unsigned int height, GLenum glFormat = GL_RGBA, GLuint HostFBO=0); 71 | bool WriteTexturePixels(unsigned char *pixels, unsigned int width, unsigned int height, GLenum glFormat = GL_RGBA, bool bAlignment = true); 72 | 73 | bool ReadTexture (GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, bool bInvert=false, GLuint HostFBO=0); 74 | bool WriteTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, bool bInvert=false, GLuint HostFBO=0); 75 | #ifdef USE_PBO_EXTENSIONS 76 | bool LoadTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, unsigned char *data); 77 | #endif 78 | 79 | bool BindSharedTexture(); 80 | bool UnBindSharedTexture(); 81 | 82 | bool DrawSharedTexture(float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = true); 83 | bool DrawToSharedTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = true, GLuint HostFBO = 0); 84 | 85 | // DX9 86 | bool bUseDX9; // Use DX11 (default) or DX9 87 | bool UseDX9(bool bDX9); 88 | bool isDX9(); 89 | 90 | // Set and get flags only 91 | void SetDX9(bool bDX9); 92 | bool GetDX9(); 93 | 94 | D3DFORMAT DX9format; // the DX9 texture format to be used 95 | void SetDX9format(D3DFORMAT textureformat); 96 | 97 | int GetNumAdapters(); // Get the number of graphics adapters in the system 98 | bool GetAdapterName(int index, char *adaptername, int maxchars); // Get an adapter name 99 | bool SetAdapter(int index); // Set required graphics adapter for output 100 | int GetAdapter(); // Get the SpoutDirectX global adapter index 101 | 102 | bool CreateDX9interop(unsigned int width, unsigned int height, DWORD dwFormat, bool bReceive = true); 103 | bool OpenDirectX9(HWND hWnd); // Initialize and prepare DirectX9 104 | void CleanupDX9(); 105 | 106 | // DX11 107 | DXGI_FORMAT DX11format; // the DX11 texture format to be used 108 | void SetDX11format(DXGI_FORMAT textureformat); // set format by user 109 | 110 | bool CreateDX11interop(unsigned int width, unsigned int height, DWORD dwFormat, bool bReceive); 111 | bool OpenDirectX11(); // Initialize and prepare DirectX11 112 | void CleanupDX11(); 113 | 114 | // Common 115 | bool OpenDirectX(HWND hWnd, bool bDX9); 116 | HANDLE LinkGLDXtextures(void* pDXdevice, void* pSharedTexture, HANDLE dxShareHandle, GLuint glTextureID); 117 | void CleanupDirectX(); 118 | 119 | // TODO - not working 120 | // bool LinkGLtexture(GLuint glTexture) ; 121 | 122 | // Utilities 123 | bool GLDXcompatible(); 124 | int GetVerticalSync(); 125 | bool SetVerticalSync(bool bSync = true); 126 | bool GetAdapterInfo(char *renderadapter, 127 | char *renderdescription, char *renderversion, 128 | char *displaydescription, char *displayversion, 129 | int maxsize, bool &bUseDX9); 130 | 131 | // Registry read/write 132 | bool ReadDwordFromRegistry(DWORD *pValue, const char *subkey, const char *valuename); 133 | bool WriteDwordToRegistry(DWORD dwValue, const char *subkey, const char *valuename); 134 | 135 | spoutMemoryShare MemoryShare; // Shared memory method 136 | spoutSenderNames senders; // Sender management 137 | spoutDirectX spoutdx; // DirectX class 138 | 139 | // Locks for gl/dx interop functions 140 | HRESULT LockInteropObject(HANDLE hDevice, HANDLE *hObject); 141 | HRESULT UnlockInteropObject(HANDLE hDevice, HANDLE *hObject); 142 | 143 | GLuint m_glTexture; // the OpenGL texture linked to the shared DX texture 144 | GLuint m_fbo; 145 | 146 | // ==================== 147 | // DEBUG 148 | // public for debugging 149 | IDirect3DDevice9Ex* m_pDevice; // DX9 device 150 | LPDIRECT3DTEXTURE9 m_dxTexture; // the shared DX9 texture 151 | void GLerror(); 152 | // ==================== 153 | 154 | protected: 155 | 156 | bool m_bInitialized; // this instance initialized flag 157 | bool bExtensionsLoaded; // extensions have been loaded 158 | bool bFBOavailable; // fbo extensions available 159 | bool bBLITavailable; // fbo blit extensions available 160 | bool bPBOavailable; // pbo extensions available 161 | bool bSWAPavailable; // swap extensions available 162 | 163 | HWND m_hWnd; // parent window 164 | HANDLE m_hSharedMemory; // handle to the texture info shared memory 165 | SharedTextureInfo m_TextureInfo; // local texture info structure 166 | 167 | // DX11 168 | ID3D11Device* g_pd3dDevice; 169 | ID3D11DeviceContext* g_pImmediateContext; 170 | D3D_DRIVER_TYPE g_driverType; 171 | D3D_FEATURE_LEVEL g_featureLevel; 172 | ID3D11Texture2D* g_pSharedTexture; // The shared DX11 texture 173 | 174 | // DX9 175 | IDirect3D9Ex* m_pD3D; // DX9 object 176 | // IDirect3DDevice9Ex* m_pDevice; // DX9 device 177 | // LPDIRECT3DTEXTURE9 m_dxTexture; // the shared DX9 texture 178 | 179 | HANDLE m_hInteropDevice; // handle to the DX/GL interop device 180 | HANDLE m_hInteropObject; // handle to the DX/GL interop object (the shared texture) 181 | HANDLE m_dxShareHandle; // shared DX texture handle 182 | HANDLE m_hAccessMutex; // Texture access mutex lock handle 183 | 184 | bool getSharedTextureInfo(char* sharedMemoryName); 185 | bool setSharedTextureInfo(char* sharedMemoryName); 186 | 187 | bool OpenDeviceKey(const char* key, int maxsize, char *description, char *version); 188 | void trim(char * s); 189 | 190 | 191 | // DEBUG 192 | // Timing calcs 193 | // __int64 CounterStart; 194 | // double PCFreq; 195 | // void StartCounter(); 196 | // double GetCounter(); 197 | 198 | }; 199 | 200 | #endif 201 | -------------------------------------------------------------------------------- /src/vdome/input/spout/SpoutSDK/SpoutSDK.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SpoutSDK.h 4 | 5 | The main SDK include file 6 | 7 | 8 | Copyright (c) 2014-2015, Lynn Jarvis. All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without modification, 11 | are permitted provided that the following conditions are met: 12 | 13 | 1. Redistributions of source code must retain the above copyright notice, 14 | this list of conditions and the following disclaimer. 15 | 16 | 2. Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the following disclaimer in the documentation 18 | and/or other materials provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 21 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | #pragma once 32 | #ifndef __SpoutSDK__ 33 | #define __SpoutSDK__ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include // for timegettime 41 | #include // for _getcwd 42 | #include // for path functions 43 | #include "Shellapi.h" // for shellexecute 44 | 45 | #pragma comment(lib, "shlwapi.lib") // for path functions 46 | #pragma comment(lib, "Shell32.lib") // for shellexecute 47 | #pragma comment(lib, "Advapi32.lib") // for registry functions 48 | #pragma comment(lib, "Version.lib") // for VersionInfo API 49 | 50 | 51 | #include "SpoutCommon.h" 52 | #include "spoutMemoryShare.h" 53 | #include "SpoutSenderNames.h" 54 | #include "spoutGLDXinterop.h" 55 | 56 | #if defined(__x86_64__) || defined(_M_X64) 57 | #define is64bit 58 | // #elif defined(__i386) || defined(_M_IX86) 59 | // x86 32-bit 60 | #endif 61 | 62 | class SPOUT_DLLEXP Spout { 63 | 64 | public: 65 | 66 | Spout(); 67 | ~Spout(); 68 | 69 | // ================== // 70 | // PUBLIC FUNCTIONS // 71 | // ================== // 72 | 73 | // Sender 74 | bool CreateSender(char *name, unsigned int width, unsigned int height, DWORD dwFormat = 0); 75 | bool UpdateSender(char* Sendername, unsigned int width, unsigned int height); 76 | void ReleaseSender(DWORD dwMsec = 0); 77 | bool SendTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, bool bInvert=true, GLuint HostFBO=0); 78 | bool SendImage(unsigned char* pixels, unsigned int width, unsigned int height, GLenum glFormat = GL_RGBA, bool bAlignment = true, bool bInvert=true); 79 | 80 | // Receiver 81 | bool CreateReceiver(char* name, unsigned int &width, unsigned int &height, bool bUseActive = false); 82 | void ReleaseReceiver(); 83 | 84 | bool ReceiveTexture(char* Sendername, unsigned int &width, unsigned int &height, GLuint TextureID = 0, GLuint TextureTarget = 0, bool bInvert = false, GLuint HostFBO=0); 85 | bool ReceiveImage(char* Sendername, unsigned int &width, unsigned int &height, unsigned char* pixels, GLenum glFormat = GL_RGBA, GLuint HostFBO=0); 86 | 87 | bool GetImageSize (char* sendername, unsigned int &width, unsigned int &height, bool &bMemoryMode); 88 | 89 | bool BindSharedTexture(); 90 | bool UnBindSharedTexture(); 91 | 92 | bool DrawSharedTexture(float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = true); 93 | bool DrawToSharedTexture(GLuint TextureID, GLuint TextureTarget, unsigned int width, unsigned int height, float max_x = 1.0, float max_y = 1.0, float aspect = 1.0, bool bInvert = true, GLuint HostFBO = 0); 94 | 95 | int GetSenderCount(); 96 | bool GetSenderName(int index, char* sendername, int MaxSize = 256); 97 | bool GetSenderInfo(const char* sendername, unsigned int &width, unsigned int &height, HANDLE &dxShareHandle, DWORD &dwFormat); 98 | bool GetActiveSender(char* Sendername); 99 | bool SetActiveSender(char* Sendername); 100 | 101 | // Utilities 102 | bool SetDX9(bool bDX9 = true); // User request to use DirectX 9 (default is DirectX 11) 103 | bool GetDX9(); // Return the flag that has been set 104 | 105 | 106 | int GetNumAdapters(); // Get the number of graphics adapters in the system 107 | bool GetAdapterName(int index, char *adaptername, int maxchars); // Get an adapter name 108 | bool SetAdapter(int index = 0); // Set required graphics adapter for output 109 | int GetAdapter(); // Get the SpoutDirectX global adapter index 110 | 111 | bool GetMemoryShareMode(); 112 | bool SetMemoryShareMode(bool bMemory = true); 113 | int GetVerticalSync(); 114 | bool SetVerticalSync(bool bSync = true); 115 | bool SelectSenderPanel(const char* message = NULL); 116 | 117 | bool CheckSpoutPanel(); // Public for debugging 118 | bool OpenSpout(); // Public for debugging 119 | 120 | // Registry read/write 121 | bool WritePathToRegistry(const char *filepath, const char *subkey, const char *valuename); 122 | bool ReadPathFromRegistry(const char *filepath, const char *subkey, const char *valuename); 123 | 124 | spoutGLDXinterop interop; // Opengl/directx interop texture sharing 125 | 126 | // For debugging only - to disable/enable texture access locks in SpoutDirectX.cpp 127 | void UseAccessLocks(bool bUseLocks); 128 | void SpoutCleanUp(bool bExit = false); 129 | 130 | 131 | /* 132 | // 133 | // 134 | // http://msdn.microsoft.com/en-us/library/windows/desktop/bb172558%28v=vs.85%29.aspx 135 | // 136 | // Compatible DX11/DX9 format for Texture2D 137 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ff471324%28v=vs.85%29.aspx 138 | // 139 | // DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, DXGI_FORMAT_B8G8R8A8_UNORM 140 | // are compatible with DX9 - D3DFMT_A8B8G8R8 141 | // 142 | // Noted that DX11 -> DX9 only works if the DX11 format is set to DXGI_FORMAT_B8G8R8A8_UNORM 143 | // if the DX9 format is set to D3DFMT_A8B8G8R8 144 | 145 | DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, 146 | DXGI_FORMAT_R8G8B8A8_UNORM = 28, 147 | DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, 148 | DXGI_FORMAT_R8G8B8A8_UINT = 30, 149 | DXGI_FORMAT_R8G8B8A8_SNORM = 31, 150 | DXGI_FORMAT_R8G8B8A8_SINT = 32, 151 | DXGI_FORMAT_B8G8R8A8_UNORM = 87, 152 | DXGI_FORMAT_B8G8R8X8_UNORM = 88, 153 | DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, 154 | DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, 155 | DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, 156 | DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, 157 | 158 | */ 159 | 160 | protected : 161 | 162 | // ================================= // 163 | // PRIVATE VARIABLES AND FUNCTIONS // 164 | // ================================= // 165 | char g_SharedMemoryName[256]; 166 | char UserSenderName[256]; // used for the sender selection dialog 167 | unsigned int g_Width; 168 | unsigned int g_Height; 169 | HANDLE g_ShareHandle; 170 | DWORD g_Format; 171 | GLuint g_TexID; 172 | HWND g_hWnd; 173 | bool bMemory; // force memoryshare flag 174 | bool bGLDXcompatible; 175 | bool bMemoryShareInitOK; 176 | bool bDxInitOK; 177 | bool bInitialized; 178 | bool bChangeRequested; 179 | bool bSpoutPanelOpened; 180 | bool bUseActive; // Use the active sender for CreateReceiver 181 | SHELLEXECUTEINFOA ShExecInfo; 182 | 183 | bool GLDXcompatible(); 184 | bool OpenReceiver(char *name, unsigned int& width, unsigned int& height); 185 | bool InitReceiver(HWND hwnd, char* sendername, unsigned int width, unsigned int height, bool bMemoryMode); 186 | bool InitSender(HWND hwnd, char* sendername, unsigned int width, unsigned int height, DWORD dwFormat, bool bMemoryMode); 187 | bool InitMemoryShare(bool bReceiver); 188 | bool ReleaseMemoryShare(); 189 | // void SpoutCleanUp(bool bExit = false); 190 | bool FlipVertical(unsigned char *src, unsigned int width, unsigned int height, GLenum glFormat = GL_RGB); 191 | 192 | // FPS calcs - TODO cleanup 193 | double timeNow, timeThen, elapsedTime, frameTime, lastFrameTime, frameRate, fps, PCFreq, waitMillis, millisForFrame; 194 | __int64 CounterStart; 195 | 196 | // Find a file version 197 | bool FindFileVersion(const char *filepath, DWORD &versMS, DWORD &versLS); 198 | 199 | // TODO - used ? cleanup 200 | void StartCounter(); 201 | double GetCounter(); 202 | 203 | }; 204 | 205 | #endif 206 | 207 | 208 | -------------------------------------------------------------------------------- /src/vdome/renderer/window.cpp: -------------------------------------------------------------------------------- 1 | #include "window.h" 2 | namespace vd { 3 | 4 | ofEvent Window::keyPressEvent = ofEvent(); 5 | ofEvent Window::keyReleaseEvent = ofEvent(); 6 | 7 | /****************************************** 8 | 9 | CONSTRUCTOR 10 | 11 | ********************************************/ 12 | 13 | Window::Window(){ 14 | x = y = 0; 15 | fullscreen = false; 16 | } 17 | 18 | /****************************************** 19 | 20 | INIT 21 | 22 | ********************************************/ 23 | void Window::init(){ 24 | ofHideCursor(); 25 | ofBackground(0,0,0); 26 | ofDisableAntiAliasing(); 27 | ofSetFullscreen(fullscreen); 28 | 29 | ofSetWindowShape(width, height); 30 | ofSetWindowPosition(x, y); 31 | 32 | // projection shader 33 | shader.load("settings/shaders/vdome.vert", "settings/shaders/vdome.frag"); 34 | 35 | //fix 36 | /*maskHistory.clear(); 37 | for (int i=0; i<=(maxHistory+2); i++) { 38 | ofPixels buffer; 39 | buffer.allocate(1920, 1080, OF_IMAGE_COLOR_ALPHA); //FIXME: HARDCODED RESOLUTION? 40 | maskHistory.push_back(buffer); 41 | }*/ 42 | } 43 | 44 | /****************************************** 45 | 46 | SETUP 47 | 48 | ********************************************/ 49 | 50 | void Window::setup(){} 51 | 52 | /****************************************** 53 | 54 | UPDATE 55 | 56 | ********************************************/ 57 | 58 | void Window::update(){ 59 | // if (input->source != input->SYPHON){ 60 | //texture.loadData(input->getPixels()); //fix 61 | //texture = input->getTexture(); 62 | 63 | //} 64 | #ifdef TARGET_WIN32 65 | if (input->source == SPOUT) 66 | spout.update(); 67 | #endif 68 | 69 | if (menu.active) { 70 | menu.update(); 71 | } 72 | } 73 | 74 | /****************************************** 75 | 76 | DRAW 77 | 78 | ********************************************/ 79 | 80 | void Window::draw(){ 81 | ofSetColor(255); 82 | 83 | for (int i=0; isource == input->SYPHON || input->source == input->SPOUT){ 88 | #ifdef TARGET_OSX 89 | syphon.bind(); 90 | #endif 91 | 92 | #ifdef TARGET_WIN32 93 | spout.bind(); 94 | #endif 95 | } 96 | else{ 97 | input->bind(); 98 | } 99 | 100 | model.draw(); 101 | 102 | if (input->source == input->SYPHON || input->source == input->SPOUT) { 103 | #ifdef TARGET_OSX 104 | syphon.unbind(); 105 | #endif 106 | #ifdef TARGET_WIN32 107 | spout.unbind(); 108 | #endif 109 | } 110 | else{ 111 | input->unbind(); 112 | } 113 | 114 | 115 | projectors[i].end(); 116 | 117 | ofDisableNormalizedTexCoords(); 118 | 119 | projectors[i].renderFbo.begin(); 120 | ofClear(0); 121 | 122 | projectors[i].bind(); 123 | projectors[i].draw(); 124 | projectors[i].unbind(); 125 | 126 | projectors[i].renderFbo.end(); 127 | 128 | ofEnableNormalizedTexCoords(); 129 | 130 | 131 | projectors[i].renderFbo.getTexture().bind(); 132 | 133 | if (projectors[i].active){ 134 | projectors[i].mask.draw(); 135 | } 136 | 137 | shader.begin(); 138 | 139 | shader.setUniform1f("brightness", projectors[i].brightness); 140 | shader.setUniform1f("contrast", projectors[i].contrast); 141 | shader.setUniform1f("saturation", projectors[i].saturation); 142 | 143 | shader.setUniform1i("interp", 1 ); 144 | shader.setUniform1f("amt", 1.0 ); 145 | shader.setUniform1f("mapdim", 256.0 ); 146 | 147 | shader.setUniformTexture("texsampler", projectors[i].renderFbo.getTexture(), 0); 148 | shader.setUniformTexture("colorlut", projectors[i].curves.colorlutTextureRef(), 1); 149 | shader.setUniformTexture("maskTex", projectors[i].mask.maskFbo.getTexture(), 2); 150 | 151 | projectors[i].renderPlane.draw(); 152 | 153 | shader.end(); 154 | 155 | projectors[i].renderFbo.getTexture().unbind(); 156 | 157 | } 158 | 159 | if (menu.active) { 160 | menu.draw(projectors[i].index, projectors[i].index + projectorStartingIndex); 161 | } 162 | } 163 | } 164 | 165 | /****************************************** 166 | 167 | ACCESSORS 168 | 169 | ********************************************/ 170 | 171 | void Window::setVSync(bool val) { 172 | ofSetVerticalSync(val); 173 | } 174 | void Window::setFrameRate(int val) { 175 | ofSetFrameRate(val); 176 | } 177 | 178 | /****************************************** 179 | 180 | ACCESSORS 181 | 182 | ********************************************/ 183 | 184 | ofPoint Window::getPosition() { 185 | return ofPoint(x, y); 186 | } 187 | void Window::setPosition(int x, int y) { 188 | this->x = x; 189 | this->y = y; 190 | ofSetWindowPosition(x, y); 191 | } 192 | 193 | ofPoint Window::getResolution() { 194 | return ofPoint(width, height); 195 | } 196 | void Window::setResolution(int w, int h) { 197 | width = w; 198 | height = h; 199 | ofSetWindowShape(w, h); 200 | } 201 | 202 | /****************************************** 203 | 204 | SETTINGS 205 | 206 | ********************************************/ 207 | 208 | void Window::loadXML(ofXml &xml) { 209 | model.loadXML(xml); 210 | 211 | xml.setTo("window["+ ofToString(index) + "]"); 212 | 213 | // get window xml settings 214 | string str = ""; 215 | if (xml.exists("[@position]")) { 216 | str = xml.getAttribute("[@position]"); 217 | x = ofToInt(ofSplitString(str, ",")[0]); 218 | y = ofToInt(ofSplitString(str, ",")[1]); 219 | } 220 | if (xml.exists("[@resolution]")) { 221 | str = xml.getAttribute("[@resolution]"); 222 | width = ofToInt(ofSplitString(str, ",")[0]); 223 | height = ofToInt(ofSplitString(str, ",")[1]); 224 | } 225 | if (xml.exists("[@fullscreen]")) { 226 | str = ofToString( xml.getAttribute("[@fullscreen]") ); 227 | if (str == "on") fullscreen = true; 228 | else fullscreen = false; 229 | } 230 | 231 | // initialize window settings 232 | init(); 233 | 234 | //get projector count from xml 235 | int projectorCount = xml.getNumChildren("projector"); 236 | 237 | // virtual projector position 238 | ofPoint pos(0,0); 239 | 240 | // loop through projectors 241 | for (int j=0; j cmds; 17 | public: 18 | SetProjectors(vector cmds) : cmds(cmds) {} 19 | void execute() { 20 | for (int i = 0; i < cmds.size(); i++){ 21 | cmds.at(i)->execute(); 22 | } 23 | } 24 | void undo() { 25 | for (int i = 0; i < cmds.size(); i++){ 26 | cmds.at(i)->undo(); 27 | } 28 | } 29 | void redo() { 30 | for (int i = 0; i < cmds.size(); i++){ 31 | cmds.at(i)->redo(); 32 | } 33 | } 34 | }; 35 | 36 | 37 | // enable 38 | class SetEnable : public Command { 39 | protected: 40 | Projector& obj; 41 | bool v; 42 | bool l; 43 | public: 44 | SetEnable(Projector& obj, bool v) : obj(obj), v(v) {} 45 | void execute() { 46 | l = obj.enable; 47 | obj.enable = v; } 48 | void undo() { obj.enable = l; } 49 | void redo() { obj.enable = v; } 50 | }; 51 | 52 | // intensity 53 | class SetBrightness : public Command { 54 | protected: 55 | Projector& obj; 56 | float v; 57 | float l; 58 | public: 59 | SetBrightness(Projector& obj, float v) : obj(obj), v(v) {} 60 | void execute() { 61 | l = obj.brightness; 62 | obj.brightness = v; } 63 | void undo() { obj.brightness = l; } 64 | void redo() { obj.brightness = v; } 65 | }; 66 | 67 | class SetContrast : public Command { 68 | protected: 69 | Projector& obj; 70 | float v; 71 | float l; 72 | public: 73 | SetContrast(Projector& obj, float v) : obj(obj), v(v) {} 74 | void execute() { 75 | l = obj.contrast; 76 | obj.contrast = v; } 77 | void undo() { obj.contrast = l; } 78 | void redo() { obj.contrast = v; } 79 | }; 80 | 81 | class SetBrushScale : public Command { 82 | protected: 83 | Projector& obj; 84 | float v; 85 | float l; 86 | public: 87 | SetBrushScale(Projector& obj, float v) : obj(obj), v(v) {} 88 | void execute() { 89 | l = obj.mask.brushScale; 90 | obj.mask.brushScale = v; } 91 | void undo() { obj.mask.brushScale = l; } 92 | void redo() { obj.mask.brushScale = v; } 93 | }; 94 | 95 | class SetBrushOpacity : public Command { 96 | protected: 97 | Projector& obj; 98 | float v; 99 | float l; 100 | public: 101 | SetBrushOpacity(Projector& obj, float v) : obj(obj), v(v) {} 102 | void execute() { 103 | l = obj.mask.brushOpacity; 104 | obj.mask.brushOpacity = v; } 105 | void undo() { obj.mask.brushOpacity = l; } 106 | void redo() { obj.mask.brushOpacity = v; } 107 | }; 108 | 109 | class SetBrushPoints : public Command { 110 | protected: 111 | Projector& obj; 112 | int v; 113 | int l; 114 | public: 115 | SetBrushPoints(Projector& obj) : obj(obj), v(v), l(l) {} 116 | void execute() { 117 | l = obj.mask.hIndex; 118 | v = l+1; 119 | obj.mask.store(v); 120 | } 121 | void undo() { obj.mask.recall(l); } 122 | void redo() { obj.mask.recall(v); } 123 | }; 124 | 125 | class ResetBrushOpacity : public Command { 126 | protected: 127 | Projector& obj; 128 | float v; 129 | float l; 130 | Command* cmd; 131 | public: 132 | ResetBrushOpacity(Projector& obj, float v) : obj(obj), v(v) {} 133 | void execute() { 134 | l = obj.mask.brushOpacity; 135 | obj.mask.brushOpacity = v; 136 | cmd = new SetBrushPoints(obj); 137 | cmd->execute(); 138 | obj.mask.reset(); 139 | } 140 | void undo() { obj.mask.brushOpacity = l; cmd->undo(); } 141 | void redo() { obj.mask.brushOpacity = v; obj.mask.reset(); } 142 | }; 143 | 144 | class ResetBrushScale : public Command { 145 | protected: 146 | Projector& obj; 147 | float v; 148 | float l; 149 | Command* cmd; 150 | public: 151 | ResetBrushScale(Projector& obj, float v) : obj(obj), v(v) {} 152 | void execute() { 153 | l = obj.mask.brushScale; 154 | obj.mask.brushScale = v; 155 | cmd = new SetBrushPoints(obj); 156 | cmd->execute(); 157 | obj.mask.reset(); 158 | } 159 | void undo() { obj.mask.brushScale = l; cmd->undo(); } 160 | void redo() { obj.mask.brushScale = v; obj.mask.reset(); } 161 | }; 162 | 163 | 164 | 165 | // color 166 | class SetHue : public Command { 167 | protected: 168 | Projector& obj; 169 | float v; 170 | float l; 171 | public: 172 | SetHue(Projector& obj, float v) : obj(obj), v(v) {} 173 | void execute() { 174 | l = obj.hue; 175 | obj.hue = v; } 176 | void undo() { obj.hue = l; } 177 | void redo() { obj.hue = v; } 178 | }; 179 | 180 | class SetSaturation : public Command { 181 | protected: 182 | Projector& obj; 183 | float v; 184 | float l; 185 | public: 186 | SetSaturation(Projector& obj, float v) : obj(obj), v(v) {} 187 | void execute() { 188 | l = obj.saturation; 189 | obj.saturation = v; } 190 | void undo() { obj.saturation = l; } 191 | void redo() { obj.saturation = v; } 192 | }; 193 | 194 | class SetLightness : public Command { 195 | protected: 196 | Projector& obj; 197 | float v; 198 | float l; 199 | public: 200 | SetLightness(Projector& obj, float v) : obj(obj), v(v) {} 201 | void execute() { 202 | l = obj.lightness; 203 | obj.lightness = v; } 204 | void undo() { obj.lightness = l; } 205 | void redo() { obj.lightness = v; } 206 | }; 207 | 208 | 209 | 210 | // plane 211 | 212 | class SetCornerpinPoints : public Command { 213 | protected: 214 | Projector& obj; 215 | vector v; 216 | vector l; 217 | public: 218 | SetCornerpinPoints(Projector& obj, vector v, vector l) : obj(obj), v(v), l(l) {} 219 | void execute() {; 220 | obj.setKeystonePoints(v); 221 | } 222 | void undo() { 223 | bool tmp = obj.plane.cornerpinActive; 224 | obj.plane.cornerpinActive = true; 225 | obj.plane.setCornerpinPoints(l); 226 | obj.plane.draw(); 227 | obj.plane.cornerpinActive = tmp; 228 | } 229 | void redo() { 230 | bool tmp = obj.plane.cornerpinActive; 231 | obj.plane.cornerpinActive = true; 232 | obj.plane.setCornerpinPoints(v); 233 | obj.plane.draw(); 234 | obj.plane.cornerpinActive = tmp; 235 | } 236 | }; 237 | 238 | class SetGridPoints : public Command { 239 | protected: 240 | Projector& obj; 241 | vector v; 242 | vector l; 243 | public: 244 | SetGridPoints(Projector& obj, vector v, vector l) : obj(obj), v(v), l(l) {} 245 | void execute() {; 246 | obj.setGridPoints(v); 247 | } 248 | void undo() { 249 | obj.setGridPoints(l); 250 | } 251 | void redo() { 252 | obj.setGridPoints(v); 253 | } 254 | }; 255 | 256 | 257 | class ResetCornerpin : public Command { 258 | protected: 259 | Projector& obj; 260 | Command* cmd; 261 | vector l; 262 | public: 263 | ResetCornerpin(Projector& obj) : obj(obj) {} 264 | void execute() { 265 | l = obj.getKeystonePoints(); 266 | cmd = new SetCornerpinPoints(obj, l, l); 267 | obj.plane.resetCornerpin(); 268 | } 269 | void undo() { 270 | cmd->undo(); 271 | } 272 | void redo() { 273 | obj.plane.resetCornerpin(); 274 | } 275 | }; 276 | 277 | 278 | class ResetGrid : public Command { 279 | protected: 280 | Projector& obj; 281 | Command* cmd; 282 | vector l; 283 | public: 284 | ResetGrid(Projector& obj) : obj(obj) {} 285 | void execute() { 286 | l = obj.getGridPoints(); 287 | obj.plane.resetGrid(); 288 | } 289 | void undo() { 290 | obj.setGridPoints(l); 291 | } 292 | void redo() { 293 | obj.plane.resetGrid(); 294 | } 295 | }; 296 | 297 | 298 | // camera 299 | class SetCameraPosition : public Command { 300 | protected: 301 | Projector& obj; 302 | float azi, ele, dis; 303 | ofVec3f l; 304 | public: 305 | SetCameraPosition(Projector& obj, float azi, float ele, float dis) : obj(obj), azi(azi), ele(ele), dis(dis) {} 306 | void execute() { 307 | l = obj.getCameraPosition(); 308 | obj.setCameraPosition(azi, ele, dis); 309 | } 310 | void undo() { obj.setCameraPosition(l.x, l.y, l.z); } 311 | void redo() { obj.setCameraPosition(azi, ele, dis); } 312 | }; 313 | 314 | class SetCameraOrientation : public Command { 315 | protected: 316 | Projector& obj; 317 | float roll, tilt, pan; 318 | ofVec3f l; 319 | public: 320 | SetCameraOrientation(Projector& obj, float roll, float tilt, float pan) : obj(obj), roll(roll), tilt(tilt), pan(pan) {} 321 | void execute() { 322 | l = obj.getCameraOrientation(); 323 | obj.setCameraOrientation(roll, tilt, pan); 324 | } 325 | void undo() { obj.setCameraOrientation(l.x, l.y, l.z); } 326 | void redo() { obj.setCameraOrientation(roll, tilt, pan); } 327 | }; 328 | 329 | class SetCameraFov : public Command { 330 | protected: 331 | Projector& obj; 332 | float v; 333 | float l; 334 | public: 335 | SetCameraFov(Projector& obj, float v) : obj(obj), v(v) {} 336 | void execute() { 337 | l = obj.getCameraFov(); 338 | obj.setCameraFov(v); 339 | } 340 | void undo() { obj.setCameraFov(l); } 341 | void redo() { obj.setCameraFov(v); } 342 | }; 343 | 344 | class SetCameraOffset : public Command { 345 | protected: 346 | Projector& obj; 347 | float x, y; 348 | ofVec2f l; 349 | public: 350 | SetCameraOffset(Projector& obj, float x, float y) : obj(obj), x(x), y(y) {} 351 | void execute() { 352 | l = obj.getCameraOffset(); 353 | obj.setCameraOffset(x,y); 354 | } 355 | void undo() { obj.setCameraOffset(l.x, l.y); } 356 | void redo() { obj.setCameraOffset(x, y); } 357 | }; 358 | 359 | } 360 | -------------------------------------------------------------------------------- /src/vdome/input/input.cpp: -------------------------------------------------------------------------------- 1 | #include "input.h" 2 | #include "commands.h" 3 | 4 | namespace vd { 5 | 6 | extern int maxHistory; 7 | extern CommandHistory history; 8 | extern vector maskHistory; 9 | 10 | /****************************************** 11 | 12 | CONSTRUCTOR 13 | 14 | ********************************************/ 15 | 16 | Input::Input(){ 17 | durationSent = false; 18 | resolution = 2048; 19 | framerate = 30; 20 | setLoop(false); 21 | setResolution(resolution); 22 | ofAddListener(media.endEvent, this, &Input::mediaEnd); 23 | format = 0; 24 | } 25 | 26 | /****************************************** 27 | 28 | SETUP 29 | 30 | ********************************************/ 31 | 32 | void Input::setup(){ 33 | close(); 34 | 35 | durationSent = false; 36 | endSent = false; 37 | 38 | switch(source){ 39 | case GRID: media.open("settings/media/warp/grid-2k.png"); break; 40 | case MEDIA: media.open(filepath); break; 41 | case CAPTURE: capture.open(); break; 42 | case BLACK: color.setup(); color.fillBlack(); break; 43 | case WHITE: color.setup(); color.fillWhite(); break; 44 | case GREY: color.setup(); color.fillGrey(); break; 45 | case COLOR: color.setup(); color.fill(cColor.r, cColor.g, cColor.b); break; 46 | default: color.setup(); color.fillBlack(); break; 47 | } 48 | 49 | // letterbox non-square aspect ratios 50 | ratio = -99999; 51 | if (source == MEDIA){ 52 | ratio = media.getRealHeight()/media.getRealWidth(); 53 | } 54 | else if (source == CAPTURE){ 55 | ratio = capture.getRealHeight()/capture.getRealWidth(); 56 | } 57 | } 58 | 59 | /****************************************** 60 | 61 | UPDATE 62 | 63 | ********************************************/ 64 | 65 | void Input::update(){ 66 | if (source == MEDIA) 67 | media.update(); 68 | else if (source == CAPTURE) 69 | capture.update(); 70 | } 71 | 72 | 73 | /****************************************** 74 | 75 | CONTROLS 76 | 77 | ********************************************/ 78 | 79 | string Input::getSource() { 80 | string s = ""; 81 | if (source == MEDIA) s = "media"; 82 | else if (source == CAPTURE) s = "capture"; 83 | else if (source == SYPHON) s = "syphon"; 84 | else if (source == SPOUT) s = "spout"; 85 | else if (source == GRID) s = "grid"; 86 | else if (source == BLACK) s = "black"; 87 | else if (source == WHITE) s = "white"; 88 | else if (source == GREY) s = "grey"; 89 | else if (source == COLOR) s = "color"; 90 | return s; 91 | } 92 | 93 | int Input::convertSourceString(string s) { 94 | int sint; 95 | if (s == "media") sint = MEDIA; 96 | else if (s == "capture") sint = CAPTURE; 97 | else if (s == "syphon") sint = SYPHON; 98 | else if (s == "spout") sint = SPOUT; 99 | else if (s == "grid") sint = GRID; 100 | else if (s == "black") sint = BLACK; 101 | else if (s == "white") sint = WHITE; 102 | else if (s == "grey") sint = GREY; 103 | else if (s == "color") sint = COLOR; 104 | return sint; 105 | } 106 | 107 | void Input::setSourceInt(int i) { 108 | source = i; 109 | // must call: setup(); 110 | } 111 | int Input::getSourceInt() { 112 | return source; 113 | } 114 | 115 | int Input::convertFormatString(string s){ 116 | int sint; 117 | if (s == "domemaster") sint = DOMEMASTER; 118 | else if (s == "hd") sint = HD; 119 | return sint; 120 | } 121 | 122 | void Input::setFormat() { 123 | if (source == GRID || source == BLACK || source == WHITE || source == GREY){ 124 | format = DOMEMASTER; 125 | } 126 | } 127 | 128 | void Input::setFormatInt(int i) { 129 | format = i; 130 | // must call: setFormat(); 131 | } 132 | 133 | int Input::getFormatInt() { 134 | return format; 135 | } 136 | 137 | void Input::play() { 138 | if (source == MEDIA) media.play(); 139 | } 140 | 141 | bool Input::isPlaying() { 142 | if (source == MEDIA && media.isPlaying()) { 143 | return true; 144 | } 145 | else { 146 | return false; 147 | } 148 | } 149 | 150 | void Input::stop() { 151 | if (source == MEDIA) media.stop(); 152 | } 153 | 154 | void Input::close() { 155 | stop(); 156 | if (source == MEDIA) media.close(); 157 | else if (source == CAPTURE) capture.close(); 158 | else if (source == GRID) media.close(); 159 | else if (source == BLACK || source == WHITE || source == GREY || source == COLOR) color.close(); 160 | 161 | } 162 | 163 | void Input::seek(float f) { 164 | if (source == MEDIA) media.seek(f); 165 | } 166 | 167 | bool Input::getLoop() { 168 | return media.getLoop(); 169 | } 170 | void Input::setLoop(bool b) { 171 | media.setLoop(b); 172 | } 173 | 174 | float Input::getPosition() { 175 | return media.getPosition(); 176 | } 177 | 178 | float Input::getDuration() { 179 | return media.getDuration(); 180 | } 181 | 182 | void Input::setResolution(int r){ 183 | resolution = r; 184 | capture.setResolution(r); 185 | color.setResolution(r); 186 | } 187 | 188 | string Input::getFilepath(){ 189 | return media.getFilepath(); 190 | } 191 | 192 | void Input::setVolume(float v){ 193 | media.setVolume(v); 194 | } 195 | 196 | void Input::mediaEnd(bool &end){ 197 | if (!endSent) { 198 | socket->sendEnd(); 199 | endSent = true; 200 | } 201 | } 202 | 203 | void Input::setColor(int r, int g, int b){ 204 | cColor = ofColor(r,g,b); 205 | color.fill(cColor.r, cColor.g, cColor.b); 206 | } 207 | 208 | /****************************************** 209 | 210 | KEYBOARD 211 | 212 | ********************************************/ 213 | 214 | void Input::keyPressed(int key) {} 215 | 216 | /****************************************** 217 | 218 | FILE OPEN 219 | 220 | ********************************************/ 221 | 222 | void Input::setFile(string file){ 223 | filepath = file; 224 | source = MEDIA; 225 | } 226 | 227 | void Input::openFile(string file){ 228 | setFile(file); 229 | setup(); 230 | } 231 | 232 | void Input::setFramerate(int frate){ 233 | framerate = frate; 234 | capture.setFramerate(frate); 235 | } 236 | 237 | /****************************************** 238 | 239 | SETTINGS 240 | 241 | ********************************************/ 242 | 243 | void Input::loadXML(ofXml &xml) { 244 | string v; 245 | 246 | if (xml.exists("[@resolution]")){ 247 | setResolution(ofToInt( xml.getAttribute("[@resolution]"))); 248 | } 249 | 250 | if (xml.exists("input[@framerate]")){ 251 | setFramerate(ofToInt( xml.getAttribute("[@framerate]"))); 252 | } 253 | 254 | if (xml.exists("input[@file]")){ 255 | setFile(ofToString(xml.getAttribute("input[@file]"))); 256 | } 257 | 258 | if (xml.exists("input[@source]")) { 259 | v = xml.getAttribute("input[@source]"); 260 | if (v == "grid") source = GRID; 261 | else if (v == "media") source = MEDIA; 262 | else if (v == "capture") source = CAPTURE; 263 | else if (v == "syphon") source = SYPHON; 264 | else if (v == "spout") source = SPOUT; 265 | else if (v == "black") source = BLACK; 266 | else if (v == "white") source = WHITE; 267 | else if (v == "grey") source = GREY; 268 | } 269 | 270 | if (xml.exists("input[@loop]")) { 271 | v = xml.getAttribute("input[@loop]"); 272 | if (v == "on") setLoop(true); 273 | else setLoop(false); 274 | } 275 | } 276 | 277 | void Input::saveXML(ofXml &xml) { 278 | xml.setAttribute("resolution", ofToString(resolution)); 279 | 280 | xml.setTo("input"); 281 | string str; 282 | 283 | if (source == GRID) str = "grid"; 284 | else if (source == MEDIA) str = "media"; 285 | else if (source == CAPTURE) str = "capture"; 286 | else if (source == SYPHON) str = "syphon"; 287 | else if (source == SPOUT) str = "spout"; 288 | else if (source == BLACK) str = "black"; 289 | else if (source == WHITE) str = "white"; 290 | else if (source == GREY) str = "grey"; 291 | 292 | xml.setAttribute("source", str); 293 | xml.setAttribute("file", filepath); 294 | xml.setAttribute("framerate", ofToString(framerate)); 295 | 296 | if (getLoop()) xml.setAttribute("loop", "on"); 297 | else xml.setAttribute("loop", "off"); 298 | 299 | xml.setToParent(); 300 | } 301 | 302 | ofPixels& Input::getPixels(){ 303 | if (source == MEDIA) return media.getPixels(); 304 | else if (source == CAPTURE) return capture.getPixels(); 305 | else if (source == GRID) return media.getPixels(); 306 | else if (source == BLACK) return color.getPixels(); 307 | else if (source == WHITE) return color.getPixels(); 308 | else if (source == GREY) return color.getPixels(); 309 | else if (source == COLOR) return color.getPixels(); 310 | } 311 | 312 | void Input::bind(){ 313 | if (source == MEDIA) return media.bind(); 314 | else if (source == CAPTURE) return capture.bind(); 315 | else if (source == GRID) return media.bind(); 316 | else if (source == BLACK) return color.bind(); 317 | else if (source == WHITE) return color.bind(); 318 | else if (source == GREY) return color.bind(); 319 | else if (source == COLOR) return color.bind(); 320 | } 321 | 322 | void Input::unbind() { 323 | if (source == MEDIA) return media.unbind(); 324 | else if (source == CAPTURE) return capture.unbind(); 325 | else if (source == GRID) return media.unbind(); 326 | else if (source == BLACK) return color.unbind(); 327 | else if (source == WHITE) return color.unbind(); 328 | else if (source == GREY) return color.unbind(); 329 | else if (source == COLOR) return color.unbind(); 330 | } 331 | 332 | } 333 | -------------------------------------------------------------------------------- /src/vdome/renderer/projector/plane.cpp: -------------------------------------------------------------------------------- 1 | #include "plane.h" 2 | namespace vd { 3 | 4 | /****************************************** 5 | 6 | CONSTRUCTOR 7 | 8 | ********************************************/ 9 | 10 | Plane::Plane(){ 11 | cornerpinValues.push_back(ofPoint(0,0)); 12 | cornerpinValues.push_back(ofPoint(1,0)); 13 | cornerpinValues.push_back(ofPoint(0,1)); 14 | cornerpinValues.push_back(ofPoint(1,1)); 15 | cornerpinPoints.push_back(ofPoint(0,0)); 16 | cornerpinPoints.push_back(ofPoint(1,0)); 17 | cornerpinPoints.push_back(ofPoint(0,1)); 18 | cornerpinPoints.push_back(ofPoint(1,1)); 19 | 20 | bfirst = true; 21 | group = false; 22 | drawBox = false; 23 | xRes = 10; 24 | yRes = 10; 25 | pointIndex = -1; 26 | value = 1; 27 | cornerpinActive = false; 28 | gridActive = false; 29 | 30 | wXml = new ofXml; 31 | } 32 | 33 | /****************************************** 34 | 35 | SETUP 36 | 37 | ********************************************/ 38 | 39 | void Plane::setup(int i){ 40 | index = i; 41 | 42 | int w = width; 43 | int h = height; 44 | 45 | int x = position[0]; 46 | int y = position[1]; 47 | 48 | value = 1; 49 | 50 | ofPoint tl(cornerpinValues[0].x, cornerpinValues[0].y); 51 | ofPoint tr(cornerpinValues[1].x, cornerpinValues[1].y); 52 | ofPoint bl(cornerpinValues[2].x, cornerpinValues[2].y); 53 | ofPoint br(cornerpinValues[3].x, cornerpinValues[3].y); 54 | 55 | cornerpin.setAnchorSize(w/2, h/2); 56 | cornerpin.setSourceRect(ofRectangle(0,0,w,h)); 57 | cornerpin.setTopLeftCornerPosition(tl); 58 | cornerpin.setTopRightCornerPosition(tr); 59 | cornerpin.setBottomLeftCornerPosition(bl); 60 | cornerpin.setBottomRightCornerPosition(br); 61 | cornerpin.setup(); 62 | 63 | grid.setup(width, height, 6, 20); 64 | 65 | vector v = grid.getVertices(); 66 | for (int i=0; i c = grid.getControlPnts(); 95 | 96 | ofMatrix4x4 m = cornerpin.getMatrix(); 97 | 98 | /* 99 | if (bfirst) { 100 | lm.makeIdentityMatrix(); 101 | bfirst = false; 102 | } 103 | else lm = lm.getInverse(); 104 | 105 | for (int i=0; i v = grid.getVertices(); 115 | for (int i=0; i 2) 150 | grid.setControlPntDim(grid.getControlPntDim()-1); 151 | } 152 | else if (key == 61){ // - = increase points 153 | grid.setControlPntDim(grid.getControlPntDim()+1); 154 | }*/ 155 | } 156 | } 157 | 158 | void Plane::keyReleased(int key){ 159 | ofKeyEventArgs keyArgs; 160 | keyArgs.key = key; 161 | if (cornerpinActive) 162 | cornerpin.keyReleased(keyArgs); 163 | else if (gridActive) 164 | grid.keyReleased(keyArgs); 165 | } 166 | 167 | /****************************************** 168 | 169 | MOUSE 170 | 171 | ********************************************/ 172 | 173 | void Plane::onMouseDragged(ofMouseEventArgs& mouseArgs){ 174 | mouseArgs.x -= position[0]; 175 | mouseArgs.y -= position[1]; 176 | 177 | if (cornerpinActive) 178 | cornerpin.onMouseDragged(mouseArgs); 179 | else if (gridActive) 180 | grid.mouseDragged(mouseArgs); 181 | } 182 | 183 | void Plane::onMousePressed(ofMouseEventArgs& mouseArgs){ 184 | mouseArgs.x -= position[0]; 185 | mouseArgs.y -= position[1]; 186 | if (cornerpinActive) 187 | cornerpin.onMousePressed(mouseArgs); 188 | else if (gridActive) 189 | grid.mousePressed(mouseArgs); 190 | } 191 | 192 | void Plane::onMouseReleased(ofMouseEventArgs& mouseArgs){ 193 | mouseArgs.x -= position[0]; 194 | mouseArgs.y -= position[1]; 195 | if (gridActive) 196 | grid.mouseReleased(mouseArgs); 197 | } 198 | 199 | /****************************************** 200 | 201 | SETTINGS 202 | 203 | ********************************************/ 204 | 205 | void Plane::load(ofXml &xml, int projectorStartingIndex) { 206 | wXml->clear(); 207 | wXml->load("settings/warp/warp-"+ofToString(index+1+projectorStartingIndex)+".xml"); 208 | 209 | if (wXml->exists("cornerpin[@points]")) { 210 | string str = wXml->getAttribute("cornerpin[@points]"); 211 | cornerpinValues[0].x = ofToFloat(ofSplitString(str, ",")[0]); 212 | cornerpinValues[0].y = ofToFloat(ofSplitString(str, ",")[1]); 213 | cornerpinValues[1].x = ofToFloat(ofSplitString(str, ",")[2]); 214 | cornerpinValues[1].y = ofToFloat(ofSplitString(str, ",")[3]); 215 | cornerpinValues[2].x = ofToFloat(ofSplitString(str, ",")[4]); 216 | cornerpinValues[2].y = ofToFloat(ofSplitString(str, ",")[5]); 217 | cornerpinValues[3].x = ofToFloat(ofSplitString(str, ",")[6]); 218 | cornerpinValues[3].y = ofToFloat(ofSplitString(str, ",")[7]); 219 | } 220 | 221 | wXml->setTo("bezier"); 222 | string str; 223 | vector vec; 224 | for (int i = 0; igetNumChildren(); i++) { 225 | if (wXml->exists("point["+ofToString(i)+"][@xyz]")) { 226 | str = wXml->getAttribute("point["+ofToString(i)+"][@xyz]"); 227 | int x = ofToInt(ofSplitString(str, ",")[0]); 228 | int y = ofToInt(ofSplitString(str, ",")[1]); 229 | int z = ofToInt(ofSplitString(str, ",")[2]); 230 | vec.push_back(ofVec3f(x,y,z)); 231 | } 232 | } 233 | 234 | int w = width; 235 | int h = height; 236 | 237 | int x = index*w; 238 | int y = 0; 239 | 240 | ofPoint tl(cornerpinValues[0].x*w, cornerpinValues[0].y*h); 241 | ofPoint tr(cornerpinValues[1].x*w, cornerpinValues[1].y*h); 242 | ofPoint bl(cornerpinValues[2].x*w, cornerpinValues[2].y*h); 243 | ofPoint br(cornerpinValues[3].x*w, cornerpinValues[3].y*h); 244 | 245 | cornerpin.setAnchorSize(w/2, h/2); 246 | cornerpin.setSourceRect(ofRectangle(0,0,w,h)); 247 | cornerpin.setTopLeftCornerPosition(tl); 248 | cornerpin.setTopRightCornerPosition(tr); 249 | cornerpin.setBottomLeftCornerPosition(bl); 250 | cornerpin.setBottomRightCornerPosition(br); 251 | 252 | grid.setup(width, height, 6, 20); 253 | 254 | if (vec.size() > 0) { 255 | grid.setControlPnts(vec); 256 | } 257 | 258 | gridActive = true; 259 | draw(); 260 | gridActive = false; 261 | 262 | } 263 | 264 | void Plane::save(ofXml &xml) { 265 | int w = width; 266 | int h = height; 267 | int x = index*w; 268 | int y = 0; 269 | 270 | wXml->clear(); 271 | 272 | wXml->addChild("projector"); 273 | wXml->setTo("projector"); 274 | 275 | wXml->addChild("cornerpin"); 276 | wXml->setTo("cornerpin"); 277 | 278 | wXml->setAttribute("points", 279 | ofToString((cornerpin.dstPoints[0].x)/w) + "," + 280 | ofToString((cornerpin.dstPoints[0].y)/h) + "," + 281 | ofToString((cornerpin.dstPoints[1].x)/w) + "," + 282 | ofToString((cornerpin.dstPoints[1].y)/h) + "," + 283 | ofToString((cornerpin.dstPoints[3].x)/w) + "," + 284 | ofToString((cornerpin.dstPoints[3].y)/h) + "," + 285 | ofToString((cornerpin.dstPoints[2].x)/w) + "," + 286 | ofToString((cornerpin.dstPoints[2].y)/h) ); 287 | 288 | wXml->setToParent(); 289 | wXml->addChild("bezier"); 290 | wXml->setTo("bezier"); 291 | 292 | vector vec = grid.getControlPnts(); 293 | for (int i = 0; iaddChild("point"); 295 | wXml->setToChild(i); 296 | wXml->setAttribute("xyz", ofToString(vec[i].x) + "," + ofToString(vec[i].y) + "," + ofToString(vec[i].z)); 297 | wXml->setToParent(); 298 | } 299 | } 300 | 301 | vector Plane::getCornerpinPoints() { 302 | for (int i=0; i<4; i++) { 303 | cornerpinPoints[i] = cornerpin.dstPoints[i]; 304 | } 305 | return cornerpinPoints; 306 | } 307 | void Plane::setCornerpinPoints(vector pts){ 308 | for (int i=0; i<4; i++) { 309 | cornerpinPoints[i] = pts[i]; 310 | } 311 | cornerpin.setTopLeftCornerPosition(cornerpinPoints[0]); 312 | cornerpin.setTopRightCornerPosition(cornerpinPoints[1]); 313 | cornerpin.setBottomLeftCornerPosition(cornerpinPoints[3]); 314 | cornerpin.setBottomRightCornerPosition(cornerpinPoints[2]); 315 | } 316 | 317 | vector Plane::getGridPoints() { 318 | return grid.getControlPnts(); 319 | } 320 | void Plane::setGridPoints(vector v) { 321 | grid.setControlPnts(v); 322 | } 323 | 324 | } 325 | --------------------------------------------------------------------------------