summaryrefslogtreecommitdiff
path: root/include/graviface.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/graviface.h')
-rw-r--r--include/graviface.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/include/graviface.h b/include/graviface.h
new file mode 100644
index 0000000..9e422fa
--- /dev/null
+++ b/include/graviface.h
@@ -0,0 +1,91 @@
+/*
+ grav - N-body gravity simulation
+
+ Copyright (C) 2011 Ian Cowburn <ianc@noddybox.co.uk>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+
+ $Id$
+
+ This file provides a common interface shared between the core grav
+ program and the GFX drivers.
+*/
+
+#ifndef GRAV_GRAVIFACE_H
+#define GRAV_GRAVIFACE_H "$Id$"
+
+#include <mp.h>
+
+
+/* ---------------------------------------------------------------------------
+ This determinate the version of the interface, so both sides can
+ check they were built with the same interface.
+*/
+#define GRAV_INTERFACE_VERSION 1
+
+
+/* ---------------------------------------------------------------------------
+ This type defines an instance of any data that the driver needs to maintain.
+ As the drivers are sharable objects, it is recommended that this points to
+ dynamic memory.
+*/
+typedef void *grav_interface_t;
+
+
+/* ---------------------------------------------------------------------------
+ This structure is passed to the driver on initialisation so it can check
+ compataility. The first field is guaranteed to be an int
+ holding GRAV_INTERFACE_VERSION.
+*/
+typedef struct
+{
+ /* Interface version info.
+ */
+ int grav_interface_version;
+
+ /* The version of the GNU MP library the core is compiled against.
+ */
+ int grav_mp_version_major;
+ int grav_mp_version_minor;
+
+ /* An interface the driver can use to query the loaded config. If the
+ variable is undefined NULL is returned, else its value.
+ */
+ const char (*grav_config_func)(const char *p_section,
+ const char *p_variable);
+
+ /* An interface the driver can use to request termination. p_reason can
+ be NULL.
+ */
+ void (*grav_exit_func)(const char *p_reason);,
+
+} grav_icb_t;
+
+
+/* ---------------------------------------------------------------------------
+ Drawing commands? -- Pass structs with masses, or discrete drawing funcs?
+*/
+
+
+/* ---------------------------------------------------------------------------
+ This function must be exported by the driver, and is used to initialise the
+ driver. If the driver disagrees with the version then false should be
+ returned, otherwise true.
+
+ The passed pointer is a pointer to a grav_icb_t.
+*/
+typedef int (*grav_interface_init_func)(const void *p);
+
+
+#endif /* GRAV_GRAVIFACE_H */