@@ -54,10 +54,12 @@ def main():
5454 spoutReceiverWidth = args .spout_size [0 ]
5555 spoutReceiverHeight = args .spout_size [1 ]
5656 # create spout receiver
57- spoutReceiver = SpoutSDK .SpoutReceiver ()
57+ spoutReceiver = SpoutSDK .SpoutReceive ()
5858
5959 # Its signature in c++ looks like this: bool pyCreateReceiver(const char* theName, unsigned int theWidth, unsigned int theHeight, bool bUseActive);
60- spoutReceiver .pyCreateReceiver (receiverName ,spoutReceiverWidth ,spoutReceiverHeight , False )
60+ spoutReceiver .SetupReceiver (spoutReceiverWidth ,spoutReceiverHeight , False )
61+
62+ spoutReceiver .SetReceiverName (receiverName );
6163
6264 # create texture for spout receiver
6365 textureReceiveID = glGenTextures (1 )
@@ -77,13 +79,33 @@ def main():
7779 while (True ):
7880 for event in pygame .event .get ():
7981 if event .type == pygame .QUIT :
80- spoutReceiver . ReleaseReceiver ()
82+ spoutReceive . CloseReceiver ()
8183 pygame .quit ()
8284 quit ()
83-
85+
86+ if spoutReceiver .IsUpdated ():
87+ # this means the resolution of the spout sender has changed
88+ spoutReceiverWidth = spoutReceiver .GetSenderWidth ()
89+ spoutReceiverHeight = spoutReceiver .GetSenderHeight ()
90+ # create texture for spout receiver
91+ textureReceiveID = glGenTextures (1 )
92+ # reinitalise receiver texture
93+ glBindTexture (GL_TEXTURE_2D , textureReceiveID )
94+ glTexParameterf (GL_TEXTURE_2D , GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE )
95+ glTexParameterf (GL_TEXTURE_2D , GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE )
96+ glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER , GL_NEAREST )
97+ glTexParameteri (GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER , GL_NEAREST )
98+
99+ # copy data into texture
100+ glTexImage2D (GL_TEXTURE_2D , 0 , GL_RGBA , spoutReceiverWidth , spoutReceiverHeight , 0 , GL_RGBA , GL_UNSIGNED_BYTE , None )
101+ glBindTexture (GL_TEXTURE_2D , 0 )
102+
103+ if spoutReceiver .GetSenderFrame () > 0 :
104+ print ("frame: " , spoutReceiver .GetSenderFrame ())
105+
84106 # receive texture
85107 # Its signature in c++ looks like this: bool pyReceiveTexture(const char* theName, unsigned int theWidth, unsigned int theHeight, GLuint TextureID, GLuint TextureTarget, bool bInvert, GLuint HostFBO);
86- spoutReceiver .pyReceiveTexture ( receiverName , spoutReceiverWidth , spoutReceiverHeight , textureReceiveID , GL_TEXTURE_2D , False , 0 )
108+ spoutReceiver .ReceiveTextureData ( textureReceiveID , GL_TEXTURE_2D , 0 )
87109
88110 glBindTexture (GL_TEXTURE_2D , textureReceiveID )
89111
0 commit comments