GraphicsDevice.Clear() Is Not Working On Properly 2.3.x Devices

Hi,

I am creating RenderTarget2D objects and clearing them with GraphicsDevice.Clear(Color.Transparent) before I do any drawing. This works fine on most devices and on the GenyMotion emulator running 2.3.7.

Unfortunately though I have just tested on a Google Nexus One running 2.3.6 and it’s not working, the background of the RenderTarget remains black.

Is anyone aware of any issues around this or does anyone have any suggestions for another way I could try clearing the RenderTarget to transparent before drawing?

cheers

public RenderTarget2D CreateRenderTarget2D( int width, int height )
{
	RenderTarget2D texture = new RenderTarget2D (
		game.GraphicsDevice,
		width,
		height,
		false,
		SurfaceFormat.Color,
		DepthFormat.None,
		0,
		RenderTargetUsage.PreserveContents);

	game.GraphicsDevice.SetRenderTarget (texture);
	game.GraphicsDevice.Clear (Color.Transparent);
	game.GraphicsDevice.SetRenderTarget (null);
	return texture;
}

Actually I don’t think it’s specifically to do with GraphicsDevice.Clear() - I think what’s happening is the RenderTarget2D is not preserving its contents correctly and is getting set to black at the next SpriteBatch.Draw() (or something like that anyway).

Even if I add the following horrible hack instead of clearing it it doesn’t work - clearing it to white using this method also results in a black background as well which leads me to think it’s the contents not getting preserved.

UInt32[] data	= new UInt32[ texture.Width * texture.Height ];
for( int i=0; i<data.Length; i++ )
{
	data[i] = UInt32.MaxValue;
// or data[i] = 0;
}
texture.SetData<UInt32>(data);

Any suggestions appreciated…