Convert RenderTarget/Texture to System.Drawing.Bitmap?

boyamer

10-12-2009 14:13:47

HI all,i want to have a RenderTarget preview into my application,i would like to know if there is a
possibility to convert RenderTarget/RenderTexture/Texturo to System.Drawing.Bitmap and then preview
it into PictureBox control ?

Any help would be appreciated
Thanks

kwertz

18-01-2010 16:36:48

Time to revive this thread! ;)

You can use this code to convert a TexturePtr to a System.Drawing.Bitmap (taken from another thread; warning, ultra-slow!):

/// <summary>
/// Converts an Ogre image to System.Drawing.Bitmap.
/// </summary>
/// <param name="img">Mogre.Image to convert</param>
/// <returns>System.Drawing.Bitmap</returns>
public static Bitmap MogreImageToBitmap(Image img)
{
var bmp = new Bitmap((int)img.Width, (int)img.Height);
for (var x = 0; x < bmp.Width; x++)
{
for (var y = 0; y < bmp.Height; y++)
{
var color = img.GetColourAt(x, y, 0);
bmp.SetPixel(x, y, Color.FromArgb((int)color.GetAsARGB()));
}
}

return bmp;
}
/// <summary>
/// Converts an TexturePtr to an System.Drawing.Bitmap
/// </summary>
/// <param name="TexturePtr">Valid TexturePtr</param>
/// <param name="BitmapType">eg: PNG</param>
/// <param name="GroupName">the group where Mogre will find the image.</param>
/// <returns>System.Drawin.Bitmap</returns>
public static Bitmap TexturePtrToBitmap(TexturePtr TexturePtr, String BitmapType, String GroupName)
{
var img = new Image();
DataStreamPtr dPtr;
var name = TexturePtr.Name;
if (TexturePtr.Name.StartsWith(GroupName))
name = TexturePtr.Name.Replace(GroupName, "");
if (name.Contains(".png"))
name = name.Replace(".png", "");
try
{
dPtr = ResourceGroupManager.Singleton.OpenResource(name + "." + BitmapType, GroupName);
}
catch
{
throw new Exception("Bitmap not found, or wrong image type.");
}
img.Load(dPtr, BitmapType);
return MogreImageToBitmap(img);
}
}


But I wonder if a direct memory copy is possible through Marshal.Copy(...) ...
Like so (but Bitmap to Bitmap):

/// <summary>
/// Performs a fast bitmap copy. Very useful for creating a managed copy of a Bitmap. The ImageFormat properties have to equal, otherwise the bitmap gets corrupted.
/// </summary>
/// <param name="source">The source bitmap.</param>
/// <param name="destination">The destination bitmap.</param>
public static void FastCopy(Bitmap source, Bitmap destination)
{
// Lock both bitmaps
var data = source.LockBits(new Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadOnly, source.PixelFormat);
var data2 = destination.LockBits(new Rectangle(0, 0, destination.Width, destination.Height), ImageLockMode.WriteOnly, destination.PixelFormat);

var ptr1 = data.Scan0;
var ptr2 = data2.Scan0;

var bytes = data.Stride * data.Height;
var rgbValues = new byte[bytes];

Marshal.Copy(ptr1, rgbValues, 0, bytes);
Marshal.Copy(rgbValues, 0, ptr2, bytes);

destination.UnlockBits(data2);
source.UnlockBits(data);
}


Have fun! :)

kwertz

18-01-2010 16:54:55

But I wonder if a direct memory copy is possible through Marshal.Copy(...) ...
Yeah, got it! :)


/// <summary>
/// Converts a TexturePtr to a System.Drawing.Bitmap.
/// </summary>
/// <param name="texturePtr">The TexturePtr.</param>
/// <returns>A System.Drawing.Bitmap.</returns>
public unsafe static Bitmap MogreTexturePtrToBitmap(TexturePtr texturePtr)
{
var bitmap = new Bitmap((int)texturePtr.Width, (int)texturePtr.Height, PixelFormat.Format32bppArgb);
var rgbValues = new byte[texturePtr.Width * 4 * texturePtr.Height];
fixed (byte* ptr = &rgbValues[0])
{
var pixelBox = new PixelBox(texturePtr.Width, texturePtr.Height, 1, Mogre.PixelFormat.PF_A8R8G8B8,
(IntPtr)ptr);

texturePtr.GetBuffer().BlitToMemory(pixelBox);
}
var bitmapData = bitmap.LockBits(new Rectangle(0, 0, (int) texturePtr.Width, (int) texturePtr.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
Marshal.Copy(rgbValues, 0, bitmapData.Scan0, rgbValues.Length);
bitmap.UnlockBits(bitmapData);

return bitmap;
}


Runs perfectly!
Found in the thread here: http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=5073

Solver

18-01-2010 20:45:34

Thanks kwertz - just happened to be looking for something similar myself. Any idea how to do the opposite? If I have a TexturePtr and want to update that texture with a System.Drawing.Bitmap object's contents, how would I do that? I'm essentially looking for any way to modify small textures at run-time in Mogre.

EDIT: Also, the above code calculates the size of the byte array as width * height * 4. Would that still work on 64-bit systems?

kwertz

29-01-2010 11:46:43

I wrote a small class helping you to convert a TexturePtr to System.Drawing.Bitmap and vice versa.


using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Mogre;
using Image=Mogre.Image;
using Rectangle=System.Drawing.Rectangle;
using System.Drawing.Imaging;
using PixelFormat=System.Drawing.Imaging.PixelFormat;

namespace Mogre.Extensions
{
public static class MogreIo
{
// Use static variables to decrease memory usage since this is a performance application!
private static byte[] _pBuffer;
private static GCHandle _handle;
private static unsafe void* _pUnsafeBuffer;
private static MemoryDataStream _memoryStream;
private static DataStreamPtr _ptrDataStream;
private static Image _mogreImage = new Image();

public static unsafe TexturePtr BitmapToMogreTexture(Stream stream, string textureName)
{
// Back to the start of the stream
stream.Position = 0;

// Read all the stream
var oBinaryReader = new BinaryReader(stream);
_pBuffer = oBinaryReader.ReadBytes((int)oBinaryReader.BaseStream.Length);
stream.Close(); // No more needed
TextureManager.Singleton.Remove(textureName); // Remove eventually texture with the same name

_handle = GCHandle.Alloc(_pBuffer, GCHandleType.Pinned);
_pUnsafeBuffer = (void*)_handle.AddrOfPinnedObject();

_memoryStream = new MemoryDataStream(_pUnsafeBuffer, (uint)_pBuffer.Length);
_ptrDataStream = new DataStreamPtr(_memoryStream);
_mogreImage = _mogreImage.Load(_ptrDataStream);

var ptr = TextureManager.Singleton.LoadImage(textureName, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, _mogreImage, TextureType.TEX_TYPE_2D, 0, 2.2f, false, Mogre.PixelFormat.PF_A8R8G8B8);

_handle.Free();
return ptr;
}

/// <summary>
/// Converts a TexturePtr to a System.Drawing.Bitmap.
/// </summary>
/// <param name="texturePtr">The TexturePtr.</param>
/// <returns>A System.Drawing.Bitmap.</returns>
public unsafe static Bitmap MogreTexturePtrToBitmap(TexturePtr texturePtr)
{
var bitmap = new Bitmap((int)texturePtr.Width, (int)texturePtr.Height, PixelFormat.Format32bppArgb);
var rgbValues = new byte[texturePtr.Width * 4 * texturePtr.Height];
fixed (byte* ptr = &rgbValues[0])
{
var pixelBox = new PixelBox(texturePtr.Width, texturePtr.Height, 1, Mogre.PixelFormat.PF_A8R8G8B8,
(IntPtr)ptr);

texturePtr.GetBuffer().BlitToMemory(pixelBox);
}
var bitmapData = bitmap.LockBits(new Rectangle(0, 0, (int) texturePtr.Width, (int) texturePtr.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);
Marshal.Copy(rgbValues, 0, bitmapData.Scan0, rgbValues.Length);
bitmap.UnlockBits(bitmapData);

return bitmap;
}
}
}


Also, the above code calculates the size of the byte array as width * height * 4. Would that still work on 64-bit systems?
Yes, I think so. But because MOGRE only runs on x86 (via WOW64 on Windows 64-bit versions), you don't have to care about that.

fletch27502

08-04-2010 17:31:41

I've replaced our code to render a bitmap into a MogreTexture and I've seen 2-4X increase in speed, which is great!

Question: This code removes and creates a new MogreTexture each time it is called. I'm copying images from a movie that I have playing offscreen, and I'd like to get the best frame rate possible. Since each frame of the movie is the same size is there away to preform the BitmapToMogreTexture without having to Remove the old texture and recreate a new one? Basically, copy the new bitmap into the Mogre.Image of the existing Texture.

Thanks,
Scott

smiley80

08-04-2010 18:25:27


public unsafe void ConvertImageToTexture(System.Drawing.Image image, string textureName, Size size)
{
int width = size.Width;
int height = size.Height;
using (ResourcePtr rpt = TextureManager.Singleton.GetByName(textureName))
{
using (TexturePtr texture = rpt)
{
HardwarePixelBufferSharedPtr texBuffer = texture.GetBuffer();
texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
PixelBox pb = texBuffer.CurrentLock;

using (Bitmap bm = new Bitmap(
width,
height,
(int)((width * 4) + (pb.RowSkip * 4)),
System.Drawing.Imaging.PixelFormat.Format32bppArgb,
pb.data))
{
using (Graphics g = Graphics.FromImage(bm))
{
g.DrawImage(image, 0, 0, width, height);
}
}

texBuffer.Unlock();
texBuffer.Dispose();
}
}
}

Assumes the texture has already been created. 'size' is generally the size of the original texture.

fletch27502

08-04-2010 22:33:27

Sweet! The movie is now rendering at about 30-40 fps. Wooooo Hoooo, thanks.

smiley80

09-04-2010 14:13:44

Fiddled with it a bit more, should now be 3x faster:
[DllImport("kernel32.dll", EntryPoint = "RtlMoveMemory")]
private static extern void CopyMemory(IntPtr Destination, IntPtr Source, uint Length);

public static unsafe void ConvertImageToTexture(Bitmap image, string textureName, Size size)
{
int width = size.Width;
int height = size.Height;
using (ResourcePtr rpt = TextureManager.Singleton.GetByName(textureName))
{
using (TexturePtr texture = rpt)
{
HardwarePixelBufferSharedPtr texBuffer = texture.GetBuffer();
texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
PixelBox pb = texBuffer.CurrentLock;

BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
CopyMemory(pb.data, data.Scan0, (uint)(width * height * 4));
image.UnlockBits(data);

texBuffer.Unlock();
texBuffer.Dispose();
}
}
}

The P/Invoke can be replaced with Marshal.Copy, but that's slower.

Coolzero

19-04-2010 19:33:06

Hi smiley80,

i'm trying to draw a bitmap to a texture and found this thread :D.
I've converted your code to VB.NET:
Public Sub ConvertImageToTexture(ByVal image As Drawing.Bitmap, ByVal textureName As String, ByVal size As Drawing.Size)
Dim width As Integer = size.Width
Dim height As Integer = size.Height
Using rpt As ResourcePtr = TextureManager.Singleton.GetByName(textureName)
Using texture As TexturePtr = rpt
Dim texBuffer As HardwarePixelBufferSharedPtr = texture.GetBuffer()
Dim pb As PixelBox = texBuffer.CurrentLock

texBuffer.Lock(pb.box, HardwareBuffer.LockOptions.HBL_DISCARD)

Dim data As Drawing.Imaging.BitmapData = image.LockBits(New System.Drawing.Rectangle(0, 0, width, height), Drawing.Imaging.ImageLockMode.ReadOnly, Drawing.Imaging.PixelFormat.Format32bppArgb)
CopyMemory(pb.data, data.Scan0, CUInt((width * height * 4)))

image.UnlockBits(data)

texBuffer.Unlock()
texBuffer.Dispose()
End Using
End Using
End Sub


But when i start my application an AccessViolationException error occurs at:
CopyMemory(pb.data, data.Scan0, CUInt((width * height * 4)))
Can you (or some one else) explain me this error ?

smiley80

19-04-2010 20:04:28

Make sure the Mogre texture you've created before, has the 'PF_A8R8G8B8' PixelFormat and the correct size (if you're graphics card doesn't support non power-of-two textures, it'll be upscaled).
Also, i've only tested it with 32bit argb Bitmaps. No idea how it'll behave with other formats.

Coolzero

20-04-2010 08:54:15

Here is the complete source code:
Dim BBset As BillboardSet
Dim HealtBar As Billboard

Public Sub DrawInfoBar(ByVal pos As Mogre.Vector3, ByVal mdl As Entity)
Dim MAT_BB As MaterialPtr = MaterialManager.Singleton.Create("MAT_BB", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
Dim tex As Texture = TextureManager.Singleton.CreateManual("bar", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, 60, 5, 1, PixelFormat.PF_R8G8B8A8)

BBset = myScene.CreateBillboardSet("healthbar")
HealtBar = BBset.CreateBillboard(pos + New Vector3(0, mdl.BoundingBox.Maximum.y + 5, 0)) 'sets the position +5 units on top of the height of the object
myScene.RootSceneNode.CreateChildSceneNode("healthbar_node").AttachObject(BBset)

HealtBar.SetDimensions(System.Math.Abs(mdl.BoundingBox.Maximum.x) + System.Math.Abs(mdl.BoundingBox.Minimum.x), 5) 'bar width = object width along the x axis

'draw a black rectangle as border
Dim bm As New Drawing.Bitmap(60, 5)
For PXy As Integer = 0 To 4
For PXx As Integer = 0 To 59
If PXy = 0 Or PXy = 4 Then
bm.SetPixel(PXx, PXy, Drawing.Color.Black)
End If
If PXx = 0 Or PXx = 59 Then
bm.SetPixel(PXx, PXy, Drawing.Color.Black)
End If
Next
Next

ConvertImageToTexture(bm, tex.Name, New Drawing.Size(60, 5))
BBset.MaterialName = MAT_BB.Name
End Sub

Public Sub ConvertImageToTexture(ByVal image As Drawing.Bitmap, ByVal textureName As String, ByVal size As Drawing.Size)
Dim width As Integer = size.Width
Dim height As Integer = size.Height
Using rpt As ResourcePtr = TextureManager.Singleton.GetByName(textureName)
Using texture As TexturePtr = rpt
Dim texBuffer As HardwarePixelBufferSharedPtr = texture.GetBuffer()
Dim pb As PixelBox = texBuffer.CurrentLock

texBuffer.Lock(pb.box, HardwareBuffer.LockOptions.HBL_DISCARD)

Dim data As Drawing.Imaging.BitmapData = image.LockBits(New System.Drawing.Rectangle(0, 0, width, height), Drawing.Imaging.ImageLockMode.ReadOnly, Drawing.Imaging.PixelFormat.Format32bppArgb)
CopyMemory(pb.data, data.Scan0, CUInt((width * height * 4)))

image.UnlockBits(data)

texBuffer.Unlock()
texBuffer.Dispose()
End Using
End Using
End Sub

smiley80

20-04-2010 12:11:40

Overlooked something, that:

Dim pb As PixelBox = texBuffer.CurrentLock
texBuffer.Lock(pb.box, HardwareBuffer.LockOptions.HBL_DISCARD)

should be:

texBuffer.Lock(New Box(0, 0, width, height), HardwareBuffer.LockOptions.HBL_DISCARD)
Dim pb As PixelBox = texBuffer.CurrentLock

Coolzero

20-04-2010 15:06:02

You're right, it works :D.

But now i've another question.

Your function is named: ConvertImageToTexture.
I think the most important thing is this line of code:
CopyMemory(pb.data, data.Scan0, CUInt((width * height * 4)))

But how can i asign the texture to the material, all i see is an black billboard :?.

smiley80

20-04-2010 16:28:45

Dim bm As New Drawing.Bitmap(60, 5)
creates a transparent bitmap, If your texture should also be transparent:
MAT_BB.GetTechnique(0).SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA)

Coolzero

21-04-2010 10:03:45

Now it works :lol: :lol: :lol:.

The problem was the Pixelformat from the texture wich was Pixelformat.PF_R8G8B8A8 but in your function (ConvertImageToTexture) i'm using Pixelformat.Format32bppArgb :roll:

Now here's the working code:
Imports Mogre

Module InfoBar

Dim BBset As BillboardSet
Dim HealtBar As Billboard

Public Sub DrawInfoBar(ByVal pos As Mogre.Vector3, ByVal mdl As Entity)
Dim MAT_BB As MaterialPtr = MaterialManager.Singleton.Create("MAT_BB", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
Dim tex As Texture = TextureManager.Singleton.CreateManual("bar", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, 300, 25, 1, PixelFormat.PF_A8R8G8B8)

BBset = myScene.CreateBillboardSet("healthbar")
HealtBar = BBset.CreateBillboard(pos + New Vector3(0, mdl.BoundingBox.Maximum.y + 5, 0)) 'sets the position +5 units on top of the height of the object
myScene.RootSceneNode.CreateChildSceneNode("healthbar_node").AttachObject(BBset)

HealtBar.SetDimensions(System.Math.Abs(mdl.BoundingBox.Maximum.x) + System.Math.Abs(mdl.BoundingBox.Minimum.x), 5) 'bar width = object width along the x axis

'draw a black rectangle as border
Dim bm As New Drawing.Bitmap(300, 25)
For PXy As Integer = 0 To 24
For PXx As Integer = 0 To 299
bm.SetPixel(PXx, PXy, Drawing.Color.Green)
If PXy = 0 Or PXy = 24 Then
bm.SetPixel(PXx, PXy, Drawing.Color.Black)
End If
If PXx = 0 Or PXx = 299 Then
bm.SetPixel(PXx, PXy, Drawing.Color.Black)
End If
Next
Next

ConvertImageToTexture(bm, tex.Name, New Drawing.Size(300, 25))
MAT_BB.GetTechnique(CUShort(0)).GetPass(CUShort(0)).CreateTextureUnitState(tex.Name)
BBset.MaterialName = MAT_BB.Name
End Sub

Public Sub ConvertImageToTexture(ByVal image As Drawing.Bitmap, ByVal textureName As String, ByVal size As Drawing.Size)
Dim width As Integer = size.Width
Dim height As Integer = size.Height
Using rpt As ResourcePtr = TextureManager.Singleton.GetByName(textureName)
Using texture As TexturePtr = rpt
Dim texBuffer As HardwarePixelBufferSharedPtr = texture.GetBuffer()

texBuffer.Lock(New Box(0, 0, size.Width, size.Height), HardwareBuffer.LockOptions.HBL_DISCARD)

Dim pb As PixelBox = texBuffer.CurrentLock
Dim data As Drawing.Imaging.BitmapData = image.LockBits(New System.Drawing.Rectangle(0, 0, width, height), Drawing.Imaging.ImageLockMode.ReadOnly, Drawing.Imaging.PixelFormat.Format32bppArgb)
CopyMemory(pb.data, data.Scan0, CUInt((width * height * 4)))

image.UnlockBits(data)

texBuffer.Unlock()
texBuffer.Dispose()
End Using
End Using
End Sub
End Module


Thanks smiley80 :D

andyhebear1

21-05-2010 13:53:02

Imports Mogre

Module InfoBar

Dim BBset As BillboardSet
Dim HealtBar As Billboard

Public Sub DrawInfoBar(ByVal pos As Mogre.Vector3, ByVal mdl As Entity)
Dim MAT_BB As MaterialPtr = MaterialManager.Singleton.Create("MAT_BB", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
Dim tex As Texture = TextureManager.Singleton.CreateManual("bar", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME, TextureType.TEX_TYPE_2D, 300, 25, 1, PixelFormat.PF_A8R8G8B8)

BBset = myScene.CreateBillboardSet("healthbar")
HealtBar = BBset.CreateBillboard(pos + New Vector3(0, mdl.BoundingBox.Maximum.y + 5, 0)) 'sets the position +5 units on top of the height of the object
myScene.RootSceneNode.CreateChildSceneNode("healthbar_node").AttachObject(BBset)

HealtBar.SetDimensions(System.Math.Abs(mdl.BoundingBox.Maximum.x) + System.Math.Abs(mdl.BoundingBox.Minimum.x), 5) 'bar width = object width along the x axis

'draw a black rectangle as border
Dim bm As New Drawing.Bitmap(300, 25)
For PXy As Integer = 0 To 24
For PXx As Integer = 0 To 299
bm.SetPixel(PXx, PXy, Drawing.Color.Green)
If PXy = 0 Or PXy = 24 Then
bm.SetPixel(PXx, PXy, Drawing.Color.Black)
End If
If PXx = 0 Or PXx = 299 Then
bm.SetPixel(PXx, PXy, Drawing.Color.Black)
End If
Next
Next

ConvertImageToTexture(bm, tex.Name, New Drawing.Size(300, 25))
MAT_BB.GetTechnique(CUShort(0)).GetPass(CUShort(0)).CreateTextureUnitState(tex.Name)
BBset.MaterialName = MAT_BB.Name
End Sub

Public Sub ConvertImageToTexture(ByVal image As Drawing.Bitmap, ByVal textureName As String, ByVal size As Drawing.Size)
Dim width As Integer = size.Width
Dim height As Integer = size.Height
Using rpt As ResourcePtr = TextureManager.Singleton.GetByName(textureName)
Using texture As TexturePtr = rpt
Dim texBuffer As HardwarePixelBufferSharedPtr = texture.GetBuffer()

texBuffer.Lock(New Box(0, 0, size.Width, size.Height), HardwareBuffer.LockOptions.HBL_DISCARD)

Dim pb As PixelBox = texBuffer.CurrentLock
Dim data As Drawing.Imaging.BitmapData = image.LockBits(New System.Drawing.Rectangle(0, 0, width, height), Drawing.Imaging.ImageLockMode.ReadOnly, Drawing.Imaging.PixelFormat.Format32bppArgb)
CopyMemory(pb.data, data.Scan0, CUInt((width * height * 4)))

image.UnlockBits(data)

texBuffer.Unlock()
texBuffer.Dispose()
End Using
End Using
End Sub
End Module

Bady

03-07-2012 03:57:53

Someone please tell me what is the "TexturePtr" and how can i give it to the program ?
I searching about that, but I can't find anithing uasable. :?

tafkag

03-07-2012 08:47:30

Someone please tell me what is the "TexturePtr" and how can i give it to the program ?

A TextuerPtr references a Mogre texture. You can create a texture manually[1] or retreive a texture resource via the TextureManager[2].

[1] Example:

TexturePtr texture = TextureManager.Singleton.CreateManual(
"myNewTexture",
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
TextureType.TEX_TYPE_2D,
TexSize, TexSize, 0, PixelFormat.PF_BYTE_BGRA,
(int)TextureUsage.TU_DYNAMIC_WRITE_ONLY_DISCARDABLE)


[2]

TexturePtr texture = TextureManager.Singleton.GetByName("myTexture")

Bady

04-07-2012 04:30:25

ok, And I how to get the name of the Mogre texture? (in your code the "myTexture".)
I use a simple startup sequence (not tne tutorial framework) , and I don't define it aniwhere.

tafkag

04-07-2012 08:39:41

ok, And I how to get the name of the Mogre texture? (in your code the "myTexture".)
I use a simple startup sequence (not tne tutorial framework) , and I don't define it aniwhere.


There is a Defining Resources section in the Mogre Tutorials which should help you out. I recommend going through the other tutorials as well if you haven't done that already.

Bady

04-07-2012 16:10:14

In this tutorial not mentioning the the name of the Mogre texture.
I already Go trough this tutorial...


And this tutorial too:
http://www.ogre3d.org/tikiwiki/tiki-index.php?page=MOGRE+Intermediate+Tutorial+7

but in this tutorial say:
The first parameter to CreateManual() is the name of the texture, which is commonly named RttTex.
I tried a lot of thing, and I always get an empty TexturePtr.




How put the Mogrerenderscreen (what I see on the screen, when the Mogre rendering, you know, objects, planes, etc...) to the System.Drawing.Bitmap? :(


An another problem:
I render the mogre in a picturebox, and when I use this command:
mWindow.WriteContentsToFile("start.png");
The mogre save the picture in the size of the picturebox.
(but I set the renderwindow size 1024x768)
When I put the renderscreen in the picturebox, the screen size setting is cange? I know, it is logical, but I hope the render screen is stay the configured size, and just resize it on my picturebox.

Bady

07-07-2012 15:06:38

Forget it, i figured out....
:)