From 44525767b158902ea0183b4e5e36973bea010a08 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 14 Jan 2011 15:14:14 +0000 Subject: Development checkin --- config/config | 40 ++++++++++----------- include/graviface.h | 100 --------------------------------------------------- src/graviface.h | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 120 deletions(-) delete mode 100644 include/graviface.h create mode 100644 src/graviface.h diff --git a/config/config b/config/config index 288fdb8..1238e11 100644 --- a/config/config +++ b/config/config @@ -10,29 +10,13 @@ # -# This defines the GFX driver. If left undefined then the data generated is -# simply dumped to stdout. +# This defines the output driver. If left undefined then the data generated is +# simply dumped to stdout in a simple XML format. # # Drivers can have their own personal configuration section elsewhere. # -[gfx] -driver = drivers/sdl-gl.so - - -# Example driver configuration. -# -[sdl-gl] -width = 800 -height = 600 -fullscreen = yes - - -# 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 +[output] +driver = sdl-gl.so # This defines the bodies that will be placed in the simulation and the @@ -50,3 +34,19 @@ example2 = files/file.png G = 1 body = sun body = planet + + +# Example sdl-gl driver configuration. +# +[sdl-gl] +width = 800 +height = 600 +fullscreen = yes + +[sdl-gl-textures] +example1 = files/file1.png +example2 = files/file2.png + +[sdl-gl-texture-mappings] +sun = example1 +planet = example2 diff --git a/include/graviface.h b/include/graviface.h deleted file mode 100644 index a632e3d..0000000 --- a/include/graviface.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - grav - N-body gravity simulation - - Copyright (C) 2011 Ian Cowburn - - 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 . - - $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 - - -/* --------------------------------------------------------------------------- - 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 iterate over loaded config. - p_func is called for every variable in the section along with the - pass client data. - */ - const char (*grav_config_func)(const char *p_section, - void (*p_func)(void *p_client_data, - const char *p_section, - const char *p_value), - void *p_client_data); - - /* 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; - - -/* --------------------------------------------------------------------------- - This structure defines a mass to be drawn. Masses are passed in arbitary - order. Each mass has a unique identifier, which is defined by "id". -*/ -typedef struct -{ - mpz_t id; -} grav_public_mass_t; - - -/* --------------------------------------------------------------------------- - 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 */ diff --git a/src/graviface.h b/src/graviface.h new file mode 100644 index 0000000..a34f7b5 --- /dev/null +++ b/src/graviface.h @@ -0,0 +1,101 @@ +/* + grav - N-body gravity simulation + + Copyright (C) 2011 Ian Cowburn + + 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 . + + $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 + + +/* --------------------------------------------------------------------------- + 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 iterate over loaded config. + p_func is called for every variable in the section along with the + pass client data. + */ + const char (*grav_config_func)(const char *p_section, + void (*p_func)(void *p_client_data, + const char *p_section, + const char *p_value), + void *p_client_data); + + /* 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; + + +/* --------------------------------------------------------------------------- + This structure defines a mass to be drawn. Masses are passed in arbitary + order. Each mass has a unique identifier, which is defined by "id". +*/ +typedef struct +{ + mpz_t id; + const char *name; +} grav_public_mass_t; + + +/* --------------------------------------------------------------------------- + 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 */ -- cgit v1.2.3