Re: REPL and OpenGL

2013-06-07 Thread Oskar Wieland

Hi,

thanks for the suggestions but I couldn't find a way to get it worrking 
together.


Maybe I didn't made myself clear enough, the link shows what I'm trying 
to do:


Lisp, Opengl and live editting of code:
http://www.youtube.com/watch?v=XLkUI89fgRI

Is this possible with picoLisp?

Regards
Oskar
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: REPL and OpenGL

2013-06-07 Thread Alexander Burger
Hi Oskar,

 Maybe I didn't made myself clear enough, the link shows what I'm
 trying to do:
 
 Lisp, Opengl and live editting of code:
 http://www.youtube.com/watch?v=XLkUI89fgRI
 
 Is this possible with picoLisp?

Yes ... as I said in my last mail:

   Can we find out the socket fd where the events arrive on?

   If so, then I would trigger 'glutMainLoopEvent' whenever an event
   arrives:

   (task socketFd (glutMainLoopEvent))

So you must put the call to (glutMainLoopEvent) into a background task.
The same mechanism is used in the PicoLisp GUI, for example.

Then you have the normal ':' prompt and you can debug your program while
the OpenGL output runs in the separate X11 window.

But 'task' either requires a file descriptor (a positive number,
typically a socket) or a timeout value in milliseconds (a negative
number). The timeout is probably not so useful, so the question is if it
is possible to get hold of some file descriptor (socker, pipe or
whatever) where the X11 events are signalled.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: REPL and OpenGL

2013-06-07 Thread Alexander Burger
On Fri, Jun 07, 2013 at 03:01:43PM +0200, Alexander Burger wrote:
Can we find out the socket fd where the events arrive on?
 
If so, then I would trigger 'glutMainLoopEvent' whenever an event
arrives:
 
(task socketFd (glutMainLoopEvent))
 
 So you must put the call to (glutMainLoopEvent) into a background task.
 The same mechanism is used in the PicoLisp GUI, for example.

If such a file descriptor is indeed not available, then simply replace

   (catch 'quit (glutMainLoop))

with

   (task -10 0
  (native `*GlutLib glutMainLoopEvent) )

i.e. set a background task with a 10 msec timeout.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: REPL and OpenGL

2013-05-28 Thread Alexander Burger
Hi Oskar,

 Thus I added the following definition from glut to OpenGL:
 : (de glutMainLoopEvent () (native `*GlutLib glutMainLoopEvent) )
 
 I set up some kind of main loop:
 : (mouseFunc '((Btn State X Y) (setq _run NIL))) # Exit upon mouse click
 : (de go () (setq _run T)(while _run (glutMainLoopEvent)))
 
 Is there a function to keep the REPL in the console alive, like
 
 (de go () (setq _run T)(while _run (glutMainLoopEvent DO_THE_REPL)))
 
 or is there another (better) way to create a OpenGL window without
 loosing control to glutMainLoop?

I would simply use catch and throw:

   (mouseFunc
  '((Btn State X Y)
 (if (= Btn 1)
(throw 'quit)  # Stop on middle button press
... do something with other button presses ... ) ) )

   (catch 'quit (glutMainLoop))


'glutMainLoopEvent' might also be useful. Can we find out the socket fd
where the events arrive on?

If so, then I would trigger 'glutMainLoopEvent' whenever an event
arrives:

   (task socketFd (glutMainLoopEvent))

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: REPL and OpenGL

2013-05-28 Thread Jorge Acereda Maciá
A couple of options:

- Use coroutines and yield control to the main thread in the glutIdleFunc.
- Use a library that doesn't take control of the main loop. I can think of mine 
( http://code.google.com/p/libaw/ ) and GLFW ( http://www.glfw.org ).


On May 28, 2013, at 10:57 AM, Oskar Wieland oskar.wiel...@gmx.de wrote:

 Hi,
 
 I'm trying to create an OpenGL window without loosing control to the 
 glutMainLoop.
 
 Thus I added the following definition from glut to OpenGL:
 : (de glutMainLoopEvent () (native `*GlutLib glutMainLoopEvent) )
 
 I set up some kind of main loop:
 : (mouseFunc '((Btn State X Y) (setq _run NIL))) # Exit upon mouse click
 : (de go () (setq _run T)(while _run (glutMainLoopEvent)))
 
 Is there a function to keep the REPL in the console alive, like
 
 (de go () (setq _run T)(while _run (glutMainLoopEvent DO_THE_REPL)))
 
 or is there another (better) way to create a OpenGL window without loosing 
 control to glutMainLoop?
 
 Oskar
 -- 
 UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe