Vectrex
24-02-2010 11:51:05
smiley80
24-02-2010 14:07:27
Good job!
Quick and dirty Mogre test:
Now I finally know why my approach didn't work. The wrapper was ok, but there was a stupid mistake in the convert to bitmap part.
anthrax11
24-02-2010 19:53:52
rattus
25-06-2010 14:19:11
Hi there,
could you please post working sample with berkelium in mogre ?
I've been fiddling with it today and cannot find way to correctly get data from paint event to mogre texture..
pretty please.
smiley80
25-06-2010 16:20:02
Paint event handler:
private void win_Paint(Window window, IntPtr sourceBuffer, Sirikata.BerkeliumSharp.Rect rect, int dx, int dy, Sirikata.BerkeliumSharp.Rect scrollRect)
{
using (ResourcePtr rpt = TextureManager.Singleton.GetByName(textureName))
{
using (TexturePtr texture = rpt)
{
HardwarePixelBufferSharedPtr texBuffer = texture.GetBuffer();
if (dx != 0 || dy != 0)
{
var sourceRect = new System.Drawing.Rectangle(scrollRect.Left, scrollRect.Top, scrollRect.Width, scrollRect.Height);
var destRect = sourceRect;
destRect.X += dx;
destRect.Y += dy;
var overlap = System.Drawing.Rectangle.Intersect(destRect, sourceRect);
if (destRect.Left < 0)
{
sourceRect.X -= destRect.Left;
destRect.X = 0;
}
if (destRect.Top < 0)
{
sourceRect.Y -= destRect.Top;
destRect.Y = 0;
}
destRect.Width = sourceRect.Width = overlap.Width;
destRect.Height = sourceRect.Height = overlap.Height;
if ((sourceRect.Width > 0) && (sourceRect.Height > 0))
{
PixelBox pb = texBuffer.Lock(
new Box(
(uint)sourceRect.Left,
(uint)sourceRect.Top,
(uint)sourceRect.Right,
(uint)sourceRect.Bottom),
HardwareBuffer.LockOptions.HBL_READ_ONLY);
texBuffer.Unlock();
texBuffer.BlitFromMemory(
pb,
pb.box);
}
}
texBuffer.BlitFromMemory(
new PixelBox(
(uint)rect.Width,
(uint)rect.Height,
0,
texture.Format,
sourceBuffer),
new Box(
(uint)rect.Left,
(uint)rect.Top,
(uint)rect.Right,
(uint)rect.Bottom));
texBuffer.Dispose();
}
}
}