├── .gitignore ├── LICENSE.txt ├── Makefile ├── README.md ├── glm.i ├── glm ├── constants.i ├── functions.i ├── mat3.i ├── mat4.i ├── quat.i ├── vec2.i ├── vec3.i └── vec4.i ├── openFrameworks.i └── openFrameworks ├── attributes.i ├── deprecated.i ├── lang ├── lua │ ├── lua.i │ ├── lua_code.i │ └── of_filesystem_path.i └── python │ ├── of_filesystem_path.i │ ├── python.i │ └── python_code.i └── openFrameworks ├── 3d.i ├── app.i ├── communication.i ├── events.i ├── gl.i ├── graphics.i ├── main.i ├── math.i ├── sound.i ├── types.i ├── utils.i └── video.i /.gitignore: -------------------------------------------------------------------------------- 1 | # generated files 2 | *.cpp 3 | *.h 4 | *_symbols.txt 5 | 6 | # generated directories 7 | ./lua 8 | ./python 9 | 10 | # macOS 11 | .DS_Store 12 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2023 Dan Wilcox 2 | All rights reserved. 3 | 4 | The following terms (the "Standard Improved BSD License") apply to all files 5 | associated with the software unless explicitly disclaimed in individual files: 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | 1. Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above 14 | copyright notice, this list of conditions and the following 15 | disclaimer in the documentation and/or other materials provided 16 | with the distribution. 17 | 3. The name of the author may not be used to endorse or promote 18 | products derived from this software without specific prior 19 | written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY 22 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 25 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 27 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 31 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 | THE POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile to generate OF bindings using SWIG 3 | # 4 | # 2014-2018 Dan Wilcox 5 | # 6 | # running `make` generates desktop os lua bindings and puts them in ./lua, 7 | # running `make ios` generates ios lua bindings, etc 8 | # 9 | # override any of the following variables using make, i.e. to generate Python 10 | # bindings with a different filename and dest location: 11 | # 12 | # make LANG=python NAME=ofxPythonBindings DEST_DIR=../src/bindings 13 | # 14 | 15 | # swig command 16 | SWIG = swig 17 | 18 | # default output language, see swig -h for more 19 | LANG = lua 20 | 21 | # default platform target, available targets are: 22 | # * desktop: win, linux, & mac osx 23 | # * ios: apple iOS using OpenGL ES 24 | # * linuxarm: embedded linux using OpenGL ES 25 | TARGET = desktop 26 | 27 | # where to place the generated bindings 28 | DEST_DIR = $(LANG) 29 | 30 | # any extra SWIG flags per-language, etc 31 | SWIG_FLAGS = -O -small 32 | 33 | ############## 34 | # main targets 35 | ############## 36 | 37 | .PHONY: all clean desktop ios linuxarm header libs libs-clean \ 38 | openFrameworks openFrameorks-header openFrameorks-symbols openFrameworks-clean \ 39 | glm glm-symbols glm-clean 40 | 41 | all: desktop header libs 42 | 43 | clean: openFrameworks-clean libs-clean 44 | 45 | # desktop OS generation 46 | desktop: desktop-prepare openFrameworks 47 | 48 | desktop-prepare: 49 | $(eval TARGET := desktop) 50 | $(eval CFLAGS := $(CFLAGS)) 51 | 52 | # iOS specific generation 53 | ios: ios-prepare openFrameworks 54 | 55 | ios-prepare: 56 | $(eval TARGET := ios) 57 | $(eval CFLAGS := $(CFLAGS) -DTARGET_OPENGLES -DTARGET_IOS) 58 | 59 | # embedded linux specific generation 60 | linuxarm: linuxarm-prepare openFrameworks 61 | 62 | linuxarm-prepare: 63 | $(eval TARGET := linuxarm) 64 | $(eval CFLAGS := $(CFLAGS) -DTARGET_OPENGLES) 65 | 66 | # runtime header generation 67 | header: openFrameworks-header 68 | 69 | # additional library generation 70 | libs: glm 71 | 72 | libs-clean: glm-clean 73 | 74 | ####################### 75 | # openFrameworks module 76 | ####################### 77 | 78 | # module name 79 | MODULE_NAME = of 80 | 81 | # strip "of" from function, class, & define/enum names? 82 | RENAME = true 83 | 84 | # allow deprecated functions? otherwise, ignore 85 | DEPRECATED = false 86 | 87 | # generated bindings filename 88 | NAME = ofBindings 89 | 90 | # OF libs header path 91 | OF_HEADERS = -I../../../libs 92 | 93 | # Python specific preferences 94 | # typically, long names are used in Python, 95 | # and function names remain unaltered (see pyOpenGL for instance) 96 | ifeq ($(LANG), python) 97 | MODULE_NAME = openframeworks 98 | RENAME = false 99 | SWIG_FLAGS += -modern 100 | endif 101 | 102 | # populate CFLAGS for openFrameworks 103 | OF_CFLAGS = $(OF_HEADERS)/openFrameworks -DMODULE_NAME=$(MODULE_NAME) 104 | 105 | ifeq ($(RENAME), true) 106 | OF_CFLAGS += -DOF_SWIG_RENAME 107 | endif 108 | 109 | ifeq ($(DEPRECATED), true) 110 | OF_CFLAGS += -DOF_SWIG_DEPRECATED 111 | endif 112 | 113 | ifeq ($(ATTRIBUTES), true) 114 | OF_CFLAGS += -DOF_SWIG_ATTRIBUTES 115 | endif 116 | 117 | # generates bindings 118 | openFrameworks: 119 | @echo "### Generating: openFrameworks $(TARGET)" 120 | @mkdir -p $(DEST_DIR)/$(TARGET) 121 | $(SWIG) -c++ -$(LANG) $(SWIG_FLAGS) $(CFLAGS) $(OF_CFLAGS) -o $(DEST_DIR)/$(TARGET)/$(NAME).cpp openFrameworks.i 122 | 123 | # generates swig runtime header 124 | openFrameworks-header: 125 | @echo "### Generating: openFrameworks header" 126 | $(SWIG) -c++ -$(LANG) -external-runtime $(DEST_DIR)/$(NAME).h 127 | 128 | # outputs swig language symbols 129 | openFrameworks-symbols: 130 | $(SWIG) -c++ -$(LANG) $(SWIG_FLAGS) -debug-lsymbols $(CFLAGS) $(OF_CFLAGS) openFrameworks.i > $(MODULE_NAME)_$(LANG)_symbols.txt 131 | rm -f *.cxx 132 | if [ $(LANG) = "python" ]; then rm -f *.py; fi 133 | 134 | # clean dest dir 135 | openFrameworks-clean: 136 | rm -rf $(DEST_DIR)/desktop 137 | rm -rf $(DEST_DIR)/ios 138 | rm -rf $(DEST_DIR)/linuxarm 139 | rm -f $(DEST_DIR)/$(NAME).h 140 | rm -f $(MODULE_NAME)_*_symbols.txt 141 | 142 | ############ 143 | # glm module 144 | ############ 145 | 146 | # generates glm bindings 147 | glm: 148 | @echo "### Generating: glm" 149 | @mkdir -p $(DEST_DIR) 150 | $(SWIG) -c++ -$(LANG) $(SWIG_FLAGS) $(OF_HEADERS)/glm/include -o $(DEST_DIR)/glmBindings.cpp glm.i 151 | 152 | # outputs swig language symbols 153 | glm-symbols: 154 | $(SWIG) -c++ -$(LANG) $(SWIG_FLAGS) -debug-lsymbols $(OF_HEADERS)/glm/include glm.i > glm_$(LANG)_symbols.txt 155 | rm -f *.cxx 156 | if [ $(LANG) = "python" ]; then rm -f *.py; fi 157 | 158 | # clean dest dir 159 | glm-clean: 160 | rm -f $(DEST_DIR)/glmBindings.cpp 161 | rm -f glm_*_symbols.txt 162 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | swig-openframeworks 2 | ------------------- 3 | 4 | a SWIG interface for openFrameworks with included Makefile 5 | 6 | Copyright (c) [Dan Wilcox](danomatika.com) 2015-2025 7 | 8 | BSD Simplified License. 9 | 10 | For information on usage and redistribution, and for a DISCLAIMER OF ALL 11 | WARRANTIES, see the file, "LICENSE.txt," in this distribution. 12 | 13 | See for documentation 14 | 15 | Description 16 | ----------- 17 | 18 | swig-openframeworks provides a centralized OpenFrameworks API interface file for the Simple Wrapper and Interface Generator (SWIG) tool which can be used to generate C++ bindings for various scripting languages, including Lua, Python, and Javascript. 19 | 20 | [SWIG](http://www.swig.org) is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. 21 | 22 | Installation 23 | ------------ 24 | 25 | This repository is designed to be used as a submodule within OpenFrameworks addons which provide scripting access to OF. 26 | 27 | The suggested installation is to the `swig` folder in your main repo: 28 | 29 | git submodule add https://github.com/danomatika/swig-openframeworks.git swig 30 | 31 | Git users of your addon will then need to checkout this submodule when they clone your addon: 32 | 33 | git submodule init 34 | git submodule update 35 | 36 | ### Which version to use? 37 | 38 | If you are using a stable version (0.8.4, 0.9.0, ...) of OpenFrameworks then you want to use a git tag of swig-openframeworks for that version. You can select the tag in the Github "Current Branch" menu or clone and check it out using git. 39 | 40 | The master branch of swig-openframeworks will work with the current stable version. 41 | 42 | OF API Bindings 43 | --------------- 44 | 45 | Currently the swig interface file covers *most* of the api while leaving out base classes. It creates a module containing all the imported functions, classes, constants & enums. 46 | 47 | To see the main differences with the OF C++ API run the following: 48 | 49 | find . -name "*.i" -exec grep "// DIFF" {} \; 50 | 51 | To see work to be done on the bindings run: 52 | 53 | find . -name "*.i" -exec grep "// TODO" {} \; 54 | 55 | To see attributes which can be added to various classes: 56 | 57 | find . -name "*.i" -exec grep "// ATTR" {} \; 58 | 59 | Currently supported (aka tested) scripting languages are: 60 | 61 | * Lua 62 | * Python 63 | 64 | Other language bindings supported by swig can be generated. Feel free to create a PR adding required updates to the Makefile and interface file. 65 | 66 | ### Lua 67 | 68 | In Lua, all wrapped functions, classes, defines, and enums are added to an "of" module (aka table) like a Lua library. 69 | 70 | The contents of the module are renamed by default: 71 | 72 | * **function**: ofBackground -> of.background 73 | * **class**: ofColor -> of.Color 74 | * **constant**: OF_LOG_VERBOSE -> of.LOG_VERBOSE 75 | * **enum**: 76 | - global OF_KEY_BACKSPACE -> of.KEY_BACKSPACE 77 | - class ofShader::POSITION_ATTRIBUTE -> of.Shader.POSITION_ATTRIBUTE 78 | 79 | ### Python 80 | 81 | In Python, the module (aka library) is called "openframeworks" and its members retain the "of" prefix: 82 | 83 | from openframeworks import * 84 | 85 | ofBackground(255) 86 | color = ofColor() 87 | ... 88 | 89 | glm Bindings 90 | ------------ 91 | 92 | As of openFrameworks 0.10.0, the glm library math types (vec3, mat3, quat, etc) have become integral to the OF API and are now wrapped via a swig interface as well. The resulting module is named "glm" and associated functions and types are accessed from within this name space. 93 | 94 | For example, in Lua: 95 | 96 | -- constructors 97 | local v1 = glm.vec3(1, 2, 3) 98 | local v2 = glm.vec3(4, 5, 6) 99 | 100 | -- operators 101 | local v3 = v1 + v2 102 | v3 = v2 / v1 103 | 104 | -- functions 105 | local dot = glm.dot(v1, v2) 106 | 107 | One **important point**: Most scripting languages cannot support the casting operators which allow the OF math types (ofVec3f, ofMatrix3x3, etc) to be used with functions which take glm type arguments. To get around this problem, each math type has a special member function which returns the associated glm type: 108 | 109 | * ofVec2f -> glm::vec2: vec2() 110 | * ofVec3f -> glm::vec3: vec3() 111 | * ofVec4f -> glm::vec4: vec4() 112 | * ofQuaternion -> glm::quat: quat() 113 | * ofMatrix3x3 -> glm::mat4: mat3() 114 | * ofMatrix4x4 -> glm::mat4: mat4() 115 | 116 | Essentially, the following will *not* work as it does in C++: 117 | 118 | -- error! 119 | local v = of.Vec2f(100, 100) 120 | of.drawRectangle(v, 20, 20) -- needs a glm.vec2 121 | 122 | Either convert the OF math type to a glm type or use a glm type directly: 123 | 124 | -- convert 125 | local v = of.Vec2f(100, 100) 126 | of.drawRectangle(v.vec2(), 20, 20) 127 | 128 | -- use glm::vec2 129 | local v = glm.vec2(100, 100) 130 | of.drawRectangle(v, 20, 20) 131 | 132 | Usage 133 | ----- 134 | 135 | A Makefile is provided to handle SWIG and platform specific details. It generates both a .cpp binding implementation as well as a .h header for SWIG helper functions. 136 | 137 | Basic usage is: 138 | 139 | make 140 | 141 | which generates Lua bindings for desktop OSs and places them in `../src/bindings/desktop`. 142 | 143 | ### Languages 144 | 145 | Available scripting languages are listed by the SWIG help: `swig -h`. The language can be set by the LANG makefile variable and is `lua` by default. 146 | 147 | Example: To generate python bindings for desktop: 148 | 149 | make LANG=python 150 | 151 | ### Platforms 152 | 153 | The Makefile current supports generating bindings for the following target platforms: 154 | 155 | * **desktop**: win, linux, & mac osx 156 | * **ios**: apple iOS using OpenGL ES 157 | * **linuxarm**: embedded linux using OpenGL ES 158 | 159 | Generated bindings are placed within platform subfolders in the destination directory. 160 | 161 | Example: To generate python bindings for iOS: 162 | 163 | make ios LANG=python 164 | 165 | ### Destination Dir 166 | 167 | The destination directory where the bindings are installed can be set by the DEST_DIR makefile variable and is `../src/bindings` by default. 168 | 169 | Example: To generate python bindings for desktop and place them in a nearby test dir: 170 | 171 | make desktop LANG=python DEST_DIR=test 172 | 173 | ### Bindings Filename 174 | 175 | The Makefile generates bindings files using the NAME makefile variable and is `openFrameworks_wrap` by default. 176 | 177 | Example: To generate python bindings for desktop with the name "ofxPythonBindings": 178 | 179 | make desktop LANG=python NAME=ofxPythonBindings 180 | 181 | ### Module Name 182 | 183 | The scripting language bindings use the "of" module by default. In the case of Lua, this refers to the parent "of" table that contains all warped functions, classes, and defines. This may not be desirable for particular scripting languages (ie. Python), so the module name can be set using the MODULE_NAME makefile variable. 184 | 185 | Example: To generate python bindings with the module name "openframeworks": 186 | 187 | make LANG=python MODULE_NAME=openframeworks 188 | 189 | ### Renaming 190 | 191 | By default, functions, classes, enums, & defines are reamed to strip the "of" prefix. This may not be desirable for particular scripting languages (ie. Python) and can be disabled by setting the MODULE_NAME makefile variable to false: 192 | 193 | make RENAME=false 194 | 195 | ### Deprecated Functions & Classes 196 | 197 | By default, functions & classes marked as deprecated in the OF api are ignored when generating bindings. If you want to allow deprecations, set the DEPRECATED makefile variable to true: 198 | 199 | make DEPRECATED=true 200 | 201 | ### Attributes 202 | 203 | Many target scripting languages support attributes using getters/setters, ie: 204 | 205 | -- lua 206 | image = of.Image("hello.png") 207 | print("width: "..image:getWidth()) 208 | print("width: "..image.width) -- same as above using a getter attribute 209 | 210 | To enable attribute bindings, set the ATTRIBUTES makefile variable to true: 211 | 212 | make ATTRIBUTES=true 213 | 214 | ### SWIG Flags 215 | 216 | SWIG has a large number of flags for customizing bindings generation, many of which are specific to each generated language. The Makefile uses the SWIG_FLAGS makefile variable for these extra options, for instance generating Python bindings uses the `-modern` option to focus on newer versions of Python. 217 | 218 | ### Scripting 219 | 220 | Generating bindings for all platform targets can be done easily using a script which calls the Makefile. See [generate_bindings.sh](https://github.com/danomatika/ofxLua/blob/swig/scripts/generate_bindings.sh) in ofxLua for an example. 221 | 222 | ### Debugging 223 | 224 | Debugging scripting language bindings can be a pain, so SWIG can output the binding symbols for the target language. The Makefile provides a target that creates a `of_LANG_symbols.txt` so you can see which classes, functions, & enums are being wrapped and how. 225 | 226 | Example: To debug python bindings: 227 | 228 | make symbols LANG=python 229 | 230 | generates a file called `of_python_symbols.txt`. 231 | 232 | Example 233 | ------- 234 | 235 | swig-openframeworks was originally developed for ofxLua which is using it as a submodule in the "swig" branch: 236 | 237 | Developing 238 | ---------- 239 | 240 | You can help develop swig-openframeworks on GitHub: 241 | 242 | Create an account, clone or fork the repo, then request a push/merge. 243 | 244 | If you find any bugs or suggestions please log them to GitHub as well. 245 | -------------------------------------------------------------------------------- /glm.i: -------------------------------------------------------------------------------- 1 | // minimal SWIG (http://www.swig.org) interface wrapper for the glm library 2 | // defines only the types used in openFrameworks: vec2, vec3, mat3, mat4, quat 3 | // 2018 Dan Wilcox 4 | // some parts adapted from https://github.com/IndiumGames/swig-wrapper-glm 5 | 6 | // main MODULE 7 | %module glm 8 | %{ 9 | #include 10 | #include 11 | #include 12 | 13 | // these included in math/ofVectorMath.h 14 | // we declare some things manually, so some includes are commented out 15 | #include "glm/vec2.hpp" 16 | #include "glm/vec3.hpp" 17 | #include "glm/vec4.hpp" 18 | #include "glm/mat3x3.hpp" 19 | #include "glm/mat4x4.hpp" 20 | #include "glm/geometric.hpp" 21 | #include "glm/common.hpp" 22 | #include "glm/trigonometric.hpp" 23 | #include "glm/exponential.hpp" 24 | //#include "glm/vector_relational.hpp" 25 | //#include "glm/ext.hpp" 26 | 27 | //#include "glm/gtc/constants.hpp" 28 | #include "glm/gtc/matrix_transform.hpp" 29 | #include "glm/gtc/matrix_inverse.hpp" 30 | //#include "glm/gtc/quaternion.hpp" 31 | #include "glm/gtc/epsilon.hpp" 32 | #include "glm/gtx/norm.hpp" 33 | #include "glm/gtx/perpendicular.hpp" 34 | #include "glm/gtx/quaternion.hpp" 35 | #include "glm/gtx/rotate_vector.hpp" 36 | #include "glm/gtx/spline.hpp" 37 | #include "glm/gtx/transform.hpp" 38 | #include "glm/gtx/vector_angle.hpp" 39 | //#include "glm/gtx/scalar_multiplication.hpp" 40 | //#include 41 | 42 | // extras included via glm/ext.h 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | %} 49 | 50 | // ----- C++ ----- 51 | 52 | %include 53 | %include 54 | 55 | // expanded primitives 56 | %typedef unsigned int std::size_t; 57 | 58 | // ----- Bindings------ 59 | 60 | namespace glm { 61 | 62 | #ifdef SWIGLUA 63 | %rename(add) operator+; 64 | %rename(sub) operator-; 65 | %rename(mul) operator*; 66 | %rename(div) operator/; 67 | %rename(eq) operator==; 68 | #endif 69 | 70 | %typedef int length_t; 71 | 72 | %include "glm/vec2.i" 73 | %include "glm/vec3.i" 74 | %include "glm/vec4.i" 75 | %include "glm/mat3.i" 76 | %include "glm/mat4.i" 77 | %include "glm/quat.i" 78 | %include "glm/constants.i" 79 | %include "glm/functions.i" 80 | 81 | } // namespace 82 | -------------------------------------------------------------------------------- /glm/constants.i: -------------------------------------------------------------------------------- 1 | // glm constants bindings 2 | // adapted from https://github.com/IndiumGames/swig-wrapper-glm 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Copyright (c) 2016 Indium Games (www.indiumgames.fi) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | // ----- glm/gtc/constants.hpp ----- 27 | 28 | template T epsilon(); 29 | template T zero(); 30 | template T one(); 31 | template T pi(); 32 | template T two_pi(); 33 | template T root_pi(); 34 | template T half_pi(); 35 | template T three_over_two_pi(); 36 | template T quarter_pi(); 37 | template T one_over_pi(); 38 | template T one_over_two_pi(); 39 | template T two_over_pi(); 40 | template T four_over_pi(); 41 | template T two_over_root_pi(); 42 | template T one_over_root_two(); 43 | template T root_half_pi(); 44 | template T root_two_pi(); 45 | template T root_ln_four(); 46 | template T e(); 47 | template T euler(); 48 | template T root_two(); 49 | template T root_three(); 50 | template T root_five(); 51 | template T ln_two(); 52 | template T ln_ten(); 53 | template T ln_ln_two(); 54 | template T third(); 55 | template T two_thirds(); 56 | template T golden_ratio(); 57 | 58 | %template(epsilon) epsilon; 59 | %template(zero) zero; 60 | %template(one) one; 61 | %template(pi) pi; 62 | %template(root_pi) root_pi; 63 | %template(half_pi) half_pi; 64 | %template(quarter_pi) quarter_pi; 65 | %template(one_over_pi) one_over_pi; 66 | %template(two_over_pi) two_over_pi; 67 | %template(two_over_root_pi) two_over_root_pi; 68 | %template(one_over_root_two) one_over_root_two; 69 | %template(root_half_pi) root_half_pi; 70 | %template(root_two_pi) root_two_pi; 71 | %template(root_ln_four) root_ln_four; 72 | %template(e) e; 73 | %template(euler) euler; 74 | %template(root_two) root_two; 75 | %template(root_three) root_three; 76 | %template(root_five) root_five; 77 | %template(ln_two) ln_two; 78 | %template(ln_ten) ln_ten; 79 | %template(ln_ln_two) ln_ln_two; 80 | %template(third) third; 81 | %template(two_thirds) two_thirds; 82 | %template(golden_ratio) golden_ratio; 83 | -------------------------------------------------------------------------------- /glm/functions.i: -------------------------------------------------------------------------------- 1 | // glm function bindings 2 | // adapted from https://github.com/IndiumGames/swig-wrapper-glm 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Copyright (c) 2016 Indium Games (www.indiumgames.fi) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE. 25 | 26 | %define FLOAT_VECTOR(function_name) 27 | vec2 function_name(const vec2 &); 28 | vec3 function_name(const vec3 &); 29 | vec4 function_name(const vec4 &); 30 | %enddef 31 | 32 | %define FLOAT_VECTOR_2_PARAMS(function_name) 33 | vec2 function_name(const vec2 &, const vec2 &); 34 | vec3 function_name(const vec3 &, const vec3 &); 35 | vec4 function_name(const vec4 &, const vec4 &); 36 | %enddef 37 | 38 | %define FLOAT_VECTOR_3_PARAMS(function_name) 39 | vec2 function_name(const vec2 &, const vec2 &, const vec2 &); 40 | vec3 function_name(const vec3 &, const vec3 &, const vec3 &); 41 | vec4 function_name(const vec4 &, const vec4 &, const vec4 &); 42 | %enddef 43 | 44 | %define FLOAT_VECTOR_RETURN_VALUE(function_name) 45 | float function_name(const vec2 &); 46 | float function_name(const vec3 &); 47 | float function_name(const vec4 &); 48 | %enddef 49 | 50 | %define FLOAT_VECTOR_RETURN_VALUE_2_PARAMS(function_name) 51 | float function_name(const vec2 &, const vec2 &); 52 | float function_name(const vec3 &, const vec3 &); 53 | float function_name(const vec4 &, const vec4 &); 54 | %enddef 55 | 56 | %define FLOAT_SCALAR_OR_VECTOR(function_name) 57 | float function_name(const float &); 58 | vec2 function_name(const vec2 &); 59 | vec3 function_name(const vec3 &); 60 | vec4 function_name(const vec4 &); 61 | %enddef 62 | 63 | %define FLOAT_SCALAR_OR_VECTOR_RETURN_VALUE(function_name) 64 | float function_name(const float &); 65 | float function_name(const vec2 &); 66 | float function_name(const vec3 &); 67 | float function_name(const vec4 &); 68 | %enddef 69 | 70 | %define FLOAT_SCALAR_OR_VECTOR_2_PARAMS(function_name) 71 | float function_name(const float &, const float &); 72 | vec2 function_name(const vec2 &, const vec2 &); 73 | vec3 function_name(const vec3 &, const vec3 &); 74 | vec4 function_name(const vec4 &, const vec4 &); 75 | %enddef 76 | 77 | %define FLOAT_SCALAR_OR_VECTOR_2_PARAMS_VECTOR_VALUE(function_name) 78 | vec2 function_name(const vec2 &, const float &); 79 | vec3 function_name(const vec3 &, const float &); 80 | vec4 function_name(const vec4 &, const float &); 81 | %enddef 82 | 83 | %define FLOAT_SCALAR_OR_VECTOR_3_PARAMS(function_name) 84 | float function_name(const float &, const float &, const float &); 85 | vec2 function_name(const vec2 &, const vec2 &, const vec2 &); 86 | vec3 function_name(const vec3 &, const vec3 &, const vec3 &); 87 | vec4 function_name(const vec4 &, const vec4 &, const vec4 &); 88 | %enddef 89 | 90 | %define FLOAT_SCALAR_OR_VECTOR_3_PARAMS_VECTOR_VALUE_VALUE(function_name) 91 | vec2 function_name(const vec2 &, const float &, const float &); 92 | vec3 function_name(const vec3 &, const float &, const float &); 93 | vec4 function_name(const vec4 &, const float &, const float &); 94 | %enddef 95 | 96 | %define FLOAT_SCALAR_OR_VECTOR_3_PARAMS_VECTOR_VECTOR_VALUE(function_name) 97 | vec2 function_name(const vec2 &, const vec2 &, const float &); 98 | vec3 function_name(const vec3 &, const vec3 &, const float &); 99 | vec4 function_name(const vec4 &, const vec4 &, const float &); 100 | %enddef 101 | 102 | // ----- glm/common.hpp ----- 103 | 104 | FLOAT_SCALAR_OR_VECTOR(abs); 105 | FLOAT_SCALAR_OR_VECTOR(sign); 106 | FLOAT_SCALAR_OR_VECTOR(floor); 107 | FLOAT_SCALAR_OR_VECTOR(trunc); 108 | FLOAT_SCALAR_OR_VECTOR(round); 109 | FLOAT_SCALAR_OR_VECTOR(roundEven); 110 | FLOAT_SCALAR_OR_VECTOR(ceil); 111 | FLOAT_SCALAR_OR_VECTOR(fract); 112 | FLOAT_SCALAR_OR_VECTOR_2_PARAMS(mod); 113 | FLOAT_SCALAR_OR_VECTOR_2_PARAMS_VECTOR_VALUE(mod); 114 | float modf(const float &, float &); 115 | vec2 modf(const vec2 &, vec2 &); 116 | vec3 modf(const vec3 &, vec3 &); 117 | vec4 modf(const vec4 &, vec4 &); 118 | FLOAT_SCALAR_OR_VECTOR_2_PARAMS(min); 119 | FLOAT_SCALAR_OR_VECTOR_2_PARAMS_VECTOR_VALUE(min); 120 | FLOAT_SCALAR_OR_VECTOR_2_PARAMS(max); 121 | FLOAT_SCALAR_OR_VECTOR_2_PARAMS_VECTOR_VALUE(max); 122 | FLOAT_SCALAR_OR_VECTOR_3_PARAMS(clamp); 123 | FLOAT_SCALAR_OR_VECTOR_3_PARAMS_VECTOR_VALUE_VALUE(clamp); 124 | float mix(const float &, const float &, const float &); 125 | float mix(const float &, const float &, const bool &); 126 | vec2 mix(const vec2 &, const vec2 &, const vec2 &); 127 | vec3 mix(const vec3 &, const vec3 &, const vec3 &); 128 | vec4 mix(const vec4 &, const vec4 &, const vec4 &); 129 | vec2 mix(const vec2 &, const vec2 &, const bool &); 130 | vec3 mix(const vec3 &, const vec3 &, const bool &); 131 | vec4 mix(const vec4 &, const vec4 &, const bool &); 132 | vec2 step(const vec2 &, const vec2 &); 133 | vec3 step(const vec3 &, const vec3 &); 134 | vec4 step(const vec4 &, const vec4 &); 135 | vec2 step(const float &, const vec2 &); 136 | vec3 step(const float &, const vec3 &); 137 | vec4 step(const float &, const vec4 &); 138 | FLOAT_SCALAR_OR_VECTOR_3_PARAMS(smoothstep); 139 | vec2 smoothstep(const float &, const float &, const vec2 &); 140 | vec3 smoothstep(const float &, const float &, const vec3 &); 141 | vec4 smoothstep(const float &, const float &, const vec4 &); 142 | bool isnan(const float &); 143 | bool isinf(const float &); 144 | 145 | // fma appears to be scalar only now? 146 | //FLOAT_SCALAR_OR_VECTOR_3_PARAMS(fma); 147 | float fma(const float &, const float &, const float &); 148 | 149 | // ----- glm/exponential.hpp ----- 150 | 151 | FLOAT_SCALAR_OR_VECTOR_2_PARAMS(pow); 152 | FLOAT_SCALAR_OR_VECTOR(exp); 153 | FLOAT_SCALAR_OR_VECTOR(log); 154 | FLOAT_SCALAR_OR_VECTOR(exp2); 155 | FLOAT_SCALAR_OR_VECTOR(log2); 156 | FLOAT_VECTOR(sqrt); 157 | FLOAT_SCALAR_OR_VECTOR(inversesqrt); 158 | 159 | // ----- glm/geometric.hpp ----- 160 | 161 | FLOAT_VECTOR_RETURN_VALUE(length); 162 | FLOAT_VECTOR_RETURN_VALUE_2_PARAMS(distance); 163 | FLOAT_VECTOR_RETURN_VALUE_2_PARAMS(dot); 164 | vec3 cross(const vec3 &, const vec3 &); 165 | FLOAT_VECTOR(normalize); 166 | FLOAT_VECTOR_3_PARAMS(faceforward); 167 | FLOAT_VECTOR_2_PARAMS(reflect); 168 | vec2 refract(const vec2 &, const vec2 &, const float &); 169 | vec3 refract(const vec3 &, const vec3 &, const float &); 170 | vec4 refract(const vec4 &, const vec4 &, const float &); 171 | 172 | // ----- glm/matrix.hpp ----- 173 | 174 | mat3 matrixCompMult(const mat3 &, const mat3 &); 175 | mat4 matrixCompMult(const mat4 &, const mat4 &); 176 | mat3 outerProduct(const vec3 &, const vec3 &); 177 | mat4 outerProduct(const vec4 &, const vec4 &); 178 | mat3 transpose(const mat3 &); 179 | mat4 transpose(const mat4 &); 180 | float determinant(const mat3 &); 181 | float determinant(const mat4 &); 182 | mat3 inverse(const mat3 &); 183 | mat4 inverse(const mat4 &); 184 | 185 | // ----- glm/trigonometric.hpp ----- 186 | 187 | FLOAT_SCALAR_OR_VECTOR(radians); 188 | FLOAT_SCALAR_OR_VECTOR(degrees); 189 | FLOAT_SCALAR_OR_VECTOR(sin); 190 | FLOAT_SCALAR_OR_VECTOR(cos); 191 | FLOAT_SCALAR_OR_VECTOR(tan); 192 | FLOAT_SCALAR_OR_VECTOR(asin); 193 | FLOAT_SCALAR_OR_VECTOR(acos); 194 | FLOAT_SCALAR_OR_VECTOR_2_PARAMS(atan); 195 | FLOAT_SCALAR_OR_VECTOR(atan); 196 | FLOAT_SCALAR_OR_VECTOR(sinh); 197 | FLOAT_SCALAR_OR_VECTOR(cosh); 198 | FLOAT_SCALAR_OR_VECTOR(tanh); 199 | FLOAT_SCALAR_OR_VECTOR(asinh); 200 | FLOAT_SCALAR_OR_VECTOR(acosh); 201 | FLOAT_SCALAR_OR_VECTOR(atanh); 202 | 203 | // ----- glm/gtc/epsilon.hpp ----- 204 | 205 | bool epsilonEqual(const float &, const float &, const float &); 206 | vec2 epsilonEqual(const vec2 &, const vec2 &, const float &); 207 | vec3 epsilonEqual(const vec3 &, const vec3 &, const float &); 208 | 209 | bool epsilonNotEqual(const float &, const float &, const float &); 210 | vec2 epsilonNotEqual(const vec2 &, const vec2 &, const float &); 211 | vec3 epsilonNotEqual(const vec3 &, const vec3 &, const float &); 212 | 213 | // ----- glm/gtc/matrix_access.hpp ----- 214 | 215 | vec3 row(const mat3 &, const length_t &); 216 | vec4 row(const mat4 &, const length_t &); 217 | mat3 row(const mat3 &, const length_t &, const vec3 &); 218 | mat4 row(const mat4 &, const length_t &, const vec4 &); 219 | vec3 column(const mat3 &, const length_t &); 220 | vec4 column(const mat4 &, const length_t &); 221 | mat3 column(const mat3 &, const length_t &, const vec3 &); 222 | mat4 column(const mat4 &, const length_t &, const vec4 &); 223 | 224 | // ----- glm/gtc/matrix_inverse.hpp ----- 225 | 226 | mat3 affineInverse(const mat3 &); 227 | mat4 affineInverse(const mat4 &); 228 | mat3 inverseTranspose(const mat3 &); 229 | mat4 inverseTranspose(const mat4 &); 230 | 231 | // ----- glm/ext/matrix_transform.hpp ----- 232 | 233 | //mat4 identity(); 234 | mat4 translate(const mat4 &, const vec3 &); 235 | mat4 rotate(const mat4 &, const float &, const vec3 &); 236 | mat4 scale(const mat4 &, const vec3 &); 237 | mat4 lookAt(const vec3 &, const vec3 &, const vec3 &); 238 | 239 | // ----- glm/ext/matrix_clip_space.hpp ----- 240 | 241 | mat4 ortho(const float &, const float &, 242 | const float &, const float &); 243 | mat4 ortho(const float &, const float &, 244 | const float &, const float &, 245 | const float &, const float &); 246 | mat4 frustum(const float &, const float &, 247 | const float &, const float &, 248 | const float &, const float &); 249 | mat4 perspective(const float &, const float &, 250 | const float &, const float &); 251 | mat4 perspectiveFov(const float &, 252 | const float &, const float &, 253 | const float &, const float &); 254 | mat4 infinitePerspective(const float &, const float &, const float &); 255 | mat4 tweakedInfinitePerspective(const float &, const float &, const float &); 256 | 257 | // ----- glm/ext/matrix_projection.hpp ----- 258 | 259 | vec3 project(const vec3 &, const mat4 &, const mat4 &, const vec4 &); 260 | vec3 unProject(const vec3 &, const mat4 &, const mat4 &, const vec4 &); 261 | mat4 pickMatrix(const vec2 &, const vec2 &, const vec4 &); 262 | 263 | // ----- glm/gtx/compatibility.hpp ----- 264 | 265 | FLOAT_SCALAR_OR_VECTOR_3_PARAMS(lerp); 266 | FLOAT_SCALAR_OR_VECTOR_3_PARAMS_VECTOR_VECTOR_VALUE(lerp); 267 | FLOAT_VECTOR(saturate); 268 | FLOAT_VECTOR_2_PARAMS(atan2); 269 | bool isfinite(float &); 270 | vec2 isfinite(vec2 &); 271 | vec3 isfinite(vec3 &); 272 | vec4 isfinite(vec4 &); 273 | 274 | // scalar types seem to cause issues 275 | //float atan2(float, float); 276 | //float saturate(float); 277 | 278 | // ----- glm/gtx/fast_square_root.hpp ----- 279 | 280 | FLOAT_VECTOR(fastSqrt); 281 | FLOAT_SCALAR_OR_VECTOR(fastInverseSqrt); 282 | FLOAT_VECTOR_RETURN_VALUE(fastLength); 283 | FLOAT_VECTOR_RETURN_VALUE_2_PARAMS(fastDistance); 284 | FLOAT_VECTOR(fastNormalize); 285 | 286 | // ----- glm/gtx/norm.hpp ----- 287 | 288 | FLOAT_VECTOR_RETURN_VALUE(length2); 289 | FLOAT_VECTOR_RETURN_VALUE_2_PARAMS(distance2); 290 | float l1Norm(vec3 const &, vec3 const &); 291 | float l1Norm(vec3 const &); 292 | float l2Norm(vec3 const &, vec3 const &); 293 | float l2Norm(vec3 const &); 294 | float lxNorm(vec3 const &, vec3 const &, unsigned int); 295 | float lxNorm(vec3 const &, unsigned int); 296 | 297 | // ----- glm/gtx/perpendicular.hpp ----- 298 | 299 | vec2 perp(const vec2 &, const vec2 &); 300 | vec3 perp(const vec3 &, const vec3 &); 301 | 302 | // ----- glm/gtx/rotate_vector.hpp ----- 303 | 304 | vec3 slerp(const vec3 &, const vec3 &, const float &); 305 | vec2 rotate(const vec2 &, const float &); 306 | vec3 rotate(const vec3 &, const float &, const vec3 &); 307 | vec4 rotate(const vec4 &, const float &, const vec3 &); 308 | vec3 rotateX(const vec3 &, const float &); 309 | vec4 rotateX(const vec4 &, const float &); 310 | vec3 rotateY(const vec3 &, const float &); 311 | vec4 rotateY(const vec4 &, const float &); 312 | vec3 rotateZ(const vec3 &, const float &); 313 | vec4 rotateZ(const vec4 &, const float &); 314 | mat4 orientation(const vec3 &, const vec3 &); 315 | 316 | // ----- glm/gtx/scalar_multiplication.hpp ----- 317 | 318 | // handled in the type interfaces (ie. vec2.i, vec3.i, etc) 319 | 320 | // ----- glm/gtx/spline.hpp ----- 321 | 322 | vec2 catmullRom(const vec2 &, const vec2 &, const vec2 &, const vec2 &, const float &); 323 | vec3 catmullRom(const vec3 &, const vec3 &, const vec3 &, const vec3 &, const float &); 324 | vec2 hermite(const vec2 &, const vec2 &, const vec2 &, const vec2 &, const float &); 325 | vec3 hermite(const vec3 &, const vec3 &, const vec3 &, const vec3 &, const float &); 326 | vec2 cubic(const vec2 &, const vec2 &, const vec2 &, const vec2 &, const float &); 327 | vec3 cubic(const vec3 &, const vec3 &, const vec3 &, const vec3 &, const float &); 328 | 329 | // ----- glm/gtx/transform.hpp ----- 330 | 331 | mat4 translate(const vec3 &); 332 | mat4 rotate(float angle, const vec3 &); 333 | mat4 scale(const vec3 &); 334 | 335 | // ----- glm/gtx/vector_angle.hpp ----- 336 | 337 | FLOAT_VECTOR_RETURN_VALUE_2_PARAMS(angle); 338 | float orientedAngle(const vec2 &, const vec2 &); 339 | float orientedAngle(const vec3 &, const vec3 &, const vec3 &); 340 | -------------------------------------------------------------------------------- /glm/mat3.i: -------------------------------------------------------------------------------- 1 | // glm::mat3 bindings 2 | // 2018 Dan Wilcox 3 | 4 | // ----- glm/detail/type_mat3.hpp ----- 5 | 6 | struct mat3 { 7 | 8 | static length_t length(); 9 | 10 | mat3(); 11 | mat3(mat3 const & v); 12 | mat3(float scalar); 13 | mat3(float x0, float y0, float z0, 14 | float x1, float y1, float z1, 15 | float x2, float y2, float z2); 16 | mat3(vec3 const & v1, vec3 const & v2, vec3 const & v3); 17 | mat3(glm::mat4 const & m); 18 | 19 | mat3 & operator=(mat3 const & m); 20 | }; 21 | 22 | mat3 operator+(mat3 const & m, float scalar); 23 | mat3 operator+(float scalar, mat3 const & m); 24 | mat3 operator+(mat3 const & m1, mat3 const & m2); 25 | mat3 operator-(mat3 const & m, float scalar); 26 | mat3 operator-(float scalar, mat3 const & m); 27 | mat3 operator-(mat3 const & m1, mat3 const & m2); 28 | mat3 operator*(mat3 const & m, float scalar); 29 | mat3 operator*(float scalar, mat3 const & m); 30 | mat3 operator*(mat3 const & m1, mat3 const & m2); 31 | vec3 operator*(vec3 const & v, mat3 const & m); 32 | vec3 operator*(mat3 const & m, vec3 const & v); 33 | mat3 operator/(mat3 const & m, float scalar); 34 | mat3 operator/(float scalar, mat3 const & m); 35 | mat3 operator/(mat3 const & m1, mat3 const & m2); 36 | vec3 operator/(mat3 const & m, vec3 const & v); 37 | vec3 operator/(vec3 const & v, mat3 const & m); 38 | bool operator==(mat3 const & m1, mat3 const & m2); 39 | bool operator!=(mat3 const & m1, mat3 const & m2); 40 | 41 | %extend mat3 { 42 | 43 | // [] getter 44 | // out of bounds throws a string, which causes a Lua error 45 | vec3 __getitem__(int i) throw (std::out_of_range) { 46 | #ifdef SWIGLUA 47 | if(i < 1 || i > $self->length()) { 48 | throw std::out_of_range("in glm::mat3::__getitem__()"); 49 | } 50 | return (*$self)[i-1]; 51 | #else 52 | if(i < 0 || i >= $self->length()) { 53 | throw std::out_of_range("in glm::mat3::__getitem__()"); 54 | } 55 | return (*$self)[i]; 56 | #endif 57 | } 58 | 59 | // [] setter 60 | // out of bounds throws a string, which causes a Lua error 61 | void __setitem__(int i, vec3 v) throw (std::out_of_range) { 62 | #ifdef SWIGLUA 63 | if(i < 1 || i > $self->length()) { 64 | throw std::out_of_range("in glm::mat3::__setitem__()"); 65 | } 66 | (*$self)[i-1] = v; 67 | #else 68 | if(i < 0 || i >= $self->length()) { 69 | throw std::out_of_range("in glm::mat3::__setitem__()"); 70 | } 71 | (*$self)[i] = v; 72 | #endif 73 | } 74 | 75 | // tostring operator 76 | std::string __tostring() { 77 | std::stringstream str; 78 | const glm::length_t width = $self->length(); 79 | const glm::length_t height = (*$self)[0].length(); 80 | for(glm::length_t row = 0; row < height; ++row) { 81 | for(glm::length_t col = 0; col < width; ++col) { 82 | str << (*$self)[col][row]; 83 | if(col + 1 != width) { 84 | str << "\t"; 85 | } 86 | } 87 | if(row + 1 != height) { 88 | str << "\n"; 89 | } 90 | } 91 | return str.str(); 92 | } 93 | 94 | // extend operators, otherwise some languages (lua) 95 | // won't be able to act on objects directly (ie. v1 + v2) 96 | mat3 operator+(float scalar) {return (*$self) + scalar;} 97 | mat3 operator+(mat3 const & m) {return (*$self) + m;} 98 | mat3 operator-(float scalar) {return (*$self) - scalar;} 99 | mat3 operator-(mat3 const & m) {return (*$self) - m;} 100 | mat3 operator*(float scalar) {return (*$self) * scalar;} 101 | mat3 operator*(mat3 const & m) {return (*$self) * m;} 102 | vec3 operator*(vec3 const & v) {return (*$self) * v;} 103 | mat3 operator/(float scalar) {return (*$self) / scalar;} 104 | mat3 operator/(mat3 const & m) {return (*$self) / m;} 105 | vec3 operator/(vec3 const & v) {return (*$self) / v;} 106 | bool operator==(mat3 const & m) {return (*$self) == m;} 107 | bool operator!=(mat3 const & m1) {return (*$self) != m;} 108 | }; 109 | -------------------------------------------------------------------------------- /glm/mat4.i: -------------------------------------------------------------------------------- 1 | // glm::mat4 bindings 2 | // 2018 Dan Wilcox 3 | 4 | // ----- glm/detail/type_mat4hpp ----- 5 | 6 | struct mat4 { 7 | 8 | static length_t length(); 9 | 10 | mat4(); 11 | mat4(mat4 const & v); 12 | mat4(float scalar); 13 | mat4(float x0, float y0, float z0, float w0, 14 | float x1, float y1, float z1, float w1, 15 | float x2, float y2, float z2, float w2, 16 | float x3, float y3, float z3, float w3); 17 | mat4(vec4 const & v1, vec4 const & v2, vec4 const & v3, vec4 const & v4); 18 | mat4(mat3 const & m); 19 | 20 | mat4 & operator=(mat4 const & m); 21 | }; 22 | 23 | mat4 operator+(mat4 const & m, float scalar); 24 | mat4 operator+(float scalar, mat4 const & m); 25 | mat4 operator+(mat4 const & m1, mat4 const & m2); 26 | mat4 operator-(mat4 const & m, float scalar); 27 | mat4 operator-(float scalar, mat4 const & m); 28 | mat4 operator-(mat4 const & m1, mat4 const & m2); 29 | mat4 operator*(mat4 const & m, float scalar); 30 | mat4 operator*(float scalar, mat4 const & v); 31 | mat4 operator*(mat4 const & m1, mat4 const & m2); 32 | vec4 operator*(mat4 const & m, vec4 const & v); 33 | vec4 operator*(vec4 const & v, mat4 const & m); 34 | mat4 operator/(mat4 const & m, float scalar); 35 | mat4 operator/(float scalar, mat4 const & m); 36 | mat4 operator/(mat4 const & m1, mat4 const & m2); 37 | vec4 operator/(mat4 const & m, vec4 const & v); 38 | vec4 operator/(vec4 const & v, mat4 const & m); 39 | bool operator==(mat4 const & m1, mat4 const & m2); 40 | bool operator!=(mat4 const & m1, mat4 const & m2); 41 | 42 | %extend mat4 { 43 | 44 | // [] getter 45 | // out of bounds throws a string, which causes a Lua error 46 | vec4 __getitem__(int i) throw (std::out_of_range) { 47 | #ifdef SWIGLUA 48 | if(i < 1 || i > $self->length()) { 49 | throw std::out_of_range("in glm::mat4::__getitem__()"); 50 | } 51 | return (*$self)[i-1]; 52 | #else 53 | if(i < 0 || i >= $self->length()) { 54 | throw std::out_of_range("in glm::mat4::__getitem__()"); 55 | } 56 | return (*$self)[i]; 57 | #endif 58 | } 59 | 60 | // [] setter 61 | // out of bounds throws a string, which causes a Lua error 62 | void __setitem__(int i, vec4 v) throw (std::out_of_range) { 63 | #ifdef SWIGLUA 64 | if(i < 1 || i > $self->length()) { 65 | throw std::out_of_range("in glm::mat4::__setitem__()"); 66 | } 67 | (*$self)[i-1] = v; 68 | #else 69 | if(i < 0 || i >= $self->length()) { 70 | throw std::out_of_range("in glm::mat4::__setitem__()"); 71 | } 72 | (*$self)[i] = v; 73 | #endif 74 | } 75 | 76 | // tostring operator 77 | std::string __tostring() { 78 | std::stringstream str; 79 | const glm::length_t width = $self->length(); 80 | const glm::length_t height = (*$self)[0].length(); 81 | for(glm::length_t row = 0; row < height; ++row) { 82 | for(glm::length_t col = 0; col < width; ++col) { 83 | str << (*$self)[col][row]; 84 | if(col + 1 != width) { 85 | str << "\t"; 86 | } 87 | } 88 | if(row + 1 != height) { 89 | str << "\n"; 90 | } 91 | } 92 | return str.str(); 93 | } 94 | 95 | // extend operators, otherwise some languages (lua) 96 | // won't be able to act on objects directly (ie. v1 + v2) 97 | mat4 operator+(float scalar) {return (*$self) + scalar;} 98 | mat4 operator+(mat4 const & m) {return (*$self) + m;} 99 | mat4 operator-(float scalar) {return (*$self) - scalar;} 100 | mat4 operator-(mat4 const & m) {return (*$self) - m;} 101 | mat4 operator*(float scalar) {return (*$self) * scalar;} 102 | mat4 operator*(mat4 const & m) {return (*$self) * m;} 103 | vec4 operator*(vec4 const & v) {return (*$self) * v;} 104 | mat4 operator/(float scalar) {return (*$self) / scalar;} 105 | mat4 operator/(mat4 const & m) {return (*$self) / m;} 106 | vec4 operator/(vec4 const & v) {return (*$self) / v;} 107 | bool operator==(mat4 const & m) {return (*$self) == m;} 108 | bool operator!=(mat4 const & m1) {return (*$self) != m;} 109 | }; 110 | -------------------------------------------------------------------------------- /glm/quat.i: -------------------------------------------------------------------------------- 1 | // glm::quat bindings 2 | // 2018 Dan Wilcox 3 | 4 | // ----- glm/gtc/quaternion.hpp ----- 5 | 6 | struct quat { 7 | 8 | float x, y, z, w; 9 | 10 | static length_t length(); 11 | 12 | quat(); 13 | quat(quat const & q); 14 | quat(float s, vec3 const & v); 15 | quat(float w, float x, float y, float z); 16 | quat(vec3 const & u, vec3 const & v); 17 | quat(vec3 const & eulerAngles); 18 | quat(mat3 const & m); 19 | quat(mat4 const & m); 20 | }; 21 | 22 | quat operator+(quat const & q, quat const & p); 23 | quat operator*(quat const & q, quat const & p); 24 | vec3 operator*(quat const & q, vec3 const & v); 25 | vec3 operator*(vec3 const & v, quat const & q); 26 | vec4 operator*(quat const & q, vec4 const & v); 27 | vec4 operator*(vec4 const & v, quat const & q); 28 | quat operator*(quat const & q, float const & s); 29 | quat operator*(float const & s, quat const & q); 30 | quat operator/(quat const & q, float const & s); 31 | bool operator==(quat const & q1, quat const & q2); 32 | bool operator!=(quat const & q1, quat const & q2); 33 | 34 | float length(quat const & q); 35 | 36 | quat normalize(quat const & q); 37 | float dot(quat const & x, quat const & y); 38 | quat mix(quat const & x, quat const & y, float a); 39 | quat lerp(quat const & x, quat const & y, float a); 40 | quat slerp(quat const & x, quat const & y, float a); 41 | quat conjugate(quat const & q); 42 | quat inverse(quat const & q); 43 | quat rotate(quat const & q, float const & angle, vec3 const & axis); 44 | vec3 eulerAngles(quat const & x); 45 | float roll(quat const & x); 46 | float pitch(quat const & x); 47 | float yaw(quat const & x); 48 | mat3 mat3_cast(quat const & x); 49 | mat4 mat4_cast(quat const & x); 50 | quat quat_cast(glm::mat3 const & x); 51 | quat quat_cast(glm::mat4 const & x); 52 | float angle(quat const & x); 53 | vec3 axis(quat const & x); 54 | quat angleAxis(float const & angle, vec3 const & axis); 55 | 56 | // not sure what to do with these yet 57 | // vec4 lessThan(quat const & x, quat const & y); 58 | // vec4 lessThanEqual(quat const & x, quat const & y); 59 | // vec4 greaterThan(quat const & x, quat const & y); 60 | // vec4 greaterThanEqual(quat const & x, quat const & y); 61 | // vec4 equal(quat const & x, quat const & y); 62 | // vec4 notEqual(quat const & x, quat const & y); 63 | // vec4 isnan(quat const & x); 64 | // vec4 isinf(quat const & x); 65 | 66 | %extend quat { 67 | 68 | // [] getter 69 | // out of bounds throws a string, which causes a Lua error 70 | float __getitem__(int i) throw (std::out_of_range) { 71 | #ifdef SWIGLUA 72 | if(i < 1 || i > $self->length()) { 73 | throw std::out_of_range("in glm::quat::__getitem__()"); 74 | } 75 | return (*$self)[i-1]; 76 | #else 77 | if(i < 0 || i >= $self->length()) { 78 | throw std::out_of_range("in glm::quat::__getitem__()"); 79 | } 80 | return (*$self)[i]; 81 | #endif 82 | } 83 | 84 | // [] setter 85 | // out of bounds throws a string, which causes a Lua error 86 | void __setitem__(int i, float f) throw (std::out_of_range) { 87 | #ifdef SWIGLUA 88 | if(i < 1 || i > $self->length()) { 89 | throw std::out_of_range("in glm::quat::__setitem__()"); 90 | } 91 | (*$self)[i-1] = f; 92 | #else 93 | if(i < 0 || i >= $self->length()) { 94 | throw std::out_of_range("in glm::quat::__setitem__()"); 95 | } 96 | (*$self)[i] = f; 97 | #endif 98 | } 99 | 100 | // to string operator 101 | std::string __tostring() { 102 | std::stringstream str; 103 | for(glm::length_t i = 0; i < $self->length(); ++i) { 104 | str << (*$self)[i]; 105 | if(i + 1 != $self->length()) { 106 | str << " "; 107 | } 108 | } 109 | return str.str(); 110 | } 111 | 112 | // extend operators, otherwise some languages (lua) 113 | // won't be able to act on objects directly (ie. v1 + v2) 114 | quat operator+(quat const & q) {return (*$self) + q;} 115 | quat operator*(quat const & q) {return (*$self) * q;} 116 | vec3 operator*(vec3 const & v) {return (*$self) * v;} 117 | vec4 operator*(vec4 const & v) {return (*$self) * v;} 118 | quat operator*(float const & s) {return (*$self) * s;} 119 | quat operator/(float const & s) {return (*$self) / s;} 120 | bool operator==(quat const & q) {return (*$self) == q;} 121 | bool operator!=(quat const & q) {return (*$self) != q;} 122 | }; 123 | -------------------------------------------------------------------------------- /glm/vec2.i: -------------------------------------------------------------------------------- 1 | // glm::vec2 bindings 2 | // 2018 Dan Wilcox 3 | 4 | // ----- glm/detail/type_vec2.hpp ----- 5 | 6 | struct vec2 { 7 | 8 | float x, y; 9 | 10 | static length_t length(); 11 | 12 | vec2(); 13 | vec2(vec2 const & v); 14 | vec2(float scalar); 15 | vec2(float s1, float s2); 16 | vec2(glm::vec3 const & v); 17 | vec2(glm::vec4 const & v); 18 | 19 | vec2 & operator=(vec2 const & v); 20 | }; 21 | 22 | vec2 operator+(vec2 const & v, float scalar); 23 | vec2 operator+(float scalar, vec2 const & v); 24 | vec2 operator+(vec2 const & v1, vec2 const & v2); 25 | vec2 operator-(vec2 const & v, float scalar); 26 | vec2 operator-(float scalar, vec2 const & v); 27 | vec2 operator-(vec2 const & v1, vec2 const & v2); 28 | vec2 operator*(vec2 const & v, float scalar); 29 | vec2 operator*(float scalar, vec2 const & v); 30 | vec2 operator*(vec2 const & v1, vec2 const & v2); 31 | vec2 operator/(vec2 const & v, float scalar); 32 | vec2 operator/(float scalar, vec2 const & v); 33 | vec2 operator/(vec2 const & v1, vec2 const & v2); 34 | vec2 operator%(vec2 const & v, float scalar); 35 | vec2 operator%(float scalar, vec2 const & v); 36 | vec2 operator%(vec2 const & v1, vec2 const & v2); 37 | bool operator==(vec2 const & v1, vec2 const & v2); 38 | bool operator!=(vec2 const & v1, vec2 const & v2); 39 | 40 | %extend vec2 { 41 | 42 | // [] getter 43 | // out of bounds throws a string, which causes a Lua error 44 | float __getitem__(int i) throw (std::out_of_range) { 45 | #ifdef SWIGLUA 46 | if(i < 1 || i > $self->length()) { 47 | throw std::out_of_range("in glm::vec2::__getitem__()"); 48 | } 49 | return (*$self)[i-1]; 50 | #else 51 | if(i < 0 || i >= $self->length()) { 52 | throw std::out_of_range("in glm::vec2::__getitem__()"); 53 | } 54 | return (*$self)[i]; 55 | #endif 56 | } 57 | 58 | // [] setter 59 | // out of bounds throws a string, which causes a Lua error 60 | void __setitem__(int i, float f) throw (std::out_of_range) { 61 | #ifdef SWIGLUA 62 | if(i < 1 || i > $self->length()) { 63 | throw std::out_of_range("in glm::vec2::__setitem__()"); 64 | } 65 | (*$self)[i-1] = f; 66 | #else 67 | if(i < 0 || i >= $self->length()) { 68 | throw std::out_of_range("in glm::vec2::__setitem__()"); 69 | } 70 | (*$self)[i] = f; 71 | #endif 72 | } 73 | 74 | // tostring operator 75 | std::string __tostring() { 76 | std::stringstream str; 77 | for(glm::length_t i = 0; i < $self->length(); ++i) { 78 | str << (*$self)[i]; 79 | if(i + 1 != $self->length()) { 80 | str << " "; 81 | } 82 | } 83 | return str.str(); 84 | } 85 | 86 | // extend operators, otherwise some languages (lua) 87 | // won't be able to act on objects directly (ie. v1 + v2) 88 | vec2 operator+(vec2 const & v) {return (*$self) + v;} 89 | vec2 operator+(float scalar) {return (*$self) + scalar;} 90 | vec2 operator-(vec2 const & v) {return (*$self) - v;} 91 | vec2 operator-(float scalar) {return (*$self) - scalar;} 92 | vec2 operator*(vec2 const & v) {return (*$self) * v;} 93 | vec2 operator*(float scalar) {return (*$self) * scalar;} 94 | vec2 operator/(vec2 const & v) {return (*$self) / v;} 95 | vec2 operator/(float scalar) {return (*$self) / scalar;} 96 | vec2 operator%(vec2 const & v) {return (*$self) % v;} 97 | vec2 operator%(float scalar) {return (*$self) % scalar;} 98 | bool operator==(vec2 const & v) {return (*$self) == v;} 99 | bool operator!=(vec2 const & v) {return (*$self) != v;} 100 | }; 101 | -------------------------------------------------------------------------------- /glm/vec3.i: -------------------------------------------------------------------------------- 1 | // glm::vec3 bindings 2 | // 2018 Dan Wilcox 3 | 4 | // ----- glm/detail/type_vec3.hpp ----- 5 | 6 | struct vec3 { 7 | 8 | float x, y, z; 9 | 10 | static length_t length(); 11 | 12 | vec3(); 13 | vec3(vec3 const & v); 14 | vec3(float scalar); 15 | vec3(float s1, float s2, float s3); 16 | vec3(glm::vec2 const & a, float b); 17 | vec3(float a, glm::vec2 const & b); 18 | vec3(glm::vec4 const & v); 19 | 20 | vec3 & operator=(vec3 const & v); 21 | }; 22 | 23 | vec3 operator+(vec3 const & v, float scalar); 24 | vec3 operator+(float scalar, vec3 const & v); 25 | vec3 operator+(vec3 const & v1, vec3 const & v2); 26 | vec3 operator-(vec3 const & v, float scalar); 27 | vec3 operator-(float scalar, vec3 const & v); 28 | vec3 operator-(vec3 const & v1, vec3 const & v2); 29 | vec3 operator*(vec3 const & v, float scalar); 30 | vec3 operator*(float scalar, vec3 const & v); 31 | vec3 operator*(vec3 const & v1, vec3 const & v2); 32 | vec3 operator/(vec3 const & v, float scalar); 33 | vec3 operator/(float scalar, vec3 const & v); 34 | vec3 operator/(vec3 const & v1, vec3 const & v2); 35 | vec3 operator%(vec3 const & v, float scalar); 36 | vec3 operator%(float scalar, vec3 const & v); 37 | vec3 operator%(vec3 const & v1, vec3 const & v2); 38 | bool operator==(vec3 const & v1, vec3 const & v2); 39 | bool operator!=(vec3 const & v1, vec3 const & v2); 40 | 41 | %extend vec3 { 42 | 43 | // [] getter 44 | // out of bounds throws a string, which causes a Lua error 45 | float __getitem__(int i) throw (std::out_of_range) { 46 | #ifdef SWIGLUA 47 | if(i < 1 || i > $self->length()) { 48 | throw std::out_of_range("in glm::vec3::__getitem__()"); 49 | } 50 | return (*$self)[i-1]; 51 | #else 52 | if(i < 0 || i >= $self->length()) { 53 | throw std::out_of_range("in glm::vec3::__getitem__()"); 54 | } 55 | return (*$self)[i]; 56 | #endif 57 | } 58 | 59 | // [] setter 60 | // out of bounds throws a string, which causes a Lua error 61 | void __setitem__(int i, float f) throw (std::out_of_range) { 62 | #ifdef SWIGLUA 63 | if(i < 1 || i > $self->length()) { 64 | throw std::out_of_range("in glm::vec3::__setitem__()"); 65 | } 66 | (*$self)[i-1] = f; 67 | #else 68 | if(i < 0 || i >= $self->length()) { 69 | throw std::out_of_range("in glm::vec3::__setitem__()"); 70 | } 71 | (*$self)[i] = f; 72 | #endif 73 | } 74 | 75 | // tostring operator 76 | std::string __tostring() { 77 | std::stringstream str; 78 | for(glm::length_t i = 0; i < $self->length(); ++i) { 79 | str << (*$self)[i]; 80 | if(i + 1 != $self->length()) { 81 | str << " "; 82 | } 83 | } 84 | return str.str(); 85 | } 86 | 87 | // extend operators, otherwise some languages (lua) 88 | // won't be able to act on objects directly (ie. v1 + v2) 89 | vec3 operator+(vec3 const & v) {return (*$self) + v;} 90 | vec3 operator+(float scalar) {return (*$self) + scalar;} 91 | vec3 operator-(vec3 const & v) {return (*$self) - v;} 92 | vec3 operator-(float scalar) {return (*$self) - scalar;} 93 | vec3 operator*(vec3 const & v) {return (*$self) * v;} 94 | vec3 operator*(float scalar) {return (*$self) * scalar;} 95 | vec3 operator/(vec3 const & v) {return (*$self) / v;} 96 | vec3 operator/(float scalar) {return (*$self) / scalar;} 97 | vec3 operator%(vec3 const & v) {return (*$self) % v;} 98 | vec3 operator%(float scalar) {return (*$self) % scalar;} 99 | bool operator==(vec3 const & v) {return (*$self) == v;} 100 | bool operator!=(vec3 const & v) {return (*$self) != v;} 101 | }; 102 | -------------------------------------------------------------------------------- /glm/vec4.i: -------------------------------------------------------------------------------- 1 | // glm::vec4 bindings 2 | // 2018 Dan Wilcox 3 | 4 | // ----- glm/detail/type_vec4.hpp ----- 5 | 6 | struct vec4 { 7 | 8 | float x, y, z, w; 9 | 10 | static length_t length(); 11 | 12 | vec4(); 13 | vec4(vec4 const & v); 14 | vec4(float scalar); 15 | vec4(float s1, float s2, float s3, float s4); 16 | vec4(vec2 const & a, vec2 const & b); 17 | vec4(vec2 const & a, float b, float c); 18 | vec4(float a, vec2 const & b, float c); 19 | vec4(float a, float b, vec2 const & c); 20 | vec4(vec3 const & a, float b); 21 | vec4(float a, vec3 const & b); 22 | 23 | vec4 & operator=(vec4 const & v); 24 | }; 25 | 26 | vec4 operator+(vec4 const & v, float scalar); 27 | vec4 operator+(float scalar, vec4 const & v); 28 | vec4 operator+(vec4 const & v1, vec4 const & v2); 29 | vec4 operator-(vec4 const & v, float scalar); 30 | vec4 operator-(float scalar, vec4 const & v); 31 | vec4 operator-(vec4 const & v1, vec4 const & v2); 32 | vec4 operator*(vec4 const & v, float scalar); 33 | vec4 operator*(float scalar, vec4 const & v); 34 | vec4 operator*(vec4 const & v1, vec4 const & v2); 35 | vec4 operator/(vec4 const & v, float scalar); 36 | vec4 operator/(float scalar, vec4 const & v); 37 | vec4 operator/(vec4 const & v1, vec4 const & v2); 38 | vec4 operator%(vec4 const & v, float scalar); 39 | vec4 operator%(float scalar, vec4 const & v); 40 | vec4 operator%(vec4 const & v1, vec4 const & v2); 41 | bool operator==(vec4 const & v1, vec4 const & v2); 42 | bool operator!=(vec4 const & v1, vec4 const & v2); 43 | 44 | %extend vec4 { 45 | 46 | // [] getter 47 | // out of bounds throws a string, which causes a Lua error 48 | float __getitem__(int i) throw (std::out_of_range) { 49 | #ifdef SWIGLUA 50 | if(i < 1 || i > $self->length()) { 51 | throw std::out_of_range("in glm::vec4::__getitem__()"); 52 | } 53 | return (*$self)[i-1]; 54 | #else 55 | if(i < 0 || i >= $self->length()) { 56 | throw std::out_of_range("in glm::vec4::__getitem__()"); 57 | } 58 | return (*$self)[i]; 59 | #endif 60 | } 61 | 62 | // [] setter 63 | // out of bounds throws a string, which causes a Lua error 64 | void __setitem__(int i, float f) throw (std::out_of_range) { 65 | #ifdef SWIGLUA 66 | if(i < 1 || i > $self->length()) { 67 | throw std::out_of_range("in glm::vec4::__setitem__()"); 68 | } 69 | (*$self)[i-1] = f; 70 | #else 71 | if(i < 0 || i >= $self->length()) { 72 | throw std::out_of_range("in glm::vec4::__setitem__()"); 73 | } 74 | (*$self)[i] = f; 75 | #endif 76 | } 77 | 78 | // tostring operator 79 | std::string __tostring() { 80 | std::stringstream str; 81 | for(glm::length_t i = 0; i < $self->length(); ++i) { 82 | str << (*$self)[i]; 83 | if(i + 1 != $self->length()) { 84 | str << " "; 85 | } 86 | } 87 | return str.str(); 88 | } 89 | 90 | // extend operators, otherwise some languages (lua) 91 | // won't be able to act on objects directly (ie. v1 + v2) 92 | vec4 operator+(vec4 const & v) {return (*$self) + v;} 93 | vec4 operator+(float scalar) {return (*$self) + scalar;} 94 | vec4 operator-(vec4 const & v) {return (*$self) - v;} 95 | vec4 operator-(float scalar) {return (*$self) - scalar;} 96 | vec4 operator*(vec4 const & v) {return (*$self) * v;} 97 | vec4 operator*(float scalar) {return (*$self) * scalar;} 98 | vec4 operator/(vec4 const & v) {return (*$self) / v;} 99 | vec4 operator/(float scalar) {return (*$self) / scalar;} 100 | vec4 operator%(vec4 const & v) {return (*$self) % v;} 101 | vec4 operator%(float scalar) {return (*$self) % scalar;} 102 | bool operator==(vec4 const & v) {return (*$self) == v;} 103 | bool operator!=(vec4 const & v) {return (*$self) != v;} 104 | }; 105 | -------------------------------------------------------------------------------- /openFrameworks.i: -------------------------------------------------------------------------------- 1 | // SWIG (http://www.swig.org) interface wrapper for the openFrameworks core API 2 | // 2014-17 Dan Wilcox 3 | 4 | // workaround when compiling in MinGW (Python) 5 | %begin %{ 6 | #if defined( __WIN32__ ) || defined( _WIN32 ) 7 | #include 8 | #endif 9 | %} 10 | 11 | // main MODULE 12 | %module MODULE_NAME 13 | %{ 14 | #include "ofMain.h" 15 | #undef check 16 | %} 17 | %include 18 | %include 19 | 20 | // custom attribute wrapper for nested union var access 21 | %define %attributeVar(Class, AttributeType, AttributeName, GetVar, SetVar...) 22 | #if #SetVar != "" 23 | %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetVar, SetVar, self_->GetVar, self_->SetVar = val_) 24 | #else 25 | %attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetVar, self_->GetVar) 26 | #endif 27 | %enddef 28 | 29 | // ----- C++ ----- 30 | 31 | // SWIG doesn't understand C++ streams 32 | %ignore operator <<; 33 | %ignore operator >>; 34 | 35 | // expanded primitives 36 | %typedef unsigned int size_t; 37 | %typedef long long int64_t; 38 | %typedef unsigned long long uint64_t; 39 | 40 | %include 41 | %include 42 | %include 43 | 44 | // ----- Renaming ----- 45 | 46 | #ifdef OF_SWIG_RENAME 47 | 48 | // strip "of" prefix from classes 49 | %rename("%(strip:[of])s", %$isclass) ""; 50 | 51 | // strip "of" prefix from global functions & make first char lowercase 52 | %rename("%(regex:/of(.*)/\\l\\1/)s", %$isfunction) ""; 53 | 54 | // strip "OF_" from constants & enums 55 | %rename("%(strip:[OF_])s", %$isconstant) ""; 56 | %rename("%(strip:[OF_])s", %$isenumitem) ""; 57 | 58 | #endif 59 | 60 | // ----- Lang specifics ------ 61 | 62 | #ifdef SWIGLUA 63 | %include "openFrameworks/lang/lua/lua.i" 64 | #endif 65 | 66 | #ifdef SWIGPYTHON 67 | %include "openFrameworks/lang/python/python.i" 68 | #endif 69 | 70 | // ----- Deprecated ------ 71 | 72 | #ifndef OF_SWIG_DEPRECATED 73 | %include "openFrameworks/deprecated.i" 74 | #endif 75 | 76 | // ----- Bindings------ 77 | 78 | // Look for the follow notes: 79 | // TODO: something that might need to be updated or fixed in the future 80 | // DIFF: an important difference as compared to the OF C++ API 81 | // 82 | // Make sure to %rename & %ignore *before* %including a header. 83 | // 84 | // The order of class declarations is important! This is why a number of 85 | // classes are %included at the beginning of main.i before ofBaseTypes.h. 86 | // 87 | // If a header forward declares a class like (AnotherClass.h): 88 | // 89 | // class SomeClass; 90 | // class AnotherClass { 91 | // ... 92 | // 93 | // and this header is %included before the actual class implementation 94 | // (SomeClass.h), SWIG will wrap the empty declaration and *not* the actual 95 | // class! This basically allows you to create the class in the bound language, 96 | // but it does nothing and has no attributes or functions. Bummer. 97 | // 98 | // What needs to be done is either %include SomeClass.h before AnotherClass.h 99 | // 100 | // %include "SomeClass.h" 101 | // %include "AnotherClass.h" 102 | // 103 | // or make a forward declaration before %including SomeClass.h: 104 | // 105 | // class SomeClass {}; 106 | // %include AnotherClass.h 107 | // 108 | // This forward declaration is then overridden by the actual implementation after 109 | // %include "SomeClass.h" later on. 110 | 111 | %include "openFrameworks/openFrameworks/main.i" 112 | %include "openFrameworks/openFrameworks/3d.i" 113 | %include "openFrameworks/openFrameworks/app.i" 114 | #if !defined(TARGET_IOS) && !defined(TARGET_ANDROID) 115 | %include "openFrameworks/openFrameworks/communication.i" 116 | #endif 117 | %include "openFrameworks/openFrameworks/math.i" 118 | %include "openFrameworks/openFrameworks/events.i" 119 | %include "openFrameworks/openFrameworks/gl.i" 120 | %include "openFrameworks/openFrameworks/graphics.i" 121 | %include "openFrameworks/openFrameworks/sound.i" 122 | %include "openFrameworks/openFrameworks/types.i" 123 | %include "openFrameworks/openFrameworks/utils.i" 124 | %include "openFrameworks/openFrameworks/video.i" 125 | 126 | // ----- Attributes ------ 127 | 128 | #ifdef OF_SWIG_ATTRIBUTES 129 | %include "openFrameworks/attributes.i" 130 | #endif 131 | 132 | // ----- Lang code ------ 133 | 134 | #ifdef SWIGLUA 135 | %include "openFrameworks/lang/lua/lua_code.i" 136 | #endif 137 | 138 | #ifdef SWIGPYTHON 139 | %include "openFrameworks/lang/python/python_code.i" 140 | #endif 141 | -------------------------------------------------------------------------------- /openFrameworks/attributes.i: -------------------------------------------------------------------------------- 1 | // scripting language attributes to add using getters/setters 2 | // 2015 Dan Wilcox 3 | 4 | // ----- ofFbo.h ----- 5 | 6 | // ATTR: ofFbo.h: 7 | // ATTR: getter: allocated, texture, depthTexture, width, height, 8 | // ATTR: numTextures, id, idDrawBuffer, depthBuffer, stencilBuffer 9 | // ATTR: getter/setter: defaultTexture 10 | %attribute(ofFbo, bool, allocated, isAllocated); 11 | %attribute(ofFbo, int, defaultTexture, getDefaultTextureIndex, setDefaultTextureIndex); 12 | %attribute(ofFbo, ofTexture &, texture, getTexture); 13 | %attribute(ofFbo, ofTexture &, depthTexture, getDepthTexture); 14 | %attribute(ofFbo, float, width, getWidth); 15 | %attribute(ofFbo, float, height, getHeight); 16 | %attribute(ofFbo, int, numTextures, getNumTextures); 17 | %attribute(ofFbo, unsigned int, id, getId); 18 | %attribute(ofFbo, unsigned int, idDrawBuffer, getIdDrawBuffer); 19 | %attribute(ofFbo, unsigned int, depthBuffer, getDepthBuffer); 20 | %attribute(ofFbo, unsigned int, stencilBuffer, getStencilBuffer); 21 | 22 | // ----- ofTexture.h ----- 23 | 24 | // ATTR: ofTexture.h: 25 | // ATTR: getter: allocated, width, height, usingTextureMatrix, textureData 26 | // ATTR: getter/setter: textureMatrix 27 | %attribute(ofTexture, bool, allocated, isAllocated); 28 | %attribute(ofTexture, float, width, getWidth); 29 | %attribute(ofTexture, float, height, getHeight); 30 | %attribute(ofTexture, ofMatrix4x4 &, textureMatrix, getTextureMatrix, setTextureMatrix); 31 | %attribute(ofTexture, bool, usingTextureMatrix, isUsingTextureMatrix); 32 | %attribute(ofTexture, ofTextureData &, textureData, getTextureData); 33 | 34 | // ----- ofImage.h ----- 35 | 36 | // ATTR: ofImage.h: 37 | // ATTR: getter: allocated, texture, pixels, width, height, imageType 38 | // ATTR: getter/setter: usingTexture 39 | %attribute(ofImage_, bool, allocated, isAllocated); 40 | %attribute(ofImage_, bool, usingTexture, isUsingTexture, setUseTexture); 41 | %attribute(ofImage_, ofTexture &, texture, getTexture); 42 | %attribute(ofImage_, ofPixels &, pixels, getPixels); 43 | %attribute(ofImage_, float, width, getWidth); 44 | %attribute(ofImage_, float, height, getHeight); 45 | %attribute(ofImage_, ofImageType, imageType, getImageType, setImageType); 46 | 47 | %attribute(ofImage_, bool, allocated, isAllocated); 48 | %attribute(ofImage_, bool, usingTexture, isUsingTexture, setUseTexture); 49 | %attribute(ofImage_, ofTexture &, texture, getTexture); 50 | %attribute(ofImage_, ofPixels &, pixels, getPixels); 51 | %attribute(ofImage_, float, width, getWidth); 52 | %attribute(ofImage_, float, height, getHeight); 53 | %attribute(ofImage_, ofImageType, imageType, getImageType, setImageType); 54 | 55 | %attribute(ofImage_, bool, allocated, isAllocated); 56 | %attribute(ofImage_, bool, usingTexture, isUsingTexture, setUseTexture); 57 | %attribute(ofImage_, ofTexture &, texture, getTexture); 58 | %attribute(ofImage_, ofPixels &, pixels, getPixels); 59 | %attribute(ofImage_, float, width, getWidth); 60 | %attribute(ofImage_, float, height, getHeight); 61 | %attribute(ofImage_, ofImageType, imageType, getImageType, setImageType); 62 | 63 | // ----- ofSoundStream.h ----- 64 | 65 | // ATTR: ofSoundStream.h: 66 | // ATTR: getter: tickCount, numInputChannels, numOutputChannels, 67 | // ATTR: sampleRate, bufferSize 68 | %attribute(ofSoundStream, unsigned long, tickCount, getTickCount); 69 | %attribute(ofSoundStream, int, numInputChannels, getNumInputChannels); 70 | %attribute(ofSoundStream, int, numOutputChannels, getNumOutputChannels); 71 | %attribute(ofSoundStream, int, sampleRate, getSampleRate); 72 | %attribute(ofSoundStream, int, bufferSize, getBufferSize); 73 | 74 | // ----- ofSoundPlayer.h ----- 75 | 76 | // ATTR: ofSoundPlayer.h: 77 | // ATTR: getter: playing, loaded 78 | // ATTR: getter/setter: volume, pan, speed, position, positionMS 79 | %attribute(ofSoundPlayer, float, volume, getVolume, setVolume); 80 | %attribute(ofSoundPlayer, float, pan, getPan, setPan); 81 | %attribute(ofSoundPlayer, float, speed, getSpeed, setSpeed); 82 | %attribute(ofSoundPlayer, float, position, getPosition, setPosition); 83 | %attribute(ofSoundPlayer, int, positionMS, getPositionMS, setPositionMS); 84 | %attribute(ofSoundPlayer, bool, playing, isPlaying); 85 | %attribute(ofSoundPlayer, bool, loaded, isLoaded); 86 | 87 | // ----- ofFpsCounter.h ----- 88 | 89 | // ATTR: ofFpsCounter.h: getter: fps, numFrames, lastFrameNanos, lastFrameSecs 90 | %attribute(ofFpsCounter, double, fps, getFps); 91 | %attribute(ofFpsCounter, uint64_t, numFrames, getNumFrames); 92 | %attribute(ofFpsCounter, uint64_t, lastFrameNanos, getLastFrameNanos); 93 | %attribute(ofFpsCounter, double, lastFrameSecs, getLastFrameSecs); 94 | 95 | // ----- ofBufferObject.h ----- 96 | 97 | // ATTR: ofBufferObject.h: getter: allocated, id 98 | %attribute(ofBufferObject, bool, allocated, isAllocated); 99 | %attribute(ofBufferObject, unsigned int, id, getId); 100 | 101 | // ----- ofPixels.h ----- 102 | 103 | // ATTR: ofPixels.h: getter: width & height 104 | %attribute(ofPixels_, float, width, getWidth); 105 | %attribute(ofPixels_, float, height, getHeight); 106 | 107 | %attribute(ofPixels_, float, width, getWidth); 108 | %attribute(ofPixels_, float, height, getHeight); 109 | 110 | %attribute(ofPixels_, float, width, getWidth); 111 | %attribute(ofPixels_, float, height, getHeight); 112 | 113 | // ----- ofTrueTypeFont.h ----- 114 | 115 | // ATTR: ofTrueTypeFont.h: getter/setter: lineHeight, letterSpacing, & spaceSize 116 | %attribute(ofTrueTypeFont, float, lineHeight, getLineHeight, setLineHeight); 117 | %attribute(ofTrueTypeFont, float, letterSpacing, getLetterSpacing, setLetterSpacing); 118 | %attribute(ofTrueTypeFont, float, spaceSize, getSpaceSize, setSpaceSize); 119 | 120 | // ----- ofFileUtils.h ----- 121 | 122 | // ATTR: ofFileUtils.h: ofBuffer getter: length, data, text 123 | %attribute(ofBuffer, long, length, size); 124 | %attribute(ofBuffer, char *, data, getData); 125 | %attributestring(ofBuffer, std::string, text, getText); 126 | 127 | // ----- ofVideoGrabber.h ----- 128 | 129 | // ATTR: ofVideoGrabber.h: 130 | // ATTR: getter: frameNew, pixelFormat, pixels, texture, 131 | // ATTR: width, height, initialized 132 | // ATTR: getter/setter: usingTexture 133 | %attribute(ofVideoGrabber, bool, frameNew, isFrameNew); 134 | %attribute(ofVideoGrabber, ofPixelFormat, pixelFormat, getPixelFormat); 135 | %attribute(ofVideoGrabber, ofPixels &, pixels, getPixels); 136 | %attribute(ofVideoGrabber, ofTexture &, texture, getTexture); 137 | %attribute(ofVideoGrabber, bool, usingTexture, isUsingTexture, setUseTexture); 138 | %attribute(ofVideoGrabber, float, width, getWidth); 139 | %attribute(ofVideoGrabber, float, height, getHeight); 140 | %attribute(ofVideoGrabber, bool, initialized, isInitialized); 141 | 142 | // ----- ofVideoPlayer.h ----- 143 | 144 | // ATTR: ofVideoPlayer.h: 145 | // ATTR: getter: frameNew, pixels, movieDone, texture, width, 146 | // ATTR: height, duration, loaded, playing, initialized, numFrames 147 | // ATTR: getter/setter: usingTexture, pixelFormat, position, 148 | // ATTR: speed, loopState, paused, frame 149 | %attributestring(ofVideoPlayer, std::string, moviePath, getMoviePath); 150 | %attribute(ofVideoPlayer, ofPixelFormat, pixelFormat, getPixelFormat, setPixelFormat); 151 | %attribute(ofVideoPlayer, bool, frameNew, isFrameNew); 152 | %attribute(ofVideoPlayer, ofPixels &, pixels, getPixels); 153 | %attribute(ofVideoPlayer, float, position, getPosition, setPosition); 154 | %attribute(ofVideoPlayer, float, speed, getSpeed, setSpeed); 155 | %attribute(ofVideoPlayer, float, duration, getDuration); 156 | %attribute(ofVideoPlayer, ofLoopType, loopState, getLoopState, setLoopState); 157 | %attribute(ofVideoPlayer, bool, movieDone, getIsMovieDone); 158 | %attribute(ofVideoPlayer, bool, usingTexture, isUsingTexture, setUseTexture); 159 | %attribute(ofVideoPlayer, ofTexture &, texture, getTexture); 160 | %attribute(ofVideoPlayer, int, frame, getCurrentFrame, setFrame); 161 | %attribute(ofVideoPlayer, int, numFrames, getTotalNumFrames); 162 | %attribute(ofVideoPlayer, float, width, getWidth); 163 | %attribute(ofVideoPlayer, float, height, getHeight); 164 | %attribute(ofVideoPlayer, bool, paused, isPaused, setPaused); 165 | %attribute(ofVideoPlayer, bool, loaded, isLoaded); 166 | %attribute(ofVideoPlayer, bool, playing, isPlaying); 167 | %attribute(ofVideoPlayer, bool, initialized, isInitialized); 168 | -------------------------------------------------------------------------------- /openFrameworks/deprecated.i: -------------------------------------------------------------------------------- 1 | // deprecations to ignore (aka not wrapped), 2 | // these are functions wrapped by the OF_DEPRECATED_MSG macro 3 | // 2015 Dan Wilcox 4 | 5 | // ----- ofNode.h ----- 6 | 7 | %ignore ofNode::getPitch; 8 | %ignore ofNode::getHeading; 9 | %ignore ofNode::getRoll; 10 | %ignore ofNode::getOrientationEuler; 11 | %ignore ofNode::tilt; 12 | %ignore ofNode::pan; 13 | %ignore ofNode::roll; 14 | %ignore ofNode::rotate; 15 | %ignore ofNode::rotateAround(float, const glm::vec3&, const glm::vec3&); 16 | %ignore ofNode::orbit; 17 | 18 | // ----- ofMaterial.h ----- 19 | 20 | %ignore ofMaterial::getData; 21 | %ignore ofMaterial::setData; 22 | 23 | // ----- ofRectangle.h ----- 24 | 25 | %ignore ofRectangle::getPositionRef; 26 | 27 | // ----- ofFbo.h ----- 28 | 29 | %ignore ofFbo::destroy; 30 | %ignore ofFbo::getTextureReference; 31 | %ignore ofFbo::begin(bool) const; 32 | %ignore ofFbo::getFbo; 33 | %ignore ofFbo::Settings; 34 | 35 | // ----- ofGLUtils.h ----- 36 | 37 | // deprecated in favor of ofGetGL* 38 | %ignore ofGetGlInternalFormat; 39 | %ignore ofGetGlInternalFormatName; 40 | %ignore ofGetGlTypeFromInternal; 41 | %ignore ofGetGlType; 42 | %ignore ofGetGlFormat; 43 | 44 | // ----- ofTexture.h ----- 45 | 46 | %ignore ofSetTextureWrap; 47 | %ignore ofGetUsingCustomTextureWrap; 48 | %ignore ofRestoreTextureWrap; 49 | %ignore ofSetMinMagFilters; 50 | %ignore ofGetUsingCustomMinMagFilters; 51 | %ignore ofRestoreMinMagFilters; 52 | %ignore ofTexture::bAllocated; 53 | 54 | // ----- ofImage.h ----- 55 | 56 | %ignore ofImage_::bAllocated; 57 | %ignore ofImage_::loadImage; 58 | %ignore ofImage_::getTextureReference; 59 | %ignore ofImage_::getPixelsRef; 60 | %ignore ofImage_::saveImage; 61 | 62 | // ----- ofSoundStream.h ----- 63 | 64 | %ignore ofSoundStreamSetup(int, int); 65 | %ignore ofSoundStreamSetup(int, int, ofBaseApp *); 66 | %ignore ofSoundStreamSetup(int, int, int, int, int); 67 | %ignore ofSoundStreamSetup(int, int, ofBaseApp *, int, int, int); 68 | 69 | %ignore ofSoundStream::setDeviceID; 70 | %ignore ofSoundStream::setDevice; 71 | %ignore ofSoundStream::setup(ofBaseApp *, int, int, int, int, int); 72 | %ignore ofSoundStream::setup(int, int, int, int, int); 73 | %ignore ofSoundStream::listDevices; 74 | 75 | // ----- ofSoundPlayer.h ----- 76 | 77 | %ignore ofSoundPlayer::loadSound; 78 | %ignore ofSoundPlayer::unloadSound; 79 | %ignore ofSoundPlayer::getIsPlaying; 80 | 81 | // ----- ofURLFileLoader.h ----- 82 | 83 | %ignore ofHttpRequest::getID; 84 | 85 | // ----- ofAppRunner.h ----- 86 | 87 | //%ignore ofSetupOpenGL(ofAppBaseWindow *, int, int, int); 88 | //%ignore ofRunApp(ofBaseApp *); 89 | 90 | // ----- ofSerial.h ----- 91 | 92 | %ignore ofSerial::enumerateDevices; 93 | 94 | // ----- ofPixels.h ----- 95 | 96 | %ignore ofPixels_::getPixels; 97 | 98 | // ----- ofPolyline.h ----- 99 | 100 | %ignore ofPolyline_::getAngleAtIndex; 101 | %ignore ofPolyline_::getAngleAtIndexInterpolated; 102 | %ignore ofPolyline_::rotate; 103 | 104 | // ----- ofPath.h ----- 105 | 106 | %ignore ofPath::setArcResolution; 107 | %ignore ofPath::getArcResolution; 108 | %ignore ofPath::rotate; 109 | 110 | // ----- ofGraphics.h ----- 111 | 112 | %ignore ofGetBackground; 113 | %ignore ofClear(float); 114 | %ignore ofbClearBg; 115 | %ignore ofTriangle; 116 | %ignore ofCircle; 117 | %ignore ofEllipse; 118 | %ignore ofLine; 119 | %ignore ofRect; 120 | %ignore ofRectRounded; 121 | %ignore ofCurve; 122 | %ignore ofBezier; 123 | %ignore ofRotate; 124 | %ignore ofRotateX; 125 | %ignore ofRotateY; 126 | %ignore ofRotateZ; 127 | %ignore ofSetupScreenPerspective(float, float, ofOrientation); 128 | %ignore ofSetupScreenPerspective(float, float, ofOrientation, bool); 129 | %ignore ofSetupScreenPerspective(float, float, ofOrientation, bool, float); 130 | %ignore ofSetupScreenPerspective(float, float, ofOrientation, bool, float, float); 131 | %ignore ofSetupScreenPerspective(float, float, ofOrientation, bool, float, float, float); 132 | %ignore ofSetupScreenOrtho(float, float, ofOrientation); 133 | %ignore ofSetupScreenOrtho(float, float, ofOrientation, bool); 134 | %ignore ofSetupScreenOrtho(float, float, ofOrientation, bool, float); 135 | %ignore ofSetupScreenOrtho(float, float, ofOrientation, bool, float, float); 136 | 137 | // ----- of3dGraphics.h ----- 138 | 139 | %ignore ofSphere; 140 | %ignore ofCone; 141 | %ignore ofBox; 142 | 143 | // ----- ofTrueTypeFont.h ----- 144 | 145 | %ignore ofTrueTypeFont::loadFont; 146 | 147 | // ----- ofMath.h ----- 148 | 149 | %ignore ofSeedRandom; 150 | 151 | // ----- ofVec2f.h ----- 152 | 153 | %ignore ofVec2f::rescaled; 154 | %ignore ofVec2f::rescale; 155 | %ignore ofVec2f::rotated; 156 | %ignore ofVec2f::normalized; 157 | %ignore ofVec2f::limited; 158 | %ignore ofVec2f::perpendiculared; 159 | %ignore ofVec2f::interpolated; 160 | %ignore ofVec2f::middled; 161 | %ignore ofVec2f::mapped; 162 | %ignore ofVec2f::distanceSquared; 163 | %ignore ofVec2f::rotated; 164 | 165 | // ----- ofVec3f.h ----- 166 | 167 | %ignore ofVec3f::rescaled; 168 | %ignore ofVec3f::rescale; 169 | %ignore ofVec3f::rotated; 170 | %ignore ofVec3f::normalized; 171 | %ignore ofVec3f::limited; 172 | %ignore ofVec3f::crossed; 173 | %ignore ofVec3f::perpendiculared; 174 | %ignore ofVec3f::mapped; 175 | %ignore ofVec3f::distanceSquared; 176 | %ignore ofVec3f::interpolated; 177 | %ignore ofVec3f::middled; 178 | %ignore ofVec3f::rotated; 179 | 180 | // ----- ofVec4f.h ----- 181 | 182 | %ignore ofVec4f::rescaled; 183 | %ignore ofVec4f::rescale; 184 | %ignore ofVec4f::normalized; 185 | %ignore ofVec4f::limited; 186 | %ignore ofVec4f::distanceSquared; 187 | %ignore ofVec4f::interpolated; 188 | %ignore ofVec4f::middled; 189 | 190 | // ----- ofFileUtils.h ----- 191 | 192 | %ignore ofBuffer::getBinaryBuffer; 193 | %ignore ofBuffer::getBinaryBuffer const; 194 | %ignore ofBuffer::getNextLine; 195 | %ignore ofBuffer::getFirstLine; 196 | %ignore ofBuffer::isLastLine; 197 | %ignore ofBuffer::resetLineReader; 198 | %ignore ofFilePath::getFileName(const of::filesystem::path &, bool); 199 | %ignore ofFile::setReadOnly; 200 | %ignore ofDirectory::setReadOnly; 201 | %ignore ofDirectory::numFiles; 202 | 203 | // ----- ofUtils.h ----- 204 | 205 | %ignore ofGetSystemTime; 206 | %ignore ofAppendUTF8; 207 | 208 | // ----- ofVideoGrabber.h ----- 209 | 210 | %ignore ofVideoGrabber::initGrabber; 211 | %ignore ofVideoGrabber::getPixelsRef; 212 | %ignore ofVideoGrabber::getTextureReference; 213 | 214 | // ----- ofVideoPlayer.h ----- 215 | 216 | %ignore ofVideoPlayer::loadMovie; 217 | %ignore ofVideoPlayer::getPixelsRef; 218 | %ignore ofVideoPlayer::getTextureReference; 219 | -------------------------------------------------------------------------------- /openFrameworks/lang/lua/lua.i: -------------------------------------------------------------------------------- 1 | // Lua specific settings 2 | // 2017 Dan Wilcox 3 | 4 | %include "of_filesystem_path.i" 5 | 6 | // ----- typemaps ----- 7 | 8 | // convert lua string to unsigned char buffer, 9 | // args from lang in to C++ function 10 | %typemap(in) (unsigned char *STRING, int LENGTH) { 11 | $2 = (int)lua_tonumber(L, $input+1); 12 | $1 = (unsigned char *)lua_tolstring(L, $input, (size_t *)&$2); 13 | } 14 | 15 | // convert lua string to char buffer, 16 | // args from lang in to C++ function 17 | %typemap(in) (char *STRING, size_t LENGTH) { 18 | $2 = (size_t)lua_tonumber(L, $input+1); 19 | $1 = (char *)lua_tolstring(L, $input, &$2); 20 | } 21 | 22 | // convert char buffer to lua string, 23 | // arg returned from C++ function out to lang 24 | %typemap(out) (const char *BUFFER) { 25 | lua_pushlstring(L, $1, arg1->size()); 26 | SWIG_arg++; 27 | } 28 | 29 | // ----- begin/end keyword renames ----- 30 | 31 | // ignore these to silence Warning 314 32 | %ignore ofBaseMaterial::begin; 33 | %ignore ofBaseMaterial::end; 34 | 35 | // ignore these to silence Warning 314 36 | %ignore ofBaseGLRenderer::begin; 37 | %ignore ofBaseGLRenderer::end; 38 | 39 | // DIFF: ofFbo: (Lua) beginFbo() & endFbo() since "end" is a Lua keyword 40 | %rename(beginFbo) ofFbo::begin; 41 | %rename(endFbo) ofFbo::end; 42 | 43 | // DIFF: ofCamera.h: (Lua) beginCamera() & endCamera() since "end" is a Lua keyword 44 | %rename(beginCamera) ofCamera::begin; 45 | %rename(endCamera) ofCamera::end; 46 | 47 | // DIFF: ofMaterial: (Lua) beginMaterial() & endMaterial() since "end" is a Lua keyword 48 | %rename(beginMaterial) ofMaterial::begin; 49 | %rename(endMaterial) ofMaterial::end; 50 | 51 | // DIFF: ofShader: (Lua) beginShader() & endShader() since "end" is a Lua keyword 52 | %rename(beginShader) ofShader::begin; 53 | %rename(endShader) ofShader::end; 54 | 55 | // ignore end keywords, even though they are within nested classes which are 56 | // effectively ignored by SWIG 57 | %ignore ofPixels_::Line::end; 58 | %ignore ofPixels_::Lines::end; 59 | %ignore ofPixels_::ConstPixels::end; 60 | %ignore ofPixels_::ConstLine::end; 61 | %ignore ofPixels_::ConstLines::end; 62 | %ignore ofPixels_::Pixels::end; 63 | 64 | %ignore ofUnicode::range::end; 65 | 66 | %ignore ofBuffer::Lines::end; 67 | %ignore ofBuffer::RLines::end; 68 | 69 | %ignore ofUTF8Iterator::end; 70 | 71 | // ----- other ----- 72 | 73 | // DIFF: ofFbo: (Lua) ofFboMode | operator renamed to of.FboModeOr(m1, m2) 74 | // DIFF: ofFbo: (Lua) ofFboMode & operator renamed to of.FboModeAnd(m1, m2) 75 | %rename(FboModeOr) operator | (ofFboMode, ofFboMode); 76 | %rename(FboModeAnd) operator & (ofFboMode, ofFboMode); 77 | 78 | // DIFF: ofTrueTypeFont.h: (LUA) string static const strings 79 | %rename(TTF_SANS) OF_TTF_SANS; 80 | %rename(TTF_SERIF) OF_TTF_SERIF; 81 | %rename(TTF_MONO) OF_TTF_MONO; 82 | -------------------------------------------------------------------------------- /openFrameworks/lang/lua/lua_code.i: -------------------------------------------------------------------------------- 1 | // Lua specific code 2 | // 2017 Dan Wilcox 3 | 4 | // ----- luacode ----- 5 | 6 | // support for simple classes from http://lua-users.org/wiki/SimpleLuaClasses 7 | // 8 | // example usage: 9 | // 10 | // -- class declaration 11 | // MyClass = class() 12 | // 13 | // -- constructor & attributes 14 | // function MyClass:__init(x, y) 15 | // self.x = x 16 | // self.y = y 17 | // self.bBeingDragged = false 18 | // self.bOver = false 19 | // self.radius = 4 20 | // end 21 | // 22 | // -- create instance & access attribute 23 | // myclass = MyClass(10, 10) 24 | // myclass.x = 100 25 | 26 | %luacode %{ 27 | 28 | -- this isn't wrapped correctly, so set it here 29 | of.CLOSE = true 30 | 31 | -- handle typedefs which swig doesn't wrap 32 | of.Point = of.Vec3f 33 | 34 | -- class.lua 35 | -- Compatible with Lua 5.1 (not 5.0). 36 | function class(base, __init) 37 | local c = {} -- a new class instance 38 | if not __init and type(base) == 'function' then 39 | __init = base 40 | base = nil 41 | elseif type(base) == 'table' then 42 | -- our new class is a shallow copy of the base class! 43 | for i,v in pairs(base) do 44 | c[i] = v 45 | end 46 | c._base = base 47 | end 48 | -- the class will be the metatable for all its objects, 49 | -- and they will look up their methods in it. 50 | c.__index = c 51 | 52 | -- expose a constructor which can be called by () 53 | local mt = {} 54 | mt.__call = function(class_tbl, ...) 55 | local obj = {} 56 | setmetatable(obj,c) 57 | if class_tbl.__init then 58 | class_tbl.__init(obj,...) 59 | else 60 | -- make sure that any stuff from the base class is initialized! 61 | if base and base.__init then 62 | base.__init(obj, ...) 63 | end 64 | end 65 | return obj 66 | end 67 | c.__init = __init 68 | c.is_a = function(self, klass) 69 | local m = getmetatable(self) 70 | while m do 71 | if m == klass then return true end 72 | m = m._base 73 | end 74 | return false 75 | end 76 | setmetatable(c, mt) 77 | return c 78 | end 79 | 80 | %} 81 | -------------------------------------------------------------------------------- /openFrameworks/lang/lua/of_filesystem_path.i: -------------------------------------------------------------------------------- 1 | // of::filesystem::path wrapper to convert to Lua strings automatically 2 | // adapted from SWIG Lib/lua/std_string.i 3 | // 2017,2023 Dan Wilcox 4 | 5 | // dummy declarations as oF 0.12+ aliases of::filesystem from boost::filesystem, 6 | // std::filesystem, or std::experimental::filesystem or SWIG throws an unknown 7 | // type error when it gets to ofConstants.h 8 | namespace std { 9 | namespace filesystem {} 10 | } 11 | namespace std { 12 | namespace experimental { 13 | namespace filesystem {} 14 | } 15 | } 16 | namespace boost { 17 | namespace filesystem {} 18 | } 19 | 20 | // of::filesystem::path type alias set in ofConstants.h 21 | %{ 22 | #include "ofConstants.h" 23 | %} 24 | 25 | namespace of { 26 | namespace filesystem { 27 | 28 | %naturalvar path; 29 | 30 | // Lua strings and std::string can contain embedded zero bytes 31 | // Therefore a standard out typemap should not be: 32 | // lua_pushstring(L, $1.c_str()); 33 | // but 34 | // lua_pushlstring(L, $1.data(), $1.size()); 35 | // 36 | // Similarly for getting the string 37 | // $1 = (char*)lua_tostring(L, $input); 38 | // becomes 39 | // size_t len = lua_rawlen(L, $input); 40 | // $1 = lua_tolstring(L, $input, &len); 41 | // 42 | // Not using: lua_tolstring() as this is only found in Lua 5.1 & not 5.0.2 43 | 44 | %typemap(in, checkfn="lua_isstring") path { 45 | size_t len = lua_rawlen(L, $input); 46 | $1 = lua_tolstring(L, $input, &len); 47 | } 48 | 49 | %typemap(out) path { 50 | lua_pushlstring(L, $1.string().data(), $1.string().size()); 51 | SWIG_arg++; 52 | } 53 | 54 | %typemap(in, checkfn="lua_isstring") const path& ($*1_ltype temp) { 55 | size_t len = lua_rawlen(L, $input); 56 | temp = lua_tolstring(L, $input, &len); 57 | $1 = &temp; 58 | } 59 | 60 | %typemap(out) const path& { 61 | lua_pushlstring(L, $1->data(), $1->size()); 62 | SWIG_arg++; 63 | } 64 | 65 | // for throwing of any kind of path, path ref's and path pointers 66 | // we convert all to lua strings 67 | %typemap(throws) path, path&, const path& { 68 | lua_pushlstring(L, $1.data(), $1.size()); 69 | SWIG_fail; 70 | } 71 | 72 | %typemap(throws) path*, const path* { 73 | lua_pushlstring(L, $1->data(), $1->size()); 74 | SWIG_fail; 75 | } 76 | 77 | %typecheck(SWIG_TYPECHECK_STRING) path, const path& { 78 | $1 = lua_isstring(L, $input); 79 | } 80 | 81 | %typemap(in) path &INPUT = const path &; 82 | 83 | %typemap(in, numinputs=0) string &OUTPUT ($*1_ltype temp) { 84 | $1 = &temp; 85 | } 86 | 87 | %typemap(argout) string &OUTPUT { 88 | lua_pushlstring(L, $1->data(), $1->size()); 89 | SWIG_arg++; 90 | } 91 | 92 | %typemap(in) path &INOUT = const path &; 93 | 94 | %typemap(argout) string &INOUT = string &OUTPUT; 95 | 96 | // a really cut down version of the std::filesystem::path class 97 | // this provides basic mapping of lua strings <-> std::filesystem::path 98 | // and little else 99 | class path { 100 | public: 101 | path(); 102 | path(const char*); 103 | string string() const; 104 | // no support for all the other features 105 | // it's probably better to do it in lua 106 | }; 107 | 108 | } // filesystem 109 | } // of 110 | -------------------------------------------------------------------------------- /openFrameworks/lang/python/of_filesystem_path.i: -------------------------------------------------------------------------------- 1 | // of::filesystem::path wrapper to convert to Python strings automatically 2 | // adapted from SWIG Lib/python/std_string.i and Lib/typemaps/std_string.swg 3 | // 2017,2023 Dan Wilcox 4 | 5 | %include 6 | 7 | %fragment(""); 8 | 9 | // note: oF 0.12 wraps std::filesystem or boost::filesystem as of::filesystem 10 | namespace of { 11 | namespace filesystem { 12 | %naturalvar path; 13 | class path; 14 | } // filesystem 15 | } // of 16 | 17 | %typemaps_std_string(of::filesystem::path, char, SWIG_AsCharPtrAndSize, SWIG_FromCharPtrAndSize, %checkcode(STDSTRING)); 18 | -------------------------------------------------------------------------------- /openFrameworks/lang/python/python.i: -------------------------------------------------------------------------------- 1 | // Python specific settings 2 | // 2017 Dan Wilcox 3 | 4 | %include "of_filesystem_path.i" 5 | 6 | // ----- operator overloads ----- 7 | 8 | %rename(__getitem__) *::operator[]; 9 | %rename(__mul__) *::operator*; 10 | %rename(__div__) *::operator/; 11 | %rename(__add__) *::operator+; 12 | %rename(__sub__) *::operator-; 13 | -------------------------------------------------------------------------------- /openFrameworks/lang/python/python_code.i: -------------------------------------------------------------------------------- 1 | // Python specific code 2 | 3 | // ----- pythoncode ----- 4 | 5 | %pythoncode %{ 6 | 7 | # handle typedefs which swig doesn't wrap 8 | ofPoint = ofVec3f 9 | OF_PRIMITIVE_TRIANGLE_STRIP = None 10 | 11 | # renaming log -> ofLog 12 | ofLog = log 13 | del log 14 | 15 | %} -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/3d.i: -------------------------------------------------------------------------------- 1 | // 3d folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofNode.h ----- 5 | 6 | // DIFF: ofNode.h: ignoring const & copy constructor in favor of && constructor 7 | %ignore ofNode::ofNode(ofNode const &); 8 | 9 | // process ofNode first since it's a base class 10 | %include "3d/ofNode.h" 11 | 12 | // ----- of3dUtils.h ----- 13 | 14 | %include "3d/of3dUtils.h" 15 | 16 | // ----- ofCamera.h ----- 17 | 18 | %include "3d/ofCamera.h" 19 | 20 | // ----- ofEasyCam.h ----- 21 | 22 | // DIFF: ofEasyCam.h: ignoring hasInteraction(int, int) in favor of 23 | // DIFF: hasInteraction(TransformType, int, int) 24 | %ignore ofEasyCam::hasInteraction(int, int); 25 | 26 | %include "3d/ofEasyCam.h" 27 | 28 | // ----- ofMesh.h ----- 29 | 30 | // tell SWIG about template vectors 31 | namespace std { 32 | #ifdef OF_SWIG_RENAME 33 | %template(DefaultVertexTypeVector) std::vector; 34 | %template(DefaultNormalTypeVector) std::vector; 35 | %template(DefaultColorTypeVector) std::vector; 36 | %template(DefaultTexCoordTypeVector) std::vector; 37 | %template(MeshFaceVector) std::vector>; 39 | #else 40 | %template(ofDefaultVertexTypeVector) std::vector; 41 | %template(ofDefaultNormalTypeVector) std::vector; 42 | %template(ofDefaultColorTypeVector) std::vector; 43 | %template(ofDefaultTexCoordTypeVector) std::vector; 44 | %template(ofMeshFaceVector) std::vector>; 46 | #endif 47 | } 48 | 49 | // DIFF: ofMesh.h: ignoring pointer functions 50 | %ignore addVertices(const V*, std::size_t); 51 | %ignore getVerticesPointer(); 52 | %ignore addNormals(const N*, std::size_t); 53 | %ignore getNormalsPointer(); 54 | %ignore addColors(const C*, std::size_t); 55 | %ignore getColorsPointer(); 56 | %ignore addTexCoords(const T*, std::size_t); 57 | %ignore getTexCoordsPointer(); 58 | %ignore addIndices(const ofIndexType*, std::size_t); 59 | %ignore getIndexPointer(); 60 | 61 | %include "3d/ofMesh.h" 62 | 63 | // tell SWIG about template classes 64 | %template(Mesh) ofMesh_; 65 | %template(MeshFace) ofMeshFace_; 66 | 67 | // ----- of3dPrimitives.h ----- 68 | 69 | %include "3d/of3dPrimitives.h" 70 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/app.i: -------------------------------------------------------------------------------- 1 | // app folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofWindowSettings.h ----- 5 | 6 | // DIFF: ofWindowSettings.h: 7 | // DIFF: ignoring api-specific window settings classes 8 | %ignore ofGLWindowSettings; 9 | %ignore ofGLESWindowSettings; 10 | 11 | %include "app/ofWindowSettings.h" 12 | 13 | // ----- ofAppRunner.h ----- 14 | 15 | // DIFF: ofAppRunner.h: 16 | // DIFF: ofInit, ofSetupOpenGL, & ofCreateWindow not applicable in target language 17 | %ignore ofInit; 18 | %ignore ofSetupOpenGL; 19 | %ignore ofCreateWindow; 20 | 21 | // DIFF: get/set main loop not applicable to target language 22 | %ignore ofGetMainLoop; 23 | %ignore ofSetMainLoop; 24 | 25 | // DIFF: run app & main loop not applicable to target language 26 | %ignore noopDeleter; 27 | %ignore ofRunApp; 28 | %ignore ofRunMainLoop; 29 | 30 | // DIFF: ofGetAppPtr not applicable in a target language 31 | %ignore ofGetAppPtr; 32 | 33 | // DIFF: ofGetWindowPtr and ofGetCurrentWindow not applicable in a target language 34 | %ignore ofGetWindowPtr; 35 | %ignore ofGetCurrentWindow; 36 | 37 | // DIFF: get/set current renderer not applicable to target language 38 | %ignore ofSetCurrentRenderer; 39 | %ignore ofGetCurrentRenderer; 40 | 41 | // DIFF: ignoring api-specific window objects: display, window, context, surface 42 | %ignore ofGetX11Display; 43 | %ignore ofGetX11Window; 44 | %ignore ofGetGLXContext; 45 | %ignore ofGetEGLDisplay; 46 | %ignore ofGetEGLContext; 47 | %ignore ofGetEGLSurface; 48 | %ignore ofGetNSGLContext; 49 | %ignore ofGetCocoaWindow; 50 | %ignore ofGetWGLContext; 51 | %ignore ofGetWin32Window; 52 | 53 | %include "app/ofAppRunner.h" 54 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/communication.i: -------------------------------------------------------------------------------- 1 | // communication folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofArduino.h ----- 5 | 6 | // DIFF: ofArduino.h: ignoring functions which return list points 7 | %ignore ofArduino::getDigitalHistory(int); 8 | %ignore ofArduino::getAnalogHistory(int); 9 | %ignore ofArduino::getSysExHistory; 10 | %ignore ofArduino::getStringHistory; 11 | 12 | // DIFF: ofArduino.h: pass binary data to I2C as full char strings 13 | %apply(const char *STRING, int LENGTH) {(const char * buffer, int numOfBytes)}; 14 | 15 | // DIFF: ofArduino.h: ignoring sendI2CWriteRequest() overloads in favor of 16 | // DIFF: version which takes bytes as a const char * 17 | %ignore ofArduino::sendI2CWriteRequest(char, unsigned char *, int, int); 18 | %ignore ofArduino::sendI2CWriteRequest(char, char *, int, int); 19 | %ignore ofArduino::sendI2CWriteRequest(char, std::vector, int); 20 | 21 | // ... and again to handle the last argument's default value default causing 22 | // SWIG to create the following function overloads 23 | %ignore ofArduino::sendI2CWriteRequest(char, unsigned char *, int); 24 | %ignore ofArduino::sendI2CWriteRequest(char, char *, int); 25 | %ignore ofArduino::sendI2CWriteRequest(char, std::vector); 26 | 27 | // tell SWIG about supportedPinTypes map 28 | %template(ArduinoSupportedPinTypesMap) std::map; 29 | 30 | %include "communication/ofArduino.h" 31 | 32 | // clear typemap 33 | %clear(const char * buffer, int numOfBytes); 34 | 35 | // ----- ofSerial.h ----- 36 | 37 | // DIFF: ofSerial.h: pass binary data as full char strings 38 | %apply(unsigned char *STRING, int LENGTH) {(unsigned char * buffer, int length)}; 39 | 40 | %include "communication/ofSerial.h" 41 | 42 | // clear typemap 43 | %clear(unsigned char * buffer, int length); 44 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/events.i: -------------------------------------------------------------------------------- 1 | // events folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofEvents.h ----- 5 | 6 | // DIFF: ofEvents.h: 7 | // DIFF: ignore event classes, event args, and registration functions 8 | %ignore ofEventArgs; 9 | %ignore ofEntryEventArgs; 10 | %ignore ofKeyEventArgs; 11 | %ignore ofMouseEventArgs; 12 | // need ofTouchEventArgs for touch callbacks 13 | %ignore ofAudioEventArgs; 14 | %ignore ofResizeEventArgs; 15 | %ignore ofWindowPosEventArgs; 16 | %ignore ofMessage; 17 | 18 | %ignore ofCoreEvents; 19 | 20 | // DIFF: ignore ofSendMessage() with ofMessage in favor of std::string 21 | %ignore ofSendMessage(ofMessage msg); 22 | 23 | %ignore ofEvents; 24 | 25 | %ignore ofRegisterMouseEvents; 26 | %ignore ofRegisterKeyEvents; 27 | %ignore ofRegisterTouchEvents; 28 | %ignore ofRegisterGetMessages; 29 | %ignore ofRegisterDragEvents; 30 | %ignore ofUnregisterMouseEvents; 31 | %ignore ofUnregisterKeyEvents; 32 | %ignore ofUnregisterTouchEvents; 33 | %ignore ofUnregisterGetMessages; 34 | %ignore ofUnregisterDragEvents; 35 | 36 | // replace ofTimeMode with an enum that SWIG doesn't ignore 37 | %inline %{ 38 | enum ofTimeModeEnum : int { 39 | TimeMode_System, 40 | TimeMode_FixedRate, 41 | TimeMode_Filtered 42 | }; 43 | %} 44 | %ignore ofTimeMode; 45 | 46 | %include "events/ofEvents.h" 47 | 48 | // DIFF: added target language tostring wrapper for ofTouchEventArgs::operator << 49 | // TODO: ofTouchEventArgs inheritance from glm::vec2 doesn't create x & y attributes 50 | %extend ofTouchEventArgs { 51 | const char* __str__() { 52 | static char temp[256]; 53 | std::stringstream str; 54 | str << (*self); 55 | std::strcpy(temp, str.str().c_str()); 56 | return &temp[0]; 57 | } 58 | }; 59 | 60 | // manually create attributes since inheriting from 61 | // glm::vec2 doesn't seem to create them 62 | %attributeVar(ofTouchEventArgs, float, x, x, x); 63 | %attributeVar(ofTouchEventArgs, float, y, y, y); 64 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/gl.i: -------------------------------------------------------------------------------- 1 | // gl folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // the following GL define values are pulled from glew.h & converted to base 10: 5 | 6 | // DIFF: defined GL types: 7 | // DIFF: textures: OF_TEXTURE_LUMINANCE, OF_TEXTURE_RGB, & OF_TEXTURE_RGBA 8 | #define OF_TEXTURE_LUMINANCE 6409 // 0x1909 9 | #define OF_TEXTURE_RGB 6407 // 0x1907 10 | #define OF_TEXTURE_RGBA 6408 // 0x1908 11 | 12 | // DIFF: mipmap filter: OF_NEAREST, OF_LINEAR 13 | #define OF_NEAREST 9728 // 0x2600 14 | #define OF_LINEAR 9729 // 0x2601 15 | 16 | // DIFF: shader: OF_FRAGMENT_SHADER, OF_VERTEX_SHADER 17 | #define OF_FRAGMENT_SHADER 35632 // 0x8B30 18 | #define OF_VERTEX_SHADER 35633 // 0x8B31 19 | 20 | // DIFF: texture wrap: OF_CLAMP_TO_EDGE, OF_CLAMP_TO_BORDER, OF_REPEAT, OF_MIRRORED_REPEAT 21 | #define OF_CLAMP_TO_EDGE 33071 // 0x812F 22 | #ifndef TARGET_OPENGLES 23 | #define OF_CLAMP_TO_BORDER 33069 // 0x812D 24 | #endif 25 | #define OF_REPEAT 10497 // 0x2901 26 | #define OF_MIRRORED_REPEAT 33648 // 0x8370 27 | 28 | // ----- ofBufferObject.h ----- 29 | 30 | %include "gl/ofBufferObject.h" 31 | 32 | // ----- ofCubeMap.h ----- 33 | 34 | // DIFF: ofCubeMap.h: 35 | // DIF:: ignoring ofCubeMapSettings struct 36 | %ignore ofCubeMapSettings; 37 | 38 | // DIFF: ignoring Data struct and ofCubeMapsData 39 | %ignore ofCubeMap::Data; 40 | %ignore ofCubeMapsData; 41 | 42 | // ignore shadowed copy constructor 43 | %ignore ofCubeMap::ofCubeMap(ofCubeMap &&); 44 | 45 | %include "gl/ofCubeMap.h" 46 | 47 | // ----- ofFbo.h ----- 48 | 49 | // handled in main.i 50 | 51 | // ----- ofGLUtils.h ----- 52 | 53 | // DIFF: ofGLUtils.h: ignoring ofGetGLRenderer() 54 | %ignore ofGetGLRenderer; 55 | 56 | // manually rename these otherwise the initial G in GL ends up lowercase 57 | #ifdef OF_SWIG_RENAME 58 | %rename(ofGLCheckExtension) GLCheckExtension; 59 | %rename(ofGLSLVersionFromGL) GLSLVersionFromGL; 60 | %rename(ofGLSupportedExtensions) GLSupportedExtensions; 61 | %rename(ofGLSupportsNPOTTextures) GLSupportsNPOTTextures; 62 | #endif 63 | 64 | // ignore extra GL defines 65 | %rename($ignore, regextarget=1) "GL_$"; 66 | 67 | %include "gl/ofGLUtils.h" 68 | 69 | // ----- ofLight.h ----- 70 | 71 | // DIFF: ofLight.h: ignoring nested Data struct and ofLightsData 72 | %ignore ofLight::Data; 73 | %ignore ofLightsData; 74 | 75 | %include "gl/ofLight.h" 76 | 77 | // ----- ofMaterial.h ----- 78 | 79 | // forward declare 80 | %ignore ofBaseMaterial; 81 | class ofBaseMaterial {}; 82 | 83 | // DIFF: ofMaterial.h: ignoring ofMaterial::Data 84 | %ignore ofMaterial::Data; 85 | 86 | %include "gl/ofMaterial.h" 87 | 88 | // ----- ofShader.h ----- 89 | 90 | // DIFF: ofShader.h: 91 | // DIFF: ignoring const & copy constructor in favor of && constructor 92 | %ignore ofShader::ofShader(ofShader const &); 93 | 94 | // DIFF: ignoring ofShaderSettings struct 95 | %ignore ofShaderSettings; 96 | %ignore ofShader::setup(const ofShaderSettings); 97 | 98 | // DIFF: ignoring TransformFeedbackSettings structs 99 | %ignore ofShader::TransformFeedbackSettings; 100 | %ignore ofShader::setup(const ofShader::TransformFeedbackSettings); 101 | 102 | // DIFF: ignoring TransformFeedback range and base structs 103 | %ignore ofShader::TransformFeedbackRangeBinding; 104 | %ignore ofShader::TransformFeedbackBaseBinding; 105 | %ignore ofShader::beginTransformFeedback; 106 | %ignore ofShader::endTransformFeedback; 107 | 108 | // DIFF: ignore defaultAttributes enum 109 | %ignore ofShader::defaultAttributes; 110 | 111 | // DIFF: ignore setUniform*v and setAttribute*v array pointer 112 | // functions until they are wrapped via typemaps, etc 113 | %ignore setUniform1iv; 114 | %ignore setUniform2iv; 115 | %ignore setUniform3iv; 116 | %ignore setUniform4iv; 117 | %ignore setUniform1fv; 118 | %ignore setUniform2fv; 119 | %ignore setUniform3fv; 120 | %ignore setUniform4fv; 121 | %ignore setAttribute1fv; 122 | %ignore setAttribute2fv; 123 | %ignore setAttribute3fv; 124 | %ignore setAttribute4fv; 125 | 126 | %include "gl/ofShader.h" 127 | 128 | // ----- ofShadow.h ----- 129 | 130 | // DIFF: ofShadow.h: ignoring GLData and Data structs and ofShadowsData 131 | %ignore ofShadow::GLData; 132 | %ignore ofShadow::Data; 133 | %ignore ofShadowsData; 134 | 135 | %include "gl/ofShadow.h" 136 | 137 | // ----- ofTexture.h ----- 138 | 139 | // handled in main.i 140 | 141 | // ----- ofVbo.h ----- 142 | 143 | %include "gl/ofVbo.h" 144 | 145 | // ----- ofVboMesh.h ----- 146 | 147 | %include "gl/ofVboMesh.h" 148 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/graphics.i: -------------------------------------------------------------------------------- 1 | // graphics folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofGraphicsBaseTypes.h ----- 5 | 6 | // handled in main.i 7 | 8 | // ----- ofGraphicsConstants.h ----- 9 | 10 | // make sure we use the actual classes 11 | %ignore ofDefaultVertexType; 12 | %ignore ofDefaultNormalType; 13 | %ignore ofDefaultColorType; 14 | %ignore ofDefaultTexCoordType; 15 | 16 | %include "graphics/ofGraphicsConstants.h" 17 | 18 | // ----- ofPixels.h ----- 19 | 20 | // include pixels first as it's used by most other classes 21 | 22 | // DIFF: ofPixels.h: 23 | // DIFF: ignoring const & copy constructor in favor of && constructor 24 | %ignore ofPixels_(const ofPixels_ &); 25 | 26 | // DIFF: ofPixels.h: 27 | // DIFF: fixed ambiguous ofPixels function overloads since enums = int in SWIG 28 | // DIFF: by renaming to allocatePixelFormat, allocateImageType, & setFromPixelsImageType 29 | %rename(allocatePixelFormat) ofPixels_::allocate(size_t, size_t, ofPixelFormat); 30 | %rename(allocateImageType) ofPixels_::allocate(size_t, size_t, ofImageType); 31 | %rename(setFromPixelsImageType) ofPixels_::setFromPixels(unsigned char const *, size_t, size_t, ofImageType); 32 | 33 | %rename(allocatePixelFormat) ofPixels_::allocate(size_t, size_t, ofPixelFormat); 34 | %rename(allocateImageType) ofPixels_::allocate(size_t, size_t, ofImageType); 35 | %rename(setFromPixelsImageType) ofPixels_::setFromPixels(float const *, size_t, size_t, ofImageType); 36 | 37 | %rename(allocatePixelFormat) ofPixels_::allocate(size_t, size_t, ofPixelFormat); 38 | %rename(allocateImageType) ofPixels_::allocate(size_t, size_t, ofImageType); 39 | %rename(setFromPixelsImageType) ofPixels_::setFromPixels(unsigned short const *, size_t, size_t, ofImageType); 40 | 41 | // DIFF: ofPixels.h: 42 | // DIFF: ignore overloaded setFromPixels, setFromExternalPixels, & 43 | // DIFF: setFromAlignedPixels w/ channels argument, 44 | // DIFF: use ofPixelType overloaded functions instead 45 | %ignore ofPixels_::setFromPixels(unsigned char const *, size_t, size_t, size_t); 46 | %ignore ofPixels_::setFromPixels(float const *, size_t, size_t, size_t); 47 | %ignore ofPixels_::setFromPixels(unsigned short const *, size_t, size_t, size_t); 48 | 49 | %ignore ofPixels_::setFromExternalPixels(unsigned char *, size_t, size_t, size_t); 50 | %ignore ofPixels_::setFromExternalPixels(float *, size_t, size_t, size_t); 51 | %ignore ofPixels_::setFromExternalPixels(unsigned short *, size_t, size_t, size_t); 52 | 53 | %ignore ofPixels_::setFromAlignedPixels(const unsigned char *, size_t, size_t, size_t, size_t); 54 | %ignore ofPixels_::setFromAlignedPixels(const float *, size_t, size_t, size_t, size_t); 55 | %ignore ofPixels_::setFromAlignedPixels(const unsigned short *, size_t, size_t, size_t, size_t); 56 | 57 | // DIFF: ofPixels.h: 58 | // DIFF: ignore setFromAlignedPixels with vector arguments 59 | %ignore ofPixels_::setFromAlignedPixels(const unsigned char *, size_t, size_t, ofPixelFormat, std::vector); 60 | %ignore ofPixels_::setFromAlignedPixels(const float *, size_t, size_t, ofPixelFormat, std::vector); 61 | %ignore ofPixels_::setFromAlignedPixels(const unsigned short *, size_t, size_t, ofPixelFormat, std::vector); 62 | 63 | %ignore ofPixels_::setFromAlignedPixels(const unsigned char *, size_t, size_t, ofPixelFormat, std::vector); 64 | %ignore ofPixels_::setFromAlignedPixels(const float *, size_t, size_t, ofPixelFormat, std::vector); 65 | %ignore ofPixels_::setFromAlignedPixels(const unsigned short *, size_t, size_t, ofPixelFormat, std::vector); 66 | 67 | // DIFF: ignoring static functions 68 | %ignore ofPixels_::pixelBitsFromPixelFormat(ofPixelFormat); 69 | %ignore ofPixels_::bytesFromPixelFormat(size_t, size_t, ofPixelFormat); 70 | 71 | // DIFF: ignoring nested structs: Pixel, Line, ConstPixel, & ConstLine 72 | %ignore ofPixels_::ConstPixel; 73 | %ignore ofPixels_::Pixel; 74 | %ignore ofPixels_::Pixels; 75 | %ignore ofPixels_::Line; 76 | %ignore ofPixels_::Lines; 77 | %ignore ofPixels_::ConstPixels; 78 | %ignore ofPixels_::ConstLine; 79 | %ignore ofPixels_::ConstLines; 80 | 81 | // DIFF: ignoring iterators 82 | %ignore ofPixels_::begin; 83 | %ignore ofPixels_::end; 84 | %ignore ofPixels_::end; 85 | %ignore ofPixels_::end; 86 | %ignore ofPixels_::rbegin; 87 | %ignore ofPixels_::rend; 88 | %ignore ofPixels_::begin const; 89 | %ignore ofPixels_::end const; 90 | %ignore ofPixels_::rbegin const; 91 | %ignore ofPixels_::rend const; 92 | %ignore ofPixels_::getLine(size_t); 93 | %ignore ofPixels_::getLines(); 94 | %ignore ofPixels_::getLines(size_t, size_t); 95 | %ignore ofPixels_::getPixelsIter(); 96 | %ignore ofPixels_::getConstLine(size_t) const; 97 | %ignore ofPixels_::getConstLines() const; 98 | %ignore ofPixels_::getConstLines(size_t, size_t) const; 99 | %ignore ofPixels_::getConstPixelsIter() const; 100 | 101 | %include "graphics/ofPixels.h" 102 | 103 | // tell SWIG about template classes 104 | #ifdef OF_SWIG_RENAME 105 | %template(Pixels) ofPixels_; 106 | %template(FloatPixels) ofPixels_; 107 | %template(ShortPixels) ofPixels_; 108 | #else 109 | %template(ofPixels) ofPixels_; 110 | %template(ofFloatPixels) ofPixels_; 111 | %template(ofShortPixels) ofPixels_; 112 | #endif 113 | 114 | // ----- ofPath.h ----- 115 | 116 | // tell SWIG about template vectors 117 | namespace std { 118 | #ifdef OF_SWIG_RENAME 119 | %template(PathVector) std::vector; 120 | #else 121 | %template(ofPathVector) std::vector; 122 | #endif 123 | }; 124 | 125 | // DIFF: ofPath.h: ignoring nested Command struct 126 | %ignore ofPath::Command; 127 | 128 | %include "graphics/ofPath.h" 129 | 130 | // ----- ofPolyline.h ----- 131 | 132 | // tell SWIG about template vectors 133 | namespace std { 134 | #ifdef OF_SWIG_RENAME 135 | %template(PolylineVector) std::vector; 136 | #else 137 | %template(ofPolylineVector) std::vector; 138 | #endif 139 | }; 140 | 141 | // ignored due to default variable overload 142 | %ignore ofPolyline_::arc(float, float, float, float, float, float, float); 143 | %ignore ofPolyline_::arcNegative(float, float, float, float, float, float, float); 144 | 145 | // DIFF: ofPolyline.h: ignoring iterators 146 | %ignore ofPolyline_::begin; 147 | %ignore ofPolyline_::end; 148 | %ignore ofPolyline_::rbegin; 149 | %ignore ofPolyline_::rend; 150 | 151 | %include "graphics/ofPolyline.h" 152 | 153 | // tell SWIG about template classes 154 | #ifdef OF_SWIG_RENAME 155 | %template(Polyline) ofPolyline_; 156 | #else 157 | %template(ofPolyline) ofPolyline_; 158 | #endif 159 | 160 | // ----- ofGraphics.h ----- 161 | 162 | // no PDF or SVG export support on mobile 163 | #if defined(TARGET_IOS) || defined(TARGET_ANDROID) 164 | %ignore ofBeginSaveScreenAsPDF; 165 | %ignore ofEndSaveScreenAsPDF(); 166 | %ignore ofBeginSaveScreenAsSVG; 167 | %ignore ofEndSaveScreenAsSVG(); 168 | #endif 169 | 170 | // DIFF: ofGraphics.h: 171 | // DIFF: ignoring ofDrawBitmapString() template functions in favor of 172 | // DIFF: string versions, target languages can handle the string conversions 173 | %ignore ofDrawBitmapString(const T &, float, float); 174 | %ignore ofDrawBitmapString(const T &, const glm::vec3 &); 175 | %ignore ofDrawBitmapString(const T &, const glm::vec2 &); 176 | %ignore ofDrawBitmapString(const T &, float, float, float); 177 | 178 | // manually define string functions here otherwise they get redefined by SWIG & then ignored 179 | void ofDrawBitmapString(const std::string & textString, float x, float y); 180 | void ofDrawBitmapString(const std::string & textString, const glm::vec3 & p); 181 | void ofDrawBitmapString(const std::string & textString, const glm::vec2 & p); 182 | void ofDrawBitmapString(const std::string & textString, float x, float y, float z); 183 | 184 | %include "graphics/ofGraphics.h" 185 | 186 | // ----- ofGraphicsCairo.h ----- 187 | 188 | %include "graphics/ofGraphicsCairo.h" 189 | 190 | // ----- of3dGraphics.h ----- 191 | 192 | // ignore base classes 193 | %ignore of3dGraphics; 194 | 195 | %include "graphics/of3dGraphics.h" 196 | 197 | // ----- ofImage.h ----- 198 | 199 | // handled in main.i 200 | 201 | // ----- ofTrueTypeFont.h ----- 202 | 203 | // DIFF: ofTrueTypeFont.h: 204 | // ignore internal font structs 205 | %ignore FT_Face; 206 | 207 | // strip "of" from following ofAlphabet enums 208 | #ifdef OF_SWIG_RENAME 209 | %rename("%(regex:/of(Alphabet.*)/\\1/)s", %$isenumitem) ""; 210 | #endif 211 | 212 | // replace std::initializer with an enum that SWIG understands 213 | %inline %{ 214 | enum ofAlphabetEnum : int { 215 | ofAlphabet_Emoji, 216 | ofAlphabet_Japanese, 217 | ofAlphabet_Chinese, 218 | ofAlphabet_Korean, 219 | ofAlphabet_Arabic, 220 | ofAlphabet_Devanagari, 221 | ofAlphabet_Latin, 222 | ofAlphabet_Greek, 223 | ofAlphabet_Cyrillic 224 | }; 225 | %} 226 | %ignore ofAlphabet; 227 | 228 | // ignore ofUnicode::range nested struct warning 229 | %warnfilter(325) ofUnicode::range; 230 | 231 | // DIFF: ignoring ofTrueTypeShutdown() & ofExitCallback() friend 232 | %ignore ofTrueTypeShutdown; 233 | %ignore ofExitCallback; 234 | 235 | // ignore std::initializer 236 | %ignore ofTrueTypeFontSettings::addRanges(std::initializer_list); 237 | 238 | // DIFF: replaced ofAlphabet static instances with ofAlphabet_ enums 239 | %extend ofTrueTypeFontSettings { 240 | void addRanges(ofAlphabetEnum alphabet) { 241 | switch(alphabet) { 242 | case ofAlphabet_Emoji: 243 | $self->addRanges(ofAlphabet::Emoji); 244 | break; 245 | case ofAlphabet_Japanese: 246 | $self->addRanges(ofAlphabet::Japanese); 247 | break; 248 | case ofAlphabet_Chinese: 249 | $self->addRanges(ofAlphabet::Chinese); 250 | break; 251 | case ofAlphabet_Korean: 252 | $self->addRanges(ofAlphabet::Korean); 253 | break; 254 | case ofAlphabet_Arabic: 255 | $self->addRanges(ofAlphabet::Arabic); 256 | break; 257 | case ofAlphabet_Devanagari: 258 | $self->addRanges(ofAlphabet::Devanagari); 259 | break; 260 | case ofAlphabet_Latin: 261 | $self->addRanges(ofAlphabet::Latin); 262 | break; 263 | case ofAlphabet_Greek: 264 | $self->addRanges(ofAlphabet::Greek); 265 | break; 266 | case ofAlphabet_Cyrillic: 267 | $self->addRanges(ofAlphabet::Cyrillic); 268 | break; 269 | default: 270 | break; 271 | } 272 | } 273 | } 274 | 275 | // DIFF: ignoring const & copy constructor in favor of && constructor 276 | %ignore ofTrueTypeFont::ofTrueTypeFont(ofTrueTypeFont const &); 277 | 278 | // DIFF: ignoring protected structs 279 | %ignore ofTrueTypeFont::range; 280 | %ignore ofTrueTypeFont::glyph; 281 | %ignore ofTrueTypeFont::glyphProps; 282 | 283 | // TODO: find a way to release ofRectangle returned by getStringBoundingBox() 284 | 285 | %include "graphics/ofTrueTypeFont.h" 286 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/main.i: -------------------------------------------------------------------------------- 1 | // forward declarations and headers which need to be handled first 2 | // 2017 Dan Wilcox 3 | 4 | // ignore everything in the private namespace 5 | %ignore of::priv; 6 | 7 | // TODO: wrap nested structs and classes? 8 | //%feature ("flatnested"); 9 | 10 | // TODO: make sure returned class instances are freed by using %newobject 11 | 12 | // tell SWIG about template vectors and maps, 13 | // needed for functions and return types 14 | namespace std { 15 | %template(IntVector) std::vector; 16 | %template(FloatVector) std::vector; 17 | %template(StringVector) std::vector; 18 | %template(UCharVector) std::vector; 19 | %template(StringMap) std::map; 20 | %template(IntMap) std::map; 21 | #ifdef OF_SWIG_RENAME 22 | %template(TextureVector) std::vector; 23 | %template(SoundDeviceVector) std::vector; 24 | %template(VideoDeviceVector) std::vector; 25 | #else 26 | %template(ofTextureVector) std::vector; 27 | %template(ofSoundDeviceVector) std::vector; 28 | %template(ofVideoDeviceVector) std::vector; 29 | #endif 30 | }; 31 | 32 | // ----- ofConstants.h ----- 33 | 34 | // GL types used as OF arguments, etc so SWIG needs to know about them 35 | typedef int GLint; 36 | typedef unsigned int GLenum; 37 | typedef unsigned int GLuint; 38 | typedef float GLfloat; 39 | 40 | // this is in tesselator.h but SWIG needs to know about it for ofIndexType 41 | #if defined(TARGET_OPENGLES) 42 | typedef unsigned short TESSindex; 43 | #else 44 | typedef unsigned int TESSindex; 45 | #endif 46 | 47 | // these has no meaning outside of C++ 48 | %ignore OF_USE_LEGACY_VECTOR_MATH; 49 | %ignore OF_HAS_TLS; 50 | %ignore OF_HAS_CPP17; 51 | %ignore OF_USING_STD_FS; 52 | 53 | %include "utils/ofConstants.h" 54 | 55 | // tell SWIG about template vectors 56 | namespace std { 57 | #ifdef OF_SWIG_RENAME 58 | %template(IndexTypeVector) std::vector; 59 | #else 60 | %template(ofIndexTypeVector) std::vector; 61 | #endif 62 | }; 63 | 64 | // ----- ofMathConstants.h ----- 65 | 66 | %ignore ofDefaultVec2; 67 | %ignore ofDefaultVec3; 68 | %ignore ofDefaultVec4; 69 | %ignore ofDefaultTexCoordType; 70 | 71 | // override these as constants since SWIG seems to ignores function calls, 72 | // ie. #define PI glm::pi() 73 | #ifndef PI 74 | #define PI 3.14159265358979323846 75 | #endif 76 | #ifndef TWO_PI 77 | #define TWO_PI 6.28318530717958647692 78 | #endif 79 | #ifndef M_TWO_PI 80 | #define M_TWO_PI 6.28318530717958647692 81 | #endif 82 | #ifndef HALF_PI 83 | #define HALF_PI 1.57079632679489661923 84 | #endif 85 | 86 | // import the glm types 87 | %import(module="glm") "../../glm.i" 88 | 89 | // include early for glm::vec* declarations, 90 | // edit: not quite needed for now as this is handled below... 91 | // ... needed for math constants 92 | %include "math/ofMathConstants.h" 93 | 94 | // ----- ofUtils.h ----- 95 | 96 | // TODO: ignore ofTime std::chrono stuff? 97 | 98 | // DIFF: ofUtils.h: 99 | // DIFF: ignoring ofTime::getAsTimespec() as it's Unix only and low-level 100 | %ignore ofTime::getAsTimespec() const; 101 | 102 | // DIFF: ignoring ofFromString as templating results in too much overloading 103 | %ignore ofFromString; 104 | 105 | // DIFF: variable argument support is painful, safer to ignore 106 | // see http://www.swig.org/Doc2.0/Varargs.html 107 | %ignore ofVAArgsToString; 108 | 109 | // DIFF: ignoring ofUTF8Iterator 110 | %ignore ofUTF8Iterator; 111 | 112 | // manually rename these otherwise the initial U in UTF ends up lowercase 113 | #ifdef OF_SWIG_RENAME 114 | %rename(ofUTF8Append) UTF8Append; 115 | %rename(ofUTF8Insert) UTF8Insert; 116 | %rename(ofUTF8Erase) UTF8Erase; 117 | %rename(ofUTF8Substring) UTF8Substring; 118 | %rename(ofUTF8ToString) UTF8ToString; 119 | %rename(ofUTF8Length) UTF8Length; 120 | #endif 121 | 122 | // strip "OF_" from static const string 123 | #ifdef OF_SWIG_RENAME 124 | %rename(BROWSER_DEFAULT_TARGET) OF_BROWSER_DEFAULT_TARGET; 125 | #endif 126 | 127 | // include early for ofToString template declaration 128 | %include "utils/ofUtils.h" 129 | 130 | // ignore further redefinitions 131 | %ignore ofToString(const T &); 132 | 133 | // ----- ofFbo.h ----- 134 | 135 | // need to forward declare these for ofFbo 136 | %ignore ofBaseDraws; 137 | class ofBaseDraws {}; 138 | 139 | %ignore ofBaseHasTexture; 140 | class ofBaseHasTexture {}; 141 | 142 | %ignore ofBaseHasPixels; 143 | class ofBaseHasPixels {}; 144 | 145 | // DIFF: ignoring const & copy constructor in favor of && constructor 146 | %ignore ofFbo::ofFbo(ofFbo const &); 147 | 148 | // DIFF: setUseTexture & isUsingTexture are "irrelevant", so ignoring 149 | %ignore ofFbo::setUseTexture; 150 | %ignore ofFbo::isUsingTexture; 151 | 152 | // DIFF: ignoring setActiveDrawBufers() due to std::vector 153 | %ignore setActiveDrawBuffers(const vector& i); 154 | 155 | // DIFF: ignoring ofFbo::Settings struct 156 | %ignore ofFbo::Settings; 157 | 158 | %include "gl/ofFbo.h" 159 | 160 | // ----- ofTexture.h ----- 161 | 162 | // DIFF: ofTexture.h: ignoring const & copy constructor in favor of && constructor 163 | %ignore ofTexture::ofTexture(ofTexture const &); 164 | 165 | %include "gl/ofTexture.h" 166 | 167 | // ----- ofImage.h ----- 168 | 169 | // forward declare needed types 170 | %ignore ofBaseImage_; 171 | template class ofBaseImage_ {}; 172 | 173 | // forward declare base template classes 174 | %ignore ofBaseImage; 175 | %ignore ofBaseFloatImage; 176 | %ignore ofBaseShortImage; 177 | #ifdef OF_SWIG_RENAME 178 | %template(BaseImage) ofBaseImage_; 179 | %template(BaseFloatImage) ofBaseImage_; 180 | %template(BaseShortImage) ofBaseImage_; 181 | #else 182 | %template(ofBaseImage) ofBaseImage_; 183 | %template(ofBaseFloatImage) ofBaseImage_; 184 | %template(ofBaseShortImage) ofBaseImage_; 185 | #endif 186 | 187 | // DIFF: ofImage.h: 188 | // DIFF: ignore ofCloseFreeImage() 189 | %ignore ofCloseFreeImage; 190 | 191 | // DIFF: ignoring ofPixels operator 192 | %ignore ofImage_::operator ofPixels_&(); 193 | 194 | // DIFF: ignoring const & copy constructor in favor of && constructor 195 | %ignore ofImage_(const ofImage_&); 196 | 197 | // TODO: find a way to release ofColor instances returned by getColor() 198 | 199 | %include "graphics/ofImage.h" 200 | 201 | // handle template implementations 202 | #ifdef OF_SWIG_RENAME 203 | %template(Image) ofImage_; 204 | %template(FloatImage) ofImage_; 205 | %template(ShortImage) ofImage_; 206 | #else 207 | %template(ofImage) ofImage_; 208 | %template(ofFloatImage) ofImage_; 209 | %template(ofShortImage) ofImage_; 210 | #endif 211 | 212 | // ----- ofGraphicsBaseTypes.h ----- 213 | 214 | // DIFF: ofGraphicsBaseTypes.h: ignore all abstract and base types 215 | %ignore ofAbstractParameter; 216 | %ignore ofBaseDraws; 217 | %ignore ofBaseUpdates; 218 | %ignore ofBaseHasTexture; 219 | %ignore ofBaseHasTexturePlanes; 220 | 221 | %ignore ofAbstractHasPixels; 222 | %ignore ofBaseHasPixels_; 223 | %ignore ofBaseHasPixels; 224 | %ignore ofBaseHasFloatPixels; 225 | %ignore ofBaseHasShortPixels; 226 | 227 | %ignore ofAbstractImage; 228 | %ignore ofBaseImage_; 229 | %ignore ofBaseImage; 230 | %ignore ofBaseFloatImage; 231 | %ignore ofBaseShortImage; 232 | 233 | %ignore ofBaseRenderer; 234 | %ignore ofBaseGLRenderer; 235 | 236 | %ignore ofBaseSerializer; 237 | %ignore ofBaseFileSerializer; 238 | %ignore ofBaseURLFileLoader; 239 | %ignore ofBaseMaterial; 240 | 241 | // include header for derived classes 242 | %include "graphics/ofGraphicsBaseTypes.h" 243 | 244 | // ----- ofSoundBaseTypes.h ----- 245 | 246 | // DIFF: ofSoundBaseTypes.h: ignore all abstract and base types 247 | 248 | %ignore ofBaseSoundInput; 249 | %ignore ofBaseSoundOutput; 250 | 251 | // include header for derived classes 252 | %include "sound/ofSoundBaseTypes.h" 253 | 254 | // ----- ofVideoBaseTypes.h ----- 255 | 256 | // DIFF: ofVideoBaseTypes.h: ignore all abstract and base types 257 | 258 | %ignore ofBaseVideo; 259 | %ignore ofBaseVideoDraws; 260 | %ignore ofBaseVideoGrabber; 261 | %ignore ofBaseVideoPlayer; 262 | 263 | // include header for derived classes 264 | %include "video/ofVideoBaseTypes.h" 265 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/math.i: -------------------------------------------------------------------------------- 1 | // math folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofMath.h ----- 5 | 6 | // DIFF: ofMath.h: ignoring ofMin & ofMax version for differing types 7 | %ignore ofMin(const T &, const Q &); 8 | %ignore ofMax(const T &, const Q &); 9 | 10 | // ignore the template functions 11 | %ignore ofInterpolateCosine; 12 | %ignore ofInterpolateCubic; 13 | %ignore ofInterpolateCatmullRom; 14 | %ignore ofInterpolateHermite; 15 | 16 | // declare float functions 17 | ofInterpolateCosine(float y1, float y2, float pct); 18 | ofInterpolateCubic(float y1, float y2, float pct); 19 | ofInterpolateCatmullRom(float y1, float y2, float pct); 20 | ofInterpolateHermite(float y1, float y2, float pct); 21 | 22 | %include "math/ofMath.h" 23 | 24 | // tell SWIG about template functions 25 | #ifdef OF_SWIG_RENAME 26 | %template(interpolateCosine) ofInterpolateCosine; 27 | %template(interpolateCubic) ofInterpolateCubic; 28 | %template(interpolateCatmullRom) ofInterpolateCatmullRom; 29 | %template(interpolateHermite) ofInterpolateHermite; 30 | #else 31 | %template(ofInterpolateCosine) ofInterpolateCosine; 32 | %template(ofInterpolateCubic) ofInterpolateCubic; 33 | %template(ofInterpolateCatmullRom) ofInterpolateCatmullRom; 34 | %template(ofInterpolateHermite) ofInterpolateHermite; 35 | #endif 36 | 37 | // ----- ofMathConstants.h ----- 38 | 39 | // handled in main.i 40 | 41 | // ----- ofMatrix3x3.h ----- 42 | 43 | // DIFF: ofMatrix3x3.h: renaming glm::mat3 operator to mat3() 44 | %rename(mat3) ofMatrix3x3::operator glm::mat3; 45 | 46 | %include "math/ofMatrix3x3.h" 47 | 48 | %extend ofMatrix3x3 { 49 | const char* __str__() { 50 | static char temp[256]; 51 | std::stringstream str; 52 | str << (*self); 53 | std::strcpy(temp, str.str().c_str()); 54 | return &temp[0]; 55 | } 56 | }; 57 | 58 | // ----- ofMatrix4x4.h ----- 59 | 60 | // DIFF: ofMatrix4x4.h: ignoring operator(size_t, size_t) const overload 61 | %ignore ofMatrix4x4::operator()(std::size_t, std::size_t) const; 62 | 63 | // DIFF: ofMatrix4x4.h: renaming glm::mat4 operator to mat4() 64 | %rename(mat4) ofMatrix4x4::operator glm::mat4; 65 | 66 | %include "math/ofMatrix4x4.h" 67 | 68 | %extend ofMatrix4x4 { 69 | const char* __str__() { 70 | static char temp[256]; 71 | std::stringstream str; 72 | str << (*self); 73 | std::strcpy(temp, str.str().c_str()); 74 | return &temp[0]; 75 | } 76 | }; 77 | 78 | // ----- ofQuaternion.h ----- 79 | 80 | // DIFF: ofQuaternion.h: renaming glm::quat operator to quat() 81 | %rename(quat) ofQuaternion::operator glm::quat; 82 | 83 | // silence warning as SWIG ignores these anyway 84 | // since it uses the non-const versions 85 | %ignore ofQuaternion::x() const; 86 | %ignore ofQuaternion::y() const; 87 | %ignore ofQuaternion::z() const; 88 | %ignore ofQuaternion::w() const; 89 | 90 | %include "math/ofQuaternion.h" 91 | 92 | %extend ofQuaternion { 93 | const char* __str__() { 94 | static char temp[256]; 95 | std::stringstream str; 96 | str << (*self); 97 | std::strcpy(temp, str.str().c_str()); 98 | return &temp[0]; 99 | } 100 | }; 101 | 102 | // ----- ofVec2f.h ----- 103 | 104 | // DIFF: ofVec2f.h: renaming glm::vec2 operator to vec2() 105 | %rename(vec2) ofVec2f::operator glm::vec2; 106 | 107 | %include "math/ofVec2f.h" 108 | 109 | %extend ofVec2f { 110 | const char* __str__() { 111 | static char temp[256]; 112 | std::stringstream str; 113 | str << (*self); 114 | std::strcpy(temp, str.str().c_str()); 115 | return &temp[0]; 116 | } 117 | }; 118 | 119 | // ----- ofVec3f.h ----- 120 | 121 | // DIFF: ofVec3f.h: renaming glm::vec3 operator to vec3() 122 | %rename(vec3) ofVec3f::operator glm::vec3; 123 | 124 | %include "math/ofVec3f.h" 125 | 126 | %extend ofVec3f { 127 | const char* __str__() { 128 | static char temp[256]; 129 | std::stringstream str; 130 | str << (*self); 131 | std::strcpy(temp, str.str().c_str()); 132 | return &temp[0]; 133 | } 134 | }; 135 | 136 | // ----- ofVec4f.h ----- 137 | 138 | // DIFF: ofVec4f.h: renaming glm::vec4 operator to vec4() 139 | %rename(vec4) ofVec4f::operator glm::vec4; 140 | 141 | %include "math/ofVec4f.h" 142 | 143 | %extend ofVec4f { 144 | const char* __str__() { 145 | static char temp[256]; 146 | std::stringstream str; 147 | str << (*self); 148 | std::strcpy(temp, str.str().c_str()); 149 | return &temp[0]; 150 | } 151 | }; 152 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/sound.i: -------------------------------------------------------------------------------- 1 | // sound folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofSoundBaseTypes.h ----- 5 | 6 | // handled in main.i 7 | 8 | // ----- ofSoundStream.h ----- 9 | 10 | // ignore overloaded functions 11 | %ignore ofSoundStream::setInput(ofBaseSoundInput &soundInput); 12 | %ignore ofSoundStream::setOutput(ofBaseSoundOutput &soundOutput); 13 | 14 | %include "sound/ofSoundStream.h" 15 | 16 | // ----- ofSoundPlayer.h ----- 17 | 18 | %ignore ofBaseSoundPlayer; 19 | class ofBaseSoundPlayer {}; 20 | 21 | // DIFF: ofSoundPlayer.h: ignoring global FMOD functions 22 | %ignore ofSoundStopAll; 23 | %ignore ofSoundShutdown; 24 | %ignore ofSoundSetVolume; 25 | %ignore ofSoundUpdate; 26 | %ignore ofSoundGetSpectrum; 27 | 28 | %include "sound/ofSoundPlayer.h" 29 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/types.i: -------------------------------------------------------------------------------- 1 | // types folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofBaseTypes.h ----- 5 | 6 | // handled in main.i 7 | 8 | // ----- ofColor.h ----- 9 | 10 | // DIFF: ofColor.h: 11 | // TODO: find a way to release static named ofColor instances 12 | 13 | // ignore SWIG Warning 312 from nested union that provides r, g, b, & a access 14 | // ignore SWIG Warning 320 from extern template classes (old) 15 | // ignore SWIG Warning 327 from extern templates (new) 16 | #pragma SWIG nowarn=312,320,327 17 | 18 | // DIFF: ignore extra ofColor template types: 19 | // DIFF: char, short, unsigned short, int, unsigned int, long, unsigned long 20 | %ignore ofColor_; 21 | %ignore ofColor_; 22 | %ignore ofColor_; 23 | %ignore ofColor_; 24 | %ignore ofColor_; 25 | %ignore ofColor_; 26 | %ignore ofColor_; 27 | 28 | %include "types/ofColor.h" 29 | 30 | // reenable 31 | #pragma SWIG nowarn= 32 | 33 | // DIFF: added ofColor_ pixel channel getters getR(), getG(), getB(), getA() 34 | // DIFF: added ofColor_ pixel channel setters setR(), setG(), setB(), setA() 35 | // DIFF: added target language tostring wrapper for ofColor_::operator << 36 | %extend ofColor_ { 37 | 38 | // pixel channel getters 39 | PixelType getR() {return $self->r;} 40 | PixelType getG() {return $self->g;} 41 | PixelType getB() {return $self->b;} 42 | PixelType getA() {return $self->a;} 43 | 44 | // pixel channel setters 45 | void setR(PixelType r) {$self->r = r;} 46 | void setG(PixelType g) {$self->g = g;} 47 | void setB(PixelType b) {$self->b = b;} 48 | void setA(PixelType a) {$self->a = a;} 49 | 50 | const char* __str__() { 51 | static char temp[256]; 52 | std::stringstream str; 53 | str << (*self); 54 | std::strcpy(temp, str.str().c_str()); 55 | return &temp[0]; 56 | } 57 | }; 58 | 59 | %attributeVar(ofColor_, unsigned char, r, r, r); 60 | %attributeVar(ofColor_, unsigned char, g, g, g); 61 | %attributeVar(ofColor_, unsigned char, b, b, b); 62 | %attributeVar(ofColor_, unsigned char, a, a, a); 63 | 64 | %attributeVar(ofColor_, float, r, r, r); 65 | %attributeVar(ofColor_, float, g, g, g); 66 | %attributeVar(ofColor_, float, b, b, b); 67 | %attributeVar(ofColor_, float, a, a, a); 68 | 69 | %attributeVar(ofColor_, unsigned short, r, r, r); 70 | %attributeVar(ofColor_, unsigned short, g, g, g); 71 | %attributeVar(ofColor_, unsigned short, b, b, b); 72 | %attributeVar(ofColor_, unsigned short, a, a, a); 73 | 74 | %attributeVar(ofColor_, double, r, r, r); 75 | %attributeVar(ofColor_, double, g, g, g); 76 | %attributeVar(ofColor_, double, b, b, b); 77 | %attributeVar(ofColor_, double, a, a, a); 78 | 79 | // tell SWIG about template classes 80 | #ifdef OF_SWIG_RENAME 81 | %template(Color) ofColor_; 82 | %template(FloatColor) ofColor_; 83 | %template(ShortColor) ofColor_; 84 | %template(DoubleColor) ofColor_; 85 | #else 86 | %template(ofColor) ofColor_; 87 | %template(ofFloatColor) ofColor_; 88 | %template(ofShortColor) ofColor_; 89 | %template(ofDoubleColor) ofColor_; 90 | #endif 91 | 92 | // ----- ofPoint.h ----- 93 | 94 | // NOTE: ofPoint is just a typedef which swig cannot wrap, so the types need to 95 | // be handled in the scripting language, see the Lua, Python, etc code in lang.i 96 | %include "types/ofPoint.h" 97 | 98 | // ----- ofRectangle.h ----- 99 | 100 | // DIFF: ofRectangle.h: 101 | // DIFF: renamed functions due to ambiguous overloading: 102 | // DIFF: scaleToScaleMode() & scaleToAspectRatio() 103 | %rename(scaleToScaleMode) ofRectangle::scaleTo(ofRectangle const &, ofScaleMode); 104 | %rename(scaleToAspectRatio) ofRectangle::scaleTo(ofRectangle const &, ofAspectRatioMode); 105 | 106 | // TODO: find a way to release returned ofRectangle instances 107 | 108 | // ignore SWIG Warning 302 due to manual override of x & y attributes 109 | %warnfilter(302) ofRectangle::x; 110 | %warnfilter(302) ofRectangle::y; 111 | 112 | %extend ofRectangle { 113 | 114 | // override these since they are float references in the orig file and we 115 | // want to access them as floats 116 | float x; 117 | float y; 118 | 119 | const char* __str__() { 120 | static char temp[256]; 121 | std::stringstream str; 122 | str << (*self); 123 | std::strcpy(temp, str.str().c_str()); 124 | return &temp[0]; 125 | } 126 | }; 127 | 128 | %include "types/ofRectangle.h" 129 | 130 | // SWIG converts the x & y float& types into pointers, 131 | // so specify x & y as attributes using the get & set functions 132 | %attribute(ofRectangle, float, x, getX, setX); 133 | %attribute(ofRectangle, float, y, getY, setY); 134 | 135 | // ----- ofTypes.h ----- 136 | 137 | // DIFF: ofTypes.h: 138 | // DIFF: ignoring video format and video device classes 139 | %ignore ofVideoFormat; 140 | %ignore ofVideoDevice; 141 | 142 | // DIFF: mutex, scoped lock, & ptr are probably too low level 143 | %ignore ofMutex; 144 | %ignore ofScopedLock; 145 | %ignore ofPtr; 146 | 147 | %include "types/ofTypes.h" 148 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/utils.i: -------------------------------------------------------------------------------- 1 | // utils folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofFpsCounter.h ----- 5 | 6 | %include "utils/ofFpsCounter.h" 7 | 8 | // ----- ofXml.h ----- 9 | 10 | // DIFF: ofXml.h: ignoring find() as it returns a pugi::xpath_node_set 11 | %ignore ofXml::find; 12 | 13 | // DIFF: ofXml.h: ignoring iterators and nested structs 14 | %ignore ofXmlIterator; 15 | %ignore ofXmlSearchIterator; 16 | %ignore ofXmlAttributeIterator; 17 | %ignore ofXml::Search; 18 | %ignore ofXml::Attribute; 19 | %ignore ofXml::Range; 20 | %ignore ofXml::Search::end; 21 | %ignore ofXml::Range::end; 22 | 23 | // DIFF: ofXml.h: ignore removeAttribute(&&) 24 | %ignore ofXml::removeAttribute(Attribute &&); 25 | 26 | // DIFF: ofXml.h: ignoring bool operator 27 | %ignore ofXml::operator bool; 28 | 29 | // DIFF: ofXml.h: ignoring ofSerialize & ofDeserialize 30 | %ignore ofSerialize; 31 | %ignore ofDeserialize; 32 | 33 | %include "utils/ofXml.h" 34 | 35 | // ----- ofMatrixStack.h ----- 36 | 37 | %include "utils/ofMatrixStack.h" 38 | 39 | // ----- ofConstants.h ----- 40 | 41 | // handled in main.i 42 | 43 | // ----- ofFileUtils.h ----- 44 | 45 | // forward declare fstream for ofFile 46 | %ignore std::fstream; 47 | class std::fstream {}; 48 | 49 | // DIFF: ofFileUtils.h: 50 | // DIFF: ignoring iterators 51 | %ignore ofBuffer::begin; 52 | %ignore ofBuffer::end; 53 | %ignore ofBuffer::rbegin; 54 | %ignore ofBuffer::rend; 55 | %ignore ofDirectory::begin; 56 | %ignore ofDirectory::end; 57 | %ignore ofDirectory::rbegin; 58 | %ignore ofDirectory::rend; 59 | 60 | // DIFF: ignoring ofBuffer istream & ostream functions 61 | %ignore ofBuffer::ofBuffer(std::istream &); 62 | %ignore ofBuffer::ofBuffer(std::istream &, size_t); 63 | %ignore ofBuffer::set(std::istream &); 64 | %ignore ofBuffer::set(std::istream &, size_t); 65 | %ignore ofBuffer::writeTo(std::ostream &) const; 66 | 67 | %ignore ofBuffer::ofBuffer(const std::string &); 68 | %ignore ofBuffer::set(const std::string &); 69 | %ignore ofBuffer::append(const std::string&); 70 | 71 | // ignore char* getData() in preference to const char* getData() whose return 72 | // type is overriden below 73 | %ignore ofBuffer::getData(); 74 | 75 | // DIFF: pass binary data to ofBuffer as full char strings 76 | // pass binary data & byte length as a single argument for ofBuffer 77 | %apply(char *STRING, size_t LENGTH) {(const char * buffer, std::size_t size)}; 78 | 79 | // DIFF: ignoring nested ofBuffer Line & Lines structs 80 | %ignore ofBuffer::Line; 81 | %ignore ofBuffer::Lines; 82 | %ignore ofBuffer::getLines(); 83 | 84 | // DIFF: ignoring nested ofBuffer RLine & RLines structs 85 | %ignore ofBuffer::RLine; 86 | %ignore ofBuffer::RLines; 87 | %ignore ofBuffer::getReverseLines(); 88 | 89 | // DIFF: ignoring string, filebuf, & of::filesystem::path operators 90 | %ignore ofBuffer::operator std::string() const; 91 | %ignore ofFile::getFileBuffer() const; 92 | %ignore ofFile::operator of::filesystem::path(); 93 | %ignore ofFile::operator of::filesystem::path() const; 94 | %ignore ofDirectory::operator of::filesystem::path(); 95 | %ignore ofDirectory::operator of::filesystem::path() const; 96 | 97 | // DIFF: ignoring OF 0.12.1 FS-related functions 98 | %ignore ofGetPathForDirectoryFS; 99 | %ignore ofGetAbsolutePathFS; 100 | %ignore getPathForDirectoryFS; 101 | %ignore getAbsolutePathFS; 102 | %ignore getCurrentExePathFS; 103 | %ignore getCurrentExeDirFS; 104 | %ignore pathFS; 105 | %ignore ofToDataPathFS; 106 | 107 | // DIFF: ignoring OF 0.12.1 internal helpers: 108 | // DIFF: ofPathToString() & ofGetExtensionLower() 109 | %ignore ofPathToString; 110 | %ignore ofGetExtensionLower; 111 | 112 | %include "utils/ofFileUtils.h" 113 | 114 | // clear typemaps 115 | %clear(const char *buffer, std::size_t size); 116 | %clear(const char *_buffer, std::size_t _size); 117 | 118 | // ----- ofLog.h ----- 119 | 120 | // function wrapper for ofLog class 121 | %inline %{ 122 | void log(ofLogLevel level, const std::string & message) { 123 | ofLog(level, message); 124 | } 125 | %} 126 | 127 | // DIFF: ofLog.h: 128 | // DIFF: ignore stream-based log classes since target languages won't support it 129 | %ignore ofLog; 130 | %ignore ofLogVerbose; 131 | %ignore ofLogNotice; 132 | %ignore ofLogWarning; 133 | %ignore ofLogError; 134 | %ignore ofLogFatalError; 135 | 136 | // DIFF: ignore logger channel classes 137 | %ignore ofBaseLoggerChannel; 138 | %ignore ofSetLoggerChannel; 139 | %ignore ofConsoleLoggerChannel; 140 | %ignore ofFileLoggerChannel; 141 | 142 | %include "utils/ofLog.h" 143 | 144 | // ----- ofSystemUtils.h ----- 145 | 146 | %include "utils/ofSystemUtils.h" 147 | 148 | // ----- ofURLFileLoader.h ----- 149 | 150 | // DIFF: ofURLFileLoader.h: ignoring ofHttpResponse ofBuffer operator 151 | %ignore ofHttpResponse::operator ofBuffer&(); 152 | 153 | // DIFF: ofURLFileLoader.h: ignoring ofURLResponseEvent() 154 | %ignore ofURLResponseEvent(); 155 | 156 | %include "utils/ofURLFileLoader.h" 157 | 158 | // ----- ofUtils.h ----- 159 | 160 | // handled in main.i 161 | -------------------------------------------------------------------------------- /openFrameworks/openFrameworks/video.i: -------------------------------------------------------------------------------- 1 | // video folder bindings 2 | // 2017 Dan Wilcox 3 | 4 | // ----- ofVideoBaseTypes.h ----- 5 | 6 | // handled in main.i 7 | 8 | // ----- ofVideoGrabber.h ----- 9 | 10 | // DIFF: ofVideoGrabber.h: ignore getGrabber/setGrabber 11 | %ignore setGrabber(shared_ptr); 12 | %ignore getGrabber(); 13 | %ignore getGrabber() const; 14 | 15 | %include "video/ofVideoGrabber.h" 16 | 17 | // ----- ofVideoPlayer.h ----- 18 | 19 | // DIFF: ofVideoPlayer.h: ignore getPlayer/setPlayer 20 | %ignore setPlayer(shared_ptr); 21 | %ignore getPlayer(); 22 | %ignore getPlayer() const; 23 | 24 | %include "video/ofVideoPlayer.h" 25 | --------------------------------------------------------------------------------