├── test.toe ├── NanomsgTOP.dll ├── python ├── nanomsg.dll ├── _nnpy.cp35-win_amd64.pyd ├── _cffi_backend.cp35-win_amd64.pyd └── nnpy │ ├── errors.py │ ├── __init__.py │ ├── tests.py │ ├── constants.py │ └── socket.py └── dll └── NanomsgTOP ├── src ├── GL_Extensions.h ├── main.cpp ├── NanomsgIO │ └── NanomsgIO.h ├── CPlusPlus_Common.h └── TOP_CPlusPlusBase.h ├── libs └── nanomsg │ ├── lib │ └── vs │ │ └── x64 │ │ ├── Debug │ │ └── nanomsg.lib │ │ └── Release │ │ └── nanomsg.lib │ ├── nanomsg.props │ ├── include │ └── nanomsg │ │ ├── inproc.h │ │ ├── tcp.h │ │ ├── bus.h │ │ ├── pair.h │ │ ├── ipc.h │ │ ├── pubsub.h │ │ ├── pipeline.h │ │ ├── reqrep.h │ │ ├── survey.h │ │ ├── ws.h │ │ └── nn.h │ └── src │ └── NanomsgIO │ └── NanomsgIO.h ├── NanomsgTOP.vcxproj.filters ├── NanomsgTOP.sln ├── NanomsgTOP.vcxproj.user └── NanomsgTOP.vcxproj /test.toe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satoruhiga/TouchDesigner-OpenCV/HEAD/test.toe -------------------------------------------------------------------------------- /NanomsgTOP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satoruhiga/TouchDesigner-OpenCV/HEAD/NanomsgTOP.dll -------------------------------------------------------------------------------- /python/nanomsg.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satoruhiga/TouchDesigner-OpenCV/HEAD/python/nanomsg.dll -------------------------------------------------------------------------------- /dll/NanomsgTOP/src/GL_Extensions.h: -------------------------------------------------------------------------------- 1 | // Stub file for simpler CPU Memory TOP usage than an OpenGLTOP 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /python/_nnpy.cp35-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satoruhiga/TouchDesigner-OpenCV/HEAD/python/_nnpy.cp35-win_amd64.pyd -------------------------------------------------------------------------------- /python/_cffi_backend.cp35-win_amd64.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satoruhiga/TouchDesigner-OpenCV/HEAD/python/_cffi_backend.cp35-win_amd64.pyd -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/lib/vs/x64/Debug/nanomsg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satoruhiga/TouchDesigner-OpenCV/HEAD/dll/NanomsgTOP/libs/nanomsg/lib/vs/x64/Debug/nanomsg.lib -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/lib/vs/x64/Release/nanomsg.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/satoruhiga/TouchDesigner-OpenCV/HEAD/dll/NanomsgTOP/libs/nanomsg/lib/vs/x64/Release/nanomsg.lib -------------------------------------------------------------------------------- /python/nnpy/errors.py: -------------------------------------------------------------------------------- 1 | from _nnpy import ffi, lib as nanomsg 2 | 3 | class NNError(Exception): 4 | def __init__(self, error_no, *args, **kwargs): 5 | super(NNError, self).__init__(*args, **kwargs) 6 | self.error_no = error_no 7 | 8 | def convert(rc, value=None): 9 | if rc < 0: 10 | error_no = nanomsg.nn_errno() 11 | chars = nanomsg.nn_strerror(error_no) 12 | msg = ffi.string(chars).decode() 13 | raise NNError(error_no, msg) 14 | if callable(value): 15 | return value() 16 | return value 17 | 18 | -------------------------------------------------------------------------------- /python/nnpy/__init__.py: -------------------------------------------------------------------------------- 1 | from .constants import * 2 | from _nnpy import ffi, lib as nanomsg 3 | from . import errors 4 | import os 5 | 6 | from .errors import NNError 7 | from .socket import Socket 8 | 9 | class PollSet(object): 10 | 11 | def __init__(self, *args): 12 | self.data = [(sock.sock, events, 0) for (sock, events) in args] 13 | self.fd_set = ffi.new('struct nn_pollfd[]', self.data) 14 | 15 | def poll(self, timeout=0): 16 | rc = nanomsg.nn_poll(self.fd_set, len(self.data), timeout) 17 | return errors.convert(rc, lambda: [fd.revents for fd in self.fd_set]) 18 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/NanomsgTOP.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {0f912659-0773-4b77-b6d9-5fa752f290e4} 6 | 7 | 8 | 9 | 10 | src 11 | 12 | 13 | src 14 | 15 | 16 | src 17 | 18 | 19 | 20 | 21 | src 22 | 23 | 24 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/nanomsg.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | .\libs\nanomsg 6 | 7 | 8 | 9 | 10 | $(NANOMSG_ROOT)\include;%(AdditionalIncludeDirectories) 11 | NN_STATIC_LIB;%(PreprocessorDefinitions) 12 | 13 | 14 | nanomsg.lib;Mswsock.lib;wsock32.lib;Ws2_32.lib;%(AdditionalDependencies) 15 | $(NANOMSG_ROOT)\lib\vs\$(PlatformShortName)\$(Configuration);%(AdditionalLibraryDirectories) 16 | 17 | 18 | 19 | 20 | $(NANOMSG_ROOT) 21 | true 22 | 23 | 24 | -------------------------------------------------------------------------------- /python/nnpy/tests.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import nnpy, unittest 3 | 4 | class Tests(unittest.TestCase): 5 | def test_basic(self): 6 | 7 | pub = nnpy.Socket(nnpy.AF_SP, nnpy.PUB) 8 | pub.setsockopt(nnpy.SOL_SOCKET, nnpy.IPV4ONLY, 0) 9 | pub.bind('inproc://foo') 10 | self.assertEqual(pub.getsockopt(nnpy.SOL_SOCKET, nnpy.DOMAIN), 1) 11 | 12 | sub = nnpy.Socket(nnpy.AF_SP, nnpy.SUB) 13 | sub_conn = sub.connect('inproc://foo') 14 | sub.setsockopt(nnpy.SUB, nnpy.SUB_SUBSCRIBE, '') 15 | 16 | pub.send('FLUB') 17 | poller = nnpy.PollSet((sub, nnpy.POLLIN)) 18 | self.assertEqual(len(poller.poll()), 1) 19 | self.assertEqual(poller.poll()[0], 1) 20 | self.assertEqual(sub.recv().decode(), 'FLUB') 21 | self.assertEqual(pub.get_statistic(nnpy.STAT_MESSAGES_SENT), 1) 22 | pub.close() 23 | sub.shutdown(sub_conn) 24 | 25 | def test_basic_nn_error(self): 26 | address = 'inproc://timeout-always' 27 | 28 | req = nnpy.Socket(nnpy.AF_SP, nnpy.REQ) 29 | req.connect(address) 30 | 31 | req.setsockopt(nnpy.SOL_SOCKET, nnpy.RCVTIMEO, 500) 32 | 33 | with self.assertRaises(nnpy.errors.NNError): 34 | req.recv() 35 | 36 | def suite(): 37 | return unittest.makeSuite(Tests) 38 | 39 | if __name__ == '__main__': 40 | unittest.main(defaultTest='suite') 41 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/inproc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Martin Sustrik All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom 9 | the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef INPROC_H_INCLUDED 24 | #define INPROC_H_INCLUDED 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define NN_INPROC -1 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/tcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Martin Sustrik All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom 9 | the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef TCP_H_INCLUDED 24 | #define TCP_H_INCLUDED 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define NN_TCP -3 31 | 32 | #define NN_TCP_NODELAY 1 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/NanomsgTOP.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.16 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanomsgTOP", "NanomsgTOP.vcxproj", "{FC340D07-29F5-4EDE-B10F-2AF65F394652}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {FC340D07-29F5-4EDE-B10F-2AF65F394652}.Debug|x64.ActiveCfg = Debug|x64 17 | {FC340D07-29F5-4EDE-B10F-2AF65F394652}.Debug|x64.Build.0 = Debug|x64 18 | {FC340D07-29F5-4EDE-B10F-2AF65F394652}.Debug|x86.ActiveCfg = Debug|Win32 19 | {FC340D07-29F5-4EDE-B10F-2AF65F394652}.Debug|x86.Build.0 = Debug|Win32 20 | {FC340D07-29F5-4EDE-B10F-2AF65F394652}.Release|x64.ActiveCfg = Release|x64 21 | {FC340D07-29F5-4EDE-B10F-2AF65F394652}.Release|x64.Build.0 = Release|x64 22 | {FC340D07-29F5-4EDE-B10F-2AF65F394652}.Release|x86.ActiveCfg = Release|Win32 23 | {FC340D07-29F5-4EDE-B10F-2AF65F394652}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {5B9999CE-939A-416F-8BD6-A913EDFF6159} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/bus.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2013 Martin Sustrik All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom 9 | the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef BUS_H_INCLUDED 24 | #define BUS_H_INCLUDED 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define NN_PROTO_BUS 7 31 | 32 | #define NN_BUS (NN_PROTO_BUS * 16 + 0) 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/pair.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Martin Sustrik All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom 9 | the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef PAIR_H_INCLUDED 24 | #define PAIR_H_INCLUDED 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define NN_PROTO_PAIR 1 31 | 32 | #define NN_PAIR (NN_PROTO_PAIR * 16 + 0) 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/ipc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Martin Sustrik All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom 9 | the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef IPC_H_INCLUDED 24 | #define IPC_H_INCLUDED 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define NN_IPC -2 31 | 32 | /* The object set here must be valid as long as you are using the socket */ 33 | #define NN_IPC_SEC_ATTR 1 34 | #define NN_IPC_OUTBUFSZ 2 35 | #define NN_IPC_INBUFSZ 3 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/pubsub.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Martin Sustrik All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), 6 | to deal in the Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | and/or sell copies of the Software, and to permit persons to whom 9 | the Software is furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 | IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef PUBSUB_H_INCLUDED 24 | #define PUBSUB_H_INCLUDED 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #define NN_PROTO_PUBSUB 2 31 | 32 | #define NN_PUB (NN_PROTO_PUBSUB * 16 + 0) 33 | #define NN_SUB (NN_PROTO_PUBSUB * 16 + 1) 34 | 35 | #define NN_SUB_SUBSCRIBE 1 36 | #define NN_SUB_UNSUBSCRIBE 2 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/pipeline.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Martin Sustrik All rights reserved. 3 | Copyright (c) 2013 GoPivotal, Inc. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom 10 | the Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | IN THE SOFTWARE. 22 | */ 23 | 24 | #ifndef PIPELINE_H_INCLUDED 25 | #define PIPELINE_H_INCLUDED 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #define NN_PROTO_PIPELINE 5 32 | 33 | #define NN_PUSH (NN_PROTO_PIPELINE * 16 + 0) 34 | #define NN_PULL (NN_PROTO_PIPELINE * 16 + 1) 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/reqrep.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Martin Sustrik All rights reserved. 3 | Copyright 2016 Garrett D'Amore 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom 10 | the Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | IN THE SOFTWARE. 22 | */ 23 | 24 | #ifndef REQREP_H_INCLUDED 25 | #define REQREP_H_INCLUDED 26 | 27 | #include "nn.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | #define NN_PROTO_REQREP 3 34 | 35 | #define NN_REQ (NN_PROTO_REQREP * 16 + 0) 36 | #define NN_REP (NN_PROTO_REQREP * 16 + 1) 37 | 38 | #define NN_REQ_RESEND_IVL 1 39 | 40 | typedef union nn_req_handle { 41 | int i; 42 | void *ptr; 43 | } nn_req_handle; 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/survey.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 Martin Sustrik All rights reserved. 3 | Copyright 2015 Garrett D'Amore 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), 7 | to deal in the Software without restriction, including without limitation 8 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 | and/or sell copies of the Software, and to permit persons to whom 10 | the Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 | IN THE SOFTWARE. 22 | */ 23 | 24 | #ifndef SURVEY_H_INCLUDED 25 | #define SURVEY_H_INCLUDED 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #define NN_PROTO_SURVEY 6 32 | 33 | /* NB: Version 0 used 16 + 0/1. That version lacked backtraces, and so 34 | is wire-incompatible with this version. */ 35 | 36 | #define NN_SURVEYOR (NN_PROTO_SURVEY * 16 + 2) 37 | #define NN_RESPONDENT (NN_PROTO_SURVEY * 16 + 3) 38 | 39 | #define NN_SURVEYOR_DEADLINE 1 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/ws.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012 250bpm s.r.o. All rights reserved. 3 | Copyright (c) 2014 Wirebird Labs LLC. All rights reserved. 4 | Copyright 2015 Garrett D'Amore 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), 8 | to deal in the Software without restriction, including without limitation 9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | and/or sell copies of the Software, and to permit persons to whom 11 | the Software is furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | IN THE SOFTWARE. 23 | */ 24 | 25 | #ifndef WS_H_INCLUDED 26 | #define WS_H_INCLUDED 27 | 28 | #include "nn.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | #define NN_WS -4 35 | 36 | /* NN_WS level socket/cmsg options. Note that only NN_WSMG_TYPE_TEXT and 37 | NN_WS_MSG_TYPE_BINARY messages are supported fully by this implementation. 38 | Attempting to set other message types is undefined. */ 39 | #define NN_WS_MSG_TYPE 1 40 | 41 | /* WebSocket opcode constants as per RFC 6455 5.2 */ 42 | #define NN_WS_MSG_TYPE_TEXT 0x01 43 | #define NN_WS_MSG_TYPE_BINARY 0x02 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "TOP_CPlusPlusBase.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "NanomsgIO/NanomsgIO.h" 9 | 10 | class NanomsgTOP : public TOP_CPlusPlusBase 11 | { 12 | public: 13 | 14 | std::shared_ptr pub; 15 | std::string nanomsg_addr; 16 | 17 | NanomsgTOP(const OP_NodeInfo *info) 18 | {} 19 | 20 | void setupParameters(OP_ParameterManager* manager) override 21 | { 22 | { 23 | OP_StringParameter p; 24 | p.name = "Nanomsgaddress"; 25 | p.label = "Nanomsg Address"; 26 | 27 | p.defaultValue = "ipc://test"; 28 | 29 | ParAppendResult res = manager->appendString(p); 30 | assert(res == PARAMETER_APPEND_SUCCESS); 31 | } 32 | } 33 | 34 | void getGeneralInfo(TOP_GeneralInfo* ginfo) override 35 | { 36 | ginfo->cookEveryFrame = true; 37 | ginfo->cookEveryFrameIfAsked = true; 38 | ginfo->executeMode = OPENGL_FBO; 39 | ginfo->memPixelType = RGBA8Fixed; 40 | } 41 | 42 | void execute(const TOP_OutputFormatSpecs* outputFormat, OP_Inputs* inputs, TOP_Context* context) override 43 | { 44 | if (inputs->getNumInputs() == 0) 45 | return; 46 | 47 | { 48 | const char* s = inputs->getParString("Nanomsgaddress"); 49 | if (nanomsg_addr != s) 50 | { 51 | pub = std::make_shared(); 52 | nanomsg_addr = s; 53 | 54 | if (!nanomsg_addr.empty()) 55 | pub->bind(nanomsg_addr); 56 | else 57 | pub.reset(); 58 | } 59 | } 60 | 61 | if (!pub) return; 62 | 63 | const OP_TOPInput* input = inputs->getInputTOP(0); 64 | 65 | OP_TOPInputDownloadOptions options; 66 | options.downloadType = OP_TOP_INPUT_DOWNLOAD_DELAYED; 67 | options.cpuMemPixelType = RGBA8Fixed; 68 | options.verticalFlip = true; 69 | const uint8_t* src = (const uint8_t*)inputs->getTOPDataInCPUMemory(input, &options); 70 | if (!src) return; 71 | 72 | int w = input->width; 73 | int h = input->height; 74 | int npixels = w * h; 75 | size_t bytes_par_pixel = 4; 76 | 77 | size_t N = npixels * bytes_par_pixel; 78 | 79 | pub->send(src, N); 80 | } 81 | }; 82 | 83 | extern "C" { 84 | DLLEXPORT int GetTOPAPIVersion(void) { 85 | return TOP_CPLUSPLUS_API_VERSION; 86 | } 87 | 88 | DLLEXPORT TOP_CPlusPlusBase* CreateTOPInstance(const OP_NodeInfo* info, TOP_Context* context) { 89 | return new NanomsgTOP(info); 90 | } 91 | 92 | DLLEXPORT void DestroyTOPInstance(TOP_CPlusPlusBase* instance, TOP_Context *context) { 93 | delete (NanomsgTOP*)instance; 94 | } 95 | }; 96 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/NanomsgTOP.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | C:\Program Files\Derivative\TouchDesigner099\bin\TouchDesigner099.exe 5 | test.toe 6 | $(SolutionDir)\..\..\ 7 | WindowsLocalDebugger 8 | TOUCH_TEXT_CONSOLE=1 9 | 10 | 11 | C:\Program Files\Derivative\TouchDesigner099\bin\TouchDesigner099.exe 12 | test.toe 13 | $(SolutionDir)\..\..\ 14 | WindowsLocalDebugger 15 | 16 | 17 | NativeOnly 18 | TOUCH_TEXT_CONSOLE=1 19 | 20 | 21 | C:\Program Files\Derivative\TouchDesigner099\bin\TouchDesigner099.exe 22 | test.toe 23 | $(SolutionDir)\..\..\ 24 | WindowsLocalDebugger 25 | TOUCH_TEXT_CONSOLE=1 26 | 27 | 28 | C:\Program Files\Derivative\TouchDesigner099\bin\TouchDesigner099.exe 29 | test.toe 30 | $(SolutionDir)\..\..\ 31 | WindowsLocalDebugger 32 | 33 | 34 | NativeOnly 35 | TOUCH_TEXT_CONSOLE=1 36 | 37 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/src/NanomsgIO/NanomsgIO.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef verify 4 | #ifdef NDEBUG 5 | #define verify(expression) expression 6 | #else 7 | #define verify(expression) assert( 0 != (expression) ) 8 | #endif 9 | #endif 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | namespace NanomsgIO 21 | { 22 | class Publisher 23 | { 24 | public: 25 | int sock; 26 | 27 | Publisher() 28 | : sock(nn_socket(AF_SP, NN_PUB)) 29 | { 30 | verify(sock >= 0); 31 | 32 | int size = 1024 * 1024 * 10; // 10MB 33 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_SNDBUF, &size, sizeof(int)) >= 0); 34 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_RCVBUF, &size, sizeof(int)) >= 0); 35 | } 36 | 37 | ~Publisher() 38 | { 39 | nn_close(sock); 40 | nn_shutdown(sock, 0); 41 | sock = 0; 42 | } 43 | 44 | bool bind(const std::string& url) 45 | { 46 | return nn_bind(sock, url.c_str()) >= 0; 47 | } 48 | 49 | bool send(const void* data, int size) 50 | { 51 | int bytes = nn_send(sock, data, size, NN_DONTWAIT); 52 | return bytes == size; 53 | } 54 | }; 55 | 56 | class Subscriber 57 | { 58 | public: 59 | int sock; 60 | 61 | Subscriber(const std::string& url) 62 | : sock(nn_socket(AF_SP, NN_SUB)) 63 | { 64 | verify(sock >= 0); 65 | verify(nn_errno() >= 0); 66 | 67 | verify(nn_setsockopt(sock, NN_SUB, NN_SUB_SUBSCRIBE, "", 0) >= 0); 68 | verify(nn_errno() >= 0); 69 | 70 | int size = 1024 * 1024 * 10; // 10MB 71 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_SNDBUF, &size, sizeof(int)) >= 0); 72 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_RCVBUF, &size, sizeof(int)) >= 0); 73 | 74 | size = 1024 * 1024 * 100; // 100MB 75 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_RCVMAXSIZE, &size, sizeof(int)) >= 0); 76 | 77 | verify(nn_connect(sock, url.c_str()) >= 0); 78 | verify(nn_errno() >= 0); 79 | } 80 | 81 | ~Subscriber() 82 | { 83 | if (sock) 84 | { 85 | nn_shutdown(sock, 0); 86 | sock = 0; 87 | } 88 | } 89 | 90 | bool recv(const std::function& callback) 91 | { 92 | char *buf = nullptr; 93 | int ret = nn_recv(sock, &buf, NN_MSG, NN_DONTWAIT); 94 | 95 | if (ret < 0) 96 | return false; 97 | 98 | const int bytes = ret; 99 | callback(buf, bytes); 100 | nn_freemsg(buf); 101 | 102 | return true; 103 | } 104 | }; 105 | } -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/src/NanomsgIO/NanomsgIO.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef verify 4 | #ifdef NDEBUG 5 | #define verify(expression) expression 6 | #else 7 | #define verify(expression) assert( 0 != (expression) ) 8 | #endif 9 | #endif 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | namespace NanomsgIO 21 | { 22 | class Publisher 23 | { 24 | public: 25 | int sock; 26 | 27 | Publisher() 28 | : sock(nn_socket(AF_SP, NN_PUB)) 29 | { 30 | verify(sock >= 0); 31 | 32 | int size = 1024 * 1024 * 10; // 10MB 33 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_SNDBUF, &size, sizeof(int)) >= 0); 34 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_RCVBUF, &size, sizeof(int)) >= 0); 35 | } 36 | 37 | ~Publisher() 38 | { 39 | nn_close(sock); 40 | nn_shutdown(sock, 0); 41 | sock = 0; 42 | } 43 | 44 | bool bind(const std::string& url) 45 | { 46 | return nn_bind(sock, url.c_str()) >= 0; 47 | } 48 | 49 | bool send(const void* data, int size) 50 | { 51 | int bytes = nn_send(sock, data, size, NN_DONTWAIT); 52 | return bytes == size; 53 | } 54 | }; 55 | 56 | class Subscriber 57 | { 58 | public: 59 | int sock; 60 | 61 | Subscriber(const std::string& url) 62 | : sock(nn_socket(AF_SP, NN_SUB)) 63 | { 64 | verify(sock >= 0); 65 | verify(nn_errno() >= 0); 66 | 67 | verify(nn_setsockopt(sock, NN_SUB, NN_SUB_SUBSCRIBE, "", 0) >= 0); 68 | verify(nn_errno() >= 0); 69 | 70 | int size = 1024 * 1024 * 10; // 10MB 71 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_SNDBUF, &size, sizeof(int)) >= 0); 72 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_RCVBUF, &size, sizeof(int)) >= 0); 73 | 74 | size = 1024 * 1024 * 100; // 100MB 75 | verify(nn_setsockopt(sock, NN_SOL_SOCKET, NN_RCVMAXSIZE, &size, sizeof(int)) >= 0); 76 | 77 | verify(nn_connect(sock, url.c_str()) >= 0); 78 | verify(nn_errno() >= 0); 79 | } 80 | 81 | ~Subscriber() 82 | { 83 | if (sock) 84 | { 85 | nn_shutdown(sock, 0); 86 | sock = 0; 87 | } 88 | } 89 | 90 | bool recv(const std::function& callback) 91 | { 92 | char *buf = NULL; 93 | int ret = nn_recv(sock, &buf, NN_MSG, NN_DONTWAIT); 94 | 95 | if (ret < 0) 96 | return false; 97 | 98 | const int bytes = ret; 99 | callback(buf, bytes); 100 | nn_freemsg(buf); 101 | 102 | return true; 103 | } 104 | }; 105 | } -------------------------------------------------------------------------------- /python/nnpy/constants.py: -------------------------------------------------------------------------------- 1 | NS_NAMESPACE = 0 2 | NS_VERSION = 1 3 | NS_DOMAIN = 2 4 | NS_TRANSPORT = 3 5 | NS_PROTOCOL = 4 6 | NS_OPTION_LEVEL = 5 7 | NS_SOCKET_OPTION = 6 8 | NS_TRANSPORT_OPTION = 7 9 | NS_OPTION_TYPE = 8 10 | NS_OPTION_UNIT = 9 11 | NS_FLAG = 10 12 | NS_ERROR = 11 13 | NS_LIMIT = 12 14 | NS_EVENT = 13 15 | NS_STATISTIC = 14 16 | TYPE_NONE = 0 17 | TYPE_INT = 1 18 | TYPE_STR = 2 19 | UNIT_NONE = 0 20 | UNIT_BYTES = 1 21 | UNIT_MILLISECONDS = 2 22 | UNIT_PRIORITY = 3 23 | UNIT_BOOLEAN = 4 24 | UNIT_COUNTER = 6 25 | UNIT_MESSAGES = 5 26 | VERSION_CURRENT = 5 27 | VERSION_REVISION = 0 28 | VERSION_AGE = 0 29 | AF_SP = 1 30 | AF_SP_RAW = 2 31 | INPROC = -1 32 | IPC = -2 33 | TCP = -3 34 | WS = -4 35 | PAIR = 16 36 | PUB = 32 37 | SUB = 33 38 | REP = 49 39 | REQ = 48 40 | PUSH = 80 41 | PULL = 81 42 | SURVEYOR = 98 43 | RESPONDENT = 99 44 | BUS = 112 45 | SOCKADDR_MAX = 128 46 | SOL_SOCKET = 0 47 | LINGER = 1 48 | SNDBUF = 2 49 | RCVBUF = 3 50 | RCVMAXSIZE = 16 51 | SNDTIMEO = 4 52 | RCVTIMEO = 5 53 | RECONNECT_IVL = 6 54 | RECONNECT_IVL_MAX = 7 55 | SNDPRIO = 8 56 | RCVPRIO = 9 57 | SNDFD = 10 58 | RCVFD = 11 59 | DOMAIN = 12 60 | PROTOCOL = 13 61 | IPV4ONLY = 14 62 | SOCKET_NAME = 15 63 | SUB_SUBSCRIBE = 1 64 | SUB_UNSUBSCRIBE = 2 65 | REQ_RESEND_IVL = 1 66 | SURVEYOR_DEADLINE = 1 67 | TCP_NODELAY = 1 68 | WS_MSG_TYPE = 1 69 | DONTWAIT = 1 70 | WS_MSG_TYPE_TEXT = 1 71 | WS_MSG_TYPE_BINARY = 2 72 | POLLIN = 1 73 | POLLOUT = 2 74 | EADDRINUSE = 100 75 | EADDRNOTAVAIL = 101 76 | EAFNOSUPPORT = 102 77 | EAGAIN = 11 78 | EBADF = 9 79 | ECONNREFUSED = 107 80 | EFAULT = 14 81 | EFSM = 156384766 82 | EINPROGRESS = 112 83 | EINTR = 4 84 | EINVAL = 22 85 | EMFILE = 24 86 | ENAMETOOLONG = 38 87 | ENETDOWN = 116 88 | ENOBUFS = 119 89 | ENODEV = 19 90 | ENOMEM = 12 91 | ENOPROTOOPT = 123 92 | ENOTSOCK = 128 93 | ENOTSUP = 129 94 | EPROTO = 134 95 | EPROTONOSUPPORT = 135 96 | ETERM = 156384765 97 | ETIMEDOUT = 138 98 | EACCES = 13 99 | ECONNABORTED = 106 100 | ECONNRESET = 108 101 | EHOSTUNREACH = 110 102 | EMSGSIZE = 115 103 | ENETRESET = 117 104 | ENETUNREACH = 118 105 | ENOTCONN = 126 106 | STAT_ESTABLISHED_CONNECTIONS = 101 107 | STAT_ACCEPTED_CONNECTIONS = 102 108 | STAT_DROPPED_CONNECTIONS = 103 109 | STAT_BROKEN_CONNECTIONS = 104 110 | STAT_CONNECT_ERRORS = 105 111 | STAT_BIND_ERRORS = 106 112 | STAT_ACCEPT_ERRORS = 107 113 | STAT_MESSAGES_SENT = 301 114 | STAT_MESSAGES_RECEIVED = 302 115 | STAT_BYTES_SENT = 303 116 | STAT_BYTES_RECEIVED = 304 117 | STAT_CURRENT_CONNECTIONS = 201 118 | STAT_INPROGRESS_CONNECTIONS = 202 119 | STAT_CURRENT_SND_PRIORITY = 401 120 | STAT_CURRENT_EP_ERRORS = 203 121 | -------------------------------------------------------------------------------- /python/nnpy/socket.py: -------------------------------------------------------------------------------- 1 | from . import errors, ffi, nanomsg 2 | import sys 3 | 4 | NN_MSG = int(ffi.cast("size_t", -1)) 5 | 6 | ustr = str if sys.version_info[0] > 2 else unicode 7 | 8 | class Socket(object): 9 | """ 10 | Nanomsg scalability protocols (SP) socket. 11 | 12 | .. seealso:: `nanomsg `_ 13 | """ 14 | def __init__(self, domain, protocol): 15 | """ 16 | Create SP socket. 17 | 18 | :param domain: Socket domain `AF_SP` or `AF_SP_RAW`. 19 | :param protocol: Type of the socket determining its exact 20 | semantics. 21 | 22 | .. seealso:: `nn_socket `_ 23 | """ 24 | self.sock = nanomsg.nn_socket(domain, protocol) 25 | 26 | def close(self): 27 | rc = nanomsg.nn_close(self.sock) 28 | return errors.convert(rc, rc) 29 | 30 | def shutdown(self, who): 31 | rc = nanomsg.nn_shutdown(self.sock, who) 32 | return errors.convert(rc, rc) 33 | 34 | def getsockopt(self, level, option): 35 | buf = ffi.new('int*') 36 | size = ffi.new('size_t*') 37 | size[0] = 4 38 | rc = nanomsg.nn_getsockopt(self.sock, level, option, buf, size) 39 | return errors.convert(rc, lambda: buf[0]) 40 | 41 | def setsockopt(self, level, option, value): 42 | if isinstance(value, int): 43 | buf = ffi.new('int*') 44 | buf[0] = value 45 | vlen = 4 46 | elif isinstance(value, ustr): 47 | buf = ffi.new('char[%s]' % len(value), value.encode()) 48 | vlen = len(value) 49 | elif isinstance(value, bytes): 50 | buf = ffi.new('char[%s]' % len(value), value) 51 | vlen = len(value) 52 | else: 53 | raise TypeError("value must be a int, str or bytes") 54 | rc = nanomsg.nn_setsockopt(self.sock, level, option, buf, vlen) 55 | errors.convert(rc) 56 | 57 | def bind(self, addr): 58 | addr = addr.encode() if isinstance(addr, ustr) else addr 59 | buf = ffi.new('char[]', addr) 60 | rc = nanomsg.nn_bind(self.sock, buf) 61 | return errors.convert(rc, rc) 62 | 63 | def connect(self, addr): 64 | addr = addr.encode() if isinstance(addr, ustr) else addr 65 | buf = ffi.new('char[]', addr) 66 | rc = nanomsg.nn_connect(self.sock, buf) 67 | return errors.convert(rc, rc) 68 | 69 | def send(self, data, flags=0): 70 | # Some data types can use a zero-copy buffer creation strategy when 71 | # paired with new versions of CFFI. Namely, CFFI 1.8 supports `bytes` 72 | # types with `from_buffer`, which is about 18% faster. We try the fast 73 | # way first and degrade as needed for the platform. 74 | try: 75 | buf = ffi.from_buffer(data) 76 | except TypeError: 77 | data = data.encode() if isinstance(data, ustr) else data 78 | buf = ffi.new('char[%i]' % len(data), data) 79 | rc = nanomsg.nn_send(self.sock, buf, len(data), flags) 80 | return errors.convert(rc, rc) 81 | 82 | def recv(self, flags=0): 83 | buf = ffi.new('char**') 84 | rc = nanomsg.nn_recv(self.sock, buf, NN_MSG, flags) 85 | errors.convert(rc) 86 | s = ffi.buffer(buf[0], rc)[:] 87 | nanomsg.nn_freemsg(buf[0]) 88 | return s 89 | 90 | def get_statistic(self, statistic): 91 | rc = nanomsg.nn_get_statistic(self.sock, statistic) 92 | return errors.convert(rc, rc) 93 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/NanomsgTOP.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {FC340D07-29F5-4EDE-B10F-2AF65F394652} 23 | v4.5.2 24 | ManagedCProj 25 | NanomsgTOP 26 | 10.0.15063.0 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | v140 33 | false 34 | Unicode 35 | 36 | 37 | DynamicLibrary 38 | false 39 | v140 40 | false 41 | Unicode 42 | 43 | 44 | DynamicLibrary 45 | true 46 | v140 47 | false 48 | Unicode 49 | 50 | 51 | DynamicLibrary 52 | false 53 | v140 54 | false 55 | Unicode 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | true 81 | $(SolutionDir)\..\..\ 82 | 83 | 84 | true 85 | $(SolutionDir)\..\..\ 86 | 87 | 88 | false 89 | $(SolutionDir)\..\..\ 90 | 91 | 92 | false 93 | $(SolutionDir)\..\..\ 94 | 95 | 96 | 97 | Level3 98 | Disabled 99 | WIN32;_DEBUG;%(PreprocessorDefinitions) 100 | NotUsing 101 | 102 | 103 | %(AdditionalDependencies) 104 | 105 | 106 | 107 | 108 | Level3 109 | Disabled 110 | WIN32;_DEBUG;%(PreprocessorDefinitions) 111 | NotUsing 112 | 113 | 114 | %(AdditionalDependencies) 115 | 116 | 117 | 118 | 119 | Level3 120 | WIN32;NDEBUG;%(PreprocessorDefinitions) 121 | NotUsing 122 | 123 | 124 | %(AdditionalDependencies) 125 | 126 | 127 | 128 | 129 | Level3 130 | WIN32;NDEBUG;%(PreprocessorDefinitions) 131 | NotUsing 132 | 133 | 134 | %(AdditionalDependencies) 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/libs/nanomsg/include/nanomsg/nn.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2014 Martin Sustrik All rights reserved. 3 | Copyright (c) 2013 GoPivotal, Inc. All rights reserved. 4 | Copyright 2016 Garrett D'Amore 5 | Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), 9 | to deal in the Software without restriction, including without limitation 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | and/or sell copies of the Software, and to permit persons to whom 12 | the Software is furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included 15 | in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 | IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef NN_H_INCLUDED 27 | #define NN_H_INCLUDED 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | /* Handle DSO symbol visibility. */ 38 | #if !defined(NN_EXPORT) 39 | # if defined(_WIN32) && !defined(NN_STATIC_LIB) 40 | # if defined NN_SHARED_LIB 41 | # define NN_EXPORT __declspec(dllexport) 42 | # else 43 | # define NN_EXPORT __declspec(dllimport) 44 | # endif 45 | # else 46 | # define NN_EXPORT extern 47 | # endif 48 | #endif 49 | 50 | /******************************************************************************/ 51 | /* ABI versioning support. */ 52 | /******************************************************************************/ 53 | 54 | /* Don't change this unless you know exactly what you're doing and have */ 55 | /* read and understand the following documents: */ 56 | /* www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html */ 57 | /* www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html */ 58 | 59 | /* The current interface version. */ 60 | #define NN_VERSION_CURRENT 5 61 | 62 | /* The latest revision of the current interface. */ 63 | #define NN_VERSION_REVISION 0 64 | 65 | /* How many past interface versions are still supported. */ 66 | #define NN_VERSION_AGE 0 67 | 68 | /******************************************************************************/ 69 | /* Errors. */ 70 | /******************************************************************************/ 71 | 72 | /* A number random enough not to collide with different errno ranges on */ 73 | /* different OSes. The assumption is that error_t is at least 32-bit type. */ 74 | #define NN_HAUSNUMERO 156384712 75 | 76 | /* On some platforms some standard POSIX errnos are not defined. */ 77 | #ifndef ENOTSUP 78 | #define ENOTSUP (NN_HAUSNUMERO + 1) 79 | #endif 80 | #ifndef EPROTONOSUPPORT 81 | #define EPROTONOSUPPORT (NN_HAUSNUMERO + 2) 82 | #endif 83 | #ifndef ENOBUFS 84 | #define ENOBUFS (NN_HAUSNUMERO + 3) 85 | #endif 86 | #ifndef ENETDOWN 87 | #define ENETDOWN (NN_HAUSNUMERO + 4) 88 | #endif 89 | #ifndef EADDRINUSE 90 | #define EADDRINUSE (NN_HAUSNUMERO + 5) 91 | #endif 92 | #ifndef EADDRNOTAVAIL 93 | #define EADDRNOTAVAIL (NN_HAUSNUMERO + 6) 94 | #endif 95 | #ifndef ECONNREFUSED 96 | #define ECONNREFUSED (NN_HAUSNUMERO + 7) 97 | #endif 98 | #ifndef EINPROGRESS 99 | #define EINPROGRESS (NN_HAUSNUMERO + 8) 100 | #endif 101 | #ifndef ENOTSOCK 102 | #define ENOTSOCK (NN_HAUSNUMERO + 9) 103 | #endif 104 | #ifndef EAFNOSUPPORT 105 | #define EAFNOSUPPORT (NN_HAUSNUMERO + 10) 106 | #endif 107 | #ifndef EPROTO 108 | #define EPROTO (NN_HAUSNUMERO + 11) 109 | #endif 110 | #ifndef EAGAIN 111 | #define EAGAIN (NN_HAUSNUMERO + 12) 112 | #endif 113 | #ifndef EBADF 114 | #define EBADF (NN_HAUSNUMERO + 13) 115 | #endif 116 | #ifndef EINVAL 117 | #define EINVAL (NN_HAUSNUMERO + 14) 118 | #endif 119 | #ifndef EMFILE 120 | #define EMFILE (NN_HAUSNUMERO + 15) 121 | #endif 122 | #ifndef EFAULT 123 | #define EFAULT (NN_HAUSNUMERO + 16) 124 | #endif 125 | #ifndef EACCES 126 | #define EACCES (NN_HAUSNUMERO + 17) 127 | #endif 128 | #ifndef EACCESS 129 | #define EACCESS (EACCES) 130 | #endif 131 | #ifndef ENETRESET 132 | #define ENETRESET (NN_HAUSNUMERO + 18) 133 | #endif 134 | #ifndef ENETUNREACH 135 | #define ENETUNREACH (NN_HAUSNUMERO + 19) 136 | #endif 137 | #ifndef EHOSTUNREACH 138 | #define EHOSTUNREACH (NN_HAUSNUMERO + 20) 139 | #endif 140 | #ifndef ENOTCONN 141 | #define ENOTCONN (NN_HAUSNUMERO + 21) 142 | #endif 143 | #ifndef EMSGSIZE 144 | #define EMSGSIZE (NN_HAUSNUMERO + 22) 145 | #endif 146 | #ifndef ETIMEDOUT 147 | #define ETIMEDOUT (NN_HAUSNUMERO + 23) 148 | #endif 149 | #ifndef ECONNABORTED 150 | #define ECONNABORTED (NN_HAUSNUMERO + 24) 151 | #endif 152 | #ifndef ECONNRESET 153 | #define ECONNRESET (NN_HAUSNUMERO + 25) 154 | #endif 155 | #ifndef ENOPROTOOPT 156 | #define ENOPROTOOPT (NN_HAUSNUMERO + 26) 157 | #endif 158 | #ifndef EISCONN 159 | #define EISCONN (NN_HAUSNUMERO + 27) 160 | #define NN_EISCONN_DEFINED 161 | #endif 162 | #ifndef ESOCKTNOSUPPORT 163 | #define ESOCKTNOSUPPORT (NN_HAUSNUMERO + 28) 164 | #endif 165 | 166 | /* Native nanomsg error codes. */ 167 | #ifndef ETERM 168 | #define ETERM (NN_HAUSNUMERO + 53) 169 | #endif 170 | #ifndef EFSM 171 | #define EFSM (NN_HAUSNUMERO + 54) 172 | #endif 173 | 174 | /* This function retrieves the errno as it is known to the library. */ 175 | /* The goal of this function is to make the code 100% portable, including */ 176 | /* where the library is compiled with certain CRT library (on Windows) and */ 177 | /* linked to an application that uses different CRT library. */ 178 | NN_EXPORT int nn_errno (void); 179 | 180 | /* Resolves system errors and native errors to human-readable string. */ 181 | NN_EXPORT const char *nn_strerror (int errnum); 182 | 183 | 184 | /* Returns the symbol name (e.g. "NN_REQ") and value at a specified index. */ 185 | /* If the index is out-of-range, returns NULL and sets errno to EINVAL */ 186 | /* General usage is to start at i=0 and iterate until NULL is returned. */ 187 | NN_EXPORT const char *nn_symbol (int i, int *value); 188 | 189 | /* Constants that are returned in `ns` member of nn_symbol_properties */ 190 | #define NN_NS_NAMESPACE 0 191 | #define NN_NS_VERSION 1 192 | #define NN_NS_DOMAIN 2 193 | #define NN_NS_TRANSPORT 3 194 | #define NN_NS_PROTOCOL 4 195 | #define NN_NS_OPTION_LEVEL 5 196 | #define NN_NS_SOCKET_OPTION 6 197 | #define NN_NS_TRANSPORT_OPTION 7 198 | #define NN_NS_OPTION_TYPE 8 199 | #define NN_NS_OPTION_UNIT 9 200 | #define NN_NS_FLAG 10 201 | #define NN_NS_ERROR 11 202 | #define NN_NS_LIMIT 12 203 | #define NN_NS_EVENT 13 204 | #define NN_NS_STATISTIC 14 205 | 206 | /* Constants that are returned in `type` member of nn_symbol_properties */ 207 | #define NN_TYPE_NONE 0 208 | #define NN_TYPE_INT 1 209 | #define NN_TYPE_STR 2 210 | 211 | /* Constants that are returned in the `unit` member of nn_symbol_properties */ 212 | #define NN_UNIT_NONE 0 213 | #define NN_UNIT_BYTES 1 214 | #define NN_UNIT_MILLISECONDS 2 215 | #define NN_UNIT_PRIORITY 3 216 | #define NN_UNIT_BOOLEAN 4 217 | #define NN_UNIT_MESSAGES 5 218 | #define NN_UNIT_COUNTER 6 219 | 220 | /* Structure that is returned from nn_symbol */ 221 | struct nn_symbol_properties { 222 | 223 | /* The constant value */ 224 | int value; 225 | 226 | /* The constant name */ 227 | const char* name; 228 | 229 | /* The constant namespace, or zero for namespaces themselves */ 230 | int ns; 231 | 232 | /* The option type for socket option constants */ 233 | int type; 234 | 235 | /* The unit for the option value for socket option constants */ 236 | int unit; 237 | }; 238 | 239 | /* Fills in nn_symbol_properties structure and returns it's length */ 240 | /* If the index is out-of-range, returns 0 */ 241 | /* General usage is to start at i=0 and iterate until zero is returned. */ 242 | NN_EXPORT int nn_symbol_info (int i, 243 | struct nn_symbol_properties *buf, int buflen); 244 | 245 | /******************************************************************************/ 246 | /* Helper function for shutting down multi-threaded applications. */ 247 | /******************************************************************************/ 248 | 249 | NN_EXPORT void nn_term (void); 250 | 251 | /******************************************************************************/ 252 | /* Zero-copy support. */ 253 | /******************************************************************************/ 254 | 255 | #define NN_MSG ((size_t) -1) 256 | 257 | NN_EXPORT void *nn_allocmsg (size_t size, int type); 258 | NN_EXPORT void *nn_reallocmsg (void *msg, size_t size); 259 | NN_EXPORT int nn_freemsg (void *msg); 260 | 261 | /******************************************************************************/ 262 | /* Socket definition. */ 263 | /******************************************************************************/ 264 | 265 | struct nn_iovec { 266 | void *iov_base; 267 | size_t iov_len; 268 | }; 269 | 270 | struct nn_msghdr { 271 | struct nn_iovec *msg_iov; 272 | int msg_iovlen; 273 | void *msg_control; 274 | size_t msg_controllen; 275 | }; 276 | 277 | struct nn_cmsghdr { 278 | size_t cmsg_len; 279 | int cmsg_level; 280 | int cmsg_type; 281 | }; 282 | 283 | /* Internal stuff. Not to be used directly. */ 284 | NN_EXPORT struct nn_cmsghdr *nn_cmsg_nxthdr_ ( 285 | const struct nn_msghdr *mhdr, 286 | const struct nn_cmsghdr *cmsg); 287 | #define NN_CMSG_ALIGN_(len) \ 288 | (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) 289 | 290 | /* POSIX-defined msghdr manipulation. */ 291 | 292 | #define NN_CMSG_FIRSTHDR(mhdr) \ 293 | nn_cmsg_nxthdr_ ((struct nn_msghdr*) (mhdr), NULL) 294 | 295 | #define NN_CMSG_NXTHDR(mhdr, cmsg) \ 296 | nn_cmsg_nxthdr_ ((struct nn_msghdr*) (mhdr), (struct nn_cmsghdr*) (cmsg)) 297 | 298 | #define NN_CMSG_DATA(cmsg) \ 299 | ((unsigned char*) (((struct nn_cmsghdr*) (cmsg)) + 1)) 300 | 301 | /* Extensions to POSIX defined by RFC 3542. */ 302 | 303 | #define NN_CMSG_SPACE(len) \ 304 | (NN_CMSG_ALIGN_ (len) + NN_CMSG_ALIGN_ (sizeof (struct nn_cmsghdr))) 305 | 306 | #define NN_CMSG_LEN(len) \ 307 | (NN_CMSG_ALIGN_ (sizeof (struct nn_cmsghdr)) + (len)) 308 | 309 | /* SP address families. */ 310 | #define AF_SP 1 311 | #define AF_SP_RAW 2 312 | 313 | /* Max size of an SP address. */ 314 | #define NN_SOCKADDR_MAX 128 315 | 316 | /* Socket option levels: Negative numbers are reserved for transports, 317 | positive for socket types. */ 318 | #define NN_SOL_SOCKET 0 319 | 320 | /* Generic socket options (NN_SOL_SOCKET level). */ 321 | #define NN_LINGER 1 322 | #define NN_SNDBUF 2 323 | #define NN_RCVBUF 3 324 | #define NN_SNDTIMEO 4 325 | #define NN_RCVTIMEO 5 326 | #define NN_RECONNECT_IVL 6 327 | #define NN_RECONNECT_IVL_MAX 7 328 | #define NN_SNDPRIO 8 329 | #define NN_RCVPRIO 9 330 | #define NN_SNDFD 10 331 | #define NN_RCVFD 11 332 | #define NN_DOMAIN 12 333 | #define NN_PROTOCOL 13 334 | #define NN_IPV4ONLY 14 335 | #define NN_SOCKET_NAME 15 336 | #define NN_RCVMAXSIZE 16 337 | #define NN_MAXTTL 17 338 | 339 | /* Send/recv options. */ 340 | #define NN_DONTWAIT 1 341 | 342 | /* Ancillary data. */ 343 | #define PROTO_SP 1 344 | #define SP_HDR 1 345 | 346 | NN_EXPORT int nn_socket (int domain, int protocol); 347 | NN_EXPORT int nn_close (int s); 348 | NN_EXPORT int nn_setsockopt (int s, int level, int option, const void *optval, 349 | size_t optvallen); 350 | NN_EXPORT int nn_getsockopt (int s, int level, int option, void *optval, 351 | size_t *optvallen); 352 | NN_EXPORT int nn_bind (int s, const char *addr); 353 | NN_EXPORT int nn_connect (int s, const char *addr); 354 | NN_EXPORT int nn_shutdown (int s, int how); 355 | NN_EXPORT int nn_send (int s, const void *buf, size_t len, int flags); 356 | NN_EXPORT int nn_recv (int s, void *buf, size_t len, int flags); 357 | NN_EXPORT int nn_sendmsg (int s, const struct nn_msghdr *msghdr, int flags); 358 | NN_EXPORT int nn_recvmsg (int s, struct nn_msghdr *msghdr, int flags); 359 | 360 | /******************************************************************************/ 361 | /* Socket mutliplexing support. */ 362 | /******************************************************************************/ 363 | 364 | #define NN_POLLIN 1 365 | #define NN_POLLOUT 2 366 | 367 | struct nn_pollfd { 368 | int fd; 369 | short events; 370 | short revents; 371 | }; 372 | 373 | NN_EXPORT int nn_poll (struct nn_pollfd *fds, int nfds, int timeout); 374 | 375 | /******************************************************************************/ 376 | /* Built-in support for devices. */ 377 | /******************************************************************************/ 378 | 379 | NN_EXPORT int nn_device (int s1, int s2); 380 | 381 | /******************************************************************************/ 382 | /* Statistics. */ 383 | /******************************************************************************/ 384 | 385 | /* Transport statistics */ 386 | #define NN_STAT_ESTABLISHED_CONNECTIONS 101 387 | #define NN_STAT_ACCEPTED_CONNECTIONS 102 388 | #define NN_STAT_DROPPED_CONNECTIONS 103 389 | #define NN_STAT_BROKEN_CONNECTIONS 104 390 | #define NN_STAT_CONNECT_ERRORS 105 391 | #define NN_STAT_BIND_ERRORS 106 392 | #define NN_STAT_ACCEPT_ERRORS 107 393 | 394 | #define NN_STAT_CURRENT_CONNECTIONS 201 395 | #define NN_STAT_INPROGRESS_CONNECTIONS 202 396 | #define NN_STAT_CURRENT_EP_ERRORS 203 397 | 398 | /* The socket-internal statistics */ 399 | #define NN_STAT_MESSAGES_SENT 301 400 | #define NN_STAT_MESSAGES_RECEIVED 302 401 | #define NN_STAT_BYTES_SENT 303 402 | #define NN_STAT_BYTES_RECEIVED 304 403 | /* Protocol statistics */ 404 | #define NN_STAT_CURRENT_SND_PRIORITY 401 405 | 406 | NN_EXPORT uint64_t nn_get_statistic (int s, int stat); 407 | 408 | #ifdef __cplusplus 409 | } 410 | #endif 411 | 412 | #endif 413 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/src/CPlusPlus_Common.h: -------------------------------------------------------------------------------- 1 | /* Shared Use License: This file is owned by Derivative Inc. (Derivative) and 2 | * can only be used, and/or modified for use, in conjunction with 3 | * Derivative's TouchDesigner software, and only if you are a licensee who has 4 | * accepted Derivative's TouchDesigner license or assignment agreement (which 5 | * also govern the use of this file). You may share a modified version of this 6 | * file with another authorized licensee of Derivative's TouchDesigner software. 7 | * Otherwise, no redistribution or sharing of this file, with or without 8 | * modification, is permitted. 9 | */ 10 | 11 | /* 12 | * Produced by: 13 | * 14 | * Derivative Inc 15 | * 401 Richmond Street West, Unit 386 16 | * Toronto, Ontario 17 | * Canada M5V 3A8 18 | * 416-591-3555 19 | * 20 | * NAME: CPlusPlus_Common.h 21 | * 22 | */ 23 | 24 | /******* 25 | Derivative Developers:: Make sure the virtual function order 26 | stays the same, otherwise changes won't be backwards compatible 27 | ********/ 28 | 29 | 30 | #ifndef __CPlusPlus_Common 31 | #define __CPlusPlus_Common 32 | 33 | #define NOMINMAX 34 | 35 | #include 36 | #ifdef _WIN32 37 | #include 38 | #include 39 | #define DLLEXPORT __declspec (dllexport) 40 | #else 41 | #include 42 | #endif 43 | #include 44 | 45 | enum CPUMemPixelType 46 | { 47 | // 8-bit per color, BGRA pixels. This is preferred for 4 channel 8-bit data 48 | BGRA8Fixed = 0, 49 | // 8-bit per color, RGBA pixels. Only use this one if absolutely nesseary. 50 | RGBA8Fixed, 51 | // 32-bit float per color, RGBA pixels 52 | RGBA32Float, 53 | 54 | // Single and double channel options 55 | // Fixed 56 | R8Fixed, 57 | RG8Fixed, 58 | // Float 59 | R32Float, 60 | RG32Float, 61 | }; 62 | 63 | 64 | class OP_NodeInfo 65 | { 66 | public: 67 | // The full path to the operator 68 | 69 | const char* opPath; 70 | 71 | // A unique ID representing the operator, no two operators will ever 72 | // have the same ID in a single TouchDesigner instance. 73 | 74 | unsigned int opID; 75 | 76 | // This is the handle to the main TouchDesigner window. 77 | // It's possible this will be 0 the first few times the operator cooks, 78 | // incase it cooks while TouchDesigner is still loading up 79 | 80 | #ifdef WIN32 81 | HWND mainWindowHandle; 82 | #endif 83 | 84 | private: 85 | int reserved[19]; 86 | }; 87 | 88 | 89 | class OP_DATInput 90 | { 91 | public: 92 | const char* opPath; 93 | unsigned int opId; 94 | 95 | int numRows; 96 | int numCols; 97 | bool isTable; 98 | 99 | // data, referenced by (row,col), which will be a const char* for the 100 | // contents of the cell 101 | // E.g getCell(1,2) will be the contents of the cell located at (1,2) 102 | 103 | const char* getCell(int row, int col) const 104 | { 105 | return cellData[row * numCols + col]; 106 | } 107 | 108 | protected: 109 | const char** cellData; 110 | 111 | private: 112 | int reserved[20]; 113 | }; 114 | 115 | class OP_TOPInput 116 | { 117 | public: 118 | const char* opPath; 119 | unsigned int opId; 120 | 121 | int width; 122 | int height; 123 | 124 | 125 | // The OpenGL Texture index for this TOP. 126 | // This is only valid when accessed from C++ TOPs. 127 | // Other C++ OPs will have this value set to 0 (invalid). 128 | GLuint textureIndex; 129 | 130 | // The OpenGL Texture target for this TOP. 131 | // E.g GL_TEXTURE_2D, GL_TEXTURE_CUBE, 132 | // GL_TEXTURE_2D_ARRAY 133 | GLenum textureType; 134 | 135 | // Depth for 3D and 2D_ARRAY textures, undefined 136 | // for other texture types 137 | unsigned int depth; 138 | 139 | // contains the internalFormat for the texture 140 | // such as GL_RGBA8, GL_RGBA32F, GL_R16 141 | GLint pixelFormat; 142 | 143 | private: 144 | int reserved[19]; 145 | }; 146 | 147 | 148 | class OP_CHOPInput 149 | { 150 | public: 151 | 152 | const char* opPath; 153 | unsigned int opId; 154 | 155 | int numChannels; 156 | int numSamples; 157 | double sampleRate; 158 | double startIndex; 159 | 160 | 161 | 162 | // Retrieve a float array for a specific channel. 163 | // 'i' ranges from 0 to numChannels-1 164 | // The returned arrray contains 'numSamples' samples. 165 | // e.g: getChannelData(1)[10] will refer to the 11th sample in the 2nd channel 166 | 167 | const float* getChannelData(int i) const 168 | { 169 | return channelData[i]; 170 | } 171 | 172 | 173 | // Retrieve the name of a specific channel. 174 | // 'i' ranges from 0 to numChannels-1 175 | // For example getChannelName(1) is the name of the 2nd channel 176 | 177 | const char* getChannelName(int i) const 178 | { 179 | return nameData[i]; 180 | } 181 | 182 | protected: 183 | 184 | const float** channelData; 185 | const char** nameData; 186 | 187 | 188 | private: 189 | 190 | int reserved[20]; 191 | }; 192 | 193 | class OP_ObjectInput 194 | { 195 | public: 196 | 197 | const char* opPath; 198 | unsigned int opId; 199 | 200 | // Use these methods to calculate object transforms 201 | double worldTransform[4][4]; 202 | double localTransform[4][4]; 203 | 204 | 205 | private: 206 | 207 | int reserved[20]; 208 | }; 209 | 210 | 211 | enum OP_TOPInputDownloadType 212 | { 213 | // The texture data will be downloaded and and available on the next frame. 214 | // Except for the first time this is used, getTOPDataInCPUMemory() 215 | // will return the texture data on the CPU from the previous frame. 216 | // The first getTOPDataInCPUMemory() is called it will be nullptr. 217 | // ** This mode should be used is most cases for performance reasons ** 218 | OP_TOP_INPUT_DOWNLOAD_DELAYED, 219 | 220 | // The texture data will be downloaded immediately and be available 221 | // this frame. This can cause a large stall though and should be avoided 222 | // in most cases 223 | OP_TOP_INPUT_DOWNLOAD_INSTANT, 224 | }; 225 | 226 | class OP_TOPInputDownloadOptions 227 | { 228 | public: 229 | OP_TOPInputDownloadOptions() 230 | { 231 | downloadType = OP_TOP_INPUT_DOWNLOAD_DELAYED; 232 | verticalFlip = false; 233 | cpuMemPixelType = BGRA8Fixed; 234 | } 235 | 236 | OP_TOPInputDownloadType downloadType; 237 | 238 | // Set this to true if you want the image vertically flipped in the 239 | // downloaded data 240 | bool verticalFlip; 241 | 242 | // Set this to how you want the pixel data to be give to you in CPU 243 | // memory. BGRA8Fixed should be used for 4 channel 8-bit data if possible 244 | CPUMemPixelType cpuMemPixelType; 245 | 246 | }; 247 | 248 | 249 | class OP_Inputs 250 | { 251 | public: 252 | // NOTE: When writting a TOP, none of these functions should 253 | // be called inside a beginGLCommands()/endGLCommands() section 254 | // as they may require GL themselves to complete execution. 255 | 256 | // these are wired into the node 257 | virtual int getNumInputs() = 0; 258 | 259 | // may return nullptr when invalid input 260 | virtual const OP_TOPInput* getInputTOP(int index) = 0; // only valid for TOP operators 261 | virtual const OP_CHOPInput* getInputCHOP(int index) = 0; // only valid for CHOP operators 262 | 263 | // these are defined by parameters. 264 | // may return nullptr when invalid input 265 | // this value is valid until the parameters are rebuilt or it is called with the same parameter name. 266 | virtual const OP_DATInput* getParDAT(const char *name) = 0; 267 | virtual const OP_TOPInput* getParTOP(const char *name) = 0; 268 | virtual const OP_CHOPInput* getParCHOP(const char *name) = 0; 269 | virtual const OP_ObjectInput* getParObject(const char *name) = 0; 270 | 271 | // these work on any type of parameter and can be interchanged 272 | // for menu types, int returns the menu selection index, string returns the item 273 | 274 | // returns the requested value, index may be 0 to 4. 275 | virtual double getParDouble(const char* name, int index=0) = 0; 276 | 277 | // for multiple values: returns True on success/false otherwise 278 | virtual bool getParDouble2(const char* name, double &v0, double &v1) = 0; 279 | virtual bool getParDouble3(const char* name, double &v0, double &v1, double &v2) = 0; 280 | virtual bool getParDouble4(const char* name, double &v0, double &v1, double &v2, double &v3) = 0; 281 | 282 | 283 | // returns the requested value 284 | virtual int getParInt(const char* name, int index=0) = 0; 285 | 286 | // for multiple values: returns True on success/false otherwise 287 | virtual bool getParInt2(const char* name, int &v0, int &v1) = 0; 288 | virtual bool getParInt3(const char* name, int &v0, int &v1, int &v2) = 0; 289 | virtual bool getParInt4(const char* name, int &v0, int &v1, int &v2, int &v3) = 0; 290 | 291 | // returns the requested value 292 | // this value is valid until the parameters are rebuilt or it is called with the same parameter name. 293 | virtual const char* getParString(const char* name) = 0; // return value usable for life of parameter 294 | 295 | // this is similar to getParString, but will return an absolute path if it exists, with 296 | // slash direction consistent with O/S requirements. 297 | // to get the original parameter value, use getParString 298 | virtual const char* getParFilePath(const char* name) = 0; // return value usable for life of parameter 299 | 300 | // returns true on success 301 | // from_name and to_name must be Object parameters 302 | virtual bool getRelativeTransform(const char* from_name, const char* to_name, double matrix[4][4]) = 0; 303 | 304 | 305 | // disable or enable updating of the parameter 306 | virtual void enablePar(const char* name, bool onoff) = 0; 307 | 308 | 309 | // these are defined by paths. 310 | // may return nullptr when invalid input 311 | // this value is valid until the parameters are rebuilt or it is called with the same parameter name. 312 | virtual const OP_DATInput* getDAT(const char *path) = 0; 313 | virtual const OP_TOPInput* getTOP(const char *path) = 0; 314 | virtual const OP_CHOPInput* getCHOP(const char *path) = 0; 315 | virtual const OP_ObjectInput* getObject(const char *path) = 0; 316 | 317 | 318 | // This function can be used to retrieve the TOPs texture data in CPU 319 | // memory. You must pass the OP_TOPInput object you get from 320 | // getParTOP/getInputTOP into this, not a copy you've made 321 | // 322 | // Fill in a OP_TOPIputDownloadOptions class with the desired options set 323 | // 324 | // Returns the data, which will be valid until the end of execute() 325 | // Returned value may be nullptr in some cases, such as the first call 326 | // to this with options->downloadType == OP_TOP_DOWNLOAD_DELAYED. 327 | virtual void* getTOPDataInCPUMemory(const OP_TOPInput *top, 328 | const OP_TOPInputDownloadOptions *options) = 0; 329 | 330 | }; 331 | 332 | class OP_InfoCHOPChan 333 | { 334 | public: 335 | char* name; 336 | float value; 337 | private: 338 | int reserved[10]; 339 | }; 340 | 341 | class OP_InfoDATSize 342 | { 343 | public: 344 | 345 | // Set this to the size you want the table to be 346 | 347 | int rows; 348 | int cols; 349 | 350 | // Set this to true if you want to return DAT entries on a column 351 | // by column basis. 352 | // Otherwise set to false, and you'll be expected to set them on 353 | // a row by row basis. 354 | // DEFAULT : false 355 | 356 | bool byColumn; 357 | 358 | 359 | private: 360 | int reserved[10]; 361 | }; 362 | 363 | class OP_InfoDATEntries 364 | { 365 | public: 366 | 367 | // This is an array of char* pointers which you are expected to assign 368 | // The start off as NULL, you need to allocate or assign constant/statis 369 | // strings to them 370 | // e.g values[1] = "myColumnName"; 371 | 372 | char** values; 373 | 374 | private: 375 | int reserved[10]; 376 | }; 377 | 378 | 379 | 380 | class OP_NumericParameter 381 | { 382 | public: 383 | 384 | OP_NumericParameter(const char* iname=nullptr) 385 | { 386 | name = iname; 387 | label = page = nullptr; 388 | 389 | for (int i=0; i<4; i++) 390 | { 391 | defaultValues[i] = 0.0; 392 | 393 | minSliders[i] = 0.0; 394 | maxSliders[i] = 1.0; 395 | 396 | minValues[i] = 0.0; 397 | maxValues[i] = 1.0; 398 | 399 | clampMins[i] = false; 400 | clampMaxes[i] = false; 401 | } 402 | } 403 | 404 | // Any char* values passed are copied immediately by the append parameter functions, 405 | // and do not need to be retained by the calling function. 406 | 407 | const char* name; // Must begin with capital letter, and contain no spaces 408 | const char* label; 409 | const char* page; 410 | 411 | double defaultValues[4]; 412 | double minValues[4]; 413 | double maxValues[4]; 414 | 415 | bool clampMins[4]; 416 | bool clampMaxes[4]; 417 | 418 | double minSliders[4]; 419 | double maxSliders[4]; 420 | 421 | private: 422 | 423 | int reserved[20]; 424 | 425 | }; 426 | 427 | class OP_StringParameter 428 | { 429 | public: 430 | 431 | OP_StringParameter(const char* iname=nullptr) 432 | { 433 | name = iname; 434 | label = page = nullptr; 435 | defaultValue = nullptr; 436 | } 437 | 438 | // Any char* values passed are copied immediately by the append parameter functions, 439 | // and do not need to be retained by the calling function. 440 | 441 | const char* name; // Must begin with capital letter, and contain no spaces 442 | const char* label; 443 | const char* page; 444 | 445 | const char* defaultValue; 446 | 447 | private: 448 | 449 | int reserved[20]; 450 | }; 451 | 452 | 453 | enum ParAppendResult 454 | { 455 | PARAMETER_APPEND_SUCCESS = 0, 456 | PARAMETER_APPEND_INVALID_NAME = 1, // invalid or duplicate name 457 | PARAMETER_APPEND_INVALID_SIZE = 2, // size out of range 458 | }; 459 | 460 | 461 | class OP_ParameterManager 462 | { 463 | 464 | public: 465 | 466 | // Returns PARAMETER_APPEND_SUCCESS on succesful 467 | 468 | virtual ParAppendResult appendFloat(const OP_NumericParameter &np, int size=1) = 0; 469 | virtual ParAppendResult appendInt(const OP_NumericParameter &np, int size=1) = 0; 470 | 471 | virtual ParAppendResult appendXY(const OP_NumericParameter &np) = 0; 472 | virtual ParAppendResult appendXYZ(const OP_NumericParameter &np) = 0; 473 | 474 | virtual ParAppendResult appendUV(const OP_NumericParameter &np) = 0; 475 | virtual ParAppendResult appendUVW(const OP_NumericParameter &np) = 0; 476 | 477 | virtual ParAppendResult appendRGB(const OP_NumericParameter &np) = 0; 478 | virtual ParAppendResult appendRGBA(const OP_NumericParameter &np) = 0; 479 | 480 | virtual ParAppendResult appendToggle(const OP_NumericParameter &np) = 0; 481 | virtual ParAppendResult appendPulse(const OP_NumericParameter &np) = 0; 482 | 483 | virtual ParAppendResult appendString(const OP_StringParameter &sp) = 0; 484 | virtual ParAppendResult appendFile(const OP_StringParameter &sp) = 0; 485 | virtual ParAppendResult appendFolder(const OP_StringParameter &sp) = 0; 486 | 487 | virtual ParAppendResult appendDAT(const OP_StringParameter &sp) = 0; 488 | virtual ParAppendResult appendCHOP(const OP_StringParameter &sp) = 0; 489 | virtual ParAppendResult appendTOP(const OP_StringParameter &sp) = 0; 490 | virtual ParAppendResult appendObject(const OP_StringParameter &sp) = 0; 491 | 492 | // Any char* values passed are copied immediately by the append parameter functions, 493 | // and do not need to be retained by the calling function. 494 | virtual ParAppendResult appendMenu(const OP_StringParameter &sp, 495 | int nitems, const char **names, 496 | const char **labels) = 0; 497 | 498 | // Any char* values passed are copied immediately by the append parameter functions, 499 | // and do not need to be retained by the calling function. 500 | virtual ParAppendResult appendStringMenu(const OP_StringParameter &sp, 501 | int nitems, const char **names, 502 | const char **labels) = 0; 503 | 504 | private: 505 | 506 | 507 | }; 508 | 509 | #endif 510 | -------------------------------------------------------------------------------- /dll/NanomsgTOP/src/TOP_CPlusPlusBase.h: -------------------------------------------------------------------------------- 1 | /* Shared Use License: This file is owned by Derivative Inc. (Derivative) and 2 | * can only be used, and/or modified for use, in conjunction with 3 | * Derivative's TouchDesigner software, and only if you are a licensee who has 4 | * accepted Derivative's TouchDesigner license or assignment agreement (which 5 | * also govern the use of this file). You may share a modified version of this 6 | * file with another authorized licensee of Derivative's TouchDesigner software. 7 | * Otherwise, no redistribution or sharing of this file, with or without 8 | * modification, is permitted. 9 | */ 10 | 11 | /* 12 | * Produced by: 13 | * 14 | * Derivative Inc 15 | * 401 Richmond Street West, Unit 386 16 | * Toronto, Ontario 17 | * Canada M5V 3A8 18 | * 416-591-3555 19 | * 20 | * NAME: TOP_CPlusPlusBase.h 21 | * 22 | */ 23 | 24 | /******* 25 | Do not edit this file directly! 26 | Make a subclass of TOP_CPlusPlusBase instead, and add your own data/function 27 | 28 | Derivative Developers:: Make sure the virtual function order 29 | stays the same, otherwise changes won't be backwards compatible 30 | ********/ 31 | 32 | 33 | #ifndef __TOP_CPlusPlusBase__ 34 | #define __TOP_CPlusPlusBase__ 35 | 36 | #ifdef WIN32 37 | #define NOMINMAX 38 | #include 39 | #include 40 | #define DLLEXPORT __declspec (dllexport) 41 | #else 42 | #define DLLEXPORT 43 | #endif 44 | #include 45 | 46 | #include "CPlusPlus_Common.h" 47 | 48 | 49 | #define TOP_CPLUSPLUS_API_VERSION 7 50 | 51 | class TOP_CPlusPlusBase; 52 | class TOP_Context; 53 | 54 | 55 | // These are the definitions for the C-functions that are used to 56 | // load the library and create instances of the object you define 57 | typedef int (__cdecl *GETTOPAPIVERSION)(void); 58 | typedef TOP_CPlusPlusBase* (__cdecl *CREATETOPINSTANCE)(const OP_NodeInfo*, 59 | TOP_Context*); 60 | typedef void (__cdecl *DESTROYTOPINSTANCE)(TOP_CPlusPlusBase*, TOP_Context*); 61 | 62 | // These classes are used to pass data to/from the functions you will define 63 | 64 | enum ExecuteType 65 | { 66 | // Rendering is done using OpenGL into a FBO/RenderBuffers 67 | // that is provided for you 68 | OPENGL_FBO = 0, 69 | 70 | // CPU memory is filled with data directly. No OpenGL calls can be 71 | // made when using this mode. Doing so will likely result in 72 | // rendering issues within TD. 73 | CPU_MEM_WRITEONLY = 1, 74 | CPU_MEM_READWRITE = 2 75 | }; 76 | 77 | 78 | // TouchDesigner will select the best pixel format based on the options you give 79 | // Not all possible combinations of channels/bit depth are possible, 80 | // so you get the best choice supported by your card 81 | 82 | class TOP_OutputFormat 83 | { 84 | public: 85 | int width; 86 | int height; 87 | 88 | 89 | // The aspect ratio of the TOP's output 90 | 91 | float aspectX; 92 | float aspectY; 93 | 94 | 95 | // The anti-alias level. 96 | // 1 means no anti-alaising 97 | // 2 means '2x', etc., up to 32 right now 98 | // Only used when executeMode == OPENGL_FBO 99 | 100 | int antiAlias; 101 | 102 | 103 | // Set true if you want this channel, false otherwise 104 | // The channel may still be present if the combination you select 105 | // isn't supported by the card (blue only for example) 106 | 107 | bool redChannel; 108 | bool greenChannel; 109 | bool blueChannel; 110 | bool alphaChannel; 111 | 112 | 113 | // The number of bits per channel. 114 | // TouchDesigner will select the closest supported number of bits based on 115 | // your cards capabilities 116 | 117 | unsigned bitsPerChannel; 118 | 119 | // Set to true if you want a floating point format. 120 | // Some bit precisions don't support floating point (8-bit for example) 121 | // while others require it (32-bit) 122 | 123 | bool floatPrecision; 124 | 125 | 126 | // If you want to use multiple render targets, you can set this 127 | // greater than one 128 | // Only used when executeMode == OPENGL_FBO 129 | 130 | int numColorBuffers; 131 | 132 | 133 | // The number of bits in the depth buffer. 134 | // 0 for no depth buffer 135 | // Only used when executeMode == OPENGL_FBO 136 | 137 | int depthBits; 138 | 139 | 140 | // The number of bits in the stencil buffer 141 | // 0 for no stencil buffer, if this is > 0 then 142 | // it will also cause a depth buffer to be created 143 | // even if you have depthBits == 0 144 | // Only used when executeMode == OPENGL_FBO 145 | 146 | int stencilBits; 147 | 148 | private: 149 | int reserved[20]; 150 | }; 151 | 152 | 153 | // This class will tell you the actual output format 154 | // that was chosen. 155 | class TOP_OutputFormatSpecs 156 | { 157 | public: 158 | int width; 159 | int height; 160 | float aspectX; 161 | float aspectY; 162 | 163 | int antiAlias; 164 | 165 | int redBits; 166 | int blueBits; 167 | int greenBits; 168 | int alphaBits; 169 | bool floatPrecision; 170 | 171 | /*** BEGIN: OPENGL_FBO executeMode specific ***/ 172 | int numColorBuffers; 173 | 174 | int depthBits; 175 | int stencilBits; 176 | 177 | 178 | GLuint reservedV5; 179 | /*** END: OPENGL_FBO executeMode specific ***/ 180 | 181 | 182 | 183 | 184 | /*** BEGIN: CPU_MEM_* executeMode specific ***/ 185 | 186 | // if the 'executeMode' is set to CPU_MEM_* 187 | // then cpuPixelData will point to three blocks of memory of size 188 | // width * height * bytesPerPixel 189 | // and one may be uploaded as a texture after the execute call. 190 | // All of these pointers will stay valid until the next execute() call 191 | // unless you set newCPUPixelDataLocation to 0, 1 or 2. In that case 192 | // the location you specified will become invalid as soon as execute() 193 | // returns. The pointers for the locations you don't specify stays 194 | // valid though. 195 | // This means you can hold onto these pointers by default and use them 196 | // after execute() returns, such as filling them in another thread. 197 | void* cpuPixelData[3]; 198 | 199 | // setting this to 0 will upload memory from cpuPixelData[0], 200 | // setting this to 1 will upload memory from cpuPixelData[1] 201 | // setting this to 2 will upload memory from cpuPixelData[2] 202 | // uploading from a memory location will invalidate it and a new memory location will be provided next execute call. 203 | // setting this to -1 will not upload any memory and retain previously uploaded texture 204 | // setting this to any other value will result in an error being displayed in the CPlusPlus TOP. 205 | // defaults to -1 206 | mutable int newCPUPixelDataLocation; 207 | 208 | /*** END: CPU_MEM_* executeMode specific ***/ 209 | 210 | 211 | 212 | /*** BEGIN: New OPENGL_FBO execudeMode specific data ***/ 213 | 214 | // The first color can either be a GL_TEXTURE_2D or a GL_RENDERBUFFER 215 | // depending on the settings. This will be set to either 216 | // GL_TEXTURE_2D or GL_RENDERBUFFER accordingly 217 | GLenum colorBuffer0Type; 218 | 219 | // The indices for the renderBuffers for the color buffers that are attached to the FBO, except for possibly index 0 (see colorBuffer0Type) 220 | // these are all GL_RENDERBUFFER GL objects, or 0 if not present 221 | GLuint colorBufferRB[32]; 222 | 223 | // The renderBuffer for the depth buffer that is attached to the FBO 224 | // This is always a GL_RENDERBUFFER GL object 225 | GLuint depthBufferRB; 226 | 227 | /*** END: OPENGL_FBO executeMode specific ***/ 228 | 229 | private: 230 | int reserved[10]; 231 | }; 232 | 233 | class TOP_GeneralInfo 234 | { 235 | public: 236 | // Set this to true if you want the TOP to cook every frame, even 237 | // if none of it's inputs/parameters are changing 238 | 239 | bool cookEveryFrame; 240 | 241 | 242 | // TouchDesigner will clear the color/depth buffers before calling 243 | // execute(), as an optimization you can disable this, if you know 244 | // you'll be overwriting all the data or calling clear yourself 245 | 246 | bool clearBuffers; 247 | 248 | 249 | // Set this to true if you want TouchDesigner to create mipmaps for all the 250 | // TOPs that are passed into execute() function 251 | 252 | bool mipmapAllTOPs; 253 | 254 | // Set this to true if you want the CHOP to cook every frame, if asked 255 | // (someone uses it's output) 256 | // This is different from 'cookEveryFrame', which causes the node to cook 257 | // every frame no matter what 258 | 259 | bool cookEveryFrameIfAsked; 260 | 261 | // When setting the output texture size using the node's common page 262 | // if using 'Input' or 'Half' options for example, it uses the first input 263 | // by default. You can use a different input by assigning a value 264 | // to inputSizeIndex. 265 | 266 | int inputSizeIndex; 267 | 268 | // executeType determines how you will update the texture 269 | // "OPENGL_FBO" - you will draw directly to the FBO using OpenGL calls. 270 | 271 | // *NOTE* - Do not use OpenGL calls when using a CPU_* executeMode. 272 | 273 | // "CPU_MEM_WRITEONLY" - cpuPixelData* will be provided that you fill in with pixel data. This will automatically be uploaded to the GPU as a texture for you. Reading from the memory will result in very poor performance. 274 | // "CPU_MEM_READWRITE" - same as CPU_MEM_WRITEONLY but reading from the memory won't result in a large performance pentalty. The initial contents of the memory is undefined still. 275 | // cpuPixelData[0] and cpupixelData[1] are width by height array of pixels. 276 | // to access pixel (x,y) you would need to offset the memory location by bytesperpixel * ( y * width + x). 277 | // all pixels should be set, pixels that was not set will have an undefined value. 278 | ExecuteType executeMode; 279 | 280 | // determines the datatype of each pixel in CPU memory. This will determin 281 | // the size of the CPU memory buffers that are given to you 282 | // in TOP_OutputFormatSpecs 283 | // "BGRA8Fixed" - each pixel will hold 4 fixed-point values of size 8 bits (use 'unsigned char' in the code). They will be ordered BGRA. This is the preferred ordering for better performance. 284 | // "RGBA8Fixed" - each pixel will hold 4 fixed-point values of size 8 bits (use 'unsigned char' in the code). They will be ordered RGBA 285 | // "RGBA32Float" - each pixel will hold 4 floating-point values of size 32 bits (use 'float' in the code). They will be ordered RGBA 286 | // 287 | // Other cases are listed in the CPUMemPixelType enumeration 288 | CPUMemPixelType memPixelType; 289 | 290 | private: 291 | int reserved[18]; 292 | }; 293 | 294 | 295 | // This class is passed into the Create and Destroy methods as well 296 | // as into execute() 297 | // You should use it to signify when you want to do GL work and when you are 298 | // done to avoid GL state conflicts with TouchDesigner's GL context. 299 | class TOP_Context 300 | { 301 | public: 302 | virtual ~TOP_Context() {} 303 | 304 | /*** BEGIN: New OPENGL_FBO execudeMode specific functions ***/ 305 | 306 | // This function will make a GL context that is unique to this 307 | // TOP active. Call this before issuing any GL commands. 308 | // During execute() it will also bind a FBO to the GL_DRAW_FRAMEBUFFER 309 | // target and attach textures/renderbuffers to the attachment points 310 | // as required. It will also call glDrawBuffersARB() with the correct 311 | // active draw buffers depending on the number of color buffers in use 312 | // All other GL state will be left as it was from the previous time 313 | // execute() was called for this TOP. 314 | // 315 | // NOTE: No functions on the OP_Inputs class should be called 316 | // between a beginGLCommands() and endGLCommands() block, as they 317 | // may require GL to complete properly due to node cooking 318 | virtual void beginGLCommands() = 0; 319 | 320 | // Call this when you are done issuing GL commands and need to do other 321 | virtual void endGLCommands() = 0; 322 | 323 | // Returns the index of the FBO that TouchDesigner has setup for you. 324 | // Only valid during execute(), between beginGLCommands() and endGLCommands() 325 | // calls. 326 | virtual GLuint getFBOIndex() = 0; 327 | 328 | /*** END: New OPENGL_FBO execudeMode specific functions ***/ 329 | }; 330 | 331 | 332 | /***** FUNCTION CALL ORDER DURING INITIALIZATION ******/ 333 | /* 334 | When the TOP loads the dll the functions will be called in this order 335 | 336 | setupParameters(OP_ParameterManager* m); 337 | 338 | */ 339 | 340 | 341 | /***** FUNCTION CALL ORDER DURING A COOK ******/ 342 | /* 343 | When the TOP cooks the functions will be called in this order 344 | 345 | getGeneralInfo() 346 | getOutputFormat() 347 | 348 | execute() 349 | getNumInfoCHOPChans() 350 | for the number of chans returned getNumInfoCHOPChans() 351 | { 352 | getInfoCHOPChan() 353 | } 354 | getInfoDATSize() 355 | for the number of rows/cols returned by getInfoDATSize() 356 | { 357 | getInfoDATEntries() 358 | } 359 | getWarningString() 360 | getErrorString() 361 | getInfoPopupString() 362 | 363 | */ 364 | 365 | 366 | /*** DO NOT EDIT THIS CLASS, MAKE A SUBCLASS OF IT INSTEAD ***/ 367 | class TOP_CPlusPlusBase 368 | { 369 | protected: 370 | TOP_CPlusPlusBase() 371 | { 372 | } 373 | 374 | 375 | public: 376 | 377 | virtual ~TOP_CPlusPlusBase() 378 | { 379 | } 380 | 381 | // BEGIN PUBLIC INTERFACE 382 | 383 | // Some general settings can be assigned here by setting memebers of 384 | // the TOP_GeneralInfo class that is passed in 385 | virtual void getGeneralInfo(TOP_GeneralInfo*) 386 | { 387 | } 388 | 389 | 390 | // This function is called so the class can tell the TOP what 391 | // kind of buffer it wants to output into. 392 | // TouchDesigner will try to find the best match based on the specifications 393 | // given. 394 | // Return true if you specify the output here 395 | // Return false if you want the output to be set by the TOP's parameters 396 | // The TOP_OutputFormat class is pre-filled with what the TOP would 397 | // output if you return false, so you can just tweak a few settings 398 | // and return true if you want 399 | 400 | virtual bool getOutputFormat(TOP_OutputFormat*) 401 | { 402 | return false; 403 | } 404 | 405 | // In this function you do whatever you want to fill the framebuffer 406 | // 407 | // See the OP_Inputs class definition for more details on it's 408 | // contents 409 | 410 | virtual void execute(const TOP_OutputFormatSpecs*, 411 | OP_Inputs* , 412 | TOP_Context* context) = 0; 413 | 414 | 415 | // Override these methods if you want to output values to the Info CHOP/DAT 416 | // returning 0 means you dont plan to output any Info CHOP channels 417 | 418 | virtual int getNumInfoCHOPChans() 419 | { 420 | return 0; 421 | } 422 | 423 | // Specify the name and value for CHOP 'index', 424 | // by assigning something to 'name' and 'value' members of the 425 | // OP_InfoCHOPChan class pointer that is passed (it points 426 | // to a valid instance of the class already. 427 | // the 'name' pointer will initially point to NULL 428 | // you must allocate memory or assign a constant string 429 | // to it. 430 | 431 | virtual void getInfoCHOPChan(int index, 432 | OP_InfoCHOPChan* chan) 433 | { 434 | } 435 | 436 | 437 | // Return false if you arn't returning data for an Info DAT 438 | // Return true if you are. 439 | // Fill in members of the OP_InfoDATSize class to specify the size 440 | 441 | virtual bool getInfoDATSize(OP_InfoDATSize* infoSize) 442 | { 443 | return false; 444 | } 445 | 446 | // You are asked to assign values to the Info DAT 1 row or column at a time 447 | // The 'byColumn' variable in 'getInfoDATSize' is how you specify 448 | // if it is by column or by row. 449 | // 'index' is the row/column index 450 | // 'nEntries' is the number of entries in the row/column 451 | 452 | virtual void getInfoDATEntries(int index, 453 | int nEntries, 454 | OP_InfoDATEntries* entries) 455 | { 456 | } 457 | 458 | // You can use this function to put the node into a warning state 459 | // with the returned string as the message. 460 | // Return NULL if you don't want it to be in a warning state. 461 | virtual const char* getWarningString() 462 | { 463 | return NULL; 464 | } 465 | 466 | // You can use this function to put the node into a error state 467 | // with the returned string as the message. 468 | // Return NULL if you don't want it to be in a error state. 469 | virtual const char* getErrorString() 470 | { 471 | return NULL; 472 | } 473 | 474 | // Use this function to return some text that will show up in the 475 | // info popup (when you middle click on a node) 476 | // Return NULL if you don't want to return anything. 477 | virtual const char* getInfoPopupString() 478 | { 479 | return NULL; 480 | } 481 | 482 | 483 | 484 | // Override these methods if you want to define specfic parameters 485 | virtual void setupParameters(OP_ParameterManager* manager) 486 | { 487 | } 488 | 489 | 490 | // This is called whenever a pulse parameter is pressed 491 | virtual void pulsePressed(const char* name) 492 | { 493 | } 494 | 495 | 496 | // END PUBLIC INTERFACE 497 | 498 | 499 | private: 500 | 501 | // Reserved for future features 502 | virtual int reservedFunc6() { return 0; } 503 | virtual int reservedFunc7() { return 0; } 504 | virtual int reservedFunc8() { return 0; } 505 | virtual int reservedFunc9() { return 0; } 506 | virtual int reservedFunc10() { return 0; } 507 | virtual int reservedFunc11() { return 0; } 508 | virtual int reservedFunc12() { return 0; } 509 | virtual int reservedFunc13() { return 0; } 510 | virtual int reservedFunc14() { return 0; } 511 | virtual int reservedFunc15() { return 0; } 512 | virtual int reservedFunc16() { return 0; } 513 | virtual int reservedFunc17() { return 0; } 514 | virtual int reservedFunc18() { return 0; } 515 | virtual int reservedFunc19() { return 0; } 516 | virtual int reservedFunc20() { return 0; } 517 | 518 | int reserved[400]; 519 | 520 | }; 521 | 522 | #endif 523 | --------------------------------------------------------------------------------