Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Two severe limitations in Graphics module
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-08-27 (22:37)
From: Berke Durak <berke@a...>
Subject: [Caml-list] Two severe limitations in Graphics module
Hello everyone,

I was wondering how many hours would coding Tetris using the Graphics
module require when I noticed that the Graphics module lacks two
important constructs :

1) The Graphics.wait_next_event doesn't allow you to wait for an event
with a timeout, à la select(). Since in Tetris things might happen
even if you don't press any key, you can't wait indefinitely.

Workarounds include :
	-- continuously calling wait_next_event [Poll;...]  and doing a
small delay between each call. I think I will do this. Not very
efficient, since the delay must be of the order of the screen refresh
	-- do a horrible hack by getting the X11 file descriptor -- but
then how will Microsoft-sequestrated people enjoy your delightful
MLtris ?

2) There is no way to get the cursor keys. Sure that's no problem to
h,j,k,l-people. Might I suggest the following bindings :

	-- left : '\002' (Ctrl-b)
	-- right : '\006' (Ctrl-f)
	-- up : '\011' (Ctrl-k)
	-- down : '\010' (Ctrl-j)

or a supplementary keysym type like

	type keysym = Latin1 of char | Left | Right | Up | Down | ...

3) It would further be nice to be able to select() another FD plus
the graphical interface, portably if possible. I know, under UNIX,
simply adding a function to the Graphics module that returns the
descriptor of the X11 connection would solve problems 1 and 3.
That would be non portable.

Has anyone managed to solve these issues cleanly (i.e. without
patching the compiler) ?
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: