From: jsancho Date: Sat, 16 Apr 2011 06:45:45 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=d4cff32858a9ff65b06f1430810699a91fbcc2b9;p=gacela.git --- diff --git a/gacela.c b/gacela.c index 24dda3d..1cd7412 100644 --- a/gacela.c +++ b/gacela.c @@ -1,68 +1,11 @@ -#include -#include -#include -#include +#include -SCM prueba () { - int flags; - - SDL_Init (SDL_INIT_EVERYTHING); - - SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); - - flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_RESIZABLE | SDL_SWSURFACE; - SDL_SetVideoMode (200, 200, 32, flags); - - glShadeModel (GL_SMOOTH); - glClearColor (0, 0, 0, 0); - glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); - glViewport (0, 0, 200, 200); - glMatrixMode (GL_PROJECTION); - glLoadIdentity (); - glOrtho (-200, 200, -200, 200, 0, 1); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - - return SCM_UNSPECIFIED; -} - -void *bucle () { - while (1) { - scm_c_eval_string("(define contador (+ contador incremento))"); - scm_c_eval_string("(if (> contador 1000) (define incremento -1))"); - scm_c_eval_string("(if (< contador 0) (define incremento 1))"); - } - pthread_exit(NULL); -} - -SCM lanzar_bucle () { - pthread_t t; - - pthread_create(&t, NULL, bucle, NULL); - return SCM_UNSPECIFIED; -} - -/*SCM ver_contador () { - return scm_from_int(contador); -}*/ - -static void* -register_functions (void* data) +int main (int argc, char *argv[]) { - scm_c_define_gsubr ("prueba", 0, 0, 0, &prueba); -// scm_c_define_gsubr ("ver-contador", 0, 0, 0, &ver_contador); - scm_c_define_gsubr ("lanzar-bucle", 0, 0, 0, &lanzar_bucle); - return NULL; -} + char exp[1024]; + printf("gacela>"); + scanf("%s", exp); -int main (int argc, char *argv[]) { - scm_with_guile (®ister_functions, NULL); - 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("(define contador 0)"); - scm_c_eval_string("(define incremento 1)"); - scm_shell (argc, argv); + return 0; } - diff --git a/gacela_core.c b/gacela_core.c new file mode 100644 index 0000000..3d2a398 --- /dev/null +++ b/gacela_core.c @@ -0,0 +1,85 @@ +#include +#include +#include +#include + +SCM prueba () { + int flags; + + SDL_Init (SDL_INIT_EVERYTHING); + + SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); + + flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE | SDL_RESIZABLE | SDL_SWSURFACE; + SDL_SetVideoMode (200, 200, 32, flags); + + glShadeModel (GL_SMOOTH); + glClearColor (0, 0, 0, 0); + glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + glViewport (0, 0, 200, 200); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + glOrtho (-200, 200, -200, 200, 0, 1); + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + + return SCM_UNSPECIFIED; +} + +void *bucle () { + while (1) { + scm_c_eval_string("(define contador (+ contador incremento))"); + scm_c_eval_string("(if (> contador 1000) (define incremento -1))"); + scm_c_eval_string("(if (< contador 0) (define incremento 1))"); + } + pthread_exit(NULL); +} + +void *bucle2 () { + char *argv[0]; + + argv[0] = malloc(10); + strcpy(argv[0], "./gacela"); + scm_shell(1, argv); +} + +int lanzar_bucle2 () { + pthread_t t; + + pthread_create(&t, NULL, bucle2, NULL); + return 0; +} + +SCM lanzar_bucle () { + pthread_t t; + + pthread_create(&t, NULL, bucle, NULL); + return SCM_UNSPECIFIED; +} + +/*SCM ver_contador () { + return scm_from_int(contador); +}*/ + +static void* +register_functions (void* data) +{ + scm_c_define_gsubr ("prueba", 0, 0, 0, &prueba); +// scm_c_define_gsubr ("ver-contador", 0, 0, 0, &ver_contador); + scm_c_define_gsubr ("lanzar-bucle", 0, 0, 0, &lanzar_bucle); + return NULL; +} + + +int main (int argc, char *argv[]) { + scm_with_guile (®ister_functions, NULL); + 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("(define contador 0)"); + scm_c_eval_string("(define incremento 1)"); +// scm_shell (argc, argv); + lanzar_bucle2(); + while (1) {} +} +