Wednesday, 27 August 2008

Future of Web....

We have so many interesting things going on. IE8 will be out soon, we've got Silverlight 2 in beta. Mozilla are working hard on TraceMonkey (huge Javascript speed-ups).

What I'd like now is two things... The first is a decent, stable DOM style interface to OpenGL (pref something like ES). The second is the ability to push and pull data from OGL. Given the amazing stunts even an old GPU can perform (operations on vectors and arrays of floats - often programmable but "simple" stuff like Multiply Accumulate and lovely matrix methods... SOoooo, what can't we have that?

The best thing to do is this... 1 - Read the OGLES spec carefully. 2 - Kill all the crap you don't need (all that old GLU type stuff). 3 - Describe the interface carefully in a format that JS will love. 4 - Release it as a standard FF plugin.

PLEASE!

Sunday, 17 August 2008

Ah.

What a nice quiet evening...

Wednesday, 13 August 2008

Mediawatch UK - FAIL! Daily Mail - FAIL!!!

Because of this...

Parents horrified as most violent video game ever to launch on 'family friendly' Wii

I now REALLLLLYYYY want 'MadWorld'! For a start it's Sega. Secondly... look at that style. Gotta love it. I'm not a huge fan of "realistic" graphics. Some of the sexiest games ever simply don't bother like (Crazy Taxi, Jet Set Radio, F0X, Rez etc...

John Beyer was quoted as saying "I've never seen this game for real or even heard of it but I think the authors should be hung from the nearest lamp post and all their women handed over to me for debriefing"

Quote the Mail "Nintendo's Wii has enjoyed phenomenal success as an innocent alternative to complex - and often violent - role play video games."... errr like Zelda? It's pretty violent when you analyse it... how about Boxing in Wii Sports, not exactly knitting practice eh?

As for the "Parents horrified"... well, amazingly not a single one was cited in the article.

I suspect the connection between the Mail and Mediawatch is some form deviant homosexual, Satanic pact to control all that we see and hear. Time will tell...

A representative from Sega left the following message "HAHHAHHHAAA Thanks for all the free publicity fuck face!"

Saturday, 9 August 2008

Retro fitting a Sony T1XP with an SSD HD.

MY (lovely) Sony T1XP _has_ had it's problems over the years. Mostly the result of excessive use and travel! Although only a 1.1Ghz Pentium M it still sharp and snappy running Win2K Pro or XP Pro. My machines run "odd" software. I'm not a regular user being a bit of a hacker. The sort of things I like to run on it are Dev Studio, MingW or similar, Photoshop, Firefox + debugging extensions, Cool Edit Pro/Audition and various control panels for outboard gear.

In the past the 40 gig 1.8" PATA drive (not ZIF) died and so was "upgraded" to a 60 gig drive. Turns out that the 1.8" drives in these things were also used on the iPods.

That HD is OK but spins _very_ slowly too save power so latency and throughput aren't great.

What can I do to A - stop the HD dying again and B - speed things up a little?

The answer I've come up with and, should, be answering over the next couple of weeks is "Can I retro fit an SSD drive into this machine"?

The first problem we find is that nearly all SSDs on the market ATM are SATA based - no go, simply can't plug it in. So, where do we turn for cheap flash storage. Well, CF (Compact Flash) card are cheap and replacable.

To plug that in we're going to need some sort of adapter (CF to 1.8" IDE). This transform actually turns out to be very easy as the only difference between CF and 1.8" EIDE is a 5 volt to 3.3 volt interface difference (sometimes) and a slight difference in pinout. We go to ebay and search for "1.8 compact flash adapter". That gets us that far.

Next we need a compact flash card. A 32gig card could cost as little as 60 quid. How fast/reliable they are I don't know. Others around 85 offer 100x speed. After that we get anything up to 300x but these are 130ish quid. Pricey (the 60gig replacement cost a little under 100 quid).

32gig isn't masses, but, think about this a little more. Maybe we could have swappable boot storage to switch OS's... I've got a use for that.

So, I'm going to charge my Paypal account and get hold of some of these bits and pieces.

Friday, 25 July 2008

Firefox 3, XAML, Silverlight (and Windows 2000 Pro)



Firefox 3, XAML, Silverlight (and Windows 2000 Pro) with Apache for local serving.

I got distracted because I am old ;-) and it works and I'm stuck with my tiny via TX series and that's fine. This machine "only" runs Windows 2000 + SP4 + loadsa patches, firewall, FF3. I wasn't expecting much Silverlight joy.

Installing Silverlight Beta 2 on Windows 2000 Pro

Download and install Silverlight 2 beta 2. I got an error message afer installation from the installer but just ignored it and restarted Firefox. Well, I kind ignored it and have yet to hit a problem. It worked! I could view XAML content on Win2K.x

Setting up Apache to Server XAML File

I used Apache to setup another local HTTP server for me. This one lives on 127.0.0.13 and will be used to server up files. My servers live at E:\servers\SomeServerName under this is public_html. In this case that server directory is called 1313.

Open Apache's conf\httpd.conf file and add a new host. If you want to name it edit %SYSTEMROOT%\System32\drivers\etc\hosts ...
<VirtualHost 127.0.0.13>
ServerAdmin wbmstr@1313.co.uk
ServerName 1313
DocumentRoot "E:/server/1313/public_html"
</VirtualHost>
Then add this to control access permissions on the folder ...
<Directory "E:/server/1313/public_html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
We will need to also edit Apache's mime.types file. To this add ...
text/xaml   xaml
This will set the Content-Type header to text/xaml when serving a file ending in the .xaml extension.

You may want to make sure that Listen is set to 80. If it isn't change port numbers elsewhere. You have several options.

Now you should restart Apache.

Now go to Firefox 3 and enter http://127.0.0.13/xaml.html

Not much yet. Let's put those files in place.
  1. The latest "Silverlight.js" from http://code.msdn.microsoft.com/silverlightjs
    Save this as E:\server\1313\public_html\Silverlight.js

  2. A .xaml file to try. XML version is important. There are many
    Save this as E:\server\1313\public_html\plugin.xaml
    <?xml version="1.0" encoding="utf-8"?>
    <Canvas xmlns="http://schemas.microsoft.com/client/2007">
    <TextBlock>Some text... don't ask me what will happen cos' I don't know...</TextBlock>
    </Canvas>

  3. An HTML file in which to host your Silverlight/XAML control.
    Save this as E:\server\1313\public_html\xaml.html
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>My Silverlight Application</title>
    <!-- Helper files for initializing and creating the Silverlight plug-in -->
    <script type="text/javascript" src="Silverlight.js"></script>
    </head>
    <!--head and html tags omitted-->
    <body>
    <P>Expect silverlight below...</p>
    <div id="slPluginHost" >
    <script type="text/javascript">
    // Create a variable that references the HTML element that hosts the plug-in.
    var parentElement = document.getElementById("slPluginHost");

    Silverlight.createObjectEx(
    {
    source: 'plugin.xaml', // Source property value.
    parentElement:parentElement, // DOM reference to hosting DIV tag.
    id:'myPlugin', // Unique plug-in ID value.
    properties:
    { // Plug-in properties.
    width:'100%', // Width of rectangular region of plug-in, in pixels.
    height:'100%', // Height of rectangular region of plug-in, in pixels.
    background:'blue', // Background color of plug-in.
    framerate:'24', // MaxFrameRate property value.
    version:'2.0'
    },
    events:{
    onError:Silverlight.default_error_handler
    },
    initParams:null, // initParams property value -- user-settable string for information passing.
    context:null,
    }
    ); // Context value -- passed to Silverlight.js onLoad event handlers.
    </script>
    </div>
    </body>

  4. 4 - Install Firebug. It's as good as it gets at the moment.
Debugging

Debugging is primitive but useful and is enabled in the example xaml.html file.

The property onError is set to Silverlight.default_error_handler.

This function is part of Silverlight.js and will produce a Javascript alert dialogue when Silverlight detects an error.

To disable the debugging alert remove the onError handler.

Silverlight Beta 2 Support

NOTE. Support for Silverlight Beta 2 is slightly fuzzy. Whilst you can force support for Beta 2 by specifying a property within the properties member of the silverlight.createObjectEx call. Add
version:'2.0.30523'.
However, the HTML object created will have the type attribute type="application/x-silverlight-2-b2".

By looking in navigator.plugins with Firebug showed that both mime types application/x-silverlight and application/x-silverlight-2-b2 invoke version 2.0.30523.8 of npctrl.dll.

The only difference is that application/x-silverlight is bound to suffix .scr. Strange.

Signing off...

Thursday, 24 July 2008

ZFS, Sun and Flash Memory

Interesting approach from Sun. Being "Big Tin" manufacturers and wholesalers they have a rather different take on the Flash vs HD argument. Simply put Flash uses less power, has better bandwidth, much, much, much better latency and is in general more reliable BUT billions of writes could wear them out. Hard drives have WAY more storage per dollar/euro/pound/yen BUT there are many components that could fail.

So... which is cheaper? Sun don't view this is a simple $/Gb... They see it as "dollars per gigabyte served". Once you take into account power things change dramatically.

There's also talk of why ZFS fits this well (in a nutshell, ZFS is very good at spotting and routing around errors

Sun CEO Jonathan Schwartz Blog Entry "Anything But a Flash in the Pan"

Tuesday, 15 July 2008

Adding a Url Scheme to a Qt Application Running on Mac Os X and Win32

Introduction

What is a URL Scheme or Plugin Protocol?

When you write a web address it starts with "http:" or "https:". An FTP connection (within a browser) starts "ftp:" that part of the address is known as the "scheme".

Many applications create their own schemes so that data can be passed from the browser via an <a href="anewscheme:this_data_is_sent_to_the_native_application"> style link.

I went through the mill getting this to work (especially on the Mac). By comparison Windows is very simple to setup - just a few registry hacks. So, let's start there.

Windows

All one needs to do to in Windows is set the appropriate registry keys. Let's assume that we've installed our application at "C:\Program Files\Acme\MyAcmeProgram.exe"

We need to add the following keys to the registry, all in HKEY Class Root. I instruct NSIS to do this at installation time as it knows where the application is to be installed.

"HKCR\anewscheme" = "URL:BODiBEAT Protocol"
"HKCR\anewscheme\URL Protocol" = ""
"HKCR\anewscheme\Shell\Open\Command" = "C:\Program Files\Acme\MyAcmeProgram.exe "%1$""

NOTE, the "URL Protocol" key really is empty. It's simply a place marker

NOTE, the extra quotes around the %1 are essential especially if your URL contains commas, spaces or any other character that specifies a parameter separator on the command line.

Operation

When the user accesses a link with like "anewscheme:datagoeshere" the application is executed and the link itself is sent to the application as argv[1]. It's that simple. You may want to make your application single instance and pipe the given URL to the first instance of the application.


Mac Os X

For the Mac we have much more work to do. The first thing we will need to do is to install an AppleEvent handler in our "main" function like this...


OSErr err = AEInstallEventHandler(kInternetEventClass,
kAEGetURL,
NewAEEventHandlerUPP((AEEventHandlerProcPtr)macCallbackGetUrl),
(long) (&app),
false);

We also need to provide the function "macCallbackGetUrl"


// AppleEvent callback
static pascal OSErr macCallbackGetUrl(const AppleEvent* inEvent,
AppleEvent* outEvent,
long refCon)
{
OSErr err = noErr;
Size actualSize = 0;
DescType descType = typeChar;

if ((err = AESizeOfParam(inEvent, keyDirectObject, &descType, &actualSize)) == noErr)
{
if (0 != actualSize)
{
// make a buffer (Qt style)
QByteArray bUrl;
bUrl.resize(actualSize + 1);

err = AEGetParamPtr(inEvent,
keyDirectObject,
typeChar,
0,
bUrl.data(),
actualSize,
&actualSize);
// Grufty C cast... meh.
(CMyApplication*)(app)->appReceivedUrl(bUrl);
}
}

return noErr;
}

NOTE:"app" is whatever you want. Possibly the most convenient object to pass to the event handler is your QApplication derived application class.

We're NEARLY there! The very last thing we need to do is to invoke the Carbon event loop. However, Qt does this for you when you create a QApplication object (which you did in main just after setting up the Apple event handler right?)

To make this all compile and link properly we need to link against the Carbon framework. TO do this we need to add one extra line to our qmake .pro file when building for the Mac

mac:LIBS += -framework Carbon

To finish off we need to add some XML to Info.plist which is inside the app bundle. Use finder to open the package and in the "Contents" folder you'll find "Info.plist" - you can use the property edit to edit this - just double click.

However! There's a little trick you can use in your qmake .pro (or .pri) file. Qt installs a very minimal Info.plist in your app bundle. To override this and provide your own add the line

mac:QMAKE_INFO_PLIST = ./Info.plist

Another way to do this is to use "install" type "man install" for more info. This lets you add/delete files from a package at will and is very powerful.

Anyhoo. These are the keys that need adding...

 <key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>A New Scheme</string>
<key>CFBundleURLSchemes</key>
<array>
<string>anewscheme</string>
</array>
</dict>
</array>
<key>NSAppleScriptEnabled</key>
<true/>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
Operation

When the user access a "anewscheme:" URL an Apple Event is received in the callback function and we can pick out that data and process it anyway we like.

Epilogue

And that's all! Honest! L8rz, burnttoy