]> git.jsancho.org Git - gacela.git/blob - gacela_core.c
(no commit message)
[gacela.git] / gacela_core.c
1 #include <SDL/SDL.h>
2 #include <GL/gl.h>
3 #include <libguile.h>
4 #include <pthread.h>
5
6 SCM prueba () {
7         int flags;
8
9         SDL_Init (SDL_INIT_EVERYTHING);
10
11         SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
12
13         flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_RESIZABLE | SDL_SWSURFACE;
14         SDL_SetVideoMode (200, 200, 32, flags);
15
16         glShadeModel (GL_SMOOTH);
17         glClearColor (0, 0, 0, 0);
18         glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
19         glViewport (0, 0, 200, 200);
20         glMatrixMode (GL_PROJECTION);
21         glLoadIdentity ();
22         glOrtho (-200, 200, -200, 200, 0, 1);
23         glMatrixMode (GL_MODELVIEW);
24         glLoadIdentity ();
25
26         return SCM_UNSPECIFIED;
27 }
28
29 void *bucle () {
30         while (1) {
31                 scm_c_eval_string("(define contador (+ contador incremento))");
32                 scm_c_eval_string("(if (> contador 1000) (define incremento -1))");
33                 scm_c_eval_string("(if (< contador 0) (define incremento 1))");
34         }
35         pthread_exit(NULL);
36 }
37
38 void *bucle2 () {
39         char *argv[0];
40         
41         argv[0] = malloc(10);
42         strcpy(argv[0], "./gacela");
43         scm_shell(1, argv);
44 }
45
46 int lanzar_bucle2 () {
47         pthread_t t;
48
49         pthread_create(&t, NULL, bucle2, NULL);
50         return 0;
51 }
52
53 SCM lanzar_bucle () {
54         pthread_t t;
55
56         pthread_create(&t, NULL, bucle, NULL);
57         return SCM_UNSPECIFIED;
58 }
59
60 /*SCM ver_contador () {
61         return scm_from_int(contador);
62 }*/
63
64 static void*
65 register_functions (void* data)
66 {
67         scm_c_define_gsubr ("prueba", 0, 0, 0, &prueba);
68 //      scm_c_define_gsubr ("ver-contador", 0, 0, 0, &ver_contador);
69         scm_c_define_gsubr ("lanzar-bucle", 0, 0, 0, &lanzar_bucle);
70         return NULL;
71 }
72
73
74 int main (int argc, char *argv[]) {
75         scm_with_guile (&register_functions, NULL);
76         scm_c_eval_string("(set-repl-prompt! \"gacela>\")");
77         scm_c_eval_string("(use-modules (ice-9 readline))");
78         scm_c_eval_string("(activate-readline)");
79         scm_c_eval_string("(define contador 0)");
80         scm_c_eval_string("(define incremento 1)");
81 //      scm_shell (argc, argv);
82         lanzar_bucle2();
83         while (1) {}
84 }
85