Vuo 2.4.4
Loading...
Searching...
No Matches
VuoSyphonSender.m
Go to the documentation of this file.
10#import "VuoSyphonSender.h"
11#include "VuoImageRenderer.h"
12#include <OpenGL/OpenGL.h>
13#include <OpenGL/CGLMacro.h>
14#include "VuoGlContext.h"
15
16#ifdef VUO_COMPILER
18 "title" : "VuoSyphonSender",
19 "dependencies" : [
20 "AppKit.framework",
21 "VuoGlContext"
22 ]
23 });
24#endif
25
26@implementation VuoSyphonSender
27
28@synthesize syphonServer;
29
35- (void) initServerWithName:(NSString*)name
36{
37 VUOLOG_PROFILE_BEGIN(mainQueue);
38 dispatch_sync(dispatch_get_main_queue(), ^{
39 VUOLOG_PROFILE_END(mainQueue);
40 VuoGlContext_perform(^(CGLContextObj cgl_ctx){
41 syphonServer = [[SyphonServer alloc] initWithName:name context:cgl_ctx options:nil];
42 });
43 });
44}
45
49- (void) publishFrame:(VuoImage)image
50{
51 if ([syphonServer hasClients] && image)
52 {
53 if (image->pixelsWide < 1 || image->pixelsHigh < 1)
54 return;
55
56 VuoGlContext_perform(^(CGLContextObj cgl_ctx){
58
59 // Syphon draws its triangles backwards, so we have to temporarily turn off backface culling.
60 glDisable(GL_CULL_FACE);
61
62 [syphonServer publishFrameTexture:image->glTextureName
63 textureTarget:GL_TEXTURE_2D
64 imageRegion:NSMakeRect(0, 0, image->pixelsWide, image->pixelsHigh)
65 textureDimensions:NSMakeSize(image->pixelsWide, image->pixelsHigh)
66 flipped:NO];
67
68 glEnable(GL_CULL_FACE);
69 });
70 }
71}
72
76- (void) setName:(NSString*)newName
77{
78 VUOLOG_PROFILE_BEGIN(mainQueue);
79 dispatch_sync(dispatch_get_main_queue(), ^{
80 VUOLOG_PROFILE_END(mainQueue);
81 syphonServer.name = newName;
82 });
83}
84
88- (void) stop
89{
90 VUOLOG_PROFILE_BEGIN(mainQueue);
91 dispatch_sync(dispatch_get_main_queue(), ^{
92 VUOLOG_PROFILE_END(mainQueue);
93 [syphonServer stop];
94 [syphonServer release];
95 });
96}
97
98@end