summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2011-01-06 15:48:58 +0000
committerIan C <ianc@noddybox.co.uk>2011-01-06 15:48:58 +0000
commit7523d7b685d835aab01f0253ba9530de7b5446d4 (patch)
treeff14abcc5cc2b73639009a97b9e08e3cc5502cba
parent221f8b42adeb776e10944a5ed3835b8f00434985 (diff)
Development checkin
-rw-r--r--BUILD4
-rw-r--r--config/config44
-rw-r--r--driver/BUILD10
-rw-r--r--include/graviface.h91
4 files changed, 130 insertions, 19 deletions
diff --git a/BUILD b/BUILD
index d5a19b5..eb26ee9 100644
--- a/BUILD
+++ b/BUILD
@@ -7,7 +7,7 @@ grav has the following dependencies:
To build grav:
$ cd grav
-$ make depend
+$ ./configure
$ make
This will generate the executable, grav. See INSTRUCTIONS for instructions on
@@ -23,5 +23,3 @@ directory.
* SDL 1.2
* SDL Image
* OpenGL
-
-
diff --git a/config/config b/config/config
index 08a7a4a..288fdb8 100644
--- a/config/config
+++ b/config/config
@@ -10,23 +10,43 @@
#
-# This defines any textures to load, and the names applied to them. Any image
-# format supported by SDL Image should be loadable.
+# This defines the GFX driver. If left undefined then the data generated is
+# simply dumped to stdout.
#
-[textures]
-example1 = files/file.png
-example2 = files/file.png
+# Drivers can have their own personal configuration section elsewhere.
+#
+[gfx]
+driver = drivers/sdl-gl.so
-# This enables or disables various graphical effects. The defaults for the
-# effects are given here.
+# Example driver configuration.
#
-[gfx]
-trails = yes
+[sdl-gl]
+width = 800
+height = 600
+fullscreen = yes
-# This defines the bodies that will be placed in the simulation.
+# This defines any textures to load, and the names applied to them. Supported
+# image formats will depend on the loaded GFX driver.
+#
+[textures]
+example1 = files/file.png
+example2 = files/file.png
+
+
+# This defines the bodies that will be placed in the simulation and the
+# constants for this universe.
+#
+# For this simulation the force acting on mass m1 from mass m2 is calculated
+# as:
+#
+# F = G x (m2 / r^2)
+#
+# This force is a vector, which normalised is the equivalent of one of the
+# co-ordinate axes discrete values in a single step of the simulation.
#
[universe]
-body = sun
-body = planet
+G = 1
+body = sun
+body = planet
diff --git a/driver/BUILD b/driver/BUILD
index ae16a7a..84b11e6 100644
--- a/driver/BUILD
+++ b/driver/BUILD
@@ -1,7 +1,9 @@
-The following display drivers are available:
+Following are the build instructions for each individual driver.
-SDL-GL [NOT YET AVAILABLE]
+============================================================================
+
+SDL-GL [NOT YET COMPLETE]
Displays using OpenGL and SDL. Require the following:
@@ -12,7 +14,7 @@ SDL-GL [NOT YET AVAILABLE]
To make:
$ cd sdl-gl
- $ make depend
+ $ ./configure
$ make
- This generates sdl-gl.so
+ This generates a sharable object for sdl-gl.
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 */