Tuesday, 24 November 2009

Facebook

Ok, I am now on Facebook. Ugh.

Saturday, 10 October 2009

Darth Vader

This was one of the most amazing things about Victoria. I guess the Deathstar also suffers from the economic crisis, and alternative sources of income become necessary. By the way: the songs he chose were really dramatic.
Posted by Picasa

Sunday, 8 June 2008

Copying a Dynamically Created Bitmap to a Texture2D with XNA

I am sure someone has done it before, but I couldn't find any complete example in the web, so I wrote my own code: essentially it allows you to create a texture from a dynamically created Bitmap object. So you don't have to load the Bitmap from a file but you can dynamically create one in memory, do some GDI+ drawing on it (e.g for procedural textures) and then load it to a texture and use it. This can be useful if you want to programmatically create textures. Even though I have not tried it yet, you should be able to even update the texture before every frame using this method. This is the code:

using SD = System.Drawing;
using SDI = System.Drawing.Imaging;

// ...

protected override void LoadContent()
{
// Create Bitmap that we want edit and transfer to a texture
SD.Bitmap bitmap = new SD.Bitmap(100, 100);

// Create Graphics for the bitmap
SD.Graphics bitmapGraphics = SD.Graphics.FromImage(bitmap);

// Do some drawing with GDI+, e.g.
bitmapGraphics.Clear(SD.Color.CornflowerBlue);
// ... what ever you want to do :)

// Get rid of the graphcis object
bitmapGraphics.Dispose();

// Initialize our custom texture (should be defined in the class)
customTexture = new Texture2D(this.GraphicsDevice, bitmap.Width, bitmap.Height, 0, TextureUsage.None, SurfaceFormat.Color);

// Lock the bitmap data
SDI.BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat);

// calculate the byte size: for PixelFormat.Format32bppArgb (standard for GDI bitmaps) it's the hight * stride
int bufferSize = data.Height * data.Stride; // stride already incorporates 4 bytes per pixel

// create buffer
byte[] bytes = new byte[bufferSize];

// copy bitmap data into buffer
Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);

// copy our buffer to the texture
customTexture.SetData(bytes);

// unlock the bitmap data
bitmap.UnlockBits(data);
}

Using a standard Windows.Form for XNA Projects

Something that I found very helpful was the article by Pedro Güida. It tells you how to render the standard XNA output to a standard Windows.Form. Why would you want to do that? Well, some say it's good for writing level editors, but in my case it was useful since I wanted to override the Forms WinProc, which isn't possible in the Game class delivered by the XNA templates. There are some other solutions that accomplish that, but Pedro's solution is the only one that let's you still use the comfortable Game's class in conjunction with a standard Form. So here you go :) Thanks Pedro for this elegant and simple solution!

Saturday, 2 February 2008

Deactivate Flash in Firefox

Firefox can cause high amount of CPU-load when displaying multiple tabs with flash content. A very nice little plug-in for Firefox is Flashblock (must be good, considering it's name ;). You can either download it from the developer's website, or via the firefox addon-page. What it does is initially replacing every flash animation on a web page you load with a little spacer. Clicking on the spacer loads the appropriate flash movie. The effect is that it dramatically reduces the CPU load, as it suppresses all flash movies by default (a nice side-effect is that lots of adds disappear, as they are often implemented in flash). It also supports a white-list of pages on which flash should be loaded as usual, so you can add pages like youtube.com if you don't want to click on the spacer every time.

Wednesday, 5 December 2007

Boardgames and Fantasy RPG in Lancaster

"Interstellar Master Traders" is a shop run by a really unique character (wise, long beard, a bit like a wizard) and offers a very comprehensive collection of boardgames, fantasy literature as well as role-playing systems and equipment. On top of that, (and most amazingly) he has played / read nearly any single game/book that he stocks and (on demand) gives very detailed and competent shopping advise. None of his recommendation failed me once (ideal if you don't exactly know what book / game to go for, if you give him an entry point, he will give you several options).

Personally, I can recommend his large selection of international board-games. He even stocks English versions of some very popular German boardgames, such as "Settlers of Catan" and "Carcassonne" (which I can really recommend, both for friends & family). The selection ranges from very simple but entertaining card games up to very complicated strategy board games. Prices are really fair and as mentioned, the owner's support is outstanding.

Links: Shop's Website | Google Maps



Please also note: that the shop has a temporary shop-front and that you enter at your own risk (should be repaired by the 10th of December):



Update: Everything is back to normal now!

Thursday, 29 November 2007

Video "Shake Well before Use!"

Rene Mayrhofer, a collegue here in Lancaster did some great work about pairing handheld devices by shaking them together. I helped a bit with creating a video for the work and funny enought, the video is now on youtube with over 24.000 hits ;)