]> git.jsancho.org Git - gacela.git/blobdiff - src/gacela.c
(no commit message)
[gacela.git] / src / gacela.c
index 42bfdf062ab1f0788c04a34945cf6266d39093e3..fc7ec31cdd86c73f307bcf8ff5bb4a112c7210a2 100644 (file)
 #include <libgen.h>
 #include "gacela_SDL.h"
 #include "gacela_GL.h"
+#include "gacela_FTGL.h"
 
 static void*
-register_functions (void* data)
+init_gacela (void *data, int argc, char **argv)
 {
+  // Guile configuration
+  scm_c_eval_string ("(set-repl-prompt! \"gacela>\")");
+  scm_c_eval_string ("(use-modules (ice-9 readline))");
+  scm_c_eval_string ("(activate-readline)");
+  scm_c_eval_string ("(use-modules (ice-9 optargs))");
+  scm_c_eval_string ("(use-modules (ice-9 receive))");
+
+  // Bindings for C functions and structs
   SDL_register_functions (NULL);
   GL_register_functions (NULL);
+  FTGL_register_functions (NULL);
+
   return NULL;
 }
 
 void
 load_scheme_files (char *path)
 {
-  //  load_scheme_file (path, "gacela.scm");
-}
+  char load_path[strlen (path) + 1024];
 
-void
-load_scheme_file (char *path, char *filename)
-{
-  char fn[strlen (path) + 1024];
-
-  strcpy (fn, path);
-  strcat (fn, "/");
-  strcat (fn, filename);
-
-  scm_c_primitive_load (fn);
+  sprintf (load_path, "(set! %%load-path (cons \"%s\" %%load-path))", path);
+  scm_c_eval_string (load_path);
+  scm_primitive_load_path (scm_from_locale_string ("gacela_loader.scm"));
 }
 
 int
 main (int argc, char *argv[])
 {
-  scm_with_guile (&register_functions, NULL);
-  scm_init_guile ();
-  scm_c_eval_string ("(set-repl-prompt! \"gacela>\")");
-  scm_c_eval_string ("(use-modules (ice-9 readline))");
-  scm_c_eval_string ("(activate-readline)");
-  scm_c_eval_string ("(use-modules (ice-9 optargs))");
+  scm_with_guile (&init_gacela, NULL);
   load_scheme_files (dirname (argv[0]));
   scm_shell (argc, argv);
 }