Skip to content

Instantly share code, notes, and snippets.

@Azerothian
Created January 13, 2012 11:12
Show Gist options
  • Save Azerothian/1605589 to your computer and use it in GitHub Desktop.
Save Azerothian/1605589 to your computer and use it in GitHub Desktop.
Axiom BrowserRender
void BrowserManager_BrowserRenderEvent(Guid id, System.Drawing.Bitmap screen)
{
if (id == _browserId)
{
_texture = TextureManager.Instance.CreateManual("DynamicTexture", ResourceGroupManager.DefaultResourceGroupName, TextureType.TwoD, screen.Width, screen.Height, 0, Axiom.Media.PixelFormat.R8G8B8A8, TextureUsage.RenderTarget);
_material = (Material)MaterialManager.Instance.Create("DynamicMaterial", ResourceGroupManager.DefaultResourceGroupName);
_material.GetTechnique(0).GetPass(0).CreateTextureUnitState("DynamicTexture");
var bitmapData = screen.LockBits(
new System.Drawing.Rectangle(0, 0, screen.Width, screen.Height),
ImageLockMode.ReadWrite,
screen.PixelFormat);
var buffer = _texture.GetBuffer();
buffer.Lock(Axiom.Graphics.BufferLocking.Normal);
buffer.CurrentLock.Data = bitmapData.Scan0;
buffer.Unlock();
screen.UnlockBits(bitmapData);
_entity.MaterialName = "DynamicMaterial";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment