Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/kernel')
-rw-r--r--source/kernel/Makefile40
-rw-r--r--source/kernel/gen_messaging/GEN_messaging.h62
-rw-r--r--source/kernel/gen_messaging/Makefile37
-rw-r--r--source/kernel/gen_messaging/intern/Makefile47
-rw-r--r--source/kernel/gen_messaging/intern/messaging.c45
-rw-r--r--source/kernel/gen_system/GEN_DataCache.h78
-rw-r--r--source/kernel/gen_system/GEN_HashedPtr.cpp47
-rw-r--r--source/kernel/gen_system/GEN_HashedPtr.h47
-rw-r--r--source/kernel/gen_system/GEN_Map.h151
-rw-r--r--source/kernel/gen_system/GEN_Matrix4x4.cpp207
-rw-r--r--source/kernel/gen_system/GEN_Matrix4x4.h78
-rw-r--r--source/kernel/gen_system/GEN_SmartPtr.h235
-rw-r--r--source/kernel/gen_system/Makefile43
-rw-r--r--source/kernel/gen_system/SYS_SingletonSystem.cpp99
-rw-r--r--source/kernel/gen_system/SYS_SingletonSystem.h65
-rw-r--r--source/kernel/gen_system/SYS_System.cpp77
-rw-r--r--source/kernel/gen_system/SYS_System.h70
17 files changed, 1428 insertions, 0 deletions
diff --git a/source/kernel/Makefile b/source/kernel/Makefile
new file mode 100644
index 00000000000..51d31f2f6ac
--- /dev/null
+++ b/source/kernel/Makefile
@@ -0,0 +1,40 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# 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. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License. See http://www.blender.org/BL/ for information
+# about this.
+#
+# 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.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+#
+# Make module object directory and bounce make to subdirectories.
+
+include nan_definitions.mk
+
+DIR = $(OCGDIR)/kernel
+SOURCEDIR = source/kernel
+DIRS = gen_system gen_messaging
+
+include nan_subdirs.mk
diff --git a/source/kernel/gen_messaging/GEN_messaging.h b/source/kernel/gen_messaging/GEN_messaging.h
new file mode 100644
index 00000000000..c415749a6e3
--- /dev/null
+++ b/source/kernel/gen_messaging/GEN_messaging.h
@@ -0,0 +1,62 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+#ifndef GEN_MESSAGING_H
+#define GEN_MESSAGING_H
+
+#include <stdio.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * Stream for error messages.
+ */
+ extern FILE* GEN_errorstream;
+
+ /**
+ * Stream for notices to the user.
+ */
+ extern FILE* GEN_userstream;
+
+ /**
+ * Initialise the messaging system. If the system is not
+ * initialised, the streams cannot be used. */
+ void GEN_init_messaging_system(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* GEN_MESSAGING_H */
diff --git a/source/kernel/gen_messaging/Makefile b/source/kernel/gen_messaging/Makefile
new file mode 100644
index 00000000000..d8420531e05
--- /dev/null
+++ b/source/kernel/gen_messaging/Makefile
@@ -0,0 +1,37 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# 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. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License. See http://www.blender.org/BL/ for information
+# about this.
+#
+# 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.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+#
+# Bounces make to subdirectories.
+
+SOURCEDIR = source/kernel/gen_messaging
+DIRS = intern
+
+include nan_subdirs.mk
diff --git a/source/kernel/gen_messaging/intern/Makefile b/source/kernel/gen_messaging/intern/Makefile
new file mode 100644
index 00000000000..cd6afa19a3f
--- /dev/null
+++ b/source/kernel/gen_messaging/intern/Makefile
@@ -0,0 +1,47 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# 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. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License. See http://www.blender.org/BL/ for information
+# about this.
+#
+# 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.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+#
+#
+
+LIBNAME = gen_messaging
+DIR = $(OCGDIR)/kernel/$(LIBNAME)
+
+include nan_compile.mk
+
+ifeq ($(OS),$(findstring $(OS), "beos darwin freebsd linux openbsd solaris windows"))
+ CFLAGS += -funsigned-char
+endif
+
+CFLAGS += $(LEVEL_1_C_WARNINGS)
+
+# path to our own external headerfiles
+CPPFLAGS += -I..
+
diff --git a/source/kernel/gen_messaging/intern/messaging.c b/source/kernel/gen_messaging/intern/messaging.c
new file mode 100644
index 00000000000..628c717a879
--- /dev/null
+++ b/source/kernel/gen_messaging/intern/messaging.c
@@ -0,0 +1,45 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * A message and error sink for c and c++
+ */
+
+
+#include "GEN_messaging.h"
+
+
+FILE* GEN_errorstream = NULL;
+FILE* GEN_userstream = NULL;
+
+void GEN_init_messaging_system(void)
+{
+ GEN_errorstream = stderr;
+ GEN_userstream = stdout;
+}
diff --git a/source/kernel/gen_system/GEN_DataCache.h b/source/kernel/gen_system/GEN_DataCache.h
new file mode 100644
index 00000000000..fb3a9ea4a72
--- /dev/null
+++ b/source/kernel/gen_system/GEN_DataCache.h
@@ -0,0 +1,78 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+#ifndef __GEN_DATACACHE_H
+#define __GEN_DATACACHE_H
+
+#include "STR_HashedString.h"
+#include "GEN_Map.h"
+
+template <class T>
+class GEN_DataCache
+{
+ GEN_Map<STR_HashedString,T*> m_dataCache;
+ virtual T* LoadData(const STR_String& name)=0;
+ virtual void FreeCacheObjects()=0;
+
+public:
+ GEN_DataCache() {};
+ virtual ~GEN_DataCache() {};
+
+ T* GetData(const STR_String& paramname)
+ {
+ T* result=NULL;
+
+ T** resultptr = m_dataCache[paramname];
+ if (resultptr)
+ {
+ result = *resultptr;
+ }
+
+ else
+ {
+ result = LoadData(paramname);
+ if (result)
+ {
+ m_dataCache.insert(paramname,result);
+ }
+ }
+
+ return result;
+ }
+
+ virtual void ClearCache()
+ {
+ FreeCacheObjects();
+ m_dataCache.clear();
+ }
+};
+
+#endif //__GEN_DATACACHE_H
diff --git a/source/kernel/gen_system/GEN_HashedPtr.cpp b/source/kernel/gen_system/GEN_HashedPtr.cpp
new file mode 100644
index 00000000000..6163b4a7c64
--- /dev/null
+++ b/source/kernel/gen_system/GEN_HashedPtr.cpp
@@ -0,0 +1,47 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ *
+ */
+#include "GEN_HashedPtr.h"
+
+unsigned int GEN_Hash(unsigned int inDWord)
+{
+ unsigned int key = inDWord;
+
+ key += ~(key << 16);
+ key ^= (key >> 5);
+ key += (key << 3);
+ key ^= (key >> 13);
+ key += ~(key << 9);
+ key ^= (key >> 17);
+
+ return key;
+}
diff --git a/source/kernel/gen_system/GEN_HashedPtr.h b/source/kernel/gen_system/GEN_HashedPtr.h
new file mode 100644
index 00000000000..3f4a8370dbe
--- /dev/null
+++ b/source/kernel/gen_system/GEN_HashedPtr.h
@@ -0,0 +1,47 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ *
+ */
+#ifndef __GEN_HASHEDPTR
+#define __GEN_HASHEDPTR
+
+unsigned int GEN_Hash(unsigned int inDWord);
+
+class GEN_HashedPtr
+{
+ void* m_valptr;
+public:
+ GEN_HashedPtr(void* val) : m_valptr(val) {};
+ unsigned int hash() const { return GEN_Hash((unsigned int) m_valptr);};
+ inline friend bool operator ==(const GEN_HashedPtr & rhs, const GEN_HashedPtr & lhs) { return rhs.m_valptr == lhs.m_valptr;};
+};
+
+#endif //__GEN_HASHEDPTR
diff --git a/source/kernel/gen_system/GEN_Map.h b/source/kernel/gen_system/GEN_Map.h
new file mode 100644
index 00000000000..bd211a6b043
--- /dev/null
+++ b/source/kernel/gen_system/GEN_Map.h
@@ -0,0 +1,151 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+#ifndef GEN_MAP_H
+#define GEN_MAP_H
+
+template <class Key, class Value>
+class GEN_Map {
+private:
+ struct Entry {
+ Entry (Entry *next, Key key, Value value) :
+ m_next(next),
+ m_key(key),
+ m_value(value) {}
+
+ Entry *m_next;
+ Key m_key;
+ Value m_value;
+ };
+
+public:
+ GEN_Map(int num_buckets = 100) : m_num_buckets(num_buckets) {
+ m_buckets = new Entry *[num_buckets];
+ for (int i = 0; i < num_buckets; ++i) {
+ m_buckets[i] = 0;
+ }
+ }
+
+ int size() {
+ int count=0;
+ for (int i=0;i<m_num_buckets;i++)
+ {
+ Entry* bucket = m_buckets[i];
+ while(bucket)
+ {
+ bucket = bucket->m_next;
+ count++;
+ }
+ }
+ return count;
+ }
+
+ Value* at(int index) {
+ int count=0;
+ for (int i=0;i<m_num_buckets;i++)
+ {
+ Entry* bucket = m_buckets[i];
+ while(bucket)
+ {
+ if (count==index)
+ {
+ return &bucket->m_value;
+ }
+ bucket = bucket->m_next;
+ count++;
+ }
+ }
+ return 0;
+ }
+
+ void clear() {
+ for (int i = 0; i < m_num_buckets; ++i) {
+ Entry *entry_ptr = m_buckets[i];
+
+ while (entry_ptr != 0) {
+ Entry *tmp_ptr = entry_ptr->m_next;
+ delete entry_ptr;
+ entry_ptr = tmp_ptr;
+ }
+ m_buckets[i] = 0;
+ }
+ }
+
+ ~GEN_Map() {
+ clear();
+ delete [] m_buckets;
+ }
+
+ void insert(const Key& key, const Value& value) {
+ Entry *entry_ptr = m_buckets[key.hash() % m_num_buckets];
+ while ((entry_ptr != 0) && !(key == entry_ptr->m_key)) {
+ entry_ptr = entry_ptr->m_next;
+ }
+
+ if (entry_ptr != 0) {
+ entry_ptr->m_value = value;
+ }
+ else {
+ Entry **bucket = &m_buckets[key.hash() % m_num_buckets];
+ *bucket = new Entry(*bucket, key, value);
+ }
+ }
+
+ void remove(const Key& key) {
+ Entry **entry_ptr = &m_buckets[key.hash() % m_num_buckets];
+ while ((*entry_ptr != 0) && !(key == (*entry_ptr)->m_key)) {
+ entry_ptr = &(*entry_ptr)->m_next;
+ }
+
+ if (*entry_ptr != 0) {
+ Entry *tmp_ptr = (*entry_ptr)->m_next;
+ delete *entry_ptr;
+ *entry_ptr = tmp_ptr;
+ }
+ }
+
+ Value *operator[](Key key) {
+ Entry *bucket = m_buckets[key.hash() % m_num_buckets];
+ while ((bucket != 0) && !(key == bucket->m_key)) {
+ bucket = bucket->m_next;
+ }
+ return bucket != 0 ? &bucket->m_value : 0;
+ }
+
+private:
+ int m_num_buckets;
+ Entry **m_buckets;
+};
+
+#endif
+
+
+
diff --git a/source/kernel/gen_system/GEN_Matrix4x4.cpp b/source/kernel/gen_system/GEN_Matrix4x4.cpp
new file mode 100644
index 00000000000..ad250ea9ffc
--- /dev/null
+++ b/source/kernel/gen_system/GEN_Matrix4x4.cpp
@@ -0,0 +1,207 @@
+/**
+ * $Id$
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#include "GEN_Matrix4x4.h"
+
+
+
+GEN_Matrix4x4::GEN_Matrix4x4()
+{
+ Identity();
+}
+
+
+
+GEN_Matrix4x4::GEN_Matrix4x4(const float value[4][4])
+{
+ for (int i=0;i<4;i++)
+ {
+ for (int j=0;j<4;j++)
+ m_V[i][j] = value[i][j];
+ }
+}
+
+
+
+GEN_Matrix4x4::GEN_Matrix4x4(const double value[16])
+{
+ for (int i=0;i<16;i++)
+ m_Vflat[i] = value[i];
+}
+
+
+
+GEN_Matrix4x4::GEN_Matrix4x4(const GEN_Matrix4x4& other)
+{
+ SetMatrix(other);
+}
+
+
+
+GEN_Matrix4x4::GEN_Matrix4x4(const MT_Point3& orig,
+ const MT_Vector3& dir,
+ const MT_Vector3 up)
+{
+ MT_Vector3 z = -(dir.normalized());
+ MT_Vector3 x = (up.cross(z)).normalized();
+ MT_Vector3 y = (z.cross(x));
+
+ m_V[0][0] = x.x();
+ m_V[0][1] = y.x();
+ m_V[0][2] = z.x();
+ m_V[0][3] = 0.0f;
+
+ m_V[1][0] = x.y();
+ m_V[1][1] = y.y();
+ m_V[1][2] = z.y();
+ m_V[1][3] = 0.0f;
+
+ m_V[2][0] = x.z();
+ m_V[2][1] = y.z();
+ m_V[2][2] = z.z();
+ m_V[2][3] = 0.0f;
+
+ m_V[3][0] = orig.x();//0.0f;
+ m_V[3][1] = orig.y();//0.0f;
+ m_V[3][2] = orig.z();//0.0f;
+ m_V[3][3] = 1.0f;
+
+ //Translate(-orig);
+}
+
+
+
+MT_Vector3 GEN_Matrix4x4::GetRight() const
+{
+ return MT_Vector3(m_V[0][0], m_V[0][1], m_V[0][2]);
+}
+
+
+
+MT_Vector3 GEN_Matrix4x4::GetUp() const
+{
+ return MT_Vector3(m_V[1][0], m_V[1][1], m_V[1][2]);
+}
+
+
+
+MT_Vector3 GEN_Matrix4x4::GetDir() const
+{
+ return MT_Vector3(m_V[2][0], m_V[2][1], m_V[2][2]);
+}
+
+
+
+MT_Point3 GEN_Matrix4x4::GetPos() const
+{
+ return MT_Point3(m_V[3][0], m_V[3][1], m_V[3][2]);
+}
+
+
+
+void GEN_Matrix4x4::Identity()
+{
+ for (int i=0; i<4; i++)
+ {
+ for (int j=0; j<4; j++)
+ m_V[i][j] = (i==j?1.0f:0.0f);
+ }
+}
+
+
+
+void GEN_Matrix4x4::SetMatrix(const GEN_Matrix4x4& other)
+{
+ for (int i=0; i<16; i++)
+ m_Vflat[i] = other.m_Vflat[i];
+}
+
+
+
+double* GEN_Matrix4x4::getPointer()
+{
+ return &m_V[0][0];
+}
+
+
+
+const double* GEN_Matrix4x4::getPointer() const
+{
+ return &m_V[0][0];
+}
+
+
+
+void GEN_Matrix4x4::setElem(int pos,double newvalue)
+{
+ m_Vflat[pos] = newvalue;
+}
+
+
+
+
+
+GEN_Matrix4x4 GEN_Matrix4x4::Perspective(MT_Scalar inLeft,
+MT_Scalar inRight,
+MT_Scalar inBottom,
+MT_Scalar inTop,
+MT_Scalar inNear,
+MT_Scalar inFar)
+{
+
+ GEN_Matrix4x4 mat;
+
+ // Column 0
+ mat(0, 0) = -(2.0*inNear) / (inRight-inLeft);
+ mat(1, 0) = 0;
+ mat(2, 0) = 0;
+ mat(3, 0) = 0;
+
+ // Column 1
+ mat(0, 1) = 0;
+ mat(1, 1) = (2.0*inNear) / (inTop-inBottom);
+ mat(2, 1) = 0;
+ mat(3, 1) = 0;
+
+ // Column 2
+ mat(0, 2) = (inRight+inLeft) / (inRight-inLeft);
+ mat(1, 2) = (inTop+inBottom) / (inTop-inBottom);
+ mat(2, 2) = -(inFar+inNear) / (inFar-inNear);
+ mat(3, 2) = -1;
+
+ // Column 3
+ mat(0, 3) = 0;
+ mat(1, 3) = 0;
+ mat(2, 3) = -(2.0*inFar*inNear) / (inFar-inNear);
+ mat(3, 3) = 0;
+
+ return mat;
+}
diff --git a/source/kernel/gen_system/GEN_Matrix4x4.h b/source/kernel/gen_system/GEN_Matrix4x4.h
new file mode 100644
index 00000000000..23a31ecbde1
--- /dev/null
+++ b/source/kernel/gen_system/GEN_Matrix4x4.h
@@ -0,0 +1,78 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+#ifndef GEN_MATRIX4X4
+#define GEN_MATRIX4X4
+
+#include "MT_Point3.h"
+
+class GEN_Matrix4x4
+{
+public:
+ // creators.
+ GEN_Matrix4x4();
+ GEN_Matrix4x4(const float value[4][4]);
+ GEN_Matrix4x4(const double value[16]);
+ GEN_Matrix4x4(const GEN_Matrix4x4 & other);
+ GEN_Matrix4x4(const MT_Point3& orig,
+ const MT_Vector3& dir,
+ const MT_Vector3 up);
+
+ void Identity();
+ void SetMatrix(const GEN_Matrix4x4 & other);
+ double* getPointer();
+ const double* getPointer() const;
+ void setElem(int pos,double newvalue);
+
+
+ MT_Vector3 GetRight() const;
+ MT_Vector3 GetUp() const;
+ MT_Vector3 GetDir() const;
+ MT_Point3 GetPos() const;
+ void SetPos(const MT_Vector3 & v);
+
+ double& operator () (int row,int col) { return m_V[col][row]; }
+
+ static GEN_Matrix4x4 Perspective(MT_Scalar inLeft,
+ MT_Scalar inRight,
+ MT_Scalar inBottom,
+ MT_Scalar inTop,
+ MT_Scalar inNear,
+ MT_Scalar inFar);
+protected:
+ union
+ {
+ double m_V[4][4];
+ double m_Vflat[16];
+ };
+};
+
+#endif //GEN_MATRIX4X4
diff --git a/source/kernel/gen_system/GEN_SmartPtr.h b/source/kernel/gen_system/GEN_SmartPtr.h
new file mode 100644
index 00000000000..535d066be57
--- /dev/null
+++ b/source/kernel/gen_system/GEN_SmartPtr.h
@@ -0,0 +1,235 @@
+#ifndef NAN_INCLUDED_GEN_SmartPtr_h
+#define NAN_INCLUDED_GEN_SmartPtr_h
+
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * @author Laurence
+ */
+
+#include <stdlib.h> // for NULL !
+
+/**
+ * @section GEN_SmartPtr
+ * This class defines a smart pointer similar to that defined in
+ * the Standard Template Library but without the painful get()
+ * semantics to access the internal c style pointer.
+ *
+ * It is often useful to explicitely decalre ownership of memory
+ * allocated on the heap within class or function scope. This
+ * class helps you to encapsulate this ownership within a value
+ * type. When an instance of this class goes out of scope it
+ * makes sure that any memory associated with it's internal pointer
+ * is deleted. It can help to inform users of an aggregate class
+ * that it owns instances of it's members and these instances
+ * should not be shared. This is not reliably enforcable in C++
+ * but this class attempts to make the 1-1 relationship clear.
+ *
+ * @section Example usage
+ *
+ * class foo {
+ * ...constructors accessors etc.
+ * int x[1000];
+ * }
+ *
+ * class bar {
+ * public :
+ * static
+ * bar *
+ * New(
+ * ) {
+ * GEN_SmartPtr<foo> afoo = new foo();
+ * GEN_SmartPtr<bar> that = new bar();
+ *
+ * if (foo == NULL || that == NULL) return NULL;
+ *
+ * that->m_foo = afoo.Release();
+ * return that.Release();
+ * }
+ *
+ * ~bar() {
+ * // smart ptr takes care of deletion
+ * }
+ * private :
+ * GEN_SmartPtr<foo> m_foo;
+ * }
+ *
+ * You my also safely construct vectors of GEN_SmartPtrs and
+ * have the vector own stuff you put into it.
+ *
+ * e.g.
+ * {
+ * std::vector<GEN_SmartPtr<foo> > foo_vector;
+ * foo_vector.push_back( new foo());
+ * foo_vector.push_back( new foo());
+ *
+ * foo_vector[0]->bla();
+ * } // foo_vector out of scope => heap memory freed for both foos
+ *
+ * @warning this class should only be used for objects created
+ * on the heap via the new function. It will not behave correctly
+ * if you pass ptrs to objects created with new[] nor with
+ * objects declared on the stack. Doing this is likely to crash
+ * the program or lead to memory leaks.
+ */
+
+template
+ < class T >
+class GEN_SmartPtr {
+
+public :
+
+ /**
+ * Construction from reference - this class
+ * always assumes ownership from the rhs.
+ */
+
+ GEN_SmartPtr(
+ const GEN_SmartPtr &rhs
+ ){
+ m_val = rhs.Release();
+ }
+
+ /**
+ * Construction from ptr - this class always
+ * assumes that it now owns the memory associated with the
+ * ptr.
+ */
+
+ GEN_SmartPtr(
+ T* val
+ ) :
+ m_val (val)
+ {
+ }
+
+ /**
+ * Defalut constructor
+ */
+
+ GEN_SmartPtr(
+ ) :
+ m_val (NULL)
+ {
+ }
+
+ /**
+ * Type conversion from this class to the type
+ * of a pointer to the template parameter.
+ * This means you can pass an instance of this class
+ * to a function expecting a ptr of type T.
+ */
+
+ operator T * () const {
+ return m_val;
+ }
+
+ /**
+ * Return a reference to the internal ptr class.
+ * Use with care when you now that the internal ptr
+ * is not NULL!
+ */
+
+ T &
+ Ref(
+ ) const {
+ return *m_val;
+ }
+
+ /**
+ * Assignment operator - ownership is transfered from rhs to lhs.
+ * There is an intenional side-effect of function of transferring
+ * ownership from the const parameter rhs. This is to insure
+ * the 1-1 relationship.
+ * The object associated with this instance is deleted if it
+ * is not the same as that contained in the rhs.
+ */
+
+ GEN_SmartPtr & operator=(
+ const GEN_SmartPtr &rhs
+ ) {
+ if (this->m_val != rhs.m_val) {
+ delete this->m_val;
+ }
+
+ this->m_val = rhs.Release();
+ return *this;
+ }
+
+ /**
+ * Overload the operator -> so that it's possible to access
+ * all the normal methods of the internal ptr.
+ */
+
+ T * operator->() const {
+ return m_val;
+ }
+
+ /**
+ * Caller takes ownership of the object - the object will not
+ * be deleted when the ptr goes out of scope.
+ */
+
+ T *
+ Release(
+ ) const {
+ T* temp = m_val;
+ (const_cast<GEN_SmartPtr *>(this))->m_val = NULL;
+ return temp;
+ }
+
+ /**
+ * Force destruction of the internal object.
+ */
+
+ void
+ Delete(
+ ) {
+ delete (m_val);
+ m_val = NULL;
+ }
+
+ /**
+ * Destructor - deletes object if it exists
+ */
+
+ ~GEN_SmartPtr(
+ ) {
+ delete (m_val);
+ }
+
+private :
+
+ /// The ptr owned by this class.
+ T * m_val;
+};
+
+#endif
diff --git a/source/kernel/gen_system/Makefile b/source/kernel/gen_system/Makefile
new file mode 100644
index 00000000000..cdaf8e8e598
--- /dev/null
+++ b/source/kernel/gen_system/Makefile
@@ -0,0 +1,43 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# 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. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License. See http://www.blender.org/BL/ for information
+# about this.
+#
+# 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.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+#
+#
+
+LIBNAME = gen_system
+DIR = $(OCGDIR)/kernel/$(LIBNAME)
+
+include nan_compile.mk
+
+CCFLAGS += $(LEVEL_2_CPP_WARNINGS)
+
+CPPFLAGS += -I$(NAN_MOTO)/include
+CPPFLAGS += -I$(NAN_STRING)/include
+
diff --git a/source/kernel/gen_system/SYS_SingletonSystem.cpp b/source/kernel/gen_system/SYS_SingletonSystem.cpp
new file mode 100644
index 00000000000..5692c5348de
--- /dev/null
+++ b/source/kernel/gen_system/SYS_SingletonSystem.cpp
@@ -0,0 +1,99 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * Unique instance of system class for system specific information / access
+ * Used by SYS_System
+ */
+#include "SYS_SingletonSystem.h"
+#include "GEN_DataCache.h"
+
+SYS_SingletonSystem* SYS_SingletonSystem::_instance = 0;
+
+void SYS_SingletonSystem::Destruct()
+{
+ if (_instance) {
+ delete _instance;
+ _instance = NULL;
+ }
+}
+
+SYS_SingletonSystem *SYS_SingletonSystem::Instance()
+{
+ if (!_instance) {
+ _instance = new SYS_SingletonSystem();
+ }
+ return _instance;
+}
+
+int SYS_SingletonSystem::SYS_GetCommandLineInt(const char *paramname, int defaultvalue)
+{
+ int *result = m_int_commandlineparms[paramname];
+ if (result)
+ return *result;
+
+ return defaultvalue;
+}
+
+float SYS_SingletonSystem::SYS_GetCommandLineFloat(const char *paramname, float defaultvalue)
+{
+ float *result = m_float_commandlineparms[paramname];
+ if (result)
+ return *result;
+
+ return defaultvalue;
+}
+
+const char *SYS_SingletonSystem::SYS_GetCommandLineString(const char *paramname, const char *defaultvalue)
+{
+ STR_String *result = m_string_commandlineparms[paramname];
+ if (result)
+ return *result;
+
+ return defaultvalue;
+}
+
+void SYS_SingletonSystem::SYS_WriteCommandLineInt(const char *paramname, int value)
+{
+ m_int_commandlineparms.insert(paramname, value);
+}
+
+void SYS_SingletonSystem::SYS_WriteCommandLineFloat(const char *paramname, float value)
+{
+ m_float_commandlineparms.insert(paramname, value);
+}
+
+void SYS_SingletonSystem::SYS_WriteCommandLineString(const char *paramname, const char *value)
+{
+ m_string_commandlineparms.insert(paramname, value);
+}
+
+SYS_SingletonSystem::SYS_SingletonSystem() : m_soundfilecache(NULL)
+{
+}
diff --git a/source/kernel/gen_system/SYS_SingletonSystem.h b/source/kernel/gen_system/SYS_SingletonSystem.h
new file mode 100644
index 00000000000..c01cb356910
--- /dev/null
+++ b/source/kernel/gen_system/SYS_SingletonSystem.h
@@ -0,0 +1,65 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * Unique instance of system class for system specific information / access
+ * Used by SYS_System
+ */
+#ifndef __SINGLETONSYSTEM_H
+#define __SINGLETONSYSTEM_H
+
+#include "GEN_Map.h"
+#include "STR_HashedString.h"
+#include "GEN_DataCache.h"
+
+class SYS_SingletonSystem
+{
+public:
+ static SYS_SingletonSystem* Instance();
+ static void Destruct();
+
+ int SYS_GetCommandLineInt(const char* paramname,int defaultvalue);
+ float SYS_GetCommandLineFloat(const char* paramname,float defaultvalue);
+ const char* SYS_GetCommandLineString(const char* paramname,const char* defaultvalue);
+
+ void SYS_WriteCommandLineInt(const char* paramname,int value);
+ void SYS_WriteCommandLineFloat(const char* paramname,float value);
+ void SYS_WriteCommandLineString(const char* paramname,const char* value);
+
+ SYS_SingletonSystem();
+
+private:
+ static SYS_SingletonSystem* _instance;
+ GEN_Map<STR_HashedString,int> m_int_commandlineparms;
+ GEN_Map<STR_HashedString,float> m_float_commandlineparms;
+ GEN_Map<STR_HashedString,STR_String> m_string_commandlineparms;
+ void* m_soundfilecache;
+};
+
+#endif //__SINGLETONSYSTEM_H
diff --git a/source/kernel/gen_system/SYS_System.cpp b/source/kernel/gen_system/SYS_System.cpp
new file mode 100644
index 00000000000..48f5b2632fd
--- /dev/null
+++ b/source/kernel/gen_system/SYS_System.cpp
@@ -0,0 +1,77 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * System specific information / access.
+ * Interface to the commandline arguments
+ */
+#include "SYS_System.h"
+#include "SYS_SingletonSystem.h"
+
+SYS_SystemHandle SYS_GetSystem()
+{
+ return (SYS_SystemHandle) SYS_SingletonSystem::Instance();
+}
+
+void SYS_DeleteSystem(SYS_SystemHandle sys)
+{
+ if (sys) {
+ ((SYS_SingletonSystem *) sys)->Destruct();
+ }
+}
+
+int SYS_GetCommandLineInt(SYS_SystemHandle sys, const char *paramname, int defaultvalue)
+{
+ return ((SYS_SingletonSystem *) sys)->SYS_GetCommandLineInt(paramname, defaultvalue);
+}
+
+float SYS_GetCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float defaultvalue)
+{
+ return ((SYS_SingletonSystem *) sys)->SYS_GetCommandLineFloat(paramname, defaultvalue);
+}
+
+const char *SYS_GetCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *defaultvalue)
+{
+ return ((SYS_SingletonSystem *) sys)->SYS_GetCommandLineString(paramname, defaultvalue);
+}
+
+void SYS_WriteCommandLineInt(SYS_SystemHandle sys, const char *paramname, int value)
+{
+ ((SYS_SingletonSystem *) sys)->SYS_WriteCommandLineInt(paramname, value);
+}
+
+void SYS_WriteCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float value)
+{
+ ((SYS_SingletonSystem *) sys)->SYS_WriteCommandLineFloat(paramname, value);
+}
+
+void SYS_WriteCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *value)
+{
+ ((SYS_SingletonSystem *) sys)->SYS_WriteCommandLineString(paramname, value);
+}
diff --git a/source/kernel/gen_system/SYS_System.h b/source/kernel/gen_system/SYS_System.h
new file mode 100644
index 00000000000..2dbd7229612
--- /dev/null
+++ b/source/kernel/gen_system/SYS_System.h
@@ -0,0 +1,70 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * 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. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * System specific information / access.
+ * Interface to the commandline arguments
+ */
+
+#ifndef __SYSTEM_INCLUDE
+#define __SYSTEM_INCLUDE
+
+#define SYS_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
+
+SYS_DECLARE_HANDLE(SYS_SystemHandle);
+
+/**
+ System specific information / access.
+ For now, only used for commandline parameters.
+ One of the available implementations must be linked to the application
+ that uses this system routines.
+ Please note that this protocol/interface is just for testing,
+ it needs discussion in the development group for a more final version.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern SYS_SystemHandle SYS_GetSystem(void);
+extern void SYS_DeleteSystem(SYS_SystemHandle sys);
+
+extern int SYS_GetCommandLineInt(SYS_SystemHandle sys, const char *paramname, int defaultvalue);
+extern float SYS_GetCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float defaultvalue);
+extern const char *SYS_GetCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *defaultvalue);
+
+extern void SYS_WriteCommandLineInt(SYS_SystemHandle sys, const char *paramname, int value);
+extern void SYS_WriteCommandLineFloat(SYS_SystemHandle sys, const char *paramname, float value);
+extern void SYS_WriteCommandLineString(SYS_SystemHandle sys, const char *paramname, const char *value);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__SYSTEM_INCLUDE