aboutsummaryrefslogtreecommitdiff
path: root/externals/gridflow/bundled
diff options
context:
space:
mode:
authorN.N. <matju@users.sourceforge.net>2008-07-08 05:56:10 +0000
committerN.N. <matju@users.sourceforge.net>2008-07-08 05:56:10 +0000
commit089475041fe26964d72cb2ebc3559a36ba89a2f2 (patch)
tree4ea7537e82b2ee34748ef7cbfc18c523425d4f7a /externals/gridflow/bundled
parentd1ad56f1da41e7a88eb9a52d6b0daaf145b54ea7 (diff)
trying to import gridflow 0.9.4
svn path=/trunk/; revision=10148
Diffstat (limited to 'externals/gridflow/bundled')
-rw-r--r--externals/gridflow/bundled/Base/CPPExtern.h521
-rw-r--r--externals/gridflow/bundled/Base/GemBase.h133
-rw-r--r--externals/gridflow/bundled/Base/GemCache.h69
-rw-r--r--externals/gridflow/bundled/Base/GemEvent.h156
-rw-r--r--externals/gridflow/bundled/Base/GemExportDef.h40
-rw-r--r--externals/gridflow/bundled/Base/GemFuncUtil.h362
-rw-r--r--externals/gridflow/bundled/Base/GemGL.h72
-rw-r--r--externals/gridflow/bundled/Base/GemGLUtil.h29
-rw-r--r--externals/gridflow/bundled/Base/GemGluObj.h96
-rw-r--r--externals/gridflow/bundled/Base/GemLoadObj.h28
-rw-r--r--externals/gridflow/bundled/Base/GemMan.h257
-rw-r--r--externals/gridflow/bundled/Base/GemMath.h89
-rw-r--r--externals/gridflow/bundled/Base/GemModelData.h42
-rw-r--r--externals/gridflow/bundled/Base/GemPBuffer.h51
-rw-r--r--externals/gridflow/bundled/Base/GemPathBase.h74
-rw-r--r--externals/gridflow/bundled/Base/GemPixConvert.h160
-rw-r--r--externals/gridflow/bundled/Base/GemPixDualObj.h190
-rw-r--r--externals/gridflow/bundled/Base/GemPixImageLoad.h37
-rw-r--r--externals/gridflow/bundled/Base/GemPixImageSave.h38
-rw-r--r--externals/gridflow/bundled/Base/GemPixObj.h142
-rw-r--r--externals/gridflow/bundled/Base/GemPixPete.h219
-rw-r--r--externals/gridflow/bundled/Base/GemPixUtil.h284
-rw-r--r--externals/gridflow/bundled/Base/GemSIMD.h111
-rw-r--r--externals/gridflow/bundled/Base/GemShape.h115
-rw-r--r--externals/gridflow/bundled/Base/GemState.h150
-rw-r--r--externals/gridflow/bundled/Base/GemVector.h77
-rw-r--r--externals/gridflow/bundled/Base/GemVersion.h30
-rw-r--r--externals/gridflow/bundled/Base/GemVertex.h37
-rw-r--r--externals/gridflow/bundled/Base/GemWinCreate.h224
-rw-r--r--externals/gridflow/bundled/Base/config.h65
-rw-r--r--externals/gridflow/bundled/Base/configLinux.h40
-rw-r--r--externals/gridflow/bundled/g_canvas.h645
32 files changed, 4583 insertions, 0 deletions
diff --git a/externals/gridflow/bundled/Base/CPPExtern.h b/externals/gridflow/bundled/Base/CPPExtern.h
new file mode 100644
index 00000000..7f0630dd
--- /dev/null
+++ b/externals/gridflow/bundled/Base/CPPExtern.h
@@ -0,0 +1,521 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ The base class for all externs written in C++
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_CPPEXTERN_H_
+#define INCLUDE_CPPEXTERN_H_
+
+//#include "Base/config.h"
+#include "Base/GemExportDef.h"
+
+#include "m_pd.h"
+//#include "Base/GemVersion.h"
+
+#include <new>
+
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ GemException
+
+ an exception class...
+
+DESCRIPTION
+
+ this is a class, we can throw on creation,
+ to make sure that the pd-object can not be created
+
+
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN GemException
+{
+ public:
+ GemException() throw();
+ GemException(const char*error) throw();
+ virtual ~GemException() throw();
+
+ virtual const char *what() const throw();
+ virtual void report() const throw();
+ private:
+ const char*ErrorString;
+};
+
+class CPPExtern;
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ Obj_header
+
+ The obligatory object header
+
+DESCRIPTION
+
+ This is in a separate struct to assure that when PD uses the
+ class, the t_object is the very first thing. If it were the
+ first thing in CPPExtern, then there could be problems with
+ the vtable.
+
+-----------------------------------------------------------------*/
+struct GEM_EXTERN Obj_header
+{
+ //////////
+ // The obligatory object header
+ t_object pd_obj;
+
+ //////////
+ // Our data structure
+ CPPExtern *data;
+};
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ CPPExtern
+
+ The base class for all externs written in C++
+
+DESCRIPTION
+
+ Each extern which is written in C++ needs to use the #defines at the
+ end of this header file. Currently, the operator new(size_t) and
+ operator delete(void *) are not overridden. This will be a problem
+ when PD expects everything to fit in its memory space and control
+ all memory allocation.
+
+ The define
+
+ CPPEXTERN_HEADER(NEW_CLASS, PARENT_CLASS)
+
+ should be somewhere in your header file.
+ One of the defines like
+
+ CPPEXTERN_NEW(NEW_CLASS)
+ CPPEXTERN_NEW_WITH_TWO_ARGS(NEW_CLASS, t_floatarg, A_FLOAT, t_floatarg, A_FLOAT)
+
+ should be the first thing in your implementation file.
+ NEW_CLASS is the name of your class and PARENT_CLASS is the
+ parent of your class.
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN CPPExtern
+{
+ public:
+
+ //////////
+ // Constructor
+ CPPExtern();
+
+ //////////
+ // The Pd header
+ t_object *x_obj;
+
+ //////////
+ // Destructor
+ virtual ~CPPExtern() = 0;
+
+ //////////
+ // Get the object's canvas
+ t_canvas *getCanvas() { return(m_canvas); }
+
+ //////////
+ // This is a holder - don't touch it
+ static t_object *m_holder;
+
+ //////////
+ // my name
+ static char *m_holdname;
+ t_symbol *m_objectname;
+
+ protected:
+
+ //////////
+ // Creation callback
+ static void real_obj_setupCallback(t_class *) {}
+
+ private:
+
+ //////////
+ // The canvas that the object is in
+ t_canvas *m_canvas;
+
+ public:
+ // these call pd's print-functions, and eventually prepend the object's name
+ void post(const char*format, ...);
+ void verbose(const int level, const char*format, ...);
+ void error(const char*format, ...); /* internally uses pd_error() */
+
+ private:
+ static bool checkGemVersion(int major, int minor);
+};
+
+// This has a dummy arg so that NT won't complain
+GEM_EXTERN void *operator new(size_t, void *location, void *dummy);
+
+////////////////////////////////////////
+// This should be used in the header
+////////////////////////////////////////
+
+#define CPPEXTERN_HEADER(NEW_CLASS, PARENT_CLASS) \
+public: \
+static void obj_freeCallback(void *data) \
+{ CPPExtern *mydata = ((Obj_header *)data)->data; delete mydata; \
+ ((Obj_header *)data)->Obj_header::~Obj_header(); } \
+static void real_obj_setupCallback(t_class *classPtr) \
+{ PARENT_CLASS::real_obj_setupCallback(classPtr); \
+ NEW_CLASS::obj_setupCallback(classPtr); } \
+private: \
+static inline NEW_CLASS *GetMyClass(void *data) {return((NEW_CLASS *)((Obj_header *)data)->data);} \
+static void obj_setupCallback(t_class *classPtr);
+
+
+////////////////////////////////////////
+// This should be the first thing in the implementation file
+////////////////////////////////////////
+
+//
+// NO ARGUMENTS
+/////////////////////////////////////////////////
+#define CPPEXTERN_NEW(NEW_CLASS) \
+ REAL_NEW(NEW_CLASS)
+//
+// ONE ARGUMENT
+/////////////////////////////////////////////////
+#define CPPEXTERN_NEW_WITH_ONE_ARG(NEW_CLASS, TYPE, PD_TYPE) \
+ REAL_NEW_WITH_ARG(NEW_CLASS, TYPE, PD_TYPE)
+//
+// GIMME ARGUMENT
+/////////////////////////////////////////////////
+#define CPPEXTERN_NEW_WITH_GIMME(NEW_CLASS) \
+ REAL_NEW_WITH_GIMME(NEW_CLASS)
+//
+// TWO ARGUMENTS
+/////////////////////////////////////////////////
+#define CPPEXTERN_NEW_WITH_TWO_ARGS(NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO) \
+ REAL_NEW_WITH_ARG_ARG(NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO)
+//
+// THREE ARGUMENTS
+/////////////////////////////////////////////////
+#define CPPEXTERN_NEW_WITH_THREE_ARGS(NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE) \
+ REAL_NEW_WITH_ARG_ARG_ARG(NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE)
+//
+// FOUR ARGUMENTS
+/////////////////////////////////////////////////
+#define CPPEXTERN_NEW_WITH_FOUR_ARGS(NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE, TFOUR, PD_FOUR) \
+ REAL_NEW_WITH_ARG_ARG_ARG_ARG(NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE, TFOUR, PD_FOUR)
+//
+// FIVE ARGUMENTS
+/////////////////////////////////////////////////
+#define CPPEXTERN_NEW_WITH_FIVE_ARGS(NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE, TFOUR, PD_FOUR, TFIVE, PD_FIVE) \
+ REAL_NEW_WITH_ARG_ARG_ARG_ARG_ARG(NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE, TFOUR, PD_FOUR, TFIVE, PD_FIVE)
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+// These should never be called or used directly!!!
+//
+//
+///////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////
+// static class:
+// by default classes are declared static
+// however, sometimes we need classes not-static, so we can refer to them
+// from other classes
+///////////////////////////////////////////////////////////////////////////////
+#ifdef NO_STATIC_CLASS
+# define STATIC_CLASS
+#else
+# define STATIC_CLASS static
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// auto registering a class
+// this creates a dummy class, whose constructor calls the setup-function
+// (registering the class with pd)
+// a static copy of this class is created at runtime, to actually do the setup-call
+///////////////////////////////////////////////////////////////////////////////
+#ifdef NO_AUTO_REGISTER_CLASS
+// if NO_AUTO_REGISTER_CLASS is defined, we will not register the class
+# define AUTO_REGISTER_CLASS(NEW_CLASS)
+#else
+// for debugging we can show the which classes are auto-registering
+# if 0
+# define POST_AUTOREGISTER(NEW_CLASS) post("auto-registering: "#NEW_CLASS)
+# else
+# define POST_AUTOREGISTER(NEW_CLASS)
+# endif
+# define AUTO_REGISTER_CLASS(NEW_CLASS) \
+ class NEW_CLASS ## _cppclass { \
+ public: \
+ NEW_CLASS ## _cppclass() {POST_AUTOREGISTER(NEW_CLASS); NEW_CLASS ## _setup(); } \
+}; \
+ static NEW_CLASS ## _cppclass NEW_CLASS ## _instance;
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// setting the help-symbol
+///////////////////////////////////////////////////////////////////////////////
+#ifndef HELPSYMBOL_BASE
+# define HELPSYMBOL_BASE ""
+#endif
+
+#ifdef HELPSYMBOL
+# define SET_HELPSYMBOL(NEW_CLASS) \
+ class_sethelpsymbol(NEW_CLASS ## _class, gensym(HELPSYMBOL_BASE HELPSYMBOL))
+#else
+# define SET_HELPSYMBOL(NEW_CLASS)
+#endif /* HELPSYMBOL */
+
+
+///////////////////////////////////////////////////////////////////////////////
+// setting the class-flags
+///////////////////////////////////////////////////////////////////////////////
+#ifndef GEM_CLASSFLAGS
+# define GEM_CLASSFLAGS 0
+#endif
+///////////////////////////////////////////////////////////////////////////////
+// no args
+///////////////////////////////////////////////////////////////////////////////
+#define REAL_NEW(NEW_CLASS) \
+STATIC_CLASS t_class * NEW_CLASS ## _class; \
+static void* create_ ## NEW_CLASS () \
+{ \
+ try{ \
+ Obj_header *obj = new (pd_new(NEW_CLASS ## _class),(void *)NULL) Obj_header; \
+ CPPExtern::m_holder = &obj->pd_obj; \
+ CPPExtern::m_holdname=(char*)#NEW_CLASS; \
+ obj->data = new NEW_CLASS; \
+ CPPExtern::m_holder = NULL; \
+ CPPExtern::m_holdname=NULL; \
+ return(obj); \
+ } catch (GemException e) {e.report(); return NULL;} \
+} \
+ extern "C" { \
+ void NEW_CLASS ## _setup() \
+ { \
+ NEW_CLASS ## _class = class_new( \
+ gensym(#NEW_CLASS), \
+ (t_newmethod)create_ ## NEW_CLASS, \
+ (t_method)&NEW_CLASS::obj_freeCallback, \
+ sizeof(Obj_header), GEM_CLASSFLAGS, \
+ A_NULL); \
+ SET_HELPSYMBOL(NEW_CLASS); \
+ NEW_CLASS::real_obj_setupCallback(NEW_CLASS ## _class); \
+ } \
+ } \
+ AUTO_REGISTER_CLASS(NEW_CLASS);
+
+
+///////////////////////////////////////////////////////////////////////////////
+// one arg
+///////////////////////////////////////////////////////////////////////////////
+#define REAL_NEW_WITH_ARG(NEW_CLASS, VAR_TYPE, PD_TYPE) \
+STATIC_CLASS t_class * NEW_CLASS ## _class; \
+static void* create_ ## NEW_CLASS (VAR_TYPE arg) \
+{ \
+ try{ \
+ Obj_header *obj = new (pd_new(NEW_CLASS ## _class),(void *)NULL) Obj_header; \
+ CPPExtern::m_holder = &obj->pd_obj; \
+ CPPExtern::m_holdname=(char*)#NEW_CLASS; \
+ obj->data = new NEW_CLASS(arg); \
+ CPPExtern::m_holder = NULL; \
+ CPPExtern::m_holdname=NULL; \
+ return(obj); \
+ } catch (GemException e) {e.report(); return NULL;} \
+} \
+extern "C" { \
+void NEW_CLASS ## _setup() \
+{ \
+ NEW_CLASS ## _class = class_new( \
+ gensym(#NEW_CLASS), \
+ (t_newmethod)create_ ## NEW_CLASS, \
+ (t_method)&NEW_CLASS::obj_freeCallback, \
+ sizeof(Obj_header), GEM_CLASSFLAGS, \
+ PD_TYPE, \
+ A_NULL); \
+ SET_HELPSYMBOL(NEW_CLASS); \
+ NEW_CLASS::real_obj_setupCallback(NEW_CLASS ## _class); \
+ } \
+} \
+ AUTO_REGISTER_CLASS(NEW_CLASS);
+
+///////////////////////////////////////////////////////////////////////////////
+// gimme arg
+///////////////////////////////////////////////////////////////////////////////
+#define REAL_NEW_WITH_GIMME(NEW_CLASS) \
+STATIC_CLASS t_class * NEW_CLASS ## _class; \
+static void* create_ ## NEW_CLASS (t_symbol *s, int argc, t_atom *argv) \
+{ \
+ try{ \
+ Obj_header *obj = new (pd_new(NEW_CLASS ## _class),(void *)NULL) Obj_header; \
+ CPPExtern::m_holder = &obj->pd_obj; \
+ CPPExtern::m_holdname=(char*)s->s_name; \
+ obj->data = new NEW_CLASS(argc, argv); \
+ CPPExtern::m_holder=NULL; \
+ CPPExtern::m_holdname=NULL; \
+ return(obj); \
+ } catch (GemException e) {e.report(); return NULL;} \
+} \
+extern "C" { \
+void NEW_CLASS ## _setup() \
+{ \
+ NEW_CLASS ## _class = class_new( \
+ gensym(#NEW_CLASS), \
+ (t_newmethod)create_ ## NEW_CLASS, \
+ (t_method)&NEW_CLASS::obj_freeCallback, \
+ sizeof(Obj_header), GEM_CLASSFLAGS, \
+ A_GIMME, \
+ A_NULL); \
+ SET_HELPSYMBOL(NEW_CLASS); \
+ NEW_CLASS::real_obj_setupCallback(NEW_CLASS ## _class); \
+ } \
+} \
+ AUTO_REGISTER_CLASS(NEW_CLASS);
+
+///////////////////////////////////////////////////////////////////////////////
+// two args
+///////////////////////////////////////////////////////////////////////////////
+#define REAL_NEW_WITH_ARG_ARG(NEW_CLASS, ONE_VAR_TYPE, ONE_PD_TYPE, TWO_VAR_TYPE, TWO_PD_TYPE) \
+STATIC_CLASS t_class * NEW_CLASS ## _class; \
+static void* create_ ## NEW_CLASS (ONE_VAR_TYPE arg, TWO_VAR_TYPE argtwo) \
+{ \
+ try{ \
+ Obj_header *obj = new (pd_new(NEW_CLASS ## _class),(void *)NULL) Obj_header; \
+ CPPExtern::m_holder = &obj->pd_obj; \
+ CPPExtern::m_holdname=(char*)#NEW_CLASS; \
+ obj->data = new NEW_CLASS(arg, argtwo); \
+ CPPExtern::m_holder = NULL; \
+ CPPExtern::m_holdname=NULL; \
+ return(obj); \
+ } catch (GemException e) {e.report(); return NULL;} \
+} \
+extern "C" { \
+void NEW_CLASS ## _setup() \
+{ \
+ NEW_CLASS ## _class = class_new( \
+ gensym(#NEW_CLASS), \
+ (t_newmethod)create_ ## NEW_CLASS, \
+ (t_method)&NEW_CLASS::obj_freeCallback, \
+ sizeof(Obj_header), GEM_CLASSFLAGS, \
+ ONE_PD_TYPE, TWO_PD_TYPE, \
+ A_NULL); \
+ SET_HELPSYMBOL(NEW_CLASS); \
+ NEW_CLASS::real_obj_setupCallback(NEW_CLASS ## _class); \
+ } \
+} \
+ AUTO_REGISTER_CLASS(NEW_CLASS);
+
+///////////////////////////////////////////////////////////////////////////////
+// three args
+///////////////////////////////////////////////////////////////////////////////
+#define REAL_NEW_WITH_ARG_ARG_ARG(NEW_CLASS, ONE_VAR_TYPE, ONE_PD_TYPE, TWO_VAR_TYPE, TWO_PD_TYPE, THREE_VAR_TYPE, THREE_PD_TYPE) \
+STATIC_CLASS t_class * NEW_CLASS ## _class; \
+static void* create_ ## NEW_CLASS (ONE_VAR_TYPE arg, TWO_VAR_TYPE argtwo, THREE_VAR_TYPE argthree) \
+{ \
+ try{ \
+ Obj_header *obj = new (pd_new(NEW_CLASS ## _class),(void *)NULL) Obj_header; \
+ CPPExtern::m_holder = &obj->pd_obj; \
+ CPPExtern::m_holdname=(char*)#NEW_CLASS; \
+ obj->data = new NEW_CLASS(arg, argtwo, argthree); \
+ CPPExtern::m_holder = NULL; \
+ CPPExtern::m_holdname=NULL; \
+ return(obj); \
+ } catch (GemException e) {e.report(); return NULL;} \
+} \
+extern "C" { \
+void NEW_CLASS ## _setup() \
+{ \
+ NEW_CLASS ## _class = class_new( \
+ gensym(#NEW_CLASS), \
+ (t_newmethod)create_ ## NEW_CLASS, \
+ (t_method)&NEW_CLASS::obj_freeCallback, \
+ sizeof(Obj_header), GEM_CLASSFLAGS, \
+ ONE_PD_TYPE, TWO_PD_TYPE, THREE_PD_TYPE, \
+ A_NULL); \
+ SET_HELPSYMBOL(NEW_CLASS); \
+ NEW_CLASS::real_obj_setupCallback(NEW_CLASS ## _class); \
+ } \
+} \
+ AUTO_REGISTER_CLASS(NEW_CLASS);
+
+///////////////////////////////////////////////////////////////////////////////
+// four args
+///////////////////////////////////////////////////////////////////////////////
+#define REAL_NEW_WITH_ARG_ARG_ARG_ARG(NEW_CLASS, ONE_VAR_TYPE, ONE_PD_TYPE, TWO_VAR_TYPE, TWO_PD_TYPE, THREE_VAR_TYPE, THREE_PD_TYPE, FOUR_VAR_TYPE, FOUR_PD_TYPE) \
+STATIC_CLASS t_class * NEW_CLASS ## _class; \
+static void* create_ ## NEW_CLASS (ONE_VAR_TYPE arg, TWO_VAR_TYPE argtwo, THREE_VAR_TYPE argthree, FOUR_VAR_TYPE argfour) \
+{ \
+ try{ \
+ Obj_header *obj = new (pd_new(NEW_CLASS ## _class),(void *)NULL) Obj_header; \
+ CPPExtern::m_holder = &obj->pd_obj; \
+ CPPExtern::m_holdname=(char*)#NEW_CLASS; \
+ obj->data = new NEW_CLASS(arg, argtwo, argthree, argfour); \
+ CPPExtern::m_holder = NULL; \
+ CPPExtern::m_holdname=NULL; \
+ return(obj); \
+ } catch (GemException e) {e.report(); return NULL;} \
+} \
+extern "C" { \
+void NEW_CLASS ## _setup() \
+{ \
+ NEW_CLASS ## _class = class_new( \
+ gensym(#NEW_CLASS), \
+ (t_newmethod)create_ ## NEW_CLASS, \
+ (t_method)&NEW_CLASS::obj_freeCallback, \
+ sizeof(Obj_header), GEM_CLASSFLAGS, \
+ ONE_PD_TYPE, TWO_PD_TYPE, THREE_PD_TYPE, FOUR_PD_TYPE, \
+ A_NULL); \
+ SET_HELPSYMBOL(NEW_CLASS); \
+ NEW_CLASS::real_obj_setupCallback(NEW_CLASS ## _class); \
+ } \
+} \
+ AUTO_REGISTER_CLASS(NEW_CLASS);
+
+///////////////////////////////////////////////////////////////////////////////
+// five args
+///////////////////////////////////////////////////////////////////////////////
+#define REAL_NEW_WITH_ARG_ARG_ARG_ARG_ARG(NEW_CLASS, ONE_VAR_TYPE, ONE_PD_TYPE, TWO_VAR_TYPE, TWO_PD_TYPE, THREE_VAR_TYPE, THREE_PD_TYPE, FOUR_VAR_TYPE, FOUR_PD_TYPE, FIVE_VAR_TYPE, FIVE_PD_TYPE) \
+STATIC_CLASS t_class * NEW_CLASS ## _class; \
+static void* create_ ## NEW_CLASS (ONE_VAR_TYPE arg, TWO_VAR_TYPE argtwo, THREE_VAR_TYPE argthree, FOUR_VAR_TYPE argfour, FIVE_VAR_TYPE argfive) \
+{ \
+ try{ \
+ Obj_header *obj = new (pd_new(NEW_CLASS ## _class),(void *)NULL) Obj_header; \
+ CPPExtern::m_holder = &obj->pd_obj; \
+ CPPExtern::m_holdname=(char*)#NEW_CLASS; \
+ obj->data = new NEW_CLASS(arg, argtwo, argthree, argfour, argfive); \
+ CPPExtern::m_holder = NULL; \
+ CPPExtern::m_holdname=NULL; \
+ return(obj); \
+ } catch (GemException e) {e.report(); return NULL;} \
+} \
+extern "C" { \
+void NEW_CLASS ## _setup() \
+{ \
+ if(!checkGemVersion(GEM_VERSION_MAJOR, GEM_VERSION_MINOR)) { \
+ ::error("[%s] will not be available", #NEW_CLASS); \
+ return;} \
+ NEW_CLASS ## _class = class_new( \
+ gensym(#NEW_CLASS), \
+ (t_newmethod)create_ ## NEW_CLASS, \
+ (t_method)&NEW_CLASS::obj_freeCallback, \
+ sizeof(Obj_header), GEM_CLASSFLAGS, \
+ ONE_PD_TYPE, TWO_PD_TYPE, THREE_PD_TYPE, FOUR_PD_TYPE, FIVE_PD_TYPE, \
+ A_NULL); \
+ SET_HELPSYMBOL(NEW_CLASS); \
+ NEW_CLASS::real_obj_setupCallback(NEW_CLASS ## _class); \
+ } \
+} \
+ AUTO_REGISTER_CLASS(NEW_CLASS);
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemBase.h b/externals/gridflow/bundled/Base/GemBase.h
new file mode 100644
index 00000000..a5ae3d1e
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemBase.h
@@ -0,0 +1,133 @@
+/*-----------------------------------------------------------------
+ LOG
+ GEM - Graphics Environment for Multimedia
+
+ The base class for all of the gem objects
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger.
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+ -----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMBASE_H_
+#define INCLUDE_GEMBASE_H_
+
+#include "Base/GemGL.h"
+
+#include "Base/CPPExtern.h"
+#include "Base/GemState.h"
+
+class GemCache;
+
+/*-----------------------------------------------------------------
+ -------------------------------------------------------------------
+ CLASS
+ GemBase
+
+ Base class for gem objects
+
+ DESCRIPTION
+
+ -----------------------------------------------------------------*/
+class GEM_EXTERN GemBase : public CPPExtern
+{
+ protected:
+
+ //////////
+ // Constructor
+ GemBase();
+
+ //////////
+ // Destructor
+ virtual ~GemBase();
+
+ //////////
+ virtual void render(GemState *state) = 0;
+
+ //////////
+ void continueRender(GemState *state);
+
+ //////////
+ // After objects below you in the chain have finished.
+ // You should reset all GEM/OpenGL states here.
+ virtual void postrender(GemState *) { ; }
+
+ //////////
+ // Called when rendering stops
+
+#if 1/*(jmz) this seems to be for gem2pdp*/
+ virtual void stoprender() { realStopRendering(); }
+#endif
+
+ //////////
+ // If you care about the start of rendering
+ virtual void startRendering() { ; }
+
+ //////////
+ // If you care about the stop of rendering
+ virtual void stopRendering() { ; }
+
+
+ //////////
+ // has rendering started ?
+ bool gem_amRendering;
+
+ //////////
+ // If anything in the object has changed
+ virtual void setModified();
+
+ //////////
+ // Don't mess with this unless you know what you are doing.
+ GemCache *m_cache;
+ //////////
+ // check whether this object has changed
+ bool m_modified;
+
+ //////////
+ // The outlet
+ t_outlet *m_out1;
+
+
+ //////////
+ // this gets called in the before the startRendering() routine
+ // if it returns TRUE, the object's startRendering(), render() and stopRendering() functions will be called
+ // it it returns FALSE, the object will be disabled
+ // when rendering is restarted, this function get's called again
+ // the default is to enable rendering
+ // this function is important if you want to disable an object because it cannot be used (e.g. missing driver support)
+ virtual bool isRunnable(void);
+
+ //////////
+ // creation callback
+ static void real_obj_setupCallback(t_class *classPtr)
+ { CPPExtern::real_obj_setupCallback(classPtr); GemBase::obj_setupCallback(classPtr); }
+
+
+ private:
+
+ void realStopRendering();
+ void gem_startstopMess(int state);
+ void gem_renderMess(GemCache* state, GemState* state2);
+
+ static inline GemBase *GetMyClass(void *data) {return((GemBase *)((Obj_header *)data)->data);}
+
+ friend class gemhead;
+ static void obj_setupCallback(t_class *classPtr);
+ static void gem_MessCallback(void *, t_symbol *,int, t_atom*);
+ static void renderCallback(GemBase *data, GemState *state);
+ static void postrenderCallback(GemBase *data, GemState *state);
+#if 1 /*jmz this seems to be for gem2pdp*/
+ static void stoprenderCallback(GemBase *data); //DH
+#endif
+
+ /* whether the object is internally disabled or not
+ * objects are to be disabled, if the system cannot make use of them, e.g. because of unsupported openGL features
+ */
+ bool m_enabled;
+
+};
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemCache.h b/externals/gridflow/bundled/Base/GemCache.h
new file mode 100644
index 00000000..bf6c1e0f
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemCache.h
@@ -0,0 +1,69 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ The state to pass among GEM objects
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMCACHE_H_
+#define INCLUDE_GEMCACHE_H_
+
+#include "Base/GemExportDef.h"
+
+class gemhead;
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ GemCache
+
+ The cache to pass among GEM objects
+
+DESCRIPTION
+
+-----------------------------------------------------------------*/
+#define GEMCACHE_MAGIC 0x1234567
+class GEM_EXTERN GemCache
+{
+ public:
+
+ //////////
+ // Constructor
+ GemCache(gemhead *parent);
+
+ //////////
+ // Destructor
+ ~GemCache();
+
+ //////////
+ // Was a modification made which will void a display list?
+ int dirty;
+
+ //////////
+ // Should the image be resent?
+ int resendImage;
+
+ //////////
+ // has the Vertex-Array changed?
+ int vertexDirty;
+
+ //////////
+ // re-set (like creation, but without instantiating
+ void reset(gemhead*parent);
+
+ //////////
+ gemhead *m_parent;
+
+ //////////
+ // indicates a valid cache
+ int m_magic;
+};
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemEvent.h b/externals/gridflow/bundled/Base/GemEvent.h
new file mode 100644
index 00000000..a7ce1f48
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemEvent.h
@@ -0,0 +1,156 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ get keyboard/mouse/tablet callbacks
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMEVENT_H_
+#define INCLUDE_GEMEVENT_H_
+
+#include "Base/GemExportDef.h"
+//#include "Base/CPPExtern.h"
+
+//////////////////////////////////////////////////////////////////
+//
+// Mouse motion callback
+//
+//////////////////////////////////////////////////////////////////
+typedef void (*MOTION_CB)(int, int, void *);
+//////////
+// Set a mouse motion callback
+GEM_EXTERN extern void setMotionCallback(MOTION_CB callback, void *data);
+
+//////////
+// Remove a mouse motion callback
+GEM_EXTERN extern void removeMotionCallback(MOTION_CB callback, void *data);
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Mouse button callback
+//
+//////////////////////////////////////////////////////////////////
+typedef void (*BUTTON_CB)(int, int, int, int, void *);
+//////////
+// Set a button callback
+// which == 0 == left
+// which == 1 == middle
+// which == 2 == right
+GEM_EXTERN extern void setButtonCallback(BUTTON_CB callback, void *data);
+
+//////////
+// Remove a button callback
+GEM_EXTERN extern void removeButtonCallback(BUTTON_CB callback, void *data);
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Mouse wheel callback
+//
+//////////////////////////////////////////////////////////////////
+typedef void (*WHEEL_CB)(int, int, void *);
+//////////
+// Set a wheel callback
+GEM_EXTERN extern void setWheelCallback(WHEEL_CB callback, void *data);
+
+//////////
+// Remove a wheel callback
+GEM_EXTERN extern void removeWheelCallback(WHEEL_CB callback, void *data);
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Tablet motion callback
+//
+//////////////////////////////////////////////////////////////////
+typedef void (*TABMOTION_CB)(int, int, float, void *);
+//////////
+// Set a tablet motion callback
+GEM_EXTERN extern void setTabletMotionCallback(TABMOTION_CB callback, void *data);
+
+//////////
+// Remove a tablet motion callback
+GEM_EXTERN extern void removeTabletMotionCallback(TABMOTION_CB callback, void *data);
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Tablet rotation callback
+//
+//////////////////////////////////////////////////////////////////
+typedef void (*TABROTATION_CB)(int, int, int, void *);
+//////////
+// Set a tablet rotation callback
+GEM_EXTERN extern void setTabletRotationCallback(TABROTATION_CB callback, void *data);
+
+//////////
+// Remove a tablet rotation callback
+GEM_EXTERN extern void removeTabletRotationCallback(TABROTATION_CB callback, void *data);
+
+
+//////////////////////////////////////////////////////////////////
+//
+// Tablet button callback
+//
+//////////////////////////////////////////////////////////////////
+typedef void (*TABBUTTON_CB)(int, int, int, int, void *);
+//////////
+// Set a tablet button callback
+// which == 0 == left
+// which == 1 == middle
+// which == 2 == right
+GEM_EXTERN extern void setTabletButtonCallback(TABBUTTON_CB callback, void *data);
+
+//////////
+// Remove a tablet button callback
+GEM_EXTERN extern void removeTabletButtonCallback(TABBUTTON_CB callback, void *data);
+
+//////////////////////////////////////////////////////////////////
+//
+// Keyboard callback
+//
+//////////////////////////////////////////////////////////////////
+typedef void (*KEYBOARD_CB)(char *,int, int, void *);
+//////////
+// Set a keyboard callback
+GEM_EXTERN extern void setKeyboardCallback(KEYBOARD_CB callback, void *data);
+
+//////////
+// Remove a keyboard callback
+GEM_EXTERN extern void removeKeyboardCallback(KEYBOARD_CB callback, void *data);
+
+//////////////////////////////////////////////////////////////////
+//
+// Resize callback
+//
+//////////////////////////////////////////////////////////////////
+typedef void (*RESIZE_CB)(int, int, void *);
+//////////
+// Set a resize callback
+GEM_EXTERN extern void setResizeCallback(RESIZE_CB callback, void *data);
+
+//////////
+// Remove a resize callback
+GEM_EXTERN extern void removeResizeCallback(RESIZE_CB callback, void *data);
+
+//////////
+// Trigger an event
+GEM_EXTERN extern void triggerMotionEvent(int x, int y);
+GEM_EXTERN extern void triggerButtonEvent(int which, int state, int x, int y);
+GEM_EXTERN extern void triggerWheelEvent(int axis, int value);
+GEM_EXTERN extern void triggerTabletMotionEvent(int x, int y, float pressure);
+GEM_EXTERN extern void triggerTabletRotationEvent(int az, int alt, int twist);
+GEM_EXTERN extern void triggerTabletButtonEvent(int which, int state, int x, int y);
+GEM_EXTERN extern void triggerKeyboardEvent(char *string, int value, int state);
+GEM_EXTERN extern void triggerResizeEvent(int xSize, int ySize);
+
+#endif // for header file
+
diff --git a/externals/gridflow/bundled/Base/GemExportDef.h b/externals/gridflow/bundled/Base/GemExportDef.h
new file mode 100644
index 00000000..26b07655
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemExportDef.h
@@ -0,0 +1,40 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Export crap
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMEXPORTDEF_H_
+#define INCLUDE_GEMEXPORTDEF_H_
+
+#ifdef _MSC_VER
+
+/* turn of some warnings on vc-compilers */
+# pragma warning( disable : 4244 )
+# pragma warning( disable : 4305 )
+# pragma warning( disable : 4091 )
+// "switch" without "case" (just "default")
+# pragma warning( disable : 4065 )
+
+// Windows requires explicit import and exporting of functions and classes.
+// While this is a pain to do sometimes, in large software development
+// projects, it is very usefull.
+#ifdef GEM_INTERNAL // GEM exporting things
+#define GEM_EXTERN __declspec(dllexport)
+#else // other's importing
+#define GEM_EXTERN __declspec(dllimport)
+#endif // for GEM_INTERNAL
+
+#else // other OS's
+#define GEM_EXTERN
+#endif
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemFuncUtil.h b/externals/gridflow/bundled/Base/GemFuncUtil.h
new file mode 100644
index 00000000..70a28f51
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemFuncUtil.h
@@ -0,0 +1,362 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ GemFuncUtil.h
+ - contains functions for graphics
+ - part of GEM
+
+ Copyright (c) 1997-2000 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMFUNCUTIL_H_
+#define INCLUDE_GEMFUNCUTIL_H_
+
+#ifdef __APPLE__
+#include <Carbon/Carbon.h>
+#endif
+
+#include "Base/GemExportDef.h"
+
+/* this should be included for ALL platforms:
+ * should we define __MMX__ for windows in there ?
+ */
+#include "config.h"
+#include "GemSIMD.h"
+#include "GemMath.h"
+
+
+// for rand()
+#include <stdlib.h>
+
+///////////////////////////////////////////////////////////////////////////////
+// powerOfTwo
+// get the next higher 2^n-number (if value is'nt 2^n by itself)
+///////////////////////////////////////////////////////////////////////////////
+inline int powerOfTwo(int value)
+{
+/*
+ int x = 1;
+ // while(x <= value) x <<= 1;
+ while(x < value) x <<= 1;
+ return(x);
+*/
+// optimization from "Hacker's Delight"
+// - above loop executes in 4n+3 instructions, where n is the power of 2 of returned int
+// - below code is branch-free and only 12 instructions!
+ value = value - 1;
+ value = value | (value >> 1);
+ value = value | (value >> 2);
+ value = value | (value >> 4);
+ value = value | (value >> 8);
+ value = value | (value >> 16);
+ return (value + 1);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// min/max functions
+//
+///////////////////////////////////////////////////////////////////////////////
+#ifndef MIN
+inline int MIN(int x, int y) { return (x<y)?x:y; }
+inline float MIN(float x, float y) { return (x<y)?x:y; }
+#endif
+#ifndef MAX
+inline int MAX(int x, int y) { return (x>y)?x:y; }
+inline float MAX(float x, float y) { return (x>y)?x:y; }
+#endif
+
+inline unsigned char TRI_MAX(unsigned char v1, unsigned char v2, unsigned char v3){
+ if (v1 > v2 && v1 > v3) return(v1);
+ if (v2 > v3) return(v2);
+ return(v3);
+}
+inline unsigned char TRI_MIN(unsigned char v1, unsigned char v2, unsigned char v3){
+ if (v1 < v2 && v1 < v3) return(v1);
+ if (v2 < v3) return(v2);
+ return(v3);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Clamp functions
+//
+///////////////////////////////////////////////////////////////////////////////
+//////////
+// Clamp a value high
+inline unsigned char CLAMP_HIGH(int x)
+ { return((unsigned char )((x > 255) ? 255 : x)); }
+
+//////////
+// Clamp a value low
+inline unsigned char CLAMP_LOW(int x)
+ { return((unsigned char )((x < 0) ? 0 : x)); }
+
+//////////
+// Clamp an int to the range of an unsigned char
+inline unsigned char CLAMP(int x)
+ { return((unsigned char)((x > 255) ? 255 : ( (x < 0) ? 0 : x))); }
+
+//////////
+// Clamp a float to the range of an unsigned char
+inline unsigned char CLAMP(float x)
+ { return((unsigned char)((x > 255.f) ? 255.f : ( (x < 0.f) ? 0.f : x))); }
+
+//////////
+// Clamp a float to 0. <= x <= 1.0
+inline float FLOAT_CLAMP(float x)
+ { return((x > 1.f) ? 1.f : ( (x < 0.f) ? 0.f : x)); }
+
+/////////
+// Clamp the Y channel of YUV (16%235)
+inline unsigned char CLAMP_Y(int x)
+ { return((unsigned char)((x > 235) ? 235 : ( (x < 16) ? 16 : x))); }
+
+///////////////////////////////////////////////////////////////////////////////
+// Multiply and interpolation
+//
+///////////////////////////////////////////////////////////////////////////////
+//////////
+// Exactly multiply two unsigned chars
+// This avoids a float value (important on Intel...)
+// From Alvy Ray Smith paper
+inline unsigned char INT_MULT(unsigned int a, unsigned int b)
+ { int t = (unsigned int)a * (unsigned int)b + 0x80;
+ return((unsigned char)(((t >> 8) + t) >> 8)); }
+
+//////////
+// Exactly LERPs two values
+// This avoids a float value (important on Intel...)
+// From Alvy Ray Smith paper
+inline unsigned char INT_LERP(unsigned int p, unsigned int q, unsigned int a)
+ { return((unsigned char)(p + INT_MULT(a, q - p))); }
+
+//////////
+// Floating point LERP
+inline float FLOAT_LERP(float p, float q, float a)
+ { return( a * (q - p) + p); }
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Step function
+//
+///////////////////////////////////////////////////////////////////////////////
+inline int stepFunc(float x, float a)
+ { return(x >= a); }
+inline int stepFunc(int x, int a)
+ { return(x >= a); }
+inline int stepFunc(unsigned char x, unsigned char a)
+ { return(x >= a); }
+
+///////////////////////////////////////////////////////////////////////////////
+// Pulse function
+//
+///////////////////////////////////////////////////////////////////////////////
+inline int pulseFunc(float x, float a, float b)
+ { return(stepFunc(a, x) - stepFunc(b, x)); }
+inline int pulseFunc(int x, int a, int b)
+ { return(stepFunc(a, x) - stepFunc(b, x)); }
+inline int pulseFunc(unsigned char x, unsigned char a, unsigned char b)
+ { return(stepFunc(a, x) - stepFunc(b, x)); }
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Clamp function
+//
+///////////////////////////////////////////////////////////////////////////////
+inline float clampFunc(float x, float a, float b)
+ { return(x < a ? a : (x > b ? b : x)); }
+inline int clampFunc(int x, int a, int b)
+ { return(x < a ? a : (x > b ? b : x)); }
+inline unsigned char clampFunc(unsigned char x, unsigned char a, unsigned char b)
+ { return(x < a ? a : (x > b ? b : x)); }
+inline void* clampFunc(void* x, void* a, void* b)
+ { return(x < a ? a : (x > b ? b : x)); }
+/*
+ inline int GateInt(int nValue,int nMin,int nMax)
+ inline float GateFlt(float nValue,float nMin,float nMax)
+ inline void* GatePtr(void* pValue,void* pMin,void* pMax)
+*/
+
+
+///////////////////////////////////////////////////////////////////////////////
+// absolute integer
+//
+///////////////////////////////////////////////////////////////////////////////
+inline int AbsInt(int inValue) { return (inValue>0)?inValue:-inValue; }
+static inline int GetSign(int inValue) { return (inValue<0)?-1:1; }
+
+///////////////////////////////////////////////////////////////////////////////
+// wrapping functions for integers
+//
+///////////////////////////////////////////////////////////////////////////////
+
+inline int GetTiled(int inValue,const int nMax) {
+ int nOutValue=(inValue%nMax);
+ if (nOutValue<0)nOutValue=((nMax-1)+nOutValue);
+ return nOutValue;
+}
+
+inline int GetMirrored(int inValue,const int nMax) {
+ const int nTwoMax=(nMax*2);
+ int nOutValue=GetTiled(inValue,nTwoMax);
+ if (nOutValue>=nMax)nOutValue=((nTwoMax-1)-nOutValue);
+ return nOutValue;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// 2D-algebra
+//
+///////////////////////////////////////////////////////////////////////////////
+static inline void Get2dTangent(float inX,float inY,float* poutX,float* poutY) {
+ *poutX=inY;
+ *poutY=-inX;
+}
+///////////////////////////////////////////////////////////////////////////////
+// 2D-dot product
+///////////////////////////////////////////////////////////////////////////////
+static inline float Dot2d(float Ax,float Ay,float Bx,float By) {
+ return ((Ax*Bx)+(Ay*By));
+}
+///////////////////////////////////////////////////////////////////////////////
+// 2D-vector normalization
+///////////////////////////////////////////////////////////////////////////////
+static inline void Normalise2d(float* pX,float* pY) {
+ const float MagSqr=Dot2d(*pX,*pY,*pX,*pY);
+ float Magnitude=(float)sqrt(MagSqr);
+ if (Magnitude<=0.0f) {
+ Magnitude=0.001f;
+ }
+ const float RecipMag=1.0f/Magnitude;
+
+ *pX*=RecipMag;
+ *pY*=RecipMag;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// higher algebra
+//
+///////////////////////////////////////////////////////////////////////////////
+inline float GetRandomFloat(void) {
+ return rand()/static_cast<float>(RAND_MAX);
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Smooth step function (3x^2 - 2x^3)
+//
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern float smoothStep(float x, float a, float b);
+GEM_EXTERN extern int smoothStep(int x, int a, int b);
+GEM_EXTERN extern unsigned char smoothStep(unsigned char x, unsigned char a, unsigned char b);
+
+///////////////////////////////////////////////////////////////////////////////
+// Bias function
+//
+// Remap unit interval (curve)
+// If a == 0.5, then is linear mapping.
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern float biasFunc(float x, float a);
+
+///////////////////////////////////////////////////////////////////////////////
+// Gain function
+//
+// Remap unit interval (S-curve)
+// Will always return 0.5 when x is 0.5
+// If a == 0.5, then is linear mapping.
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern float gainFunc(float x, float a);
+
+///////////////////////////////////////////////////////////////////////////////
+// Linear function
+//
+// val should be 0 <= val <= 1.
+// ret should point at a float of enough dimensions to hold the returned value
+// For instance, numDimen == 2, should have a ret[2]
+// numDimen is the number of dimensions to compute
+// npnts is the number of points per dimension.
+//
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern void linearFunc(float val, float *ret, int numDimen, int npnts, float *pnts);
+
+///////////////////////////////////////////////////////////////////////////////
+// Spline function
+//
+// val should be 0 <= val <= 1.
+// ret should point at a float of enough dimensions to hold the returned value
+// For instance, numDimen == 2, should have a ret[2]
+// numDimen is the number of dimensions to compute
+// nknots is the number of knots per dimension.
+// There must be at least four knots!
+//
+// Thanks to
+// _Texturing and Modeling: A Procedural Approach_
+// David S. Ebert, Ed.
+///////////////////////////////////////////////////////////////////////////////
+GEM_EXTERN extern void splineFunc(float val, float *ret, int numDimen, int nknots, float *knot);
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Pixel access functions
+//
+///////////////////////////////////////////////////////////////////////////////
+//
+// Accelerated Pixel Manipulations
+// This is sort on a vector operation on 8 chars at the same time .... could be
+// implemented in MMX
+// Alpha channel is not added !! (would be nr 3 and 7)
+
+#define ADD8_NOALPHA(a,b) \
+ ((unsigned char*)(a))[0] = CLAMP_HIGH((int)((unsigned char*)(a))[0] + ((unsigned char*)(b))[0]);\
+ ((unsigned char*)(a))[1] = CLAMP_HIGH((int)((unsigned char*)(a))[1] + ((unsigned char*)(b))[1]);\
+ ((unsigned char*)(a))[2] = CLAMP_HIGH((int)((unsigned char*)(a))[2] + ((unsigned char*)(b))[2]);\
+ ((unsigned char*)(a))[4] = CLAMP_HIGH((int)((unsigned char*)(a))[4] + ((unsigned char*)(b))[4]);\
+ ((unsigned char*)(a))[5] = CLAMP_HIGH((int)((unsigned char*)(a))[5] + ((unsigned char*)(b))[5]);\
+ ((unsigned char*)(a))[6] = CLAMP_HIGH((int)((unsigned char*)(a))[6] + ((unsigned char*)(b))[6]);\
+
+#define SUB8_NOALPHA(a,b) \
+ ((unsigned char*)(a))[0] = CLAMP_LOW((int)((unsigned char*)(a))[0] - ((unsigned char*)(b))[0]);\
+ ((unsigned char*)(a))[1] = CLAMP_LOW((int)((unsigned char*)(a))[1] - ((unsigned char*)(b))[1]);\
+ ((unsigned char*)(a))[2] = CLAMP_LOW((int)((unsigned char*)(a))[2] - ((unsigned char*)(b))[2]);\
+ ((unsigned char*)(a))[4] = CLAMP_LOW((int)((unsigned char*)(a))[4] - ((unsigned char*)(b))[4]);\
+ ((unsigned char*)(a))[5] = CLAMP_LOW((int)((unsigned char*)(a))[5] - ((unsigned char*)(b))[5]);\
+ ((unsigned char*)(a))[6] = CLAMP_LOW((int)((unsigned char*)(a))[6] - ((unsigned char*)(b))[6]);\
+
+#define ADD8(a,b) \
+ ((unsigned char*)(a))[0] = CLAMP_HIGH((int)((unsigned char*)(a))[0] + ((unsigned char*)(b))[0]);\
+ ((unsigned char*)(a))[1] = CLAMP_HIGH((int)((unsigned char*)(a))[1] + ((unsigned char*)(b))[1]);\
+ ((unsigned char*)(a))[2] = CLAMP_HIGH((int)((unsigned char*)(a))[2] + ((unsigned char*)(b))[2]);\
+ ((unsigned char*)(a))[3] = CLAMP_HIGH((int)((unsigned char*)(a))[3] + ((unsigned char*)(b))[3]);\
+ ((unsigned char*)(a))[4] = CLAMP_HIGH((int)((unsigned char*)(a))[4] + ((unsigned char*)(b))[4]);\
+ ((unsigned char*)(a))[5] = CLAMP_HIGH((int)((unsigned char*)(a))[5] + ((unsigned char*)(b))[5]);\
+ ((unsigned char*)(a))[6] = CLAMP_HIGH((int)((unsigned char*)(a))[6] + ((unsigned char*)(b))[6]);\
+ ((unsigned char*)(a))[7] = CLAMP_HIGH((int)((unsigned char*)(a))[7] + ((unsigned char*)(b))[7]);\
+
+#define SUB8(a,b) \
+ ((unsigned char*)(a))[0] = CLAMP_LOW((int)((unsigned char*)(a))[0] - ((unsigned char*)(b))[0]);\
+ ((unsigned char*)(a))[1] = CLAMP_LOW((int)((unsigned char*)(a))[1] - ((unsigned char*)(b))[1]);\
+ ((unsigned char*)(a))[2] = CLAMP_LOW((int)((unsigned char*)(a))[2] - ((unsigned char*)(b))[2]);\
+ ((unsigned char*)(a))[3] = CLAMP_LOW((int)((unsigned char*)(a))[3] - ((unsigned char*)(b))[3]);\
+ ((unsigned char*)(a))[4] = CLAMP_LOW((int)((unsigned char*)(a))[4] - ((unsigned char*)(b))[4]);\
+ ((unsigned char*)(a))[5] = CLAMP_LOW((int)((unsigned char*)(a))[5] - ((unsigned char*)(b))[5]);\
+ ((unsigned char*)(a))[6] = CLAMP_LOW((int)((unsigned char*)(a))[6] - ((unsigned char*)(b))[6]);\
+ ((unsigned char*)(a))[7] = CLAMP_LOW((int)((unsigned char*)(a))[7] - ((unsigned char*)(b))[7]);\
+
+
+
+#ifdef __APPLE__
+//Ian Ollman's function to determine the cache prefetch for altivec vec_dst()
+inline UInt32 GetPrefetchConstant( int blockSizeInVectors, int blockCount, int blockStride )
+{
+ return ((blockSizeInVectors << 24) & 0x1F000000) | ((blockCount << 16) & 0x00FF0000) | (blockStride & 0xFFFF);
+}
+#endif
+
+
+#endif // for header file
+
diff --git a/externals/gridflow/bundled/Base/GemGL.h b/externals/gridflow/bundled/Base/GemGL.h
new file mode 100644
index 00000000..24d6fe99
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemGL.h
@@ -0,0 +1,72 @@
+/*
+ * GemGL: openGL includes for GEM
+ *
+ * include this file if you want to include the
+ * openGL-headers installed on your system
+ *
+ * tasks:
+ *
+ * + this file hides the peculiarities of the various platforms
+ * (like "OpenGL/gl.h" vs "GL/gl.h")
+ *
+ * + define some pre-processor defines that are missing in the GL-headers
+ *
+ * + try to exclude parts of the GL-headers based on config.h
+ *
+ */
+
+
+#ifndef INCLUDE_GEMGL_H_
+#define INCLUDE_GEMGL_H_
+
+#include "config.h"
+
+// I hate Microsoft...I shouldn't have to do this!
+#ifdef __WIN32__
+# include <windows.h>
+#endif
+
+#define GLEW_STATIC
+//#include "Base/glew.h"
+#ifdef __APPLE__
+typedef signed long GLint;
+typedef unsigned long GLenum;
+#else
+typedef signed int GLint;
+typedef unsigned int GLenum;
+#endif
+typedef float GLfloat;
+typedef unsigned char GLboolean;
+#define GL_RGBA_MODE 0x0C31
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_RGBA 0x1908
+
+
+#ifdef __APPLE__
+# include <OpenGL/OpenGL.h>
+#elif defined __WIN32__
+# include "Base/wglew.h"
+#elif defined __linux__
+
+#endif /* OS */
+
+#ifndef GL_YUV422_GEM
+# define GL_YCBCR_422_GEM GL_YCBCR_422_APPLE
+# define GL_YUV422_GEM GL_YCBCR_422_GEM
+#endif /* GL_YUV422_GEM */
+
+
+#ifndef GL_RGBA_GEM
+# ifdef __APPLE__
+# define GL_RGBA_GEM GL_BGRA_EXT
+# else
+# define GL_RGBA_GEM GL_RGBA
+# endif
+#endif /* GL_RGBA_GEM */
+
+/* default draw-style */
+#ifndef GL_DEFAULT_GEM
+# define GL_DEFAULT_GEM 0xFFFF
+#endif
+
+#endif /* INCLUDE_GEMGL_H_ */
diff --git a/externals/gridflow/bundled/Base/GemGLUtil.h b/externals/gridflow/bundled/Base/GemGLUtil.h
new file mode 100644
index 00000000..9c5402f9
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemGLUtil.h
@@ -0,0 +1,29 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ GemGLUtil.h
+ - contains functions for graphics
+ - part of GEM
+
+ Copyright (c) 1997-2000 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMGLUTIL_H_
+#define INCLUDE_GEMGLUTIL_H_
+
+#include "Base/GemBase.h"
+#include "Base/GemExportDef.h"
+
+GEM_EXTERN extern GLenum glReportError (void);
+GEM_EXTERN extern int getGLdefine(char *name);
+GEM_EXTERN extern int getGLdefine(t_symbol *name);
+GEM_EXTERN extern int getGLdefine(t_atom *name);
+GEM_EXTERN extern int getGLbitfield(int argc, t_atom *argv);
+#endif // for header file
+
diff --git a/externals/gridflow/bundled/Base/GemGluObj.h b/externals/gridflow/bundled/Base/GemGluObj.h
new file mode 100644
index 00000000..524ba4b4
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemGluObj.h
@@ -0,0 +1,96 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ A Glu object
+
+ Copyright (c) 1997-2000 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMGLUOBJ_H_
+#define INCLUDE_GEMGLUOBJ_H_
+
+// I hate Microsoft...I shouldn't have to do this!
+#ifdef __WIN32__
+#include <windows.h>
+#endif
+
+#include <string.h>
+
+
+#include <math.h>
+#ifndef M_PI
+# define M_PI (3.1415926)
+#endif
+
+#include "Base/GemShape.h"
+
+#ifndef GLU_SILHOUETTE
+# define GLU_SILHOUETTE 0
+#endif
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ GemGluObj
+
+ A Glu object
+
+DESCRIPTION
+
+ Inlet for an int - "in2"
+
+ "in2" - the number of slices in the object
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN GemGluObj : public GemShape
+{
+ public:
+
+ //////////
+ // Constructor
+ GemGluObj(t_floatarg size, t_floatarg slices=10.f, t_floatarg stacks=0.f);
+
+ protected:
+
+ //////////
+ // Destructor
+ virtual ~GemGluObj();
+
+ //////////
+ // How the object should be drawn
+ virtual void typeMess(t_symbol *type);
+
+ //////////
+ // The number of slices in the quadric
+ void numSlicesMess(int numSlices);
+ void numSlicesMess(int numSlices, int numStacks);
+
+ //////////
+ // The number of slices
+ int m_numSlices, m_numStacks;
+
+ //////////
+ t_inlet *m_sliceInlet;
+
+ //////////
+ // creation callback
+ static void real_obj_setupCallback(t_class *classPtr)
+ { GemShape::real_obj_setupCallback(classPtr); GemGluObj::obj_setupCallback(classPtr); }
+
+ private:
+
+ static inline GemGluObj *GetMyClass(void *data) {return((GemGluObj *)((Obj_header *)data)->data);}
+
+ //////////
+ // Static member functions
+ static void obj_setupCallback(t_class *classPtr);
+ static void numSlicesMessCallback(void *data, t_symbol*, int, t_atom*);
+};
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemLoadObj.h b/externals/gridflow/bundled/Base/GemLoadObj.h
new file mode 100644
index 00000000..9e4c9625
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemLoadObj.h
@@ -0,0 +1,28 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ - loads in an alias|wavefront model file
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMLOADOBJ_H_
+#define INCLUDE_GEMLOADOBJ_H_
+
+#include "Base/GemExportDef.h"
+
+class GemModelData;
+
+//////////
+// Load in an alias|wavefront model
+// [out] GemModel * - equals NULL if failure
+GEM_EXTERN extern GemModelData *loadWaveFrontModel(const char *filename);
+
+
+#endif
diff --git a/externals/gridflow/bundled/Base/GemMan.h b/externals/gridflow/bundled/Base/GemMan.h
new file mode 100644
index 00000000..351429be
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemMan.h
@@ -0,0 +1,257 @@
+/*-----------------------------------------------------------------
+ LOG
+ GEM - Graphics Environment for Multimedia
+
+ The base functions and structures
+ Also includes gemwin header file
+
+ Copyright (c) 1997-2000 Mark Danks.mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+ -----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMMAN_H_
+#define INCLUDE_GEMMAN_H_
+
+#include "Base/GemGL.h"
+#include "Base/GemGLUtil.h"
+
+#ifdef __APPLE__
+# include <Carbon/Carbon.h>
+# include <AGL/agl.h>
+#endif // __APPLE__
+
+#ifdef __WIN32__
+# include <QTML.h>
+# include <Movies.h>
+#endif
+
+#include "Base/GemExportDef.h"
+
+class gemhead;
+class gemheadLink;
+class GemState;
+class WindowInfo;
+
+/*-----------------------------------------------------------------
+ -------------------------------------------------------------------
+ CLASS
+ GemMan
+
+ A static class to create windows, etc.
+
+ DESCRIPTION
+
+ -----------------------------------------------------------------*/
+class GEM_EXTERN GemMan
+{
+ public:
+
+ //////////
+ // Should only be called once (usually by GemSetup)
+ static void initGem(void);
+
+ //////////
+ static void addObj(gemhead *obj, int priority);
+
+ //////////
+ static void removeObj(gemhead *obj, int priority);
+
+ //////////
+ // Is there a window.
+ static int windowExists(void);
+
+ //////////
+ // Are we rendering.
+ static int getRenderState(void);
+
+ //////////
+ // is there a context (has its meaning under X)
+ static void createContext(char* disp);
+ static int contextExists(void);
+
+ //////////
+ // If an object needs to know if the window changed.
+ // This is important for display lists.
+ static int windowNumber(void);
+
+ //////////
+ // reset to the initial state
+ static void resetState(void);
+
+ //////////
+ // Just send out one frame (if double buffered, will swap buffers)
+ static void render(void *);
+ static void renderChain(gemheadLink *head, GemState *state);
+
+
+ //////////
+ // Start a clock to do rendering.
+ static void startRendering(void);
+
+ //////////
+ // Stop the clock to do rendering.
+ static void stopRendering(void);
+
+ //////////
+ // Create the window with the current parameters
+ static int createWindow(char* disp = 0);
+
+ //////////
+ // Destroy the window
+ static void destroyWindow(void);
+ // Destroy the window after a minimal delay
+ static void destroyWindowSoon(void);
+
+ //////////
+ // Swap the buffers.
+ // If single buffered, just clears the window
+ static void swapBuffers(void);
+
+ //////////
+ // Set the frame rate
+ static void frameRate(float framespersecond);
+ //////////
+ // Get the frame rate
+ static float getFramerate(void);
+
+ static int getProfileLevel(void);
+
+ static void getDimen(int*width, int*height);
+ static void getRealDimen(int*width, int*height);
+ static void getOffset(int*x, int*y);
+
+ //////////
+ // Turn on/off lighting
+ static void lightingOnOff(int state);
+
+ //////////
+ // Turn on/off cursor
+ static void cursorOnOff(int state);
+
+ //////////
+ // Turn on/off topmost position
+ static void topmostOnOff(int state);
+
+
+ //////////
+ // Request a lighting value - it is yours until you free it.
+ // The return can be 0, in which there are too many lights
+ // [in] specific - If you want a specific light. == 0 means that you don't care.
+ static GLenum requestLight(int specific = 0);
+
+ //////////
+ // Free a lighting value
+ static void freeLight(GLenum lightNum);
+
+ //////////
+ // Print out information
+ static void printInfo(void);
+
+ //////////
+ static void fillGemState(GemState &);
+
+ static int texture_rectangle_supported;
+ static int client_storage_supported;
+ static int texture_range_supported;
+ static int texture_yuv_supported;
+ static int multisample_filter_hint;
+ static GLint maxStackDepth[4]; // for push/pop of matrix-stacks
+
+
+ static float m_perspect[6]; // values for the perspective matrix
+ static float m_lookat[9]; // values for the lookat matrix
+
+ // LATER make this private (right now it is needed in gem2pdp)
+ static int m_buffer; // single(1) or double(2)
+
+ private:
+
+ //////////
+ // computer and window information
+ static char *m_title; // title to be displayed
+ static int m_fullscreen; // fullscreen (1) or not (0!)
+ static int m_menuBar; // hide (0), show(1), hide but autoshow(-1)
+ static int m_secondscreen; // set the second screen
+ static int m_height; // window height
+ static int m_width; // window width
+ static int m_w; // the real window width (reported by gemCreateWindow())
+ static int m_h; // the real window height
+ static int m_xoffset; // window offset (x)
+ static int m_yoffset; // window offset (y)
+
+ static int m_border; // window border
+ static int m_stereo; // stereoscopic
+
+ static int m_profile; // off(0), on(1), w/o image caching(2)
+ static int m_rendering;
+
+ static float m_fog; // fog density
+ enum FOG_TYPE
+ { FOG_OFF = 0, FOG_LINEAR, FOG_EXP, FOG_EXP2 };
+ static FOG_TYPE m_fogMode; // what kind of fog we have
+ static GLfloat m_fogColor[4]; // colour of the fog
+ static float m_fogStart; // start of the linear fog
+ static float m_fogEnd; // start of the linear fog
+
+ static float m_motionBlur; // motion-blur factor in double-buffer mode
+
+ static float fps;
+ static int fsaa;
+ static bool pleaseDestroy;
+#ifdef __APPLE__
+ static AGLContext masterContext;
+#endif
+
+ //////////
+ // Changing these variables is likely to crash GEM
+ // This is current rendering window information
+ // The window is created and destroyed by the user, so
+ // if there is no window, this will contain NULL pointers.
+ static WindowInfo &getWindowInfo(void);
+
+ //////////
+ // Changing these variables is likely to crash GEM
+ // This is constant rendering window information
+ // This window is always avaliable (although not visible)
+ static WindowInfo &getConstWindowInfo(void);
+ static int createConstWindow(char* disp = 0);
+
+ // gemwin is allowed to modifying "global" window attributes
+ friend class gemwin;
+
+ static GLfloat m_clear_color[4]; // the frame buffer clear
+ static GLbitfield m_clear_mask; // the clear bitmask
+ static GLfloat m_mat_ambient[4]; // default ambient material
+ static GLfloat m_mat_specular[4]; // default specular material
+ static GLfloat m_mat_shininess; // default shininess material
+
+ static GLfloat m_stereoSep; // stereo seperation
+ static GLfloat m_stereoFocal; // distance to focal point
+ static bool m_stereoLine; // draw a line between 2 stereo-screens
+
+ static double m_lastRenderTime; // the time of the last rendered frame
+
+ // gemwin should not touch the following member variables and member functions
+ static int m_windowState;
+ static int m_windowNumber;
+ static int m_windowContext;
+ static int m_cursor;
+ static int m_topmost;
+
+ static void windowInit(void);
+ static void windowCleanup(void);
+ static void resetValues(void);
+
+ static void resizeCallback(int xsize, int ysize, void*);
+ static void dispatchWinmessCallback(void);
+
+ //////////
+ // check for supported openGL extensions we might need
+ static void checkOpenGLExtensions(void);
+};
+
+#endif
diff --git a/externals/gridflow/bundled/Base/GemMath.h b/externals/gridflow/bundled/Base/GemMath.h
new file mode 100644
index 00000000..96177a05
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemMath.h
@@ -0,0 +1,89 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Matrix class
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMMATH_H_
+#define INCLUDE_GEMMATH_H_
+
+#include "Base/config.h"
+
+#include <math.h>
+
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+#ifdef __APPLE__
+# include <AvailabilityMacros.h>
+# if defined (MAC_OS_X_VERSION_10_3) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
+# else
+
+#define sqrtf(v) (float)sqrt((double)(v))
+#define cosf(v) (float)cos((double)(v))
+#define sinf(v) (float)sin((double)(v))
+#define tanf(v) (float)tan((double)(v))
+#define logf(v) (float)log((double)(v))
+#define expf(v) (float)exp((double)(v))
+
+#define atan2f(v,p) (float)atan2((double)(v), (double)(p))
+#define powf(v,p) (float)pow((double)(v), (double)(p))
+
+# endif /* OSX_10_3 */
+#endif /* __APPLE__ */
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Speedup found via Shark: ppc only
+//
+// If you do not require full precision, you can use the PowerPC floating-point
+// reciprocal square-root estimate instruction (frsqrte) instead of calling sqrt().
+//
+// If needed, you can increase the precision of the estimate returned by
+// frsqrte (5-bits of precision) by using the Newton-Raphson method for improving
+// the estimate (x0) for 1/sqrt(a) (x1 = 0.5 * x0 * [3.0 - a * x0 * x0]).
+///////////////////////////////////////////////////////////////////////////////
+#ifdef __ppc__
+# include <ppc_intrinsics.h>
+# ifdef sqrt
+# undef sqrt
+# endif
+# ifdef sqrtf
+# undef sqrtf
+# endif
+
+# define sqrt fast_sqrtf
+# define sqrtf fast_sqrtf
+
+inline double fast_sqrt(double x)
+{
+ register double est = __frsqrte(x);
+ return x * 0.5 * est * __fnmsub(est * est, x, 3.0);
+}
+
+inline float fast_sqrtf(float x)
+{
+ register float est = (float)__frsqrte(x);
+ return x * 0.5f * est * __fnmsubs(est * est, x, 3.0f);
+}
+#endif /* __ppc__ */
+
+#ifdef __WIN32__
+/* seems like there is no drand48() on w32 */
+/* JMZ: this should really return "double" instead of "float",
+ * but we need only float... */
+# define drand48() ((float)rand())/((float)RAND_MAX)
+#endif /* _WIN32 */
+
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemModelData.h b/externals/gridflow/bundled/Base/GemModelData.h
new file mode 100644
index 00000000..4545bf98
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemModelData.h
@@ -0,0 +1,42 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Structure for specifying a model for rendering
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMMODELDATA_H_
+#define INCLUDE_GEMMODELDATA_H_
+
+#include "Base/GemExportDef.h"
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ imageStruct
+
+ The basic image structure
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN GemModelData
+{
+ public:
+
+ //////////
+ // Constructor
+ GemModelData() { }
+
+ //////////
+ // Destructor
+ ~GemModelData() { }
+};
+
+
+#endif
diff --git a/externals/gridflow/bundled/Base/GemPBuffer.h b/externals/gridflow/bundled/Base/GemPBuffer.h
new file mode 100644
index 00000000..f11f5ee4
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPBuffer.h
@@ -0,0 +1,51 @@
+/* OpenGL pixel buffer
+ *
+ * Copyright (C) 2003-2004, Alexander Zaprjagaev <frustum@frustum.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __PBUFFER_H__
+#define __PBUFFER_H__
+
+struct PBuffer_data;
+
+class PBuffer {
+public:
+
+ enum {
+ GEM_PBUFLAG_RGB = 1 << 0,
+ GEM_PBUFLAG_RGBA = 1 << 1,
+ GEM_PBUFLAG_DEPTH = 1 << 2,
+ GEM_PBUFLAG_STENCIL = 1 << 3,
+ GEM_PBUFLAG_FLOAT = 1 << 4,
+ GEM_PBUFLAG_MULTISAMPLE_2 = 1 << 5,
+ GEM_PBUFLAG_MULTISAMPLE_4 = 1 << 6
+ };
+
+ PBuffer(int width,int height,int flags = GEM_PBUFLAG_RGBA | GEM_PBUFLAG_DEPTH | GEM_PBUFLAG_STENCIL);
+ ~PBuffer();
+
+ void enable();
+ void disable();
+
+ int width;
+ int height;
+
+protected:
+ struct PBuffer_data *data;
+};
+
+#endif /* __PBUFFER_H__ */
diff --git a/externals/gridflow/bundled/Base/GemPathBase.h b/externals/gridflow/bundled/Base/GemPathBase.h
new file mode 100644
index 00000000..7bd23aa4
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPathBase.h
@@ -0,0 +1,74 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Base class for paths
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMPATHBASE_H_
+#define INCLUDE_GEMPATHBASE_H_
+
+#include "Base/CPPExtern.h"
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ GemPathBase
+
+
+DESCRIPTION
+
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN GemPathBase : public CPPExtern
+{
+ CPPEXTERN_HEADER(GemPathBase, CPPExtern)
+
+ public:
+
+ //////////
+ // Constructor
+ GemPathBase(int argc, t_atom *argv);
+
+ protected:
+
+ //////////
+ // Destructor
+ virtual ~GemPathBase();
+
+ //////////
+ // When an open is received
+ virtual void openMess(t_symbol *arrayname);
+
+ //////////
+ // When a float val is received
+ virtual void floatMess(float val) = 0;
+
+ //////////
+ // The number of dimensions
+ int m_numDimens;
+
+ //////////
+ // The array
+ t_garray *m_array;
+
+ //////////
+ // The outlet
+ t_outlet *m_out1;
+
+ private:
+
+ //////////
+ // static member functions
+ static void openMessCallback(void *data, t_symbol *arrayname);
+ static void floatMessCallback(void *data, float n);
+};
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemPixConvert.h b/externals/gridflow/bundled/Base/GemPixConvert.h
new file mode 100644
index 00000000..e1cd5a3d
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPixConvert.h
@@ -0,0 +1,160 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ GemPixConvertSIMD.h
+ - header-file for color conversion
+ - this is mainly for (SIMD-)optimized routines
+ - part of GEM
+
+ Copyright (c) 2006 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+
+#ifndef INCLUDE_GEMPIXCONVERT_SIMD_H_
+#define INCLUDE_GEMPIXCONVERT_SIMD_H_
+
+#include "GemPixUtil.h"
+#include "GemSIMD.h"
+
+// use formulae from http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC30
+/*
+ * [Y] 1 [ 65.738 129.075 25.064 ] [R] [ 16]
+ * [U] = --- * [ -37.945 -74.494 112.439 ] * [G]+[128]
+ * [V] = 256 [ 112.439 -94.154 -18.285 ] [B] [128]
+ *
+ * [R] 1 [ 298.082 0.0 408.583 ] [Y] [ 16]
+ * [G] = --- * [ 298.082 -100.291 -208.120 ] * ([U]-[128])
+ * [B] = 256 [ 298.082 516.411 0.0 ] [V] [128]
+ */
+
+#define YUV_POYNTON
+// here comes something to be afraid of:
+// (probably it would be better to define the matrices as real constant-value matrices)
+// (instead of element-wise)
+
+#ifdef YUV_POYNTON
+# define Y_OFFSET 16
+# define UV_OFFSET 128
+
+// RGB2YUV
+// poynton-values rounded
+# define RGB2YUV_11 66
+# define RGB2YUV_12 129
+# define RGB2YUV_13 25
+# define RGB2YUV_21 -38
+# define RGB2YUV_22 -74
+# define RGB2YUV_23 112
+# define RGB2YUV_31 112
+# define RGB2YUV_32 -94
+# define RGB2YUV_33 -18
+
+// YUV2RGB
+// (we skip _21 and _31 as they are equal to _11)
+#if 0
+// poynton-values rounded
+# define YUV2RGB_11 298
+# define YUV2RGB_12 0
+# define YUV2RGB_13 409
+# define YUV2RGB_22 -100
+# define YUV2RGB_23 -208
+# define YUV2RGB_32 516
+# define YUV2RGB_33 0
+#else
+
+// this is round(256*inv(rgb2yuv/256))
+// so the general error should be smaller
+# define YUV2RGB_11 298
+# define YUV2RGB_12 -1
+# define YUV2RGB_13 409
+# define YUV2RGB_22 -100
+# define YUV2RGB_23 -210
+# define YUV2RGB_32 519
+# define YUV2RGB_33 0
+#endif
+
+#else
+/* the old ones: */
+# define Y_OFFSET 0
+# define UV_OFFSET 128
+// RGB2YUV
+# define RGB2YUV_11 77
+# define RGB2YUV_12 150
+# define RGB2YUV_13 29
+# define RGB2YUV_21 -43
+# define RGB2YUV_22 -85
+# define RGB2YUV_23 128
+# define RGB2YUV_31 128
+# define RGB2YUV_32 -107
+# define RGB2YUV_33 -21
+// YUV2RGB
+# define YUV2RGB_11 256
+# define YUV2RGB_12 0
+# define YUV2RGB_13 359
+# define YUV2RGB_22 -88
+# define YUV2RGB_23 -183
+# define YUV2RGB_32 454
+# define YUV2RGB_33 0
+
+#endif /* POYNTON */
+
+/* AltiVec */
+#ifdef __VEC__
+
+/* there are problems on OSX10.3 with older versions of gcc, since the intrinsic code
+ * below freely changes between signed and unsigned short vectors
+ * newer versions of gcc accept this...
+ * LATER: fix the code (GemPixConvertAltivec:750..800)
+ */
+# ifdef __GNUC__
+/* according to hcs it does NOT work with gcc-3.3
+ * for simplicity, i disable everything below gcc4
+ * JMZ: 20061114
+ */
+# if __GNUC__ < 4
+# warning disabling AltiVec for older gcc: please fix me
+# define NO_VECTORINT_TO_VECTORUNSIGNEDINT
+# endif
+# endif /* GNUC */
+
+
+ void RGB_to_YCbCr_altivec(unsigned char *rgbdata, size_t RGB_size,
+ unsigned char *pixels);
+ void RGBA_to_YCbCr_altivec(unsigned char *rgbadata, size_t RGBA_size,
+ unsigned char *pixels);
+ void BGR_to_YCbCr_altivec(unsigned char *bgrdata, size_t BGR_size,
+ unsigned char *pixels);
+ void BGRA_to_YCbCr_altivec(unsigned char *bgradata, size_t BGRA_size,
+ unsigned char *pixels);
+ void YUV422_to_BGRA_altivec(unsigned char *yuvdata, size_t pixelnum,
+ unsigned char *pixels);
+ void YV12_to_YUV422_altivec(short*Y, short*U, short*V,
+ unsigned char *data, int xsize, int ysize);
+# ifndef NO_VECTORINT_TO_VECTORUNSIGNEDINT
+ void YUV422_to_YV12_altivec(short*pY, short*pY2, short*pU, short*pV,
+ unsigned char *gem_image, int xsize, int ysize);
+# endif
+#endif /* AltiVec */
+
+/* SSE2 */
+#ifdef __SSE2__
+void RGBA_to_UYVY_SSE2(unsigned char *rgbadata,
+ size_t size,
+ unsigned char *yuvdata);
+void UYVY_to_RGBA_SSE2(unsigned char *yuvdata,
+ size_t size,
+ unsigned char *rgbadata);
+void UYVY_to_RGB_SSE2(unsigned char *yuvdata,
+ size_t size,
+ unsigned char *rgbadata);
+#endif /* SSE2 */
+
+/* in case somebody has an old machine... */
+#ifdef __MMX__
+
+#endif /* MMX */
+
+#endif /* INCLUDE_GEMPIXCONVERT_SIMD_H_ */
diff --git a/externals/gridflow/bundled/Base/GemPixDualObj.h b/externals/gridflow/bundled/Base/GemPixDualObj.h
new file mode 100644
index 00000000..ba039e2c
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPixDualObj.h
@@ -0,0 +1,190 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ An object which accepts two pixes.
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ Copyright (c) 2002 James Tittle & Chris Clepper
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMPIXDUALOBJ_H_
+#define INCLUDE_GEMPIXDUALOBJ_H_
+
+#define NEW_DUAL_PIX
+
+#include "Base/GemPixObj.h"
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ GemPixDualObj
+
+ An object which accepts two pixes.
+
+DESCRIPTION
+
+ Inlet for a gem - "gem_right"
+
+ "gem_right" - The second gem list
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN GemPixDualObj : public GemPixObj
+{
+ public:
+
+ //////////
+ // Constructor
+ GemPixDualObj();
+
+ protected:
+
+ //////////
+ // Destructor
+ virtual ~GemPixDualObj();
+
+ void render(GemState *state);
+
+ //////////
+ // Derived classes should NOT override this!
+ // This makes sure that the images are the same size.
+ // This calls the other process functions based on the input images.
+ virtual void processImage(imageStruct &image);
+
+#ifndef NEW_DUAL_PIX
+ //////////
+ // The derived class HAS override this.
+ // This is called whenever a new image comes through and
+ // both of the image structs are RGBA
+ virtual void processDualImage(imageStruct &image, imageStruct &right) = 0;
+
+ //////////
+ // The derived class CAN override this.
+ // This is called whenever a new image comes through and both
+ // of the image structs are gray8.
+ // The default behavior is to output an error.
+ virtual void processDualGray(imageStruct &image, imageStruct &right);
+
+ //////////
+ // The derived class CAN override this.
+ // This is called whenever a new image comes through and
+ // the left image is an RGBA while the right is a gray8.
+ // The default behavior is to output an error.
+ virtual void processRightGray(imageStruct &image, imageStruct &right);
+
+ //////////
+ // The derived class CAN override this.
+ // This is called whenever a new image comes through and
+ // the left image is a gray8, the right is an RGBA
+ // The default behavior is to output an error.
+ virtual void processLeftGray(imageStruct &image, imageStruct &right);
+
+ //////////
+ // The derived class CAN override this.
+ // This is called whenever a new image comes through and both
+ // of the image structs are YUV.
+ // The default behavior is to output an error.
+ virtual void processDualYUV(imageStruct &image, imageStruct &right);
+
+ //////////
+ // The derived class CAN override this.
+ // This is called whenever a new image comes through and
+ // the left image is an RGBA while the right is a YUV.
+ // The default behavior is to output an error.
+ virtual void processRightYUV(imageStruct &image, imageStruct &right);
+
+ //////////
+ // The derived class CAN override this.
+ // This is called whenever a new image comes through and
+ // the left image is a YUV, the right is an RGBA
+ // The default behavior is to output an error.
+ virtual void processLeftYUV(imageStruct &image, imageStruct &right);
+#else
+ //////////
+ // The derived class SHOULD override this, if it provides a method for "all" formats
+ virtual void processDualImage(imageStruct &left, imageStruct &right);
+ // Here come the more specific dual-processors
+ // The derived class SHOULD override these as needed
+
+ /* for simplicity this is done via preprocessor defines:
+ * the functions defined are like :
+ ** processRGBA_RGBA(left, right);
+ */
+
+#define PROCESS_DUALIMAGE(CS1, CS2) \
+ virtual void process##CS1 ##_##CS2 (imageStruct &left, imageStruct &right){processDualImage(left, right);}
+ PROCESS_DUALIMAGE(RGBA, RGBA);
+ PROCESS_DUALIMAGE(RGBA, Gray);
+ PROCESS_DUALIMAGE(RGBA, YUV );
+
+ PROCESS_DUALIMAGE(Gray, RGBA);
+ PROCESS_DUALIMAGE(Gray, Gray);
+ PROCESS_DUALIMAGE(Gray, YUV );
+
+ PROCESS_DUALIMAGE(YUV, RGBA);
+ PROCESS_DUALIMAGE(YUV, Gray);
+ PROCESS_DUALIMAGE(YUV, YUV );
+#undef PROCESS_DUALIMAGE
+
+ /* for simplicity this is done via preprocessor defines:
+ * the functions defined are like :
+ ** processRGBA_Altivec(left, right);
+ */
+#define PROCESS_DUALIMAGE_SIMD(CS1, CS2,_SIMD_EXT) \
+ virtual void process##CS1 ##_##_SIMD_EXT (imageStruct &left, imageStruct &right){ \
+ process##CS1 ##_##CS2 (left, right);}
+
+ PROCESS_DUALIMAGE_SIMD(RGBA, RGBA, MMX);
+ PROCESS_DUALIMAGE_SIMD(RGBA, MMX , SSE2);
+ PROCESS_DUALIMAGE_SIMD(RGBA, RGBA, Altivec);
+
+ PROCESS_DUALIMAGE_SIMD(YUV , YUV , MMX);
+ PROCESS_DUALIMAGE_SIMD(YUV , MMX , SSE2);
+ PROCESS_DUALIMAGE_SIMD(YUV , YUV , Altivec);
+
+ PROCESS_DUALIMAGE_SIMD(Gray, Gray, MMX);
+ PROCESS_DUALIMAGE_SIMD(Gray, MMX , SSE2);
+ PROCESS_DUALIMAGE_SIMD(Gray, Gray, Altivec);
+#undef PROCESS_DUALIMAGE_SIMD
+
+#endif
+ //////////
+ virtual void postrender(GemState *);
+ virtual void stopRendering();
+ virtual void rightstopRendering() { ; }
+ virtual void rightRender(GemState *state);
+ virtual void rightPostrender(GemState *) { ; }
+ virtual void rightStoprender() { ; }
+
+ //////////
+ GemCache *m_cacheRight;
+
+ //////////
+ pixBlock *m_pixRight;
+
+ int m_pixRightValid;
+ int org_pixRightValid;
+
+ //////////
+ t_inlet *m_inlet;
+
+ //////////
+ // creation callback
+ static void real_obj_setupCallback(t_class *classPtr)
+ { GemPixObj::real_obj_setupCallback(classPtr); GemPixDualObj::obj_setupCallback(classPtr); }
+
+ private:
+
+ static inline GemPixDualObj *GetMyClass(void *data) {return((GemPixDualObj *)((Obj_header *)data)->data);}
+
+ //////////
+ // Static member functions
+ static void obj_setupCallback(t_class *classPtr);
+ static void gem_rightMessCallback(void *x, t_symbol *s, int argc, t_atom *argv);
+};
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemPixImageLoad.h b/externals/gridflow/bundled/Base/GemPixImageLoad.h
new file mode 100644
index 00000000..5274e692
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPixImageLoad.h
@@ -0,0 +1,37 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ GemPixImageLoad.h
+ - code to load in and resize an image
+ - part of GEM
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMPIXIMAGELOAD_H_
+#define INCLUDE_GEMPIXIMAGELOAD_H_
+
+#include "Base/GemExportDef.h"
+
+struct imageStruct;
+
+// image2mem() reads an image file into memory
+// and a pointer to an imageStruct
+// NULL = failure
+//
+// format:
+// returns either GL_LUMINANCE or GL_RGBA
+//
+// automatically allocates the memory for the user
+//
+// This can read TIFF, SGI, and JPG images
+//
+GEM_EXTERN extern imageStruct *image2mem(const char *filename);
+
+#endif
diff --git a/externals/gridflow/bundled/Base/GemPixImageSave.h b/externals/gridflow/bundled/Base/GemPixImageSave.h
new file mode 100644
index 00000000..ccbe91ae
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPixImageSave.h
@@ -0,0 +1,38 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Gempiximagesave.h
+ - code to save an image
+ - part of GEM
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMPIXIMAGESAVE_H_
+#define INCLUDE_GEMPIXIMAGESAVE_H_
+
+#include "Base/GemExportDef.h"
+
+struct imageStruct;
+
+// image2mem() reads an image file into memory
+// and a pointer to an imageStruct
+// NULL = failure
+//
+// format:
+// returns either GL_LUMINANCE or GL_RGBA
+//
+// automatically allocates the memory for the user
+//
+// This can read TIFF, SGI, and JPG images
+//
+GEM_EXTERN extern int mem2image(imageStruct *image, const char *filename, const int type);
+
+
+#endif
diff --git a/externals/gridflow/bundled/Base/GemPixObj.h b/externals/gridflow/bundled/Base/GemPixObj.h
new file mode 100644
index 00000000..5d9073c7
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPixObj.h
@@ -0,0 +1,142 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Base class for pix class gem objects
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMPIXOBJ_H_
+#define INCLUDE_GEMPIXOBJ_H_
+
+#include "Base/GemBase.h"
+#include "Base/GemPixUtil.h"
+#include "stdlib.h"
+#include "string.h"
+#include "math.h"
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ GemPixObj
+
+ Base class for pix class gem objects
+
+DESCRIPTION
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN GemPixObj : public GemBase
+{
+ public:
+
+ //////////
+ // Constructor
+ GemPixObj();
+
+ protected:
+
+ //////////
+ // Destructor
+ virtual ~GemPixObj() { }
+
+ //////////
+ // The derived class should override this if it provides
+ // processing independent of the image.format
+ // This is called whenever a new image comes through.
+ // The default is to output an error
+ virtual void processImage(imageStruct &image);
+
+ //////////
+ // The derived class should override this.
+ // This is called whenever a new RGB image comes through.
+ // The default is to call processImage().
+ virtual void processRGBImage(imageStruct &image);
+
+ //////////
+ // The derived class should override this.
+ // This is called whenever a new RGBA image comes through.
+ // The default is to call processImage().
+ virtual void processRGBAImage(imageStruct &image);
+ // SIMD-optimized functions: by default the non-optimized function is called
+ virtual void processRGBAMMX(imageStruct &image);
+ virtual void processRGBASSE2(imageStruct &image);
+ virtual void processRGBAAltivec(imageStruct &image);
+
+ //////////
+ // The derived class should override this.
+ // This is called whenever a new gray8 image comes through.
+ // The default is to call processImage().
+ virtual void processGrayImage(imageStruct &image);
+ // SIMD-optimized functions: by default the non-optimized function is called
+ virtual void processGrayMMX(imageStruct &image);
+ virtual void processGraySSE2(imageStruct &image);
+ virtual void processGrayAltivec(imageStruct &image);
+
+ //////////
+ // The derived class should override this.
+ // This is called whenever a new YUV422 image comes through.
+ // The default is to call processImage().
+ virtual void processYUVImage(imageStruct &image);
+ // SIMD-optimized functions: by default the non-optimized function is called
+ virtual void processYUVMMX(imageStruct &image);
+ virtual void processYUVSSE2(imageStruct &image);
+ virtual void processYUVAltivec(imageStruct &image);
+
+ //////////
+ // If the derived class needs the image resent.
+ // This sets the dirty bit on the pixBlock.
+ void setPixModified();
+
+ //////////
+ // Turn on/off processing
+ void processOnOff(int on);
+
+ //////////
+ // the pixBlock-cache
+ pixBlock cachedPixBlock;
+ pixBlock *orgPixBlock;
+
+ //////////
+ int m_processOnOff;
+ int m_simd;
+
+ //////////
+ // creation callback
+ static void real_obj_setupCallback(t_class *classPtr) {
+ GemBase::real_obj_setupCallback(classPtr);
+ GemPixObj::obj_setupCallback(classPtr);
+ }
+
+ //////////
+ // The derived class should NOT override this unless they have some
+ // very special behavior.
+ // Do the rendering, which calls processImage or processGrayImage, etc...
+ // save the image-information
+ virtual void render(GemState *state);
+ // turn the pointer back to the old data after rendering
+ virtual void postrender(GemState *state);
+
+ void startRendering(void) {
+ //post("start rendering");
+ setPixModified();
+ }
+
+ private:
+
+ static inline GemPixObj *GetMyClass(void *data) {return((GemPixObj *)((Obj_header *)data)->data);}
+
+ //////////
+ // static member functions
+ static void obj_setupCallback(t_class *classPtr);
+ static void floatMessCallback(void *data, float n);
+ static void simdMessCallback(void *data, float n);
+};
+
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemPixPete.h b/externals/gridflow/bundled/Base/GemPixPete.h
new file mode 100644
index 00000000..be3c2e19
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPixPete.h
@@ -0,0 +1,219 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ helper stuff for ports of Pete's Plugins
+
+ http://www.petewarden.com
+
+ Copyright (c) 2004 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+#ifndef INCLUDE_GEMPIXPETE_H_
+#define INCLUDE_GEMPIXPETE_H_
+
+
+// utility functions from PeteHelpers.h
+typedef unsigned long U32;
+typedef unsigned short U16;
+typedef unsigned char U8;
+
+
+/* is this only on my system ?
+ i thought Gem's YUV is UYVY and not YVYU
+ seems weird... (jmz)
+*/
+#ifdef __APPLE__
+
+# define SHIFT_ALPHA (24)
+# define SHIFT_RED (16)
+# define SHIFT_GREEN (8)
+# define SHIFT_BLUE (0)
+
+# define SHIFT_U (24)
+# define SHIFT_Y1 (16)
+# define SHIFT_V (8)
+# define SHIFT_Y2 (0)
+
+#else
+
+# define SHIFT_ALPHA (24)
+# define SHIFT_RED (16)
+# define SHIFT_GREEN (8)
+# define SHIFT_BLUE (0)
+
+# define SHIFT_U (0)
+# define SHIFT_Y1 (8)
+# define SHIFT_V (16)
+# define SHIFT_Y2 (24)
+#endif
+
+const float Pete_Pi=3.141582f;
+const float Pete_TwoPi=(2.0f*Pete_Pi);
+const float Pete_HalfPi=(0.5f*Pete_Pi);
+
+static inline void Pete_ZeroMemory(void* pMemory,int nCount) {
+ char* pCurrent=(char*)pMemory;
+ char* pEnd=(pCurrent+nCount);
+ // while (pCurrent<pEnd) *pCurrent=0;
+ // pCurrent+=1;
+ // }
+ while(pCurrent<pEnd)*pCurrent++=0;
+// memset(pMemory,0,nCount);
+}
+
+typedef U32 PETE_PIXELDATA32;
+#define SIZEOF_PETE_PIXELDATA32 (4)
+
+typedef U32 PETE_PIXELDATA24;
+#define SIZEOF_PETE_PIXELDATA24 (3)
+
+typedef U16 PETE_PIXELDATA16;
+#define SIZEOF_PETE_PIXELDATA16 (2)
+
+static inline void Pete_CopyAndConvert24BitTo32Bit(PETE_PIXELDATA24* pSource,PETE_PIXELDATA32* pOutput,int nPixelCount) {
+
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA24);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
+
+ while (pCurrentSource<pSourceEnd) {
+ *((PETE_PIXELDATA32*)pCurrentOutput)=
+ *((PETE_PIXELDATA24*)pCurrentSource);
+
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA24;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA32;
+ }
+}
+
+static inline void Pete_CopyAndConvert32BitTo24Bit(PETE_PIXELDATA32* pSource,PETE_PIXELDATA24* pOutput,int nPixelCount) {
+
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA32);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
+
+ while (pCurrentSource<pSourceEnd) {
+ *((PETE_PIXELDATA24*)pCurrentOutput)=
+ *((PETE_PIXELDATA32*)pCurrentSource);
+
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA32;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA24;
+ }
+}
+
+static inline void Pete_InPlaceConvert24BitTo32Bit(PETE_PIXELDATA24* pBuffer,int nPixelCount) {
+ char* pBufferStart=(char*)pBuffer;
+
+ char* pBuffer32Current=(pBufferStart+((nPixelCount-1)*SIZEOF_PETE_PIXELDATA32));
+ char* pBuffer24Current=(pBufferStart+((nPixelCount-1)*SIZEOF_PETE_PIXELDATA24));
+
+ while (pBuffer32Current>=pBufferStart) {
+
+ *((PETE_PIXELDATA32*)pBuffer32Current)=
+ *((PETE_PIXELDATA24*)pBuffer24Current);
+
+ pBuffer32Current-=SIZEOF_PETE_PIXELDATA32;
+ pBuffer24Current-=SIZEOF_PETE_PIXELDATA24;
+ }
+}
+
+static inline void Pete_CopyAndConvert16Bit565To32Bit(PETE_PIXELDATA16* pSource,PETE_PIXELDATA32* pOutput,int nPixelCount) {
+
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA16);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
+
+ while (pCurrentSource<pSourceEnd) {
+
+ PETE_PIXELDATA16 SourceColour=
+ *((PETE_PIXELDATA16*)pCurrentSource);
+
+ const int nMaskedRed=(SourceColour>>11)&31;
+ const int nMaskedGreen=(SourceColour>>5)&63;
+ const int nMaskedBlue=(SourceColour>>0)&31;
+
+ const int nNormalizedRed=(nMaskedRed<<3)|(nMaskedRed>>2);
+ const int nNormalizedGreen=(nMaskedGreen<<2)|(nMaskedGreen>>4);
+ const int nNormalizedBlue=(nMaskedBlue<<3)|(nMaskedBlue>>2);
+
+ const PETE_PIXELDATA32 OutputColour=
+ (nNormalizedRed<<16)|
+ (nNormalizedGreen<<8)|
+ (nNormalizedBlue<<0);
+
+ *((PETE_PIXELDATA32*)pCurrentOutput)=OutputColour;
+
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA16;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA32;
+
+ }
+
+}
+
+static inline void Pete_CopyAndConvert32BitTo16Bit565(PETE_PIXELDATA32* pSource,PETE_PIXELDATA16* pOutput,int nPixelCount) {
+
+ char* pSourceEnd=((char*)pSource)+(nPixelCount*SIZEOF_PETE_PIXELDATA32);
+ char* pCurrentSource=((char*)pSource);
+ char* pCurrentOutput=((char*)pOutput);
+
+ while (pCurrentSource<pSourceEnd) {
+
+ PETE_PIXELDATA32 SourceColour=
+ *((PETE_PIXELDATA32*)pCurrentSource);
+
+ const int nSourceRed=(SourceColour>>16)&0xff;
+ const int nSourceGreen=(SourceColour>>8)&0xff;
+ const int nSourceBlue=(SourceColour>>0)&0xff;
+
+ const int nMaskedRed=(nSourceRed>>3);
+ const int nMaskedGreen=(nSourceGreen>>2);
+ const int nMaskedBlue=(nSourceBlue>>3);
+
+ PETE_PIXELDATA16 OutputColour=
+ (nMaskedRed<<11)|
+ (nMaskedGreen<<5)|
+ (nMaskedBlue<<0);
+
+ *((PETE_PIXELDATA16*)pCurrentOutput)=OutputColour;
+
+ pCurrentSource+=SIZEOF_PETE_PIXELDATA32;
+ pCurrentOutput+=SIZEOF_PETE_PIXELDATA16;
+ }
+}
+typedef void* SPete_MemHandle;
+
+inline SPete_MemHandle Pete_NewHandle(int nBytesToAlloc) {
+ return malloc(nBytesToAlloc);
+}
+
+inline void Pete_FreeHandle(SPete_MemHandle InHandle) {
+ free(InHandle);
+}
+
+inline void* Pete_LockHandle(SPete_MemHandle InHandle) {
+ return InHandle;
+}
+
+inline void Pete_UnLockHandle(SPete_MemHandle InHandle) {
+ // do nothing
+}
+
+const int cnBiggestSignedInt=0x7fffffff;
+
+inline int GetLuminance(const U32 inColour) {
+ const int nRed=(inColour&(0xff<<SHIFT_RED))>>16;
+ const int nGreen=(inColour&(0xff<<SHIFT_GREEN))>>8;
+ const int nBlue=(inColour&(0xff<<SHIFT_BLUE))>>0;
+
+ const int nLuminance =
+ ((77 * nRed)+
+ (150* nGreen)+ // used to be 50 which is plain wron
+ (29 * nBlue));
+
+ return nLuminance;
+}
+
+#endif /* INCLUDE_GEMPIXPETE_H_ */
+// end of PeteHelpers.h stuff
diff --git a/externals/gridflow/bundled/Base/GemPixUtil.h b/externals/gridflow/bundled/Base/GemPixUtil.h
new file mode 100644
index 00000000..88ef0afc
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemPixUtil.h
@@ -0,0 +1,284 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ GemPixUtil.h
+ - contains image functions for pix objects
+ - part of GEM
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMPIXUTIL_H_
+#define INCLUDE_GEMPIXUTIL_H_
+
+#include "Base/GemGL.h"
+
+#ifdef __APPLE__
+# include <QuickTime/QuickTime.h>
+#endif // __APPLE__
+
+#include <string.h>
+#include <stdlib.h>
+
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Color component defines
+//
+// These should be used to reference the various color channels
+///////////////////////////////////////////////////////////////////////////////
+
+/* RGBA */
+
+#if GL_RGBA_GEM == GL_RGBA
+const int chRed = 0;
+const int chGreen = 1;
+const int chBlue = 2;
+const int chAlpha = 3;
+#else
+const int chAlpha = 0;
+const int chRed = 1;
+const int chGreen = 2;
+const int chBlue = 3;
+#endif
+
+
+/* Gray */
+const int chGray = 0;
+
+/* YUV422 */
+const int chU = 0;
+const int chY0 = 1;
+const int chV = 2;
+const int chY1 = 3;
+
+// basic helper functions, like CLAMP and powerOfTwo
+#include "Base/GemFuncUtil.h"
+
+// utility functions from PeteHelpers.h
+#include "Base/GemPixPete.h"
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ imageStruct
+
+ The basic image structure
+
+-----------------------------------------------------------------*/
+// we now have a class "imageStruct";
+// since i need to compile some of the sources with an older version of Gem
+// there is a new define here:
+#define IMAGE_CLASS
+
+struct GEM_EXTERN imageStruct
+{
+ imageStruct();
+ ~imageStruct();
+
+ void info();
+ //////////
+ // columns
+ unsigned char* allocate(size_t size);
+ unsigned char* allocate();
+
+ // if we have allocated some space already, only re-allocate when needed.
+ unsigned char* reallocate(size_t size);
+ unsigned char* reallocate();
+
+ // delete the buffer (if it is ours)
+ void clear();
+
+
+ //////////
+ // dimensions of the image
+ GLint xsize;
+ GLint ysize;
+
+ //////////
+ // (average) width of 1 pixel (LUMINANCE = 1, RGBA = 4, YUV = 2)
+ GLint csize;
+
+ //////////
+ // data type - always GL_UNSIGNED_BYTE (except for OS X)
+ GLenum type;
+
+ //////////
+ // the format - either GL_RGBA, GL_LUMINANCE
+ // or GL_YCBCR_422_GEM (which is on mac-computers GL_YCBCR_422_APPLE)
+ GLenum format;
+
+ //////////
+ // is this owned by us (? what about underscores ?)
+ int notowned;
+
+ //////////
+ // gets a pixel
+ /* X,Y are the coordinates
+ * C is the offset in the interleaved data (like chRed==0 for red)
+ * you should use chRed instead of 0 (because it might not be 0)
+ */
+ // heck, why are X&Y swapped ?? (JMZ)
+ inline unsigned char GetPixel(int Y, int X, int C)
+ { return(data[Y * xsize * csize + X * csize + C]); }
+
+ //////////
+ // sets a pixel
+ /* while X and Y should be clear (coordinates),
+ * C is the offset (like chRed==0 for red).
+ * VAL is the value to set.
+ */
+ inline void SetPixel(int Y, int X, int C, unsigned char VAL)
+ { data[Y * xsize * csize + X * csize + C] = VAL; }
+
+
+ /////////
+ // gets the color of a pixel
+ void getRGB(int X, int Y, unsigned char*r, unsigned char*g, unsigned char*b);
+ void getGrey(int X, int Y, unsigned char*g);
+ void getYUV(int X, int Y, unsigned char*y, unsigned char*u, unsigned char*v);
+
+ /* following will set the whole image-data to either black or white
+ * the size of the image-data is NOT xsize*ysize*csize but datasize
+ * this is mostly slower
+ * i have put the datasize into private (like pdata) (bad idea?)
+ */
+ void setBlack();
+ void setWhite();
+
+ /* certain formats are bound to certain csizes,
+ * it's quite annoying to have to think again and again (ok, not much thinking)
+ * so we just give the format (like GL_LUMINANCE)
+ * and it will set the image format to this format
+ * and set and return the correct csize (like 1)
+ * if no format is given the current format is used
+ */
+ int setCsizeByFormat(int format);
+ int setCsizeByFormat();
+
+
+ /* various copy functions
+ * sometimes we want to copy the whole image (including pixel-data),
+ * but often it is enough to just copy the meta-data (without pixel-data)
+ * into a new imageStruct
+ */
+ void copy2Image(imageStruct *to);
+ void copy2ImageStruct(imageStruct *to); // copy the imageStruct (but not the actual data)
+ /* this is a sort of better copy2Image,
+ * which only copies the imageStruct-data if it is needed
+ */
+ void refreshImage(imageStruct *to);
+
+ /* inplace swapping Red and Blue channel */
+ void swapRedBlue ();
+
+
+ ///////////////////////////////////////////////////////////////////////////////
+ // acquiring data including colour-transformations
+ // should be accelerated if possible
+ /* i wonder whether this is the right place to put these routines
+ * they should be stored somewhere centrally
+ * (because maybe a lot of objects would like them) (like [pix_rgba]...)
+ * but it might be better to put them (the actual conversion routines) into
+ * separate files (a separate library?)
+ * orgdata points to the actual data in the given format
+ * the datasize will be read from image.xsize, image.ysize
+ * the dest-format will be given by image.format
+ * this is maybe not really clean (the meta-data is stored in the destination,
+ * while the source has no meta-data of its own)
+ */
+ void convertTo (imageStruct*to, GLenum dest_format=0);
+ void convertFrom(imageStruct*from, GLenum dest_format=0);
+
+ void fromRGB (unsigned char* orgdata);
+ void fromRGBA (unsigned char* orgdata);
+ void fromBGR (unsigned char* orgdata);
+ void fromBGRA (unsigned char* orgdata);
+ void fromRGB16 (unsigned char* orgdata);
+ void fromGray (unsigned char* orgdata);
+ void fromGray (short* orgdata);
+ void fromUYVY (unsigned char* orgdata);
+ void fromYUY2 (unsigned char* orgdata); // YUYV
+ void fromYVYU (unsigned char* orgdata);
+ /* planar YUV420: this is rather generic and not really YV12 only */
+ void fromYV12 (unsigned char* Y, unsigned char*U, unsigned char*V);
+ /* assume that the planes are near each other: YVU */
+ void fromYV12 (unsigned char* orgdata);
+ /* assume that the planes are near each other: YVU */
+ void fromYU12 (unsigned char* orgdata);
+ /* overloading the above two in order to accept pdp YV12 packets */
+ void fromYV12 (short* Y, short*U, short*V);
+ void fromYV12 (short* orgdata);
+
+ /* aliases */
+ void fromYUV422 (unsigned char* orgdata){fromUYVY(orgdata);}
+ void fromYUV420P(unsigned char* orgdata){fromYV12(orgdata);}
+ void fromYUV420P(unsigned char*Y,unsigned char*U,unsigned char*V){fromYV12(Y,U,V);}
+
+ // "data" points to the image.
+ // the memory could(!) be reserved by this class or someone else
+ // "notowned" should be set to "1", if "data" points to foreign memory
+ // "data" is not freed directly, when the destructor is called
+ unsigned char *data; // the pointer to the data
+ private:
+ // "pdata" is the private data, and is the memory reserved by this class
+ // this data is freed when the destructor is called
+ unsigned char *pdata;
+ // "datasize" is the size of data reserved at "pdata"
+ size_t datasize;
+
+ public:
+ //////////
+ // true if the image is flipped horizontally (origin is upper-left)
+ // false if the image is openGL-conformant (origin is lower-left)
+ GLboolean upsidedown;
+
+};
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ pixBlock
+
+ The pix block structure
+
+-----------------------------------------------------------------*/
+struct GEM_EXTERN pixBlock
+{
+ pixBlock();
+
+ //////////
+ // the block's image
+ imageStruct image;
+
+ //////////
+ // is this a newimage since last time?
+ // ie, has it been refreshed
+ int newimage;
+
+ //////////
+ // keeps track of when new films are loaded
+ // useful for rectangle_textures on OSX
+ int newfilm;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// imageStruct utility functions
+//
+///////////////////////////////////////////////////////////////////////////////
+//////////
+// copies all of the data over and mallocs memory
+GEM_EXTERN extern void copy2Image(imageStruct *to, imageStruct *from);
+
+//////////
+// assumes that it only has to refresh the data
+GEM_EXTERN extern void refreshImage(imageStruct *to, imageStruct *from);
+
+GEM_EXTERN extern int getPixFormat(char*);
+#endif // GEMPIXUTIL_H_
diff --git a/externals/gridflow/bundled/Base/GemSIMD.h b/externals/gridflow/bundled/Base/GemSIMD.h
new file mode 100644
index 00000000..32cdb32a
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemSIMD.h
@@ -0,0 +1,111 @@
+
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ include file for SIMD
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+/*
+ * compiler-issues:
+ *
+ * gcc: when gcc is invoked with "-mmmx" (or "-msse2" or "-maltivec")
+ * the defines __MMX__ (or corresponding) will be defined automatically
+ *
+ * vc6: you will have to install the microsoft processor-pack to use MMX/SSE2
+ * you have to have the sp5 for vc6 installed (note: do not install sp6!!)
+ * vc6/vc7: (i think) you need to define __MMX__ (and friends) by hand
+ */
+
+#ifndef INCLUDE_GEMSIMD_H_
+#define INCLUDE_GEMSIMD_H_
+
+#define GEM_VECTORALIGNMENT 128
+
+const int GEM_SIMD_NONE=0;
+const int GEM_SIMD_MMX=1;
+const int GEM_SIMD_SSE2=2;
+const int GEM_SIMD_ALTIVEC=3;
+
+
+/* include for SIMD on PC's */
+#ifdef __SSE2__
+#include <emmintrin.h>
+// for icc this should be <dvec.h>
+typedef union{
+ unsigned char c[16];
+ __m128i v;
+} vector_128;
+#elif defined __VEC__
+/* for AltiVec (PowerPC) */
+typedef union{
+ unsigned char c[16];
+ vector unsigned char v;
+} vector_128;
+#endif
+
+#if defined __MMX__
+# include <mmintrin.h>
+// for icc this should be <ivec.h>
+typedef union{
+ __m64 v; unsigned char c[8];
+} vector64i;
+
+#endif
+
+
+#ifdef __SSE__
+#include <xmmintrin.h>
+
+typedef union{
+ __m128 m; float f[4];
+} vector128f;
+#endif
+
+#include "GemExportDef.h"
+
+
+/* this is a help-class to query the capabilities of the cpu
+ * whenever you want to use SIMD-optimized code, you should
+ * make sure you chose the code-block based on the "cpuid" value
+ * of this class and NOT simply on preprocessor defines.
+ *
+ * this class needs only be instantiated once (and it is done in GemMan)
+ * this sets the cpuid
+ */
+class GEM_EXTERN GemSIMD
+{
+ public:
+ GemSIMD();
+ ~GemSIMD();
+
+ /* this gets the "cpuid" (something like GEM_SIMD_NONE) */
+ static int getCPU();
+
+ /* change the cpuid returned by getCPU()
+ * you can only set the cpuid to something that is actually supported
+ * by your processor
+ */
+ static int requestCPU(int cpuid);
+
+ /* performs a runtime-check (if possible) to determine the capabilities
+ * of the CPU
+ * sets realcpuid appropriately and returns this value
+ */
+ static int simd_runtime_check(void);
+
+ private:
+ /* this is the maximum capability of the CPU */
+ static int realcpuid;
+ /* this is the current choosen capability (normally this equals realcpuid) */
+ static int cpuid;
+};
+
+#endif /* INCLUDE_GEMSIMD_H_ */
diff --git a/externals/gridflow/bundled/Base/GemShape.h b/externals/gridflow/bundled/Base/GemShape.h
new file mode 100644
index 00000000..101c975d
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemShape.h
@@ -0,0 +1,115 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ Base class for shapes
+
+ Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMSHAPE_H_
+#define INCLUDE_GEMSHAPE_H_
+
+#include "Base/GemBase.h"
+
+/*-----------------------------------------------------------------
+-------------------------------------------------------------------
+CLASS
+ GemShape
+
+ Base class for shapes
+
+DESCRIPTION
+
+ Inlet for a float - "ft1"
+
+ "ft1" - the size of the shape
+ "draw" - the drawing style
+ "width" - the line width when drawing with lines
+
+-----------------------------------------------------------------*/
+class GEM_EXTERN GemShape : public GemBase
+{
+ public:
+
+ //////////
+ // Constructor
+ // [in] size - A size of 0. means to just use the default (ie, 1.)
+ GemShape(t_floatarg size);
+ GemShape();
+
+ protected:
+
+ //////////
+ // Destructor
+ virtual ~GemShape();
+
+ //-----------------------------------
+ // GROUP: Access functions
+ //-----------------------------------
+
+ //////////
+ // The width of the lines in line draw mode
+ void linewidthMess(float linewidth);
+
+ //////////
+ // The size of the object
+ void sizeMess(float size);
+
+ //////////
+ // How the object should be drawn
+ virtual void typeMess(t_symbol *type);
+
+ //-----------------------------------
+ // GROUP: Utility functions
+ //-----------------------------------
+
+ void SetVertex(GemState* state,float x, float y, float z, float tx, float ty,int curCoord);
+
+ //-----------------------------------
+ // GROUP: Member variables
+ //-----------------------------------
+
+ //////////
+ // The line width for GL_LINE mode
+ GLfloat m_linewidth;
+
+ //////////
+ // The size of the object
+ GLfloat m_size;
+
+ //////////
+ // The drawing style (GL_LINE, GL_POLYGON, etc)
+ GLenum m_drawType;
+
+ //////////
+ // The size inlet
+ t_inlet *m_inlet;
+
+ //-----------------------------------
+ // GROUP: Setup functions
+ //-----------------------------------
+
+ //////////
+ // creation callback
+ static void real_obj_setupCallback(t_class *classPtr)
+ { GemBase::real_obj_setupCallback(classPtr); GemShape::obj_setupCallback(classPtr); }
+
+ private:
+
+ static inline GemShape *GetMyClass(void *data) {return((GemShape *)((Obj_header *)data)->data);}
+
+ //////////
+ // static member functions
+ static void obj_setupCallback(t_class *classPtr);
+ static void linewidthMessCallback(void *data, t_floatarg linewidth);
+ static void typeMessCallback(void *data, t_symbol *type);
+ static void sizeMessCallback(void *data, t_floatarg size);
+};
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemState.h b/externals/gridflow/bundled/Base/GemState.h
new file mode 100644
index 00000000..b41d2ee3
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemState.h
@@ -0,0 +1,150 @@
+/*-----------------------------------------------------------------
+ LOG
+ GEM - Graphics Environment for Multimedia
+
+ The state to pass among GEM objects
+
+ Copyright (c) 1997-2000 Mark Danks. mark@danks.org
+ Copyright (c) Günther Geiger. geiger@epy.co.at
+ Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+ -----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMSTATE_H_
+#define INCLUDE_GEMSTATE_H_
+
+#include "Base/GemExportDef.h"
+#include "Base/GemGL.h"
+
+struct pixBlock;
+class TexCoord;
+
+/*-----------------------------------------------------------------
+ -------------------------------------------------------------------
+ CLASS
+ TexCoord
+
+
+ DESCRIPTION
+
+ -----------------------------------------------------------------*/
+class GEM_EXTERN TexCoord
+{
+ public:
+ TexCoord() : s(0.f), t(0.f) { }
+ TexCoord(float s_, float t_) : s(s_), t(t_) { }
+ float s;
+ float t;
+};
+
+
+/*-----------------------------------------------------------------
+ -------------------------------------------------------------------
+ CLASS
+ GemState
+
+ The state to pass among GEM objects
+
+ DESCRIPTION
+
+ -----------------------------------------------------------------*/
+class GEM_EXTERN GemState
+{
+ public:
+
+ //////////
+ // Has something changed since the last time?
+ int dirty;
+
+ //////////
+ // Are we in a display list creation?
+ int inDisplayList;
+
+ //////////
+ // Lighting on?
+ int lighting;
+
+ //////////
+ // Smooth shading (flat is other type)
+ int smooth;
+
+ //////////
+ // Texture mapping on?
+ // 0..off
+ // 1..normalized texture
+ // 2..rectangle texture
+ int texture;
+
+ //////////
+ // The image to texture map
+ pixBlock *image;
+
+ //////////
+ // Texture coordinates.
+ // This can be NULL if there aren't any coordinates
+ TexCoord *texCoords;
+
+ //////////
+ // The number of TexCoords
+ int numTexCoords;
+
+ //////////
+ // The number of multiTexUnits
+ // default = 0, max = 7
+ int multiTexUnits;
+
+ //////////
+ // Milliseconds since last frame
+ // If in Stereoscopic mode, then it is the same number for both left
+ // and right renderings
+ float tickTime;
+
+ //////////////////
+ // the default draw-type (might be overriden within a Geo)
+ GLenum drawType;
+
+ //////////
+ // how deep is the current stack /* 4 fields for the 4 stacks */
+ int stackDepth[4];
+
+ ////////////
+ //vertex-array data
+ int VertexDirty; // the vertex-arrays has changed
+
+ GLfloat *VertexArray;
+ int VertexArraySize;
+ int VertexArrayStride;
+
+ GLfloat *ColorArray;
+ int HaveColorArray;
+
+ GLfloat *NormalArray;
+ int HaveNormalArray;
+
+ GLfloat *TexCoordArray;
+ int HaveTexCoordArray;
+
+ //////////
+ // Constructor
+ GemState();
+
+ float texCoordX(int num) {
+ if (texture && numTexCoords > num)
+ return texCoords[num].s;
+ else return 0.;
+ }
+
+ float texCoordY(int num) {
+ if (texture && numTexCoords > num)
+ return texCoords[num].t;
+ else return 0.;
+ }
+
+ /* reset (parts of?) the GemState: to be called from [gemhead] */
+ void reset();
+
+};
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/GemVector.h b/externals/gridflow/bundled/Base/GemVector.h
new file mode 100644
index 00000000..ce000833
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemVector.h
@@ -0,0 +1,77 @@
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ vector-classes
+
+ zmoelnig@iem.at, tigital@mac.com
+
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMVECTOR_H_
+#define INCLUDE_GEMVECTOR_H_
+
+#include "Base/GemExportDef.h"
+
+
+
+// This is our 2D point class. This will be used to store the UV coordinates.
+class GEM_EXTERN CVector2 {
+public:
+ float x, y;
+};
+
+
+// This is our basic 3D point/vector class
+class GEM_EXTERN CVector3 {
+public:
+ // the elements of a vector:
+ float x, y, z;
+
+ // A default constructor
+ CVector3();
+
+ // This is our constructor that allows us to initialize our data upon creating an instance
+ CVector3(float X, float Y, float Z);
+
+ // Here we overload the + operator so we can add vectors together
+ CVector3 operator+(CVector3 vVector);
+
+ // Here we overload the - operator so we can subtract vectors
+ CVector3 operator-(CVector3 vVector);
+
+ // Here we overload the - operator so we can negate the vector
+ CVector3 operator-();
+
+ // Here we overload the * operator so we can multiply by scalars
+ CVector3 operator*(float num);
+
+ // Here we overload the * operator so we can dot-multiply
+ float operator*(CVector3 vVector);
+
+ // cross-multiplication
+ CVector3 cross(CVector3 vVector);
+
+ // Here we overload the / operator so we can divide by a scalar
+ CVector3 operator/(float num);
+
+
+ // here we calculate the absolute-value of the vector
+ float abs();
+
+ // here we calculate the square of the absolute-value of the vector
+ float abs2();
+
+ // here we normalize the vector
+ CVector3 normalize();
+
+ // here we compare 2 vectors on approx. equality
+ bool equals(CVector3 vVector, float epsilon);
+
+
+};
+
+#endif /* INCLUDE_GEMVECTOR_H_ */
diff --git a/externals/gridflow/bundled/Base/GemVersion.h b/externals/gridflow/bundled/Base/GemVersion.h
new file mode 100644
index 00000000..926407f0
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemVersion.h
@@ -0,0 +1,30 @@
+#ifndef GEM_VERSION_H
+#define GEM_VERSION_H
+
+#define GEM_VERSION_MAJOR 0
+#define GEM_VERSION_MINOR 91
+#define GEM_VERSION_BUGFIX 0
+#define GEM_VERSION_CODENAME "'tigital'"
+
+
+#define STRINGIFY2(x) #x
+#define STRINGIFY(x) STRINGIFY2(x)
+
+static const char *GEM_VERSION = \
+ "" STRINGIFY(GEM_VERSION_MAJOR) \
+ "." STRINGIFY(GEM_VERSION_MINOR) \
+ "." STRINGIFY(GEM_VERSION_BUGFIX) \
+ " " GEM_VERSION_CODENAME;
+
+
+static const char *GEM_MAINTAINER = "IOhannes m zmoelnig";
+
+static const char *GEM_AUTHORS[] = {
+ "Chris Clepper",
+ "James Tittle",
+ "IOhannes m zmoelnig"};
+
+static const char* GEM_OTHERAUTHORS =
+ "Guenter Geiger, Daniel Heckenberg, Cyrille Henry, et al.";
+#endif
+
diff --git a/externals/gridflow/bundled/Base/GemVertex.h b/externals/gridflow/bundled/Base/GemVertex.h
new file mode 100644
index 00000000..c390de98
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemVertex.h
@@ -0,0 +1,37 @@
+
+/*-----------------------------------------------------------------
+LOG
+ GEM - Graphics Environment for Multimedia
+
+ include file for VertexArrays
+
+ Copyright (c) 2004 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+ For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+
+#ifndef INCLUDE_GEMVERTEX_H_
+#define INCLUDE_GEMVERTEX_H_
+
+#include "Base/GemBase.h"
+
+class GEM_EXTERN GemVertex : public GemBase {
+ protected:
+
+
+ //////////
+ // Constructor
+ GemVertex();
+
+ ~GemVertex();
+
+ //////////
+ // If anything in the object has changed
+ // especially, if the vertex-array has changed
+ virtual void setModified();
+};
+
+
+#endif /* INCLUDE_GEMVERTEX_H_ */
diff --git a/externals/gridflow/bundled/Base/GemWinCreate.h b/externals/gridflow/bundled/Base/GemWinCreate.h
new file mode 100644
index 00000000..79104cde
--- /dev/null
+++ b/externals/gridflow/bundled/Base/GemWinCreate.h
@@ -0,0 +1,224 @@
+/*-----------------------------------------------------------------
+
+GEM - Graphics Environment for Multimedia
+
+create a window
+
+Copyright (c) 1997-1999 Mark Danks. mark@danks.org
+Copyright (c) Günther Geiger. geiger@epy.co.at
+Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
+
+-----------------------------------------------------------------*/
+
+#ifndef INCLUDE_GEMWINCREATE_H_
+#define INCLUDE_GEMWINCREATE_H_
+#include "Base/config.h"
+
+#ifdef __unix__
+# include <GL/glx.h>
+# ifdef HAVE_LIBXXF86VM
+# include <X11/extensions/xf86vmode.h>
+# endif
+#elif defined __WIN32__
+# include <windows.h>
+#elif defined __APPLE__
+# import <AGL/agl.h>
+#else
+# error Define OS specific window creation
+#endif
+
+#include "Base/GemExportDef.h"
+
+// I hate Microsoft...I shouldn't have to do this!
+#ifdef __WIN32__
+# pragma warning( disable : 4244 )
+# pragma warning( disable : 4305 )
+# pragma warning( disable : 4091 )
+#endif
+
+#include "m_pd.h"
+
+#include <string.h>
+
+/*-----------------------------------------------------------------
+ -------------------------------------------------------------------
+ CLASS
+ WindowInfo
+
+ All of the relavent information about an OpenGL window
+
+ DESCRIPTION
+
+ -----------------------------------------------------------------*/
+class GEM_EXTERN WindowInfo
+{
+ public:
+
+ // Constructor
+ WindowInfo() :
+ fs(0),
+#ifdef __unix__
+ dpy(NULL), win(0), cmap(0), context(NULL), delete_atom(0)
+#elif defined __WIN32__
+ win(NULL), dc(NULL), context(NULL)
+#elif defined __APPLE__
+ pWind(NULL), context(NULL), offscreen(NULL), pixelSize(32),
+ pixMap(NULL), rowBytes(0), baseAddr(NULL)
+#endif
+ {}
+ int fs; // FullScreen
+ int have_constContext; // 1 if we have a constant context
+
+#ifdef __unix__
+ Display *dpy; // X Display
+ Window win; // X Window
+ int screen; // X Screen
+ Colormap cmap; // X color map
+ GLXContext context; // OpenGL context
+ Atom delete_atom;
+
+#ifdef HAVE_LIBXXF86VM
+ XF86VidModeModeInfo deskMode; // originale ModeLine of the Desktop
+#endif
+
+#elif defined __WIN32__
+
+ HWND win; // Window handle
+ HDC dc; // Device context handle
+ HGLRC context; // OpenGL context
+
+#elif defined __APPLE__
+
+ WindowPtr pWind; // GEM window reference for gemwin
+ AGLContext context; // OpenGL context
+ GWorldPtr offscreen; // Macintosh offscreen buffer
+ long pixelSize; //
+ Rect r; //
+ PixMapHandle pixMap; // PixMap Handle
+ long rowBytes; //
+ void *baseAddr; //
+ short fontList; // Font
+
+#else
+#error Define OS specific window data
+#endif
+};
+
+/*-----------------------------------------------------------------
+ -------------------------------------------------------------------
+ CLASS
+ WindowHints
+
+ Hints for window creation
+
+ DESCRIPTION
+
+ -----------------------------------------------------------------*/
+class GEM_EXTERN WindowHints
+{
+ public:
+
+ //////////
+ // Should the window be realized
+ int actuallyDisplay;
+
+ //////////
+ // Single or double buffered
+ int buffer;
+
+ //////////
+ // The width/x of the window
+ int width;
+ //////////
+ // The height/y of the window
+ int height;
+
+ //////////
+ // the real width/height of the window (set by createGemWindow())
+ int real_w, real_h;
+
+ //////////
+ // The offset/x of the window (likely tobe overridden by the window-manager)
+ int x_offset;
+ //////////
+ // The offset/y of the window (likely tobe overridden by the window-manager)
+ int y_offset;
+
+ //////////
+ // Should we do fullscreen ?
+ int fullscreen;
+
+ //////////
+ // Is there a second screen ?
+ int secondscreen;
+
+ //////////
+ // Should there be a window border?
+ int border;
+
+ //////////
+ // mode for full-screen antialiasing
+ int fsaa;
+
+ ///// if we can use a different display , this has its meaning under X
+ char* display;
+
+ //////////////
+ // display some title....
+ char* title;
+
+ //////////
+ // The GLXcontext to share rendering with
+#ifdef __unix__
+ GLXContext shared;
+#elif defined __WIN32__
+ HGLRC shared;
+#elif defined __APPLE__
+ AGLContext shared;
+#else
+#error Define OS specific OpenGL context
+#endif
+};
+
+//////////
+// Create a new window
+GEM_EXTERN extern int createGemWindow(WindowInfo &info, WindowHints &hints);
+
+//////////
+// Destroy a window
+GEM_EXTERN extern void destroyGemWindow(WindowInfo &info);
+
+//////////
+// Set the cursor
+GEM_EXTERN extern int cursorGemWindow(WindowInfo &info, int state);
+
+//////////
+// Set the topmost position
+GEM_EXTERN extern int topmostGemWindow(WindowInfo &info, int state);
+
+//////////
+// swap the buffers (get's called in double-buffered mode)
+GEM_EXTERN extern void gemWinSwapBuffers(WindowInfo &nfo);
+/////////
+// reestablish a context
+GEM_EXTERN extern void gemWinMakeCurrent(WindowInfo &nfo);
+
+/////////
+// init OS-specific stuff
+GEM_EXTERN extern bool initGemWin(void);
+
+/////////
+// prepare a WindowInfo for context-sharing
+GEM_EXTERN void initWin_sharedContext(WindowInfo &info, WindowHints &hints);
+
+
+
+/////////
+//
+GEM_EXTERN extern void dispatchGemWindowMessages(WindowInfo &nfo);
+
+
+
+#endif // for header file
diff --git a/externals/gridflow/bundled/Base/config.h b/externals/gridflow/bundled/Base/config.h
new file mode 100644
index 00000000..bd2a823c
--- /dev/null
+++ b/externals/gridflow/bundled/Base/config.h
@@ -0,0 +1,65 @@
+/* configuration-file */
+#ifndef HAVE_BASE_CONFIG_H_
+#define HAVE_BASE_CONFIG_H_
+
+#ifdef _MSC_VER
+# ifndef __WIN32__
+# define __WIN32__
+# endif
+#endif
+
+#ifdef __WIN32__
+# ifndef NT
+# define NT
+# endif
+# ifndef MSW
+# define MSW
+# endif
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+#endif
+
+
+
+#ifdef HAVE_CONFIG_GENERIC_H
+
+# include "Base/configGeneric.h"
+
+#else /* includes system-specific files */
+
+# ifdef __linux__
+# include "Base/configLinux.h"
+# endif
+
+# ifdef __APPLE__
+//# include "Base/configDarwin.h"
+# define HAVE_QUICKTIME
+# endif
+
+# ifdef __WIN32__
+# include "Base/configNT.h"
+# endif
+#endif
+
+#ifdef NEW_VIDEOFILM
+# ifndef FILM_NEW
+# define FILM_NEW
+# endif
+# ifndef VIDEO_NEW
+# define VIDEO_NEW
+# endif
+#endif
+
+#ifdef HAVE_LIBFTGL
+# define FTGL
+#endif
+
+#ifdef HAVE_FFMPEG
+# define HAVE_LIBAVCODEC
+# define HAVE_LIBAVFORMAT
+#elif defined (HAVE_LIBAVCODEC) && defined (HAVE_LIBAVFORMAT)
+# define HAVE_FFMPEG
+#endif
+
+#endif /* HAVE_BASE_CONFIG_H_ */
diff --git a/externals/gridflow/bundled/Base/configLinux.h b/externals/gridflow/bundled/Base/configLinux.h
new file mode 100644
index 00000000..ca0a20b8
--- /dev/null
+++ b/externals/gridflow/bundled/Base/configLinux.h
@@ -0,0 +1,40 @@
+/* Base/configLinux.h. Generated from configLinux.h.in by configure. */
+
+/* fullscreen: querying via libXxf86vm */
+/* #undef HAVE_LIBXXF86VM */
+
+/* font rendering */
+/* #undef HAVE_LIBFTGL */
+
+/* image loading / saving */
+#define HAVE_LIBTIFF 1
+#define HAVE_LIBJPEG 1
+/* #undef HAVE_LIBMAGICKPLUSPLUS */
+
+/* movie decoding */
+#define HAVE_LIBMPEG 1
+#define HAVE_LIBMPEG3 1
+#define HAVE_LIBQUICKTIME 1
+#define HAVE_LQT_OPEN_WRITE 1
+/* #undef HAVE_LIBAVIPLAY */
+#define HAVE_FFMPEG 1
+#define GEM_AVSTREAM_CODECPOINTER 1
+
+/* video grabbing */
+#define HAVE_VIDEO4LINUX 1
+/* #undef HAVE_VIDEO4LINUX2 */
+#define HAVE_LIBDV 1
+
+/* image analysis */
+/* #undef HAVE_ARTOOLKIT */
+
+/* posix threads */
+#define HAVE_PTHREADS 1
+
+/* enable the use of the all-in-one video/movie objects */
+#define NEW_VIDEOFILM 1
+
+/* types, structures, compiler characteristics, ... */
+#define SIZEOF_VOID_P 4
+#define SIZEOF_UNSIGNED_INT 4
+
diff --git a/externals/gridflow/bundled/g_canvas.h b/externals/gridflow/bundled/g_canvas.h
new file mode 100644
index 00000000..07fa75b5
--- /dev/null
+++ b/externals/gridflow/bundled/g_canvas.h
@@ -0,0 +1,645 @@
+
+/* Copyright (c) 1997-1999 Miller Puckette.
+* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* this file defines the structure for "glists" and related structures and
+functions. "Glists" and "canvases" and "graphs" used to be different
+structures until being unified in version 0.35.
+
+A glist occupies its own window if the "gl_havewindow" flag is set. Its
+appearance on its "parent" or "owner" (if it has one) is as a graph if
+"gl_isgraph" is set, and otherwise as a text box.
+
+A glist is "root" if it has no owner, i.e., a document window. In this
+case "gl_havewindow" is always set.
+
+We maintain a list of root windows, so that we can traverse the whole
+collection of everything in a Pd process.
+
+If a glist has a window it may still not be "mapped." Miniaturized
+windows aren't mapped, for example, but a window is also not mapped
+immediately upon creation. In either case gl_havewindow is true but
+gl_mapped is false.
+
+Closing a non-root window makes it invisible; closing a root destroys it.
+
+A glist that's just a text object on its parent is always "toplevel." An
+embedded glist can switch back and forth to appear as a toplevel by double-
+clicking on it. Single-clicking a text box makes the toplevel become visible
+and raises the window it's in.
+
+If a glist shows up as a graph on its parent, the graph is blanked while the
+glist has its own window, even if miniaturized.
+
+*/
+
+/* NOTE: this file describes Pd implementation details which may change
+in future releases. The public (stable) API is in m_pd.h. */
+
+#ifndef __G_CANVAS_H
+#define __G_CANVAS_H
+#ifndef DESIRE
+
+#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
+extern "C" {
+#endif
+
+
+/* --------------------- geometry ---------------------------- */
+#define IOWIDTH 7 /* width of an inlet/outlet in pixels */
+#define IOMIDDLE ((IOWIDTH-1)/2)
+#define GLIST_DEFGRAPHWIDTH 200
+#define GLIST_DEFGRAPHHEIGHT 140
+/* ----------------------- data ------------------------------- */
+
+typedef struct _updateheader
+{
+ struct _updateheader *upd_next;
+ unsigned int upd_array:1; /* true if array, false if glist */
+ unsigned int upd_queued:1; /* true if we're queued */
+} t_updateheader;
+
+ /* types to support glists grabbing mouse motion or keys from parent */
+typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
+typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
+#endif /*DESIRE*/
+
+
+EXTERN_STRUCT _rtext;
+#define t_rtext struct _rtext
+
+#ifndef DESIRE
+
+EXTERN_STRUCT _gtemplate;
+#define t_gtemplate struct _gtemplate
+
+EXTERN_STRUCT _guiconnect;
+#define t_guiconnect struct _guiconnect
+
+EXTERN_STRUCT _tscalar;
+#define t_tscalar struct _tscalar
+
+EXTERN_STRUCT _canvasenvironment;
+#define t_canvasenvironment struct _canvasenvironment
+
+EXTERN_STRUCT _fielddesc;
+#define t_fielddesc struct _fielddesc
+
+typedef struct _selection
+{
+ t_gobj *sel_what;
+ struct _selection *sel_next;
+} t_selection;
+
+ /* this structure is instantiated whenever a glist becomes visible. */
+typedef struct _editor
+{
+ t_updateheader e_upd; /* update header structure */
+ t_selection *e_updlist; /* list of objects to update */
+ t_rtext *e_rtext; /* text responder linked list */
+ t_selection *e_selection; /* head of the selection list */
+ t_rtext *e_textedfor; /* the rtext if any that we are editing */
+ t_gobj *e_grab; /* object being "dragged" */
+ t_glistmotionfn e_motionfn; /* ... motion callback */
+ t_glistkeyfn e_keyfn; /* ... keypress callback */
+ t_binbuf *e_connectbuf; /* connections to deleted objects */
+ t_binbuf *e_deleted; /* last stuff we deleted */
+ t_guiconnect *e_guiconnect; /* GUI connection for filtering messages */
+ struct _glist *e_glist; /* glist which owns this */
+ int e_xwas; /* xpos on last mousedown or motion event */
+ int e_ywas; /* ypos, similarly */
+ int e_selectline_index1; /* indices for the selected line if any */
+ int e_selectline_outno; /* (only valid if e_selectedline is set) */
+ int e_selectline_index2;
+ int e_selectline_inno;
+ t_outconnect *e_selectline_tag;
+ unsigned int e_onmotion: 3; /* action to take on motion */
+ unsigned int e_lastmoved: 1; /* one if mouse has moved since click */
+ unsigned int e_textdirty: 1; /* one if e_textedfor has changed */
+ unsigned int e_selectedline: 1; /* one if a line is selected */
+} t_editor;
+
+#define MA_NONE 0 /* e_onmotion: do nothing on mouse motion */
+#define MA_MOVE 1 /* drag the selection around */
+#define MA_CONNECT 2 /* make a connection */
+#define MA_REGION 3 /* selection region */
+#define MA_PASSOUT 4 /* send on to e_grab */
+#define MA_DRAGTEXT 5 /* drag in text editor to alter selection */
+
+/* editor structure for "garrays". We don't bother to delete and regenerate
+this structure when the "garray" becomes invisible or visible, although we
+could do so if the structure gets big (like the "editor" above.) */
+
+typedef struct _arrayvis
+{
+ t_updateheader av_upd; /* update header structure */
+ t_garray *av_garray; /* owning structure */
+} t_arrayvis;
+
+/* the t_tick structure describes where to draw x and y "ticks" for a glist */
+
+typedef struct _tick /* where to put ticks on x or y axes */
+{
+ float k_point; /* one point to draw a big tick at */
+ float k_inc; /* x or y increment per little tick */
+ int k_lperb; /* little ticks per big; 0 if no ticks to draw */
+} t_tick;
+
+/* the t_glist structure, which describes a list of elements that live on an
+area of a window.
+
+*/
+
+struct _glist
+{
+ t_object gl_obj; /* header in case we're a glist */
+ t_gobj *gl_list; /* the actual data */
+ struct _gstub *gl_stub; /* safe pointer handler */
+ int gl_valid; /* incremented when pointers might be stale */
+ struct _glist *gl_owner; /* parent glist, supercanvas, or 0 if none */
+ int gl_pixwidth; /* width in pixels (on parent, if a graph) */
+ int gl_pixheight;
+ float gl_x1; /* bounding rectangle in our own coordinates */
+ float gl_y1;
+ float gl_x2;
+ float gl_y2;
+ int gl_screenx1; /* screen coordinates when toplevel */
+ int gl_screeny1;
+ int gl_screenx2;
+ int gl_screeny2;
+ int gl_xmargin; /* origin for GOP rectangle */
+ int gl_ymargin;
+ t_tick gl_xtick; /* ticks marking X values */
+ int gl_nxlabels; /* number of X coordinate labels */
+ t_symbol **gl_xlabel; /* ... an array to hold them */
+ float gl_xlabely; /* ... and their Y coordinates */
+ t_tick gl_ytick; /* same as above for Y ticks and labels */
+ int gl_nylabels;
+ t_symbol **gl_ylabel;
+ float gl_ylabelx;
+ t_editor *gl_editor; /* editor structure when visible */
+ t_symbol *gl_name; /* symbol bound here */
+ int gl_font; /* nominal font size in points, e.g., 10 */
+ struct _glist *gl_next; /* link in list of toplevels */
+ t_canvasenvironment *gl_env; /* root canvases and abstractions only */
+ unsigned int gl_havewindow:1; /* true if we own a window */
+ unsigned int gl_mapped:1; /* true if, moreover, it's "mapped" */
+ unsigned int gl_dirty:1; /* (root canvas only:) patch has changed */
+ unsigned int gl_loading:1; /* am now loading from file */
+ unsigned int gl_willvis:1; /* make me visible after loading */
+ unsigned int gl_edit:1; /* edit mode */
+ unsigned int gl_isdeleting:1; /* we're inside glist_delete -- hack! */
+ unsigned int gl_goprect:1; /* draw rectangle for graph-on-parent */
+ unsigned int gl_isgraph:1; /* show as graph on parent */
+};
+
+#define gl_gobj gl_obj.te_g
+#define gl_pd gl_gobj.g_pd
+
+/* a data structure to describe a field in a pure datum */
+
+#define DT_FLOAT 0
+#define DT_SYMBOL 1
+#define DT_LIST 2
+#define DT_ARRAY 3
+
+typedef struct _dataslot
+{
+ int ds_type;
+ t_symbol *ds_name;
+ t_symbol *ds_arraytemplate; /* filled in for arrays only */
+} t_dataslot;
+
+typedef struct _template
+{
+ t_pd t_pdobj; /* header */
+ struct _gtemplate *t_list; /* list of "struct"/gtemplate objects */
+ t_symbol *t_sym; /* name */
+ int t_n; /* number of dataslots (fields) */
+ t_dataslot *t_vec; /* array of dataslots */
+} t_template;
+
+struct _array
+{
+ int a_n; /* number of elements */
+ int a_elemsize; /* size in bytes; LATER get this from template */
+ char *a_vec; /* array of elements */
+ t_symbol *a_templatesym; /* template for elements */
+ int a_valid; /* protection against stale pointers into array */
+ t_gpointer a_gp; /* pointer to scalar or array element we're in */
+ t_gstub *a_stub; /* stub for pointing into this array */
+};
+
+struct _garray
+{
+ t_gobj x_gobj;
+ t_scalar *x_scalar; /* scalar "containing" the array */
+ t_glist *x_glist; /* containing glist */
+ t_symbol *x_name; /* unexpanded name (possibly with leading '$') */
+ t_symbol *x_realname; /* expanded name (symbol we're bound to) */
+ char x_usedindsp; /* true if some DSP routine is using this */
+ char x_saveit; /* true if we should save this with parent */
+ char x_listviewing; /* true if list view window is open */
+ double x_lastupdate; /* T.Grill - clock_getlogicaltime() of last array update */
+};
+
+ /* structure for traversing all the connections in a glist */
+typedef struct _linetraverser
+{
+ t_canvas *tr_x;
+ t_object *tr_ob;
+ int tr_nout;
+ int tr_outno;
+ t_object *tr_ob2;
+ t_outlet *tr_outlet;
+ t_inlet *tr_inlet;
+ int tr_nin;
+ int tr_inno;
+ int tr_x11, tr_y11, tr_x12, tr_y12;
+ int tr_x21, tr_y21, tr_x22, tr_y22;
+ int tr_lx1, tr_ly1, tr_lx2, tr_ly2;
+ t_outconnect *tr_nextoc;
+ int tr_nextoutno;
+} t_linetraverser;
+
+/* function types used to define graphical behavior for gobjs, a bit like X
+widgets. We don't use Pd methods because Pd's typechecking can't specify the
+types of pointer arguments. Also it's more convenient this way, since
+every "patchable" object can just get the "text" behaviors. */
+
+ /* Call this to get a gobj's bounding rectangle in pixels */
+typedef void (*t_getrectfn)(t_gobj *x, struct _glist *glist,
+ int *x1, int *y1, int *x2, int *y2);
+ /* and this to displace a gobj: */
+typedef void (*t_displacefn)(t_gobj *x, struct _glist *glist, int dx, int dy);
+ /* change color to show selection: */
+typedef void (*t_selectfn)(t_gobj *x, struct _glist *glist, int state);
+ /* change appearance to show activation/deactivation: */
+typedef void (*t_activatefn)(t_gobj *x, struct _glist *glist, int state);
+ /* warn a gobj it's about to be deleted */
+typedef void (*t_deletefn)(t_gobj *x, struct _glist *glist);
+ /* making visible or invisible */
+typedef void (*t_visfn)(t_gobj *x, struct _glist *glist, int flag);
+ /* field a mouse click (when not in "edit" mode) */
+typedef int (*t_clickfn)(t_gobj *x, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit);
+ /* ... and later, resizing; getting/setting font or color... */
+
+struct _widgetbehavior
+{
+ t_getrectfn w_getrectfn;
+ t_displacefn w_displacefn;
+ t_selectfn w_selectfn;
+ t_activatefn w_activatefn;
+ t_deletefn w_deletefn;
+ t_visfn w_visfn;
+ t_clickfn w_clickfn;
+};
+
+/* -------- behaviors for scalars defined by objects in template --------- */
+/* these are set by "drawing commands" in g_template.c which add appearance to
+scalars, which live in some other window. If the scalar is just included
+in a canvas the "parent" is a misnomer. There is also a text scalar object
+which really does draw the scalar on the parent window; see g_scalar.c. */
+
+/* note how the click function wants the whole scalar, not the "data", so
+doesn't work on array elements... LATER reconsider this */
+
+ /* bounding rectangle: */
+typedef void (*t_parentgetrectfn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_template *tmpl, float basex, float basey,
+ int *x1, int *y1, int *x2, int *y2);
+ /* displace it */
+typedef void (*t_parentdisplacefn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_template *tmpl, float basex, float basey,
+ int dx, int dy);
+ /* change color to show selection */
+typedef void (*t_parentselectfn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_template *tmpl, float basex, float basey,
+ int state);
+ /* change appearance to show activation/deactivation: */
+typedef void (*t_parentactivatefn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_template *tmpl, float basex, float basey,
+ int state);
+ /* making visible or invisible */
+typedef void (*t_parentvisfn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_template *tmpl, float basex, float basey,
+ int flag);
+ /* field a mouse click */
+typedef int (*t_parentclickfn)(t_gobj *x, struct _glist *glist,
+ t_word *data, t_template *tmpl, t_scalar *sc, t_array *ap,
+ float basex, float basey,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit);
+
+struct _parentwidgetbehavior
+{
+ t_parentgetrectfn w_parentgetrectfn;
+ t_parentdisplacefn w_parentdisplacefn;
+ t_parentselectfn w_parentselectfn;
+ t_parentactivatefn w_parentactivatefn;
+ t_parentvisfn w_parentvisfn;
+ t_parentclickfn w_parentclickfn;
+};
+
+ /* cursor definitions; used as return value for t_parentclickfn */
+#define CURSOR_RUNMODE_NOTHING 0
+#define CURSOR_RUNMODE_CLICKME 1
+#define CURSOR_RUNMODE_THICKEN 2
+#define CURSOR_RUNMODE_ADDPOINT 3
+#define CURSOR_EDITMODE_NOTHING 4
+#define CURSOR_EDITMODE_CONNECT 5
+#define CURSOR_EDITMODE_DISCONNECT 6
+EXTERN void canvas_setcursor(t_glist *x, unsigned int cursornum);
+
+extern t_canvas *canvas_editing; /* last canvas to start text edting */
+extern t_canvas *canvas_whichfind; /* last canvas we did a find in */
+extern t_canvas *canvas_list; /* list of all root canvases */
+extern t_class *vinlet_class, *voutlet_class;
+extern int glist_valid; /* incremented when pointers might be stale */
+
+#define PLOTSTYLE_POINTS 0 /* plotting styles for arrays */
+#define PLOTSTYLE_POLY 1
+#define PLOTSTYLE_BEZ 2
+
+/* ------------------- functions on any gobj ----------------------------- */
+EXTERN void gobj_getrect(t_gobj *x, t_glist *owner, int *x1, int *y1,
+ int *x2, int *y2);
+EXTERN void gobj_displace(t_gobj *x, t_glist *owner, int dx, int dy);
+EXTERN void gobj_select(t_gobj *x, t_glist *owner, int state);
+EXTERN void gobj_activate(t_gobj *x, t_glist *owner, int state);
+EXTERN void gobj_delete(t_gobj *x, t_glist *owner);
+EXTERN void gobj_vis(t_gobj *x, t_glist *glist, int flag);
+EXTERN int gobj_click(t_gobj *x, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit);
+EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
+EXTERN void gobj_properties(t_gobj *x, struct _glist *glist);
+EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
+
+/* -------------------- functions on glists --------------------- */
+EXTERN t_glist *glist_new( void);
+EXTERN void glist_init(t_glist *x);
+EXTERN void glist_add(t_glist *x, t_gobj *g);
+EXTERN void glist_cleanup(t_glist *x);
+EXTERN void glist_free(t_glist *x);
+
+EXTERN void glist_clear(t_glist *x);
+EXTERN t_canvas *glist_getcanvas(t_glist *x);
+EXTERN int glist_isselected(t_glist *x, t_gobj *y);
+EXTERN void glist_select(t_glist *x, t_gobj *y);
+EXTERN void glist_deselect(t_glist *x, t_gobj *y);
+EXTERN void glist_noselect(t_glist *x);
+EXTERN void glist_selectall(t_glist *x);
+EXTERN void glist_delete(t_glist *x, t_gobj *y);
+EXTERN void glist_retext(t_glist *x, t_text *y);
+EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
+ t_glistkeyfn keyfn, int xpos, int ypos);
+EXTERN int glist_isvisible(t_glist *x);
+EXTERN int glist_istoplevel(t_glist *x);
+EXTERN t_glist *glist_findgraph(t_glist *x);
+EXTERN int glist_getfont(t_glist *x);
+EXTERN void glist_sort(t_glist *canvas);
+EXTERN void glist_read(t_glist *x, t_symbol *filename, t_symbol *format);
+EXTERN void glist_mergefile(t_glist *x, t_symbol *filename, t_symbol *format);
+
+EXTERN float glist_pixelstox(t_glist *x, float xpix);
+EXTERN float glist_pixelstoy(t_glist *x, float ypix);
+EXTERN float glist_xtopixels(t_glist *x, float xval);
+EXTERN float glist_ytopixels(t_glist *x, float yval);
+EXTERN float glist_dpixtodx(t_glist *x, float dxpix);
+EXTERN float glist_dpixtody(t_glist *x, float dypix);
+
+EXTERN void glist_getnextxy(t_glist *gl, int *xval, int *yval);
+EXTERN void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv);
+EXTERN t_glist *glist_addglist(t_glist *g, t_symbol *sym,
+ float x1, float y1, float x2, float y2,
+ float px1, float py1, float px2, float py2);
+EXTERN void glist_arraydialog(t_glist *parent, t_symbol *name,
+ t_floatarg size, t_floatarg saveit, t_floatarg newgraph);
+EXTERN t_binbuf *glist_writetobinbuf(t_glist *x, int wholething);
+EXTERN int glist_isgraph(t_glist *x);
+EXTERN void glist_redraw(t_glist *x);
+EXTERN void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
+ char *tag, int x1, int y1, int x2, int y2);
+EXTERN void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag);
+EXTERN void canvas_create_editor(t_glist *x, int createit);
+void canvas_deletelinesforio(t_canvas *x, t_text *text,
+ t_inlet *inp, t_outlet *outp);
+
+
+/* -------------------- functions on texts ------------------------- */
+EXTERN void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize);
+EXTERN void text_drawborder(t_text *x, t_glist *glist, char *tag,
+ int width, int height, int firsttime);
+EXTERN void text_eraseborder(t_text *x, t_glist *glist, char *tag);
+EXTERN int text_xcoord(t_text *x, t_glist *glist);
+EXTERN int text_ycoord(t_text *x, t_glist *glist);
+EXTERN int text_xpix(t_text *x, t_glist *glist);
+EXTERN int text_ypix(t_text *x, t_glist *glist);
+EXTERN int text_shouldvis(t_text *x, t_glist *glist);
+#endif /*DESIRE */
+
+/* -------------------- functions on rtexts ------------------------- */
+
+#define RTEXT_DOWN 1
+#define RTEXT_DRAG 2
+#define RTEXT_DBL 3
+#define RTEXT_SHIFT 4
+
+EXTERN t_rtext *rtext_new(t_glist *glist, t_text *who);
+EXTERN t_rtext *glist_findrtext(t_glist *gl, t_text *who);
+EXTERN void rtext_draw(t_rtext *x);
+EXTERN void rtext_erase(t_rtext *x);
+EXTERN t_rtext *rtext_remove(t_rtext *first, t_rtext *x);
+EXTERN int rtext_height(t_rtext *x);
+EXTERN void rtext_displace(t_rtext *x, int dx, int dy);
+EXTERN void rtext_select(t_rtext *x, int state);
+EXTERN void rtext_activate(t_rtext *x, int state);
+EXTERN void rtext_free(t_rtext *x);
+EXTERN void rtext_key(t_rtext *x, int n, t_symbol *s);
+EXTERN void rtext_mouse(t_rtext *x, int xval, int yval, int flag);
+EXTERN void rtext_retext(t_rtext *x);
+EXTERN int rtext_width(t_rtext *x);
+EXTERN int rtext_height(t_rtext *x);
+EXTERN char *rtext_gettag(t_rtext *x);
+EXTERN void rtext_gettext(t_rtext *x, char **buf, int *bufsize);
+EXTERN void rtext_getseltext(t_rtext *x, char **buf, int *bufsize);
+
+/* -------------------- functions on canvases ------------------------ */
+#ifndef DESIRE
+EXTERN t_class *canvas_class;
+
+EXTERN t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv);
+EXTERN t_symbol *canvas_makebindsym(t_symbol *s);
+EXTERN void canvas_vistext(t_canvas *x, t_text *y);
+EXTERN void canvas_fixlinesfor(t_canvas *x, t_text *text);
+EXTERN void canvas_deletelinesfor(t_canvas *x, t_text *text);
+EXTERN void canvas_stowconnections(t_canvas *x);
+EXTERN void canvas_restoreconnections(t_canvas *x);
+EXTERN void canvas_redraw(t_canvas *x);
+
+EXTERN t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *sym, t_symbol* h);
+EXTERN void canvas_rminlet(t_canvas *x, t_inlet *ip);
+EXTERN t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *sym);
+EXTERN void canvas_rmoutlet(t_canvas *x, t_outlet *op);
+EXTERN void canvas_redrawallfortemplate(t_template *tmpl, int action);
+EXTERN void canvas_redrawallfortemplatecanvas(t_canvas *x, int action);
+EXTERN void canvas_zapallfortemplate(t_canvas *tmpl);
+EXTERN void canvas_setusedastemplate(t_canvas *x);
+EXTERN t_canvas *canvas_getcurrent(void);
+EXTERN void canvas_setcurrent(t_canvas *x);
+EXTERN void canvas_unsetcurrent(t_canvas *x);
+EXTERN t_symbol *canvas_realizedollar(t_canvas *x, t_symbol *s);
+EXTERN t_canvas *canvas_getrootfor(t_canvas *x);
+EXTERN void canvas_dirty(t_canvas *x, t_int n);
+EXTERN int canvas_getfont(t_canvas *x);
+typedef int (*t_canvasapply)(t_canvas *x, t_int x1, t_int x2, t_int x3);
+
+EXTERN t_int *canvas_recurapply(t_canvas *x, t_canvasapply *fn,
+ t_int x1, t_int x2, t_int x3);
+
+EXTERN void canvas_resortinlets(t_canvas *x);
+EXTERN void canvas_resortoutlets(t_canvas *x);
+EXTERN void canvas_free(t_canvas *x);
+EXTERN void canvas_updatewindowlist( void);
+EXTERN void canvas_editmode(t_canvas *x, t_floatarg yesplease);
+EXTERN int canvas_isabstraction(t_canvas *x);
+EXTERN int canvas_istable(t_canvas *x);
+EXTERN int canvas_showtext(t_canvas *x);
+EXTERN void canvas_vis(t_canvas *x, t_floatarg f);
+EXTERN t_canvasenvironment *canvas_getenv(t_canvas *x);
+EXTERN void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir);
+EXTERN void canvas_loadbang(t_canvas *x);
+EXTERN int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
+ int *x1p, int *y1p, int *x2p, int *y2p);
+EXTERN int canvas_setdeleting(t_canvas *x, int flag);
+
+typedef void (*t_undofn)(t_canvas *canvas, void *buf,
+ int action); /* a function that does UNDO/REDO */
+#define UNDO_FREE 0 /* free current undo/redo buffer */
+#define UNDO_UNDO 1 /* undo */
+#define UNDO_REDO 2 /* redo */
+EXTERN void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
+ const char *name);
+EXTERN void canvas_noundo(t_canvas *x);
+EXTERN int canvas_getindex(t_canvas *x, t_gobj *y);
+
+EXTERN void canvas_connect(t_canvas *x,
+ t_floatarg fwhoout, t_floatarg foutno,t_floatarg fwhoin, t_floatarg finno);
+EXTERN void canvas_disconnect(t_canvas *x,
+ float index1, float outno, float index2, float inno);
+EXTERN int canvas_isconnected (t_canvas *x,
+ t_text *ob1, int n1, t_text *ob2, int n2);
+EXTERN void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy);
+
+
+/* ---- functions on canvasses as objects --------------------- */
+
+EXTERN void canvas_fattenforscalars(t_canvas *x,
+ int *x1, int *y1, int *x2, int *y2);
+EXTERN void canvas_visforscalars(t_canvas *x, t_glist *glist, int vis);
+EXTERN int canvas_clicksub(t_canvas *x, int xpix, int ypix, int shift,
+ int alt, int dbl, int doit);
+EXTERN t_glist *canvas_getglistonsuper(void);
+
+EXTERN void linetraverser_start(t_linetraverser *t, t_canvas *x);
+EXTERN t_outconnect *linetraverser_next(t_linetraverser *t);
+EXTERN void linetraverser_skipobject(t_linetraverser *t);
+
+/* --------- functions on garrays (graphical arrays) -------------------- */
+
+EXTERN t_template *garray_template(t_garray *x);
+
+/* -------------------- arrays --------------------- */
+EXTERN t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *tmpl,
+ t_floatarg f, t_floatarg saveit);
+EXTERN t_array *array_new(t_symbol *templatesym, t_gpointer *parent);
+EXTERN void array_resize(t_array *x, int n);
+EXTERN void array_free(t_array *x);
+
+/* --------------------- gpointers and stubs ---------------- */
+EXTERN t_gstub *gstub_new(t_glist *gl, t_array *a);
+EXTERN void gstub_cutoff(t_gstub *gs);
+EXTERN void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x);
+
+/* --------------------- scalars ------------------------- */
+EXTERN void word_init(t_word *wp, t_template *tmpl, t_gpointer *gp);
+EXTERN void word_restore(t_word *wp, t_template *tmpl,
+ int argc, t_atom *argv);
+EXTERN t_scalar *scalar_new(t_glist *owner,
+ t_symbol *templatesym);
+EXTERN void word_free(t_word *wp, t_template *tmpl);
+EXTERN void scalar_getbasexy(t_scalar *x, float *basex, float *basey);
+EXTERN void scalar_redraw(t_scalar *x, t_glist *glist);
+
+/* ------helper routines for "garrays" and "plots" -------------- */
+EXTERN int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
+ t_symbol *elemtemplatesym,
+ float linewidth, float xloc, float xinc, float yloc, float scalarvis,
+ t_fielddesc *xfield, t_fielddesc *yfield, t_fielddesc *wfield,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit);
+
+EXTERN void array_getcoordinate(t_glist *glist,
+ char *elem, int xonset, int yonset, int wonset, int indx,
+ float basex, float basey, float xinc,
+ t_fielddesc *xfielddesc, t_fielddesc *yfielddesc, t_fielddesc *wfielddesc,
+ float *xp, float *yp, float *wp);
+
+EXTERN int array_getfields(t_symbol *elemtemplatesym,
+ t_canvas **elemtemplatecanvasp,
+ t_template **elemtemplatep, int *elemsizep,
+ t_fielddesc *xfielddesc, t_fielddesc *yfielddesc, t_fielddesc *wfielddesc,
+ int *xonsetp, int *yonsetp, int *wonsetp);
+
+/* --------------------- templates ------------------------- */
+EXTERN t_template *template_new(t_symbol *sym, int argc, t_atom *argv);
+EXTERN void template_free(t_template *x);
+EXTERN int template_match(t_template *x1, t_template *x2);
+EXTERN int template_find_field(t_template *x, t_symbol *name, int *p_onset,
+ int *p_type, t_symbol **p_arraytype);
+EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname, t_word *wp,
+ int loud);
+EXTERN void template_setfloat(t_template *x, t_symbol *fieldname, t_word *wp,
+ t_float f, int loud);
+EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
+ t_word *wp, int loud);
+EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
+ t_word *wp, t_symbol *s, int loud);
+
+EXTERN t_template *gtemplate_get(t_gtemplate *x);
+EXTERN t_template *template_findbyname(t_symbol *s);
+EXTERN t_canvas *template_findcanvas(t_template *tmpl);
+EXTERN void template_notify(t_template *tmpl,
+ t_symbol *s, int argc, t_atom *argv);
+
+EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname,
+ t_word *wp, int loud);
+EXTERN void template_setfloat(t_template *x, t_symbol *fieldname,
+ t_word *wp, t_float f, int loud);
+EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
+ t_word *wp, int loud);
+EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
+ t_word *wp, t_symbol *s, int loud);
+EXTERN t_float fielddesc_getcoord(t_fielddesc *f, t_template *tmpl,
+ t_word *wp, int loud);
+EXTERN void fielddesc_setcoord(t_fielddesc *f, t_template *tmpl,
+ t_word *wp, float pix, int loud);
+EXTERN t_float fielddesc_cvttocoord(t_fielddesc *f, float val);
+EXTERN float fielddesc_cvtfromcoord(t_fielddesc *f, float coord);
+
+
+/* ----------------------- guiconnects, g_guiconnect.c --------- */
+EXTERN t_guiconnect *guiconnect_new(t_pd *who, t_symbol *sym);
+EXTERN void guiconnect_notarget(t_guiconnect *x, double timedelay);
+
+/* ------------- IEMGUI routines used in other g_ files ---------------- */
+EXTERN t_symbol *iemgui_raute2dollar(t_symbol *s);
+EXTERN t_symbol *iemgui_dollar2raute(t_symbol *s);
+
+#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
+}
+#endif
+
+#endif /* DESIRE */
+#endif /* __G_CANVAS_H */
+