Programatically create textures ??

Jul 6, 2010 at 7:52 PM
Is there a way to create a texture from a WriteableBitmap ?

Its a lot cheaper to generate some of my textures in the client compared to downloading a 16k png file :)
Jul 7, 2010 at 5:41 AM


the Image support is a bit limiting today in Balder, something I want to clean up and make a lot more extensible. 
But, there is a way of doing this.

You can programatically create it.

- First create an instance of Image by calling the Runtimes ContentManager and initialize the Width and Height :

var image = Runtime.Instance.ContentManager.CreateAssetPart<Image>();
image.Width = 320;
image.Height = 240;

 Then you can use the ImageContext on the Frame to set the actual pixels:


That should in theory work. 

Jul 11, 2010 at 8:44 PM

No joy -- the DLLs you sent do not have content manager as a property if IRuntime.

Jul 12, 2010 at 2:26 PM


I'll look it over and see what can be done. I'm in the middle of fixing a lot of this, so I'll see what I can do to speed it up, or at least get a proper answer for you on this.

Aug 1, 2010 at 8:09 AM

In the latest version of Balder you have something called IMap, the DiffuseMap property and the ReflectionMap property of a Material is now of type IMap - you can now easily generate your own map on the fly. Look at ImageMap for more details.

Aug 4, 2010 at 8:39 PM
Hi Adept, I can't add the texture correctly. I have a wood texture image, which has vertical grain. When I try to attach it to box, the grain is rotated about 45 degree. I really don't know why. Please help. Thanks
Aug 5, 2010 at 2:14 PM

This could be a bug - but you can work around it by just rotating the Box using the Rotation property. 

You could just do Rotation="0,45,0" to rotate it 45 degrees around the Y axis.

Aug 5, 2010 at 5:11 PM
Adept, I have tried. It is not working by rotating 45 degree around the Y axis. Actually this is not just for one face. all 6 faces are the same.
Aug 5, 2010 at 8:54 PM

This sounds like there is something else going on. 

Is it possible for you to email me a simple demo with the problem in it? (einar [at] dolittle [dot] com) - I won't be able to look at it before Monday, though. 

Aug 5, 2010 at 10:55 PM
Einar, If you look the Box carefully, You will see the edge is not so smooth, looks like sawtooth. Is that not high resolution? What is the step length( or unit measure length) from 1 to 2? Thanks
Aug 6, 2010 at 6:25 AM

Do you mean the edges of the box or the edges within the texture?

The texturemapping uses relative coordinates from 0-1. For screen coordinates, that is something I'm working on - its not doing subpixling at the moment. But I've started fixing this, so everything will be more accurate.

Also worth mentioning, next version will have perspective correct texture mapping plus bilinear filtering - this is in fact implemented but not enabled yet.