A couple questions from a Lisp / Lush newb
Yann LeCun <[email protected]>
| Newsgroups | gmane.lisp.lush.devel |
|---|---|
| Message-ID | <[email protected]> |
Keir,
> a) How do I actually display a SDL_Surface object? I'm not familiar
> with SDL, so I looked at the docs, and they seemed to indicate the
> Screen object is actually an SDL_surface,
> (see http://www.libsdl.org/intro/usingvideo.html) yet
> (setq scr (new sdl-screen 640 480 "lander"))
> (sdl-surface-w scr)
> generates errors.
OK, (setq scr (new sdl-screen 640 480 "lander")) opens an SDL screen.
The SDL surface that corresponds to that screen is in the p slot of scr,
so :scr:p is a pointer to an SDL_Surface.
That, said, you don't need to go to such low-level for what you
want to do.
> What would be the best way to implement Conway's game of life
> with SDL as the display engine? (I want a super-fast simulation).
The best solution is probably to use the sdlidx-screen class:
(setq m (ubyte-matrix 480 640 3))
(setq scr (new sdlidx-screen m "Game of Life"))
This opens a 640x480 SDL screen.
Whatever you write into matrix m can be slapped
on the screen with a simple call to (==> scr flip).
So, for example (m y x 0), (m y x 1), (m y x 2) would
be the R,G, and B components to pixel (x,y).
Your game of life would look like this:
(while t
(game-of-life-update m)
(==> scr flip))
> Perhaps this can be the basis of another tutorial to help people
> along with the matrix capabilities of Lush?
Absolutely.
> b) I did the first part of the SDL-Lander tutorial, then started running
> with it on my own and added gravity, etc. However, the 'q' key does
> not work to quit, and it never did. I end up having to kill the
> SDL window. I tried copying and pasting the code for lander04 from
> the web, and it doesn't seem to work at all.
The program for the tutorial is in lush/packages/sdl/demos/tutorial.lsh
Your problem is caused by the absence of the following line:
(setq pi/180 (/ 3.1415927 180))
Anyway, if you do (load "sdl/demos/tutorial") and then (lander04)
it should work.
> c) What is there in terms of data visualization support?
Well, so far, there is only support for low-level OpenGL/GLU/GLUT
but nothing on top of this for visualization or anything.
> I was thinking perhaps
> someone (me?) should add integration with IBM's very pretty OpenDX:
> http://www.opendx.org/index2.php
That would be very cool. The only problem I see is a potential
incompatibility between licenses (IBM's license seems incompatible
with the GPL). This may stop us from distributing an OpenDX interface
as part of the standard Lush package, but it would certainly not stop
anyone from getting Lush, OpenDX, and the Lush/OpenDX interface separately.
-- Yann
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf