Showing posts with label screensaver. Show all posts
Showing posts with label screensaver. Show all posts

Monday, 27 August 2012

Hello, is it me you're looking for?

Elegant simplicity. Those were the days *sniff*.
(Atari 800XL emulated with Atari 800 Win PLus)
It never ceases to amaze me how satisfying "Hello world!" can be.

It seems so trivial now, but way back in the proverbial day the shortest BASIC program felt like a triumph.

Nearly 30 years on, the language may have changed but it's still satisfying proof that you can get something to work. In this instance it took seconds to write some C++, a couple of hours spread over half a week to work out how to cross-compile from Ubuntu to Rasbian. The relief at finally seeing those immortal words was immeasurable. Could be worse I suppose - it took researchers two years to write the first non-trivial program in Malbolge.

Virtual machine, Makefile, C++, compile, SFTP, SSH session,
and it's done. This is progress, people! Or horses for
courses, you decide.
To cut a long story short, the ARM cross-compile toolchain in the Ubuntu repos is set up for ARMv7 onwards whereas the Raspberry Pi has an ARMv6. With just a few parameters in the makefile you can tell it to compile for ARMv6 with hard float, but you also need to get hold of some ARMv6 static libraries - I just copied them over from the RPi. There's a toolchain on the Raspberry Pi repository on github which already has the correct parameters and libaries, but it's 32-bit so I had to install some 32-bit libraries to get it to run on my 64-bit Ubuntu virtual machine (libc6-i386 and lib32z1 if you're asking). It worked on 32-bit Ubuntu with no fiddling at all, but it took me a week's worth of evenings to figure that out.

This is all well and good when I'm only using the most basic libraries which come with the toolchain, but to do more interesting stuff I'll be needing more libraries. I still don't think I've found the ideal solution to this: at the moment I'm rsyncing the Raspbian libraries over from the Raspberry Pi. Compiling libraries from source seems a bit of a wasted effort. I wonder if I can set up APT to get the Raspbian libraries directly from the repo?

I've managed to get the core part of my OpenGL screensaver working on the Raspberry Pi now. It's incredibly slow, and I think that's because I'm using the OpenGL libraries which aren't supported by the GPU, so it's using the Mesa software drivers instead. To use the GPU I'm going to need to switch to Open GL ES and EGL, and that's a whole new can of worms but it's ultimately what I wanted to do anyway.

So it's been a bit of a frustrating fortnight, I've broken my update-a-week guideline, and spent too much time floundering around trying to understand the infrastructure with too little tangible progress. Having said that, floundering around for a while is fine so long as something is learnt in the process, and I think I've learnt a lot more about the GNU C++ toolchain, in particular the linker. Hopefully I'll start getting my head round OpenGL ES soon, I think it's mostly the same as regular OpenGL and it's just a matter of appreciating the differences.

Tuesday, 24 July 2012

Hello, good evening, welcome to nothing much

Welcome, gentle reader, to my blog of adventures in geekery.

Since I heard about the Raspberry Pi project I've been getting progressively more and more excited about it. I'm of the same generation as the RPi's creators, the generation of bedroom programmers and electronics hobbyists who grew up to become the engineers of today, so I can appreciate what they're trying to do with it as a way to introduce kids to programming. But it's also a great platform for more experienced tinkerers to play with, as it can easily be powered by batteries and at under £30 you don't have to be too worried about breaking it. The early adopters have had their RPis for a while now and come up with some great projects like this one. 

Due to the somewhat distracting arrival of our second child I've not pounced on the RPi as quickly as some, and by the time I'd registered my interest there was a waiting list before they'd even take a pre-order. But the orders opened up earlier this month and I placed mine last week, apparently it's now been dispatched so I'm getting giddy with excitement. Unfortunately the RPi doesn't currently come with all of the bits and pieces you need to get started, you need to order those separately and I'm going to have to wait for those. There's not much I can do without a power cable and the one I ordered isn't due for a month (!), so I'll have to see if I can use my iPad's mains to USB adaptor until the dedicated one turns up though I've seen some reports that it's been found to be inadequate. I've not ordered a powered USB hub as the decent ones are more expensive than the RPi itself, though having read a bit about power requirements and polyfuses I'm not so sure I can get away without it. Hub or hubris?

And that brings me clumsily to the point of this blog - essentially a lab book with style sheets, to keep track of my Raspberry Pi projects and other geeky projects I'm up to. It's purely for my own benefit, though should anyone other than myself and my mum read it then all the better. However as most of my friends are people from college or work colleagues, many of whom are far smarter than me and more knowledgeable about this stuff, I expect they'll only read it for the schadenfreude gleaned from my inability to perform simple tasks such as setting up SSH (must be the firewall, or I'll have to get out Wireshark).

So what have I got planned? Well, I've seen enough hardware bringups to be painfully aware that it's best to walk before I try running - let me just get the bleedin' thing plugged in and booting reliably first. Then I can try a few simple projects, maybe a Squeezebox type thing? After that I've got my eye on those GPIOs, and I'm wondering what I can wire up to them. One of my favourite toys when I were a nipper was BigTrak and I was thinking of making a programmable robot type thing, maybe add a camera, a few sensors, battery pack or really long power cable, etc., then it's all "just" software. There are lots of pre-made robot parts which I could use, the question is how much I want to make myself? Maybe I should just buy a BigTrak, chuck out the microcontroller and use the chassis?

Fifty-Nine Icosahedra screensaver (in windowed mode
for screenshot) - looks better when moving, but still
not good
As for other geek projects - they're currently languishing, damning reminders of the fact that I'm not a completer/finisher. I've been trying to get some C++ practise in an environment where I'm not afraid of breaking stuff (i.e. not work) and I've wanted to do some 3-D projects since I wrote a crude 3-D engine in college. One project is an animation tool which will do inverse kinematics, but after initial success in rendering meshes and skinning them with DirectX (and that was a mission and a half, I tells ya) I decided to switch to OpenGL and got bogged down in the code which loads in resources and follows references to more resources. So that's on permanent hold until I can be bothered with it again. I also wrote a screensaver which renders the Fifty-Nine Icosahedra. The hardest bit was recalling enough GCSE-grade trig to sort out the geometry, but once I got there it gasped into life and... it was a bit disappointing really. Though there are some really weird shapes, on the whole they're a bit samey. It really needs someone with a girlier eye to pick a decent colour scheme, or maybe it'd be better with a single colour, some light sourcing and anti-aliasing, and it could do with some funky transitions between the shapes. Also I tried it at work where it really doesn't agree with my dual monitors, though I'm told that's a problem with many screensavers. I might resume work on that once I get over my disappointment. I wonder if it'd work with the RPi's OpenGL ES? It already works under  Windows or Linux, might need some minor mods to the XWindows code

So that feature-length pilot was a small taste of the hi jinks to come. With luck my Raspberry Pi will arrive soon and the next instalment will be all about how easy it was to set up. Or have close-ups of the voltage regulator with a neat white hole burnt through it.