I have a perl script that generates the X,Y and brightness coordinate for a motion starfield. It very basic at the moment with basic orbits just for testing.

I don't want the system to boot to a desktop environment so just running from shell. I also connect remotly to the Pi and have it connected to a TV/Monitor via the HDMI port.

What I want to learn how to do is with in the Perl script, create a full screen X session on the HDMI port that I can plot points on to.

Could any one give me the basic out line of a perl script that would create the X session, and plot 3 or 4 points randomly on the screen that I can then adapt to my needs. I don't really know any thing about X sessions and how to control them, I don't need any thing fancy, just create a 2D canvass I can plot points to, at the moment the star field has about 2000 separate points that I want to plot at different brightness. Calculate the new positions and then refresh the screen.

Once I get the basic output I want to introduce Gravity and more Binary systems to the mix along with a few shooting stars stuff. Before getting hold of a pic laser projector and seeing what effect I can get in a dark room on a wall.


This kind of thing but with a bit more variation. If I can get the fundamental system working I would like to simulate real systems as well as just random fields that the user can chose via a simple on screen menu.

I am sure at some stage perl might not be the language to use but for now just want to see what kind of performance the Pi can deliver how may stars/objects can it compute and plot at a reasonable frame rate.


While Xlib does provide a graphics API,1 the normal way to do something like this would be via a higher level library such as SDL, for which there is a perl interface (there is a package in raspbian, libsdl-perl). SDL on linux makes use of OpenGL, meaning in theory it could engage hardware acceleration on the pi, although I believe not all the necessary parts for that are in place currently. However, people have made use of "pygame" on the pi, which uses SDL via python, so it must work well enough (perl is in more or less the same league as python here).

Another option would be to use the kernel framebuffer without X. This is how things like fbi and omxplayer work, and there is at least one perl interface for that too.

I am sure at some stage perl might not be the language

The pi itself is a limiting factor, and perl will generally be slower than native code, but I think you have a very good chance of getting what you want. In any case, perl is great for prototyping, as the modules are (usually) transparently built on top of native libraries, so if at some point you want to switch over to C or C++, you will already understand (e.g.) SDL and the structure of your program will be established. This is useful since coding something in perl takes a fraction of the amount of time it takes to code the same thing in C/C++, and that is time you will save in the early stages, when things may be subject to frequent and radical change ;)

IMO, the primary factor WRT to the viability of a project like this is not the language you use, but how well you use it.

What I want to learn how to do is with in the Perl script, create a full screen X session on the HDMI port that I can plot points on to.

It makes much more sense to start X with the perl application inside it, rather than vice versa. It could even be the only application (i.e., no "desktop environment", etc), something along the lines of what I've suggested here with respect to midori.

1. Although that part of Xlib does not appear to be ported in the perl module.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.